Browse Source

Move mod/smilies to src/Module/Smilies

pull/7103/head
Philipp Holzer 2 years ago
parent
commit
e90876cd86
No known key found for this signature in database GPG Key ID: 517BE60E2CE5C8A5
4 changed files with 50 additions and 32 deletions
  1. +0
    -32
      mod/smilies.php
  2. +1
    -0
      src/App/Router.php
  3. +39
    -0
      src/Module/Smilies.php
  4. +10
    -0
      view/templates/smilies.tpl

+ 0
- 32
mod/smilies.php 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;
}
}

+ 1
- 0
src/App/Router.php View 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);


+ 39
- 0
src/Module/Smilies.php 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);
}
}
}

+ 10
- 0
view/templates/smilies.tpl 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>

Loading…
Cancel
Save