]> git.mxchange.org Git - friendica.git/commitdiff
Move /itemsource to src/Module/Admin
authorHypolite Petovan <hypolite@mrpetovan.com>
Fri, 26 Apr 2019 04:08:08 +0000 (00:08 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Thu, 2 May 2019 13:52:53 +0000 (09:52 -0400)
src/App/Router.php
src/Module/Admin/Item/Source.php [new file with mode: 0644]
src/Module/BaseAdminModule.php
view/templates/admin/item/source.tpl [new file with mode: 0644]
view/templates/debug/itemsource.tpl [deleted file]

index c70c0c480c4d53bfb48f523e181aef5e9650cb8b..e0048a3321aadea4e99daedd7445b534cd68d772 100644 (file)
@@ -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 (file)
index 0000000..f5eb5af
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+
+namespace Friendica\Module\Admin\Item;
+
+use Friendica\Core\L10n;
+use Friendica\Core\Renderer;
+use Friendica\Model;
+
+/**
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+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;
+       }
+}
index 93f60172d23555a8851143a8efe1b0b0bb185815..42197aa51cc59e316337ff88d12514a1f5090396 100644 (file)
@@ -74,6 +74,9 @@ abstract class BaseAdminModule extends BaseModule
                                'logsconfig'   => ['admin/logs/', L10n::t('Logs')                   , 'logs'],\r
                                'logsview'     => ['admin/logs/view'    , L10n::t('View Logs')              , 'viewlogs'],\r
                        ]],\r
+                       'diagnostics' => [L10n::t('Diagnostics'), [\r
+                               'itemsource'   => ['admin/item/source' , L10n::t('Item Source')             , 'itemsource'],\r
+                       ]],\r
                ];\r
 \r
                $addons_admin = [];\r
diff --git a/view/templates/admin/item/source.tpl b/view/templates/admin/item/source.tpl
new file mode 100644 (file)
index 0000000..4f985cb
--- /dev/null
@@ -0,0 +1,65 @@
+<h2>Item Source</h2>
+<form action="admin/item/source" 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 Id</h3>
+               </div>
+               <div class="panel-body">
+                       {{$item_id}}
+               </div>
+       </div>
+       <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">Terms</h3>
+               </div>
+               <div class="panel-body">
+                       <table class="table table-condensed table-striped">
+                               <tr>
+                                       <th>Type</th>
+                                       <th>Term</th>
+                                       <th>URL</th>
+                               </tr>
+               {{foreach $terms as $term}}
+                               <tr>
+                                       <td>
+                       {{if $term.type == 1}}Tag{{/if}}
+                       {{if $term.type == 2}}Mention{{/if}}
+                       {{if $term.type == 8}}Implicit Mention{{/if}}
+                                       </td>
+                                       <td>
+                                               {{$term.term}}
+                                       </td>
+                                       <td>
+                                               {{$term.url}}
+                                       </td>
+                               </tr>
+               {{/foreach}}
+                       </table>
+               </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}}
diff --git a/view/templates/debug/itemsource.tpl b/view/templates/debug/itemsource.tpl
deleted file mode 100644 (file)
index 0d925b3..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<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 Id</h3>
-               </div>
-               <div class="panel-body">
-                       {{$item_id}}
-               </div>
-       </div>
-       <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">Terms</h3>
-               </div>
-               <div class="panel-body">
-                       <table class="table table-condensed table-striped">
-                               <tr>
-                                       <th>Type</th>
-                                       <th>Term</th>
-                                       <th>URL</th>
-                               </tr>
-               {{foreach $terms as $term}}
-                               <tr>
-                                       <td>
-                       {{if $term.type == 1}}Tag{{/if}}
-                       {{if $term.type == 2}}Mention{{/if}}
-                       {{if $term.type == 8}}Implicit Mention{{/if}}
-                                       </td>
-                                       <td>
-                                               {{$term.term}}
-                                       </td>
-                                       <td>
-                                               {{$term.url}}
-                                       </td>
-                               </tr>
-               {{/foreach}}
-                       </table>
-               </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}}