]> git.mxchange.org Git - friendica.git/commitdiff
Add itemsource module
authorHypolite Petovan <hypolite@mrpetovan.com>
Fri, 19 Oct 2018 02:49:25 +0000 (22:49 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Fri, 19 Oct 2018 02:49:25 +0000 (22:49 -0400)
src/Model/Conversation.php
src/Module/Itemsource.php [new file with mode: 0644]
view/templates/debug/itemsource.tpl [new file with mode: 0644]

index be1eaf2295582a7e1bb1e0777cd7410a63e56f83..25075dcfbe41cbdab375d0c964c74c62fddd9d3f 100644 (file)
@@ -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 (file)
index 0000000..bcbd557
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+namespace Friendica\Module;
+
+use Friendica\Core\L10n;
+use Friendica\Model;
+
+/**
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+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 (file)
index 0000000..377409e
--- /dev/null
@@ -0,0 +1,28 @@
+<h2>Item Source</h2>
+<form action="itemsource" method="get" class="panel panel-default">
+       <div class="panel-body">
+               <div class="form-group">
+                       {{include file="field_input.tpl" field=$guid}}
+               </div>
+               <p><button type="submit" class="btn btn-primary">Submit</button></p>
+       </div>
+</form>
+
+{{if $source}}
+<div class="itemsource-results">
+       <div class="panel panel-default">
+               <div class="panel-heading">
+                       <h3 class="panel-title">Item URI</h3>
+               </div>
+               <div class="panel-body">
+                       {{$item_uri}}
+               </div>
+       </div>
+       <div class="panel panel-default">
+               <div class="panel-heading">
+                       <h3 class="panel-title">Source</h3>
+               </div>
+               <pre><code class="language-php">{{$source}}</code></pre>
+       </div>
+</div>
+{{/if}}