Update function names and calls for Theme class.
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;
* 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();
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;
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));
}
$a->page = $orig_page;
}
- $screenshot = [get_theme_screenshot($theme), t('Screenshot')];
+ $screenshot = [Theme::getScreenshot($theme), t('Screenshot')];
if (!stristr($screenshot[0], $theme)) {
$screenshot = null;
}
'$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: '),
]);
}
-
// 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");
$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');
<?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'];
$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();
*/\r
namespace Friendica\Core;\r
\r
-use Friendica\App;\r
-use Friendica\Core\Config;\r
use Friendica\Core\System;\r
-use Friendica\Database\DBM;\r
+\r
+require_once 'boot.php';\r
\r
/**\r
* Some functions to handle themes\r
* @return array\r
*/\r
\r
- function get_theme_info($theme) {\r
+ public static function getInfo($theme)\r
+ {\r
$info=[\r
'name' => $theme,\r
'description' => "",\r
foreach ( $ll as $l ) {\r
$l = trim($l,"\t\n\r */");\r
if ($l != "") {\r
- list($k,$v) = array_map("trim", explode(":",$l,2));\r
+ list($k, $v) = array_map("trim", explode(":", $l, 2));\r
$k= strtolower($k);\r
if ($k == "author") {\r
\r
$info['maintainer'][] = ['name'=>$v];\r
}\r
} else {\r
- if (array_key_exists($k,$info)) {\r
- $info[$k]=$v;\r
+ if (array_key_exists($k, $info)) {\r
+ $info[$k] = $v;\r
}\r
}\r
-\r
}\r
}\r
-\r
}\r
return $info;\r
}\r
* @param sring $theme The name of the theme\r
* @return string\r
*/\r
- function get_theme_screenshot($theme) {\r
+ public static function getScreenshot($theme)\r
+ {\r
$exts = ['.png','.jpg'];\r
foreach ($exts as $ext) {\r
if (file_exists('view/theme/' . $theme . '/screenshot' . $ext)) {\r
}\r
\r
// install and uninstall theme\r
- function uninstall_theme($theme) {\r
+ public static function uninstall($theme)\r
+ {\r
logger("Addons: uninstalling theme " . $theme);\r
\r
include_once("view/theme/$theme/theme.php");\r
}\r
}\r
\r
- function install_theme($theme) {\r
+ public static function install($theme)\r
+ {\r
// silently fail if theme was removed\r
\r
if (! file_exists("view/theme/$theme/theme.php")) {\r
* @param string $root Full root path\r
* @return string Path to the file or empty string if the file isn't found\r
*/\r
- function theme_include($file, $root = '') {\r
+ public static function getPathForFile($file, $root = '')\r
+ {\r
$file = basename($file);\r
\r
// Make sure $root ends with a slash / if it's not blank\r