diff --git a/mod/smilies.php b/mod/smilies.php deleted file mode 100644 index bbb7de2e2..000000000 --- a/mod/smilies.php +++ /dev/null @@ -1,32 +0,0 @@ -argv[1]) && ($a->argv[1] === "json")) { - $results = []; - for ($i = 0; $i < count($smilies['texts']); $i++) { - $results[] = ['text' => $smilies['texts'][$i], 'icon' => $smilies['icons'][$i]]; - } - System::jsonExit($results); - } else { - $s = '
'; - for ($x = 0; $x < count($smilies['texts']); $x ++) { - $s .= '
' . $smilies['texts'][$x] . '
' . $smilies['icons'][$x] . '
'; - } - $s .= '
'; - - return $s; - } -} diff --git a/src/App/Router.php b/src/App/Router.php index 8373273b7..fc9bbdf15 100644 --- a/src/App/Router.php +++ b/src/App/Router.php @@ -171,6 +171,7 @@ class Router $this->routeCollector->addRoute(['GET', 'POST'], '/register', Module\Register::class); $this->routeCollector->addRoute(['GET'], '/robots.txt', Module\RobotsTxt::class); $this->routeCollector->addRoute(['GET'], '/rsd.xml', Module\ReallySimpleDiscovery::class); + $this->routeCollector->addRoute(['GET'], '/smilies[/json]', Module\Smilies::class); $this->routeCollector->addRoute(['GET'], '/statistics.json', Module\Statistics::class); $this->routeCollector->addRoute(['GET'], '/tos', Module\Tos::class); $this->routeCollector->addRoute(['GET'], '/viewsrc/{item:\d+}', Module\ItemBody::class); diff --git a/src/Module/Smilies.php b/src/Module/Smilies.php new file mode 100644 index 000000000..422f37d3e --- /dev/null +++ b/src/Module/Smilies.php @@ -0,0 +1,40 @@ +argv[1]) && ($app->argv[1] === "json")) { + $smilies = Content\Smilies::getList(); + $results = []; + for ($i = 0; $i < count($smilies['texts']); $i++) { + $results[] = ['text' => $smilies['texts'][$i], 'icon' => $smilies['icons'][$i]]; + } + System::jsonExit($results); + } + } + + public static function content() + { + $smilies = Content\Smilies::getList(); + $count = count(defaults($smilies, 'texts', [])); + + $tpl = Renderer::getMarkupTemplate('smilies.tpl'); + return Renderer::replaceMacros($tpl, [ + '$count' => $count, + '$smilies' => $smilies, + ]); + } +} diff --git a/view/templates/smilies.tpl b/view/templates/smilies.tpl new file mode 100644 index 000000000..6f9fda83b --- /dev/null +++ b/view/templates/smilies.tpl @@ -0,0 +1,10 @@ +
+
+ {{for $i=0 to $count}} +
+
{{$smilies.texts[$i] nofilter}}
+
{{$smilies.icons[$i] nofilter}}
+
+ {{/for}} +
+