]> git.mxchange.org Git - friendica.git/blob - src/Module/Admin/Themes/Embed.php
Remove duplicate $baseurl template variable
[friendica.git] / src / Module / Admin / Themes / Embed.php
1 <?php\r
2 \r
3 namespace Friendica\Module\Admin\Themes;\r
4 \r
5 use Friendica\Core\L10n;\r
6 use Friendica\Core\Renderer;\r
7 use Friendica\Module\BaseAdminModule;\r
8 use Friendica\Util\Strings;\r
9 \r
10 class Embed extends BaseAdminModule\r
11 {\r
12         public static function init()\r
13         {\r
14                 $a = self::getApp();\r
15 \r
16                 if ($a->argc > 2) {\r
17                         // @TODO: Replace with parameter from router\r
18                         $theme = $a->argv[2];\r
19                         $theme = Strings::sanitizeFilePathItem($theme);\r
20                         if (is_file("view/theme/$theme/config.php")) {\r
21                                 $a->setCurrentTheme($theme);\r
22                         }\r
23                 }\r
24         }\r
25 \r
26         public static function post()\r
27         {\r
28                 parent::post();\r
29 \r
30                 $a = self::getApp();\r
31 \r
32                 if ($a->argc > 2) {\r
33                         // @TODO: Replace with parameter from router\r
34                         $theme = $a->argv[2];\r
35                         $theme = Strings::sanitizeFilePathItem($theme);\r
36                         if (is_file("view/theme/$theme/config.php")) {\r
37                                 self::checkFormSecurityTokenRedirectOnError('/admin/themes/' . $theme . '/embed?mode=minimal', 'admin_theme_settings');\r
38 \r
39                                 require_once "view/theme/$theme/config.php";\r
40 \r
41                                 if (function_exists('theme_admin_post')) {\r
42                                         theme_admin_post($a);\r
43                                 }\r
44                         }\r
45 \r
46                         info(L10n::t('Theme settings updated.'));\r
47 \r
48                         if ($a->isAjax()) {\r
49                                 return;\r
50                         }\r
51 \r
52                         $a->internalRedirect('admin/themes/' . $theme . '/embed?mode=minimal');\r
53                 }\r
54         }\r
55 \r
56         public static function content()\r
57         {\r
58                 parent::content();\r
59 \r
60                 $a = self::getApp();\r
61 \r
62                 if ($a->argc > 2) {\r
63                         // @TODO: Replace with parameter from router\r
64                         $theme = $a->argv[2];\r
65                         $theme = Strings::sanitizeFilePathItem($theme);\r
66                         if (!is_dir("view/theme/$theme")) {\r
67                                 notice(L10n::t('Unknown theme.'));\r
68                                 return '';\r
69                         }\r
70 \r
71                         $admin_form = '';\r
72                         if (is_file("view/theme/$theme/config.php")) {\r
73                                 require_once "view/theme/$theme/config.php";\r
74 \r
75                                 if (function_exists('theme_admin')) {\r
76                                         $admin_form = theme_admin($a);\r
77                                 }\r
78                         }\r
79 \r
80                         $t = Renderer::getMarkupTemplate('admin/addons/embed.tpl');\r
81                         return Renderer::replaceMacros($t, [\r
82                                 '$action' => '/admin/themes/' . $theme . '/embed?mode=minimal',\r
83                                 '$form' => $admin_form,\r
84                                 '$form_security_token' => parent::getFormSecurityToken("admin_theme_settings"),\r
85                         ]);\r
86                 }\r
87 \r
88                 return '';\r
89         }\r
90 }