]> git.mxchange.org Git - friendica.git/commitdiff
Move mod/smilies to src/Module/Smilies
authorPhilipp Holzer <admin@philipp.info>
Sun, 5 May 2019 17:39:02 +0000 (19:39 +0200)
committerPhilipp Holzer <admin@philipp.info>
Sun, 5 May 2019 17:39:02 +0000 (19:39 +0200)
mod/smilies.php [deleted file]
src/App/Router.php
src/Module/Smilies.php [new file with mode: 0644]
view/templates/smilies.tpl [new file with mode: 0644]

diff --git a/mod/smilies.php b/mod/smilies.php
deleted file mode 100644 (file)
index bbb7de2..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-/**
- * @file mod/smilies.php
- */
-use Friendica\App;
-use Friendica\Content\Smilies;
-use Friendica\Core\System;
-
-/**
- * @param App $a App
- * @return string
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
- */
-function smilies_content(App $a)
-{
-       $smilies = Smilies::getList();
-       if (!empty($a->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 = '<div class="smiley-sample">';
-               for ($x = 0; $x < count($smilies['texts']); $x ++) {
-                       $s .= '<dl><dt>' . $smilies['texts'][$x] . '</dt><dd>' . $smilies['icons'][$x] . '</dd></dl>';
-               }
-               $s .= '</div>';
-
-               return $s;
-       }
-}
index 1dffb6b406f0d3b22bd75880710bd56a5eee8437..30375667a372c0eb29a13b84ef9b9d9ee309e5ae 100644 (file)
@@ -165,6 +165,7 @@ class Router
                });
                $this->routeCollector->addRoute(['GET', 'POST'], '/register',            Module\Register::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'],         '/webfinger',           Module\WebFinger::class);
diff --git a/src/Module/Smilies.php b/src/Module/Smilies.php
new file mode 100644 (file)
index 0000000..df4b4e1
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Core\Renderer;
+use Friendica\Core\System;
+
+/**
+ * Prints the possible Smilies of this node
+ */
+class Smilies extends BaseModule
+{
+       public static function content()
+       {
+               $smilies = \Friendica\Content\Smilies::getList();
+               $count = count(defaults($smilies, 'texts', []));
+
+               $tpl = Renderer::getMarkupTemplate('smilies.tpl');
+               return Renderer::replaceMacros($tpl, [
+                       '$count'   => $count,
+                       '$smilies' => $smilies,
+               ]);
+       }
+
+       public static function rawContent()
+       {
+               $app = self::getApp();
+               $smilies = \Friendica\Content\Smilies::getList();
+
+               if (!empty($app->argv[1]) && ($app->argv[1] === "json")) {
+                       $results = [];
+                       for ($i = 0; $i < count($smilies['texts']); $i++) {
+                               $results[] = ['text' => $smilies['texts'][$i], 'icon' => $smilies['icons'][$i]];
+                       }
+                       System::jsonExit($results);
+               }
+       }
+}
diff --git a/view/templates/smilies.tpl b/view/templates/smilies.tpl
new file mode 100644 (file)
index 0000000..6f9fda8
--- /dev/null
@@ -0,0 +1,10 @@
+<div id="smilies" class="generic-page-wrapper">
+       <div class="smiley-sample">
+               {{for $i=0 to $count}}
+               <dl>
+                       <dt>{{$smilies.texts[$i] nofilter}}</dt>
+                       <dd>{{$smilies.icons[$i] nofilter}}</dd>
+               </dl>
+               {{/for}}
+       </div>
+</div>