Files
ussr-hubzilla-addons/link/Mod_Link.php
T

67 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace Zotlabs\Module;
2026-07-16 10:29:49 +03:00
use Zotlabs\Web\Controller;
2026-07-16 10:29:49 +03:00
class Link extends Controller {
2026-07-16 10:29:49 +03:00
function init() {
2020-11-07 16:02:21 +03:00
}
2026-07-16 10:29:49 +03:00
function get() {
2020-04-04 23:18:26 +03:00
2026-07-16 10:29:49 +03:00
$item_id = ((argc() > 1) ? intval(argv(1)) : 0);
2026-07-16 10:29:49 +03:00
if(! $item_id) {
\App::$error = 404;
notice( t('Item not found.') . EOL);
return;
2020-11-07 16:02:21 +03:00
}
2026-07-16 13:17:44 +03:00
$r = q("select uuid, mid from item where id = %d limit 1",
2026-07-16 10:29:49 +03:00
intval($item_id)
2020-11-07 16:02:21 +03:00
);
2026-07-16 10:29:49 +03:00
if (!$r) {
notice( t('Item not found.') . EOL);
return;
2020-11-07 16:02:21 +03:00
}
2026-07-16 13:17:44 +03:00
$identifier = $r[0]['uuid'] ?? '';
if (!$identifier) {
if ($r[0]['mid']) {
$identifier = 'b64.' . base64url_encode($r[0]['mid']);
}
}
if (!$identifier) {
notice( t('Item not found.') . EOL);
return;
2020-11-07 16:02:21 +03:00
}
2020-04-04 23:18:26 +03:00
2026-07-16 13:17:44 +03:00
$old_argv = \App::$argv;
$old_argc = \App::$argc;
\App::$argv = ['display', $identifier];
\App::$argc = 2;
$display = new Display();
$output = $display->get();
\App::$argv = $old_argv;
\App::$argc = $old_argc;
$separator = ' - ';
$page_title = \App::$page['title'];
if (substr($page_title, -strlen($separator)) === $separator) {
$page_title = substr($page_title, 0, -strlen($separator));
}
\App::$page['title'] = $page_title;
2020-04-04 23:18:26 +03:00
2026-07-16 13:17:44 +03:00
return $output;
2020-04-04 23:18:26 +03:00
}
2020-04-04 23:18:26 +03:00
}