3 namespace Friendica\Module\Admin\Themes;
\r
5 use Friendica\Core\Config;
\r
6 use Friendica\Core\L10n;
\r
7 use Friendica\Core\Renderer;
\r
8 use Friendica\Core\Theme;
\r
9 use Friendica\Module\BaseAdminModule;
\r
10 use Friendica\Util\Strings;
\r
12 class Index extends BaseAdminModule
\r
14 public static function content()
\r
18 $a = self::getApp();
\r
20 $allowed_themes = Theme::getAllowedList();
\r
22 // reload active themes
\r
23 if (!empty($_GET['action'])) {
\r
24 parent::checkFormSecurityTokenRedirectOnError($a->getBaseURL() . '/admin/themes', 'admin_themes', 't');
\r
26 switch ($_GET['action']) {
\r
28 foreach ($allowed_themes as $theme) {
\r
29 Theme::uninstall($theme['name']);
\r
30 Theme::install($theme['name']);
\r
33 info('Themes reloaded');
\r
37 $theme = defaults($_GET, 'addon', '');
\r
39 $theme = Strings::sanitizeFilePathItem($theme);
\r
40 if (!is_dir("view/theme/$theme")) {
\r
41 notice(L10n::t('Item not found.'));
\r
45 if (in_array($theme, Theme::getAllowedList())) {
\r
46 Theme::uninstall($theme);
\r
47 info(L10n::t('Theme %s disabled.', $theme));
\r
48 } elseif (Theme::install($theme)) {
\r
49 info(L10n::t('Theme %s successfully enabled.', $theme));
\r
51 info(L10n::t('Theme %s failed to install.', $theme));
\r
59 $a->internalRedirect('admin/themes');
\r
63 $files = glob('view/theme/*');
\r
64 if (is_array($files)) {
\r
65 foreach ($files as $file) {
\r
66 $theme = basename($file);
\r
68 // Is there a style file?
\r
69 $theme_files = glob('view/theme/' . $theme . '/style.*');
\r
72 if (count($theme_files) == 0) {
\r
76 $is_experimental = intval(file_exists($file . '/experimental'));
\r
77 $is_supported = 1 - (intval(file_exists($file . '/unsupported')));
\r
78 $is_allowed = intval(in_array($theme, $allowed_themes));
\r
80 if ($is_allowed || $is_supported || Config::get('system', 'show_unsupported_themes')) {
\r
81 $themes[] = ['name' => $theme, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed];
\r
87 foreach ($themes as $theme) {
\r
88 $addons[] = [$theme['name'], (($theme['allowed']) ? 'on' : 'off'), Theme::getInfo($theme['name'])];
\r
91 $t = Renderer::getMarkupTemplate('admin/addons/index.tpl');
\r
92 return Renderer::replaceMacros($t, [
\r
93 '$title' => L10n::t('Administration'),
\r
94 '$page' => L10n::t('Themes'),
\r
95 '$submit' => L10n::t('Save Settings'),
\r
96 '$reload' => L10n::t('Reload active themes'),
\r
97 '$baseurl' => $a->getBaseURL(true),
\r
98 '$function' => 'themes',
\r
99 '$addons' => $addons,
\r
100 '$pcount' => count($themes),
\r
101 '$noplugshint' => L10n::t('No themes found on the system. They should be placed in %1$s', '<code>/view/themes</code>'),
\r
102 '$experimental' => L10n::t('[Experimental]'),
\r
103 '$unsupported' => L10n::t('[Unsupported]'),
\r
104 '$form_security_token' => parent::getFormSecurityToken('admin_themes'),
\r