Improve Module\Admin\Item\Source
- Use router parameter - Accept full URLs with GUID in form - Fix 500 error when item with guid doesn't exist
This commit is contained in:
parent
e78db3fac6
commit
7d726dbb0c
|
@ -33,15 +33,7 @@ class Source extends BaseAdmin
|
||||||
{
|
{
|
||||||
parent::content($parameters);
|
parent::content($parameters);
|
||||||
|
|
||||||
$a = DI::app();
|
$guid = basename($_REQUEST['guid'] ?? '') ?: $parameters['guid'];
|
||||||
|
|
||||||
$guid = null;
|
|
||||||
// @TODO: Replace with parameter from router
|
|
||||||
if (!empty($a->argv[3])) {
|
|
||||||
$guid = $a->argv[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
$guid = $_REQUEST['guid'] ?? $guid;
|
|
||||||
|
|
||||||
$source = '';
|
$source = '';
|
||||||
$item_uri = '';
|
$item_uri = '';
|
||||||
|
@ -50,6 +42,7 @@ class Source extends BaseAdmin
|
||||||
if (!empty($guid)) {
|
if (!empty($guid)) {
|
||||||
$item = Model\Item::selectFirst(['id', 'uri-id', 'guid', 'uri'], ['guid' => $guid]);
|
$item = Model\Item::selectFirst(['id', 'uri-id', 'guid', 'uri'], ['guid' => $guid]);
|
||||||
|
|
||||||
|
if ($item) {
|
||||||
$conversation = Model\Conversation::getByItemUri($item['uri']);
|
$conversation = Model\Conversation::getByItemUri($item['uri']);
|
||||||
|
|
||||||
$item_id = $item['id'];
|
$item_id = $item['id'];
|
||||||
|
@ -57,6 +50,7 @@ class Source extends BaseAdmin
|
||||||
$source = $conversation['source'];
|
$source = $conversation['source'];
|
||||||
$terms = Model\Tag::getByURIId($item['uri-id'], [Model\Tag::HASHTAG, Model\Tag::MENTION, Model\Tag::IMPLICIT_MENTION]);
|
$terms = Model\Tag::getByURIId($item['uri-id'], [Model\Tag::HASHTAG, Model\Tag::MENTION, Model\Tag::IMPLICIT_MENTION]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('admin/item/source.tpl');
|
$tpl = Renderer::getMarkupTemplate('admin/item/source.tpl');
|
||||||
$o = Renderer::replaceMacros($tpl, [
|
$o = Renderer::replaceMacros($tpl, [
|
||||||
|
|
Loading…
Reference in a new issue