From ad02fd140a2d18feebb83e86c2cb74501ad0f9fa Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Fri, 26 Apr 2019 00:08:08 -0400 Subject: [PATCH] Move /itemsource to src/Module/Admin --- src/App/Router.php | 1 + src/Module/Admin/Item/Source.php | 54 +++++++++++++++++++ src/Module/BaseAdminModule.php | 3 ++ .../itemsource.tpl => admin/item/source.tpl} | 2 +- 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/Module/Admin/Item/Source.php rename view/templates/{debug/itemsource.tpl => admin/item/source.tpl} (94%) diff --git a/src/App/Router.php b/src/App/Router.php index c70c0c480c..e0048a3321 100644 --- a/src/App/Router.php +++ b/src/App/Router.php @@ -135,6 +135,7 @@ class Router $collector->addRoute(['GET'] , '/federation' , Module\Admin\Federation::class); $collector->addRoute(['GET', 'POST'], '/item/delete' , Module\Admin\Item\Delete::class); + $collector->addRoute(['GET', 'POST'], '/item/source[/{guid}]' , Module\Admin\Item\Source::class); $collector->addRoute(['GET'] , '/logs/view' , Module\Admin\Logs\View::class); $collector->addRoute(['GET', 'POST'], '/logs' , Module\Admin\Logs\Settings::class); diff --git a/src/Module/Admin/Item/Source.php b/src/Module/Admin/Item/Source.php new file mode 100644 index 0000000000..f5eb5afb68 --- /dev/null +++ b/src/Module/Admin/Item/Source.php @@ -0,0 +1,54 @@ + + */ +class Source extends \Friendica\BaseModule +{ + public static function content() + { + if (!is_site_admin()) { + return; + } + + $a = self::getApp(); + + if (!empty($a->argv[1])) { + $guid = $a->argv[1]; + } + + $guid = defaults($_REQUEST['guid'], $guid); + + $source = ''; + $item_uri = ''; + $item_id = ''; + $terms = []; + if (!empty($guid)) { + $item = Model\Item::selectFirst(['id', 'guid', 'uri'], ['guid' => $guid]); + + $conversation = Model\Conversation::getByItemUri($item['uri']); + + $item_id = $item['id']; + $item_uri = $item['uri']; + $source = $conversation['source']; + $terms = Model\Term::tagArrayFromItemId($item['id'], [Model\Term::HASHTAG, Model\Term::MENTION, Model\Term::IMPLICIT_MENTION]); + } + + $tpl = Renderer::getMarkupTemplate('admin/item/source.tpl'); + $o = Renderer::replaceMacros($tpl, [ + '$guid' => ['guid', L10n::t('Item Guid'), $guid, ''], + '$source' => $source, + '$item_uri' => $item_uri, + '$item_id' => $item_id, + '$terms' => $terms, + ]); + + return $o; + } +} diff --git a/src/Module/BaseAdminModule.php b/src/Module/BaseAdminModule.php index 93f60172d2..42197aa51c 100644 --- a/src/Module/BaseAdminModule.php +++ b/src/Module/BaseAdminModule.php @@ -74,6 +74,9 @@ abstract class BaseAdminModule extends BaseModule 'logsconfig' => ['admin/logs/', L10n::t('Logs') , 'logs'], 'logsview' => ['admin/logs/view' , L10n::t('View Logs') , 'viewlogs'], ]], + 'diagnostics' => [L10n::t('Diagnostics'), [ + 'itemsource' => ['admin/item/source' , L10n::t('Item Source') , 'itemsource'], + ]], ]; $addons_admin = []; diff --git a/view/templates/debug/itemsource.tpl b/view/templates/admin/item/source.tpl similarity index 94% rename from view/templates/debug/itemsource.tpl rename to view/templates/admin/item/source.tpl index 0d925b3c8a..4f985cbdce 100644 --- a/view/templates/debug/itemsource.tpl +++ b/view/templates/admin/item/source.tpl @@ -1,5 +1,5 @@

Item Source

-
+
{{include file="field_input.tpl" field=$guid}}