Move mod/smilies to src/Module/Smilies

This commit is contained in:
Philipp Holzer 2019-05-05 19:39:02 +02:00
parent 155d541860
commit e90876cd86
No known key found for this signature in database
GPG Key ID: 517BE60E2CE5C8A5
4 changed files with 50 additions and 32 deletions

View File

@ -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;
}
}

View File

@ -165,6 +165,7 @@ class Router
}); });
$this->routeCollector->addRoute(['GET', 'POST'], '/register', Module\Register::class); $this->routeCollector->addRoute(['GET', 'POST'], '/register', Module\Register::class);
$this->routeCollector->addRoute(['GET'], '/rsd.xml', Module\ReallySimpleDiscovery::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'], '/statistics.json', Module\Statistics::class);
$this->routeCollector->addRoute(['GET'], '/tos', Module\Tos::class); $this->routeCollector->addRoute(['GET'], '/tos', Module\Tos::class);
$this->routeCollector->addRoute(['GET'], '/webfinger', Module\WebFinger::class); $this->routeCollector->addRoute(['GET'], '/webfinger', Module\WebFinger::class);

39
src/Module/Smilies.php Normal file
View File

@ -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);
}
}
}

View File

@ -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>