3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module\Moderation\Item;
25 use Friendica\Core\Config\Capability\IManageConfigValues;
26 use Friendica\Core\L10n;
27 use Friendica\Core\Renderer;
28 use Friendica\Core\Session\Capability\IHandleUserSessions;
30 use Friendica\Module\BaseModeration;
31 use Friendica\Module\Response;
32 use Friendica\Navigation\SystemMessages;
33 use Friendica\Util\Profiler;
34 use Psr\Log\LoggerInterface;
36 class Source extends BaseModeration
38 /** @var IManageConfigValues */
41 public function __construct(IManageConfigValues $config, App\Page $page, App $app, SystemMessages $systemMessages, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
43 parent::__construct($page, $app, $systemMessages, $session, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
45 $this->config = $config;
48 protected function content(array $request = []): string
52 $guid = basename($request['guid'] ?? $this->parameters['guid'] ?? '');
59 $item = Model\Post::selectFirst(['id', 'uri-id', 'guid', 'uri'], ['guid' => $guid]);
62 $item_id = $item['id'];
63 $item_uri = $item['uri'];
64 $terms = Model\Tag::getByURIId($item['uri-id'], [Model\Tag::HASHTAG, Model\Tag::MENTION, Model\Tag::IMPLICIT_MENTION]);
66 $activity = Model\Post\Activity::getByURIId($item['uri-id']);
67 if (!empty($activity)) {
68 $source = $activity['activity'];
73 $tpl = Renderer::getMarkupTemplate('moderation/item/source.tpl');
74 return Renderer::replaceMacros($tpl, [
76 'title' => $this->t('Item Source'),
77 'itemidlbl' => $this->t('Item Id'),
78 'itemurilbl' => $this->t('Item URI'),
79 'submit' => $this->t('Submit'),
80 'termslbl' => $this->t('Terms'),
81 'taglbl' => $this->t('Tag'),
82 'typelbl' => $this->t('Type'),
83 'termlbl' => $this->t('Term'),
84 'urllbl' => $this->t('URL'),
85 'mentionlbl' => $this->t('Mention'),
86 'implicitlbl' => $this->t('Implicit Mention'),
87 'error' => $this->t('Error'),
88 'notfound' => $this->t('Item not found'),
89 'nosource' => $this->t('No source recorded'),
90 'noconfig' => !$this->config->get('debug', 'store_source') ? $this->t('Please make sure the <code>debug.store_source</code> config key is set in <code>config/local.config.php</code> for future items to have sources.') : '',
92 '$guid_field' => ['guid', $this->t('Item Guid'), $guid, ''],
94 '$item_uri' => $item_uri,
95 '$item_id' => $item_id,