From: Hypolite Petovan Date: Fri, 26 Apr 2019 04:08:08 +0000 (-0400) Subject: Move /itemsource to src/Module/Admin X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ad02fd140a2d18feebb83e86c2cb74501ad0f9fa;p=friendica.git Move /itemsource to src/Module/Admin --- 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/admin/item/source.tpl b/view/templates/admin/item/source.tpl new file mode 100644 index 0000000000..4f985cbdce --- /dev/null +++ b/view/templates/admin/item/source.tpl @@ -0,0 +1,65 @@ +

Item Source

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

+
+
+ +{{if $source}} +
+
+
+

Item Id

+
+
+ {{$item_id}} +
+
+
+
+

Item URI

+
+
+ {{$item_uri}} +
+
+
+
+

Terms

+
+
+ + + + + + + {{foreach $terms as $term}} + + + + + + {{/foreach}} +
TypeTermURL
+ {{if $term.type == 1}}Tag{{/if}} + {{if $term.type == 2}}Mention{{/if}} + {{if $term.type == 8}}Implicit Mention{{/if}} + + {{$term.term}} + + {{$term.url}} +
+
+
+
+
+

Source

+
+
{{$source}}
+
+
+{{/if}} diff --git a/view/templates/debug/itemsource.tpl b/view/templates/debug/itemsource.tpl deleted file mode 100644 index 0d925b3c8a..0000000000 --- a/view/templates/debug/itemsource.tpl +++ /dev/null @@ -1,65 +0,0 @@ -

Item Source

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

-
-
- -{{if $source}} -
-
-
-

Item Id

-
-
- {{$item_id}} -
-
-
-
-

Item URI

-
-
- {{$item_uri}} -
-
-
-
-

Terms

-
-
- - - - - - - {{foreach $terms as $term}} - - - - - - {{/foreach}} -
TypeTermURL
- {{if $term.type == 1}}Tag{{/if}} - {{if $term.type == 2}}Mention{{/if}} - {{if $term.type == 8}}Implicit Mention{{/if}} - - {{$term.term}} - - {{$term.url}} -
-
-
-
-
-

Source

-
-
{{$source}}
-
-
-{{/if}}