mirror of
https://github.com/friendica/friendica
synced 2024-12-22 22:40:16 +00:00
Update Theme functions and calls
Update function names and calls for Theme class.
This commit is contained in:
parent
11cf36105c
commit
d07536e032
4 changed files with 30 additions and 26 deletions
|
@ -13,6 +13,7 @@ use Friendica\BaseObject;
|
|||
use Friendica\Content\Nav;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
|
@ -517,15 +518,15 @@ header('X-Frame-Options: sameorigin');
|
|||
* The page templates are located in /view/php/ or in the theme directory.
|
||||
*/
|
||||
if (isset($_GET["mode"])) {
|
||||
$template = theme_include($_GET["mode"] . '.php');
|
||||
$template = Theme::getPathForFile($_GET["mode"] . '.php');
|
||||
}
|
||||
|
||||
// If there is no page template use the default page template
|
||||
if (empty($template)) {
|
||||
$template = theme_include("default.php");
|
||||
$template = Theme::getPathForFile("default.php");
|
||||
}
|
||||
|
||||
/// @TODO Looks unsafe (remote-inclusion), is maybe not but theme_include() uses file_exists() but does not escape anything
|
||||
/// @TODO Looks unsafe (remote-inclusion), is maybe not but Theme::getPathForFile() uses file_exists() but does not escape anything
|
||||
require_once $template;
|
||||
|
||||
killme();
|
||||
|
|
|
@ -11,6 +11,7 @@ use Friendica\Content\Text\Markdown;
|
|||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Theme;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Database\DBStructure;
|
||||
|
@ -2007,10 +2008,10 @@ function admin_page_themes(App $a)
|
|||
toggle_theme($themes, $theme, $result);
|
||||
$s = rebuild_theme_table($themes);
|
||||
if ($result) {
|
||||
install_theme($theme);
|
||||
Theme::install($theme);
|
||||
info(sprintf('Theme %s enabled.', $theme));
|
||||
} else {
|
||||
uninstall_theme($theme);
|
||||
Theme::uninstall($theme);
|
||||
info(sprintf('Theme %s disabled.', $theme));
|
||||
}
|
||||
|
||||
|
@ -2058,7 +2059,7 @@ function admin_page_themes(App $a)
|
|||
$a->page = $orig_page;
|
||||
}
|
||||
|
||||
$screenshot = [get_theme_screenshot($theme), t('Screenshot')];
|
||||
$screenshot = [Theme::getScreenshot($theme), t('Screenshot')];
|
||||
if (!stristr($screenshot[0], $theme)) {
|
||||
$screenshot = null;
|
||||
}
|
||||
|
@ -2073,7 +2074,7 @@ function admin_page_themes(App $a)
|
|||
'$plugin' => $theme,
|
||||
'$status' => $status,
|
||||
'$action' => $action,
|
||||
'$info' => get_theme_info($theme),
|
||||
'$info' => Theme::getInfo($theme),
|
||||
'$function' => 'themes',
|
||||
'$admin_form' => $admin_form,
|
||||
'$str_author' => t('Author: '),
|
||||
|
@ -2085,14 +2086,13 @@ function admin_page_themes(App $a)
|
|||
]);
|
||||
}
|
||||
|
||||
|
||||
// reload active themes
|
||||
if (x($_GET, "a") && $_GET['a'] == "r") {
|
||||
check_form_security_token_redirectOnErr(System::baseUrl() . '/admin/themes', 'admin_themes', 't');
|
||||
foreach ($themes as $th) {
|
||||
if ($th['allowed']) {
|
||||
uninstall_theme($th['name']);
|
||||
install_theme($th['name']);
|
||||
Theme::uninstall($th['name']);
|
||||
Theme::install($th['name']);
|
||||
}
|
||||
}
|
||||
info("Themes reloaded");
|
||||
|
@ -2105,7 +2105,7 @@ function admin_page_themes(App $a)
|
|||
|
||||
$plugins = [];
|
||||
foreach ($themes as $th) {
|
||||
$plugins[] = [$th['name'], (($th['allowed']) ? "on" : "off"), get_theme_info($th['name'])];
|
||||
$plugins[] = [$th['name'], (($th['allowed']) ? "on" : "off"), Theme::getInfo($th['name'])];
|
||||
}
|
||||
|
||||
$t = get_markup_template('admin/plugins.tpl');
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
<?php
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Theme;
|
||||
|
||||
function pretheme_init(App $a) {
|
||||
|
||||
if ($_REQUEST['theme']) {
|
||||
$theme = $_REQUEST['theme'];
|
||||
$info = get_theme_info($theme);
|
||||
$info = Theme::getInfo($theme);
|
||||
if ($info) {
|
||||
// unfortunately there will be no translation for this string
|
||||
$desc = $info['description'];
|
||||
|
@ -17,7 +18,7 @@ function pretheme_init(App $a) {
|
|||
$version = '';
|
||||
$credits = '';
|
||||
}
|
||||
echo json_encode(['img' => get_theme_screenshot($theme), 'desc' => $desc, 'version' => $version, 'credits' => $credits]);
|
||||
echo json_encode(['img' => Theme::getScreenshot($theme), 'desc' => $desc, 'version' => $version, 'credits' => $credits]);
|
||||
}
|
||||
|
||||
killme();
|
||||
|
|
|
@ -4,10 +4,9 @@
|
|||
*/
|
||||
namespace Friendica\Core;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
|
||||
require_once 'boot.php';
|
||||
|
||||
/**
|
||||
* Some functions to handle themes
|
||||
|
@ -30,7 +29,8 @@ class Theme
|
|||
* @return array
|
||||
*/
|
||||
|
||||
function get_theme_info($theme) {
|
||||
public static function getInfo($theme)
|
||||
{
|
||||
$info=[
|
||||
'name' => $theme,
|
||||
'description' => "",
|
||||
|
@ -83,10 +83,8 @@ class Theme
|
|||
$info[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
@ -99,7 +97,8 @@ class Theme
|
|||
* @param sring $theme The name of the theme
|
||||
* @return string
|
||||
*/
|
||||
function get_theme_screenshot($theme) {
|
||||
public static function getScreenshot($theme)
|
||||
{
|
||||
$exts = ['.png','.jpg'];
|
||||
foreach ($exts as $ext) {
|
||||
if (file_exists('view/theme/' . $theme . '/screenshot' . $ext)) {
|
||||
|
@ -110,7 +109,8 @@ class Theme
|
|||
}
|
||||
|
||||
// install and uninstall theme
|
||||
function uninstall_theme($theme) {
|
||||
public static function uninstall($theme)
|
||||
{
|
||||
logger("Addons: uninstalling theme " . $theme);
|
||||
|
||||
include_once("view/theme/$theme/theme.php");
|
||||
|
@ -120,7 +120,8 @@ class Theme
|
|||
}
|
||||
}
|
||||
|
||||
function install_theme($theme) {
|
||||
public static function install($theme)
|
||||
{
|
||||
// silently fail if theme was removed
|
||||
|
||||
if (! file_exists("view/theme/$theme/theme.php")) {
|
||||
|
@ -153,7 +154,8 @@ class Theme
|
|||
* @param string $root Full root path
|
||||
* @return string Path to the file or empty string if the file isn't found
|
||||
*/
|
||||
function theme_include($file, $root = '') {
|
||||
public static function getPathForFile($file, $root = '')
|
||||
{
|
||||
$file = basename($file);
|
||||
|
||||
// Make sure $root ends with a slash / if it's not blank
|
||||
|
|
Loading…
Reference in a new issue