]> git.mxchange.org Git - friendica.git/blob - src/Module/Itemsource.php
Add routes for current BaseModules
[friendica.git] / src / Module / Itemsource.php
1 <?php
2
3 namespace Friendica\Module;
4
5 use Friendica\Core\L10n;
6 use Friendica\Core\Renderer;
7 use Friendica\Model;
8
9 /**
10  * @author Hypolite Petovan <mrpetovan@gmail.com>
11  */
12 class Itemsource extends \Friendica\BaseModule
13 {
14         public static function content()
15         {
16                 if (!is_site_admin()) {
17                         return;
18                 }
19
20                 $a = self::getApp();
21
22                 // @TODO: Replace with parameter from router
23                 if (!empty($a->argv[1])) {
24                         $guid = $a->argv[1];
25                 }
26
27                 $guid = defaults($_REQUEST['guid'], $guid);
28
29                 $source = '';
30                 $item_uri = '';
31                 $item_id = '';
32                 $terms = [];
33                 if (!empty($guid)) {
34                         $item = Model\Item::selectFirst(['id', 'guid', 'uri'], ['guid' => $guid]);
35
36                         $conversation = Model\Conversation::getByItemUri($item['uri']);
37
38                         $item_id = $item['id'];
39                         $item_uri = $item['uri'];
40                         $source = $conversation['source'];
41                         $terms = Model\Term::tagArrayFromItemId($item['id'], [Model\Term::HASHTAG, Model\Term::MENTION, Model\Term::IMPLICIT_MENTION]);
42                 }
43
44                 $tpl = Renderer::getMarkupTemplate('debug/itemsource.tpl');
45                 $o = Renderer::replaceMacros($tpl, [
46                         '$guid'          => ['guid', L10n::t('Item Guid'), $guid, ''],
47                         '$source'        => $source,
48                         '$item_uri'      => $item_uri,
49                         '$item_id'       => $item_id,
50                         '$terms'         => $terms,
51                 ]);
52
53                 return $o;
54         }
55 }