From d0681075bf7b6d1bf998da8ac2c43ce2134f4804 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 18 Oct 2018 22:49:25 -0400 Subject: [PATCH] Add itemsource module --- src/Model/Conversation.php | 5 ++++ src/Module/Itemsource.php | 39 +++++++++++++++++++++++++++++ view/templates/debug/itemsource.tpl | 28 +++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 src/Module/Itemsource.php create mode 100644 view/templates/debug/itemsource.tpl diff --git a/src/Model/Conversation.php b/src/Model/Conversation.php index be1eaf2295..25075dcfbe 100644 --- a/src/Model/Conversation.php +++ b/src/Model/Conversation.php @@ -26,6 +26,11 @@ class Conversation const PARCEL_TWITTER = 67; const PARCEL_UNKNOWN = 255; + public static function getByItemUri($item_uri) + { + return DBA::selectFirst('conversation', [], ['item-uri' => $item_uri]); + } + /** * @brief Store the conversation data * diff --git a/src/Module/Itemsource.php b/src/Module/Itemsource.php new file mode 100644 index 0000000000..bcbd557182 --- /dev/null +++ b/src/Module/Itemsource.php @@ -0,0 +1,39 @@ + + */ +class Itemsource extends \Friendica\BaseModule +{ + public static function content() + { + if (!is_site_admin()) { + return; + } + + $source = ''; + $item_uri = ''; + if (!empty($_REQUEST['guid'])) { + $item = Model\Item::selectFirst([], ['guid' => $_REQUEST['guid']]); + + $conversation = Model\Conversation::getByItemUri($item['uri']); + + $item_uri = $item['uri']; + $source = htmlspecialchars($conversation['source']); + } + + $tpl = get_markup_template('debug/itemsource.tpl'); + $o = replace_macros($tpl, [ + '$guid' => ['guid', L10n::t('Item Guid'), htmlentities(defaults($_REQUEST, 'guid', '')), ''], + '$source' => $source, + '$item_uri' => $item_uri + ]); + + return $o; + } +} diff --git a/view/templates/debug/itemsource.tpl b/view/templates/debug/itemsource.tpl new file mode 100644 index 0000000000..377409ebf3 --- /dev/null +++ b/view/templates/debug/itemsource.tpl @@ -0,0 +1,28 @@ +

Item Source

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

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

Item URI

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

Source

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