]> git.mxchange.org Git - friendica.git/commitdiff
Move mod/pretheme to src/Module/ThemeDetails
authorPhilipp Holzer <admin@philipp.info>
Sun, 5 May 2019 17:23:03 +0000 (19:23 +0200)
committerPhilipp Holzer <admin@philipp.info>
Sun, 5 May 2019 17:24:10 +0000 (19:24 +0200)
mod/pretheme.php [deleted file]
src/App/Router.php
src/Module/ThemeDetails.php [new file with mode: 0644]

diff --git a/mod/pretheme.php b/mod/pretheme.php
deleted file mode 100644 (file)
index 14d1f2b..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-use Friendica\App;
-use Friendica\Core\Theme;
-
-function pretheme_init(App $a) {
-
-       if ($_REQUEST['theme']) {
-               $theme = $_REQUEST['theme'];
-               $info = Theme::getInfo($theme);
-               if ($info) {
-                       // unfortunately there will be no translation for this string
-                       $desc = $info['description'];
-                       $version = $info['version'];
-                       $credits = $info['credits'];
-               } else {
-                       $desc = '';
-                       $version = '';
-                       $credits = '';
-               }
-               echo json_encode(['img' => Theme::getScreenshot($theme), 'desc' => $desc, 'version' => $version, 'credits' => $credits]);
-       }
-
-       exit();
-}
index 1dffb6b406f0d3b22bd75880710bd56a5eee8437..40f2d5ebccc4edd64311cf54e93514f8d1de1a6d 100644 (file)
@@ -153,6 +153,7 @@ class Router
                        $collector->addRoute(['GET'], '/{type}/{name}',                      Module\Photo::class);
                        $collector->addRoute(['GET'], '/{type}/{customize}/{name}',          Module\Photo::class);
                });
+               $this->routeCollector->addRoute(['GET'],         '/pretheme',            Module\ThemeDetails::class);
                $this->routeCollector->addGroup('/profile', function (RouteCollector $collector) {
                        $collector->addRoute(['GET'], '/{nickname}',                         Module\Profile::class);
                        $collector->addRoute(['GET'], '/{profile:\d+}/view',                 Module\Profile::class);
diff --git a/src/Module/ThemeDetails.php b/src/Module/ThemeDetails.php
new file mode 100644 (file)
index 0000000..7b53d1c
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Core\Theme;
+
+/**
+ * Prints theme specific details as a JSON string
+ */
+class ThemeDetails extends BaseModule
+{
+       public static function rawContent()
+       {
+               if (!empty($_REQUEST['theme'])) {
+                       $theme = $_REQUEST['theme'];
+                       $info = Theme::getInfo($theme);
+
+                       // Unfortunately there will be no translation for this string
+                       $description = defaults($info, 'description', '');
+                       $version     = defaults($info, 'version'    , '');
+                       $credits     = defaults($info, 'credits'    , '');
+
+                       echo json_encode([
+                               'img'     => Theme::getScreenshot($theme),
+                               'desc'    => $description,
+                               'version' => $version,
+                               'credits' => $credits,
+                       ]);
+               }
+               exit();
+       }
+}