3 namespace Friendica\Module;
5 use Friendica\BaseModule;
6 use Friendica\Core\ACL;
8 use Friendica\Module\Security\Login;
9 use Friendica\Network\HTTPException;
10 use Friendica\Util\Strings;
13 * Creates a bookmarklet
14 * Shows either a editor browser or adds the given bookmarklet to the current user
16 class Bookmarklet extends BaseModule
18 public static function content(array $parameters = [])
20 $_GET['mode'] = 'minimal';
23 $config = DI::config();
26 $output = '<h2>' . DI::l10n()->t('Login') . '</h2>';
27 $output .= Login::form(DI::args()->getQueryString(), intval($config->get('config', 'register_policy')) === Register::CLOSED ? false : true);
31 $referer = Strings::normaliseLink($_SERVER['HTTP_REFERER'] ?? '');
32 $page = Strings::normaliseLink(DI::baseUrl()->get() . "/bookmarklet");
34 if (!strstr($referer, $page)) {
35 if (empty($_REQUEST["url"])) {
36 throw new HTTPException\BadRequestException(DI::l10n()->t('This page is missing a url parameter.'));
39 $content = add_page_info($_REQUEST["url"]);
43 'allow_location' => $app->user['allow_location'],
44 'default_location' => $app->user['default-location'],
45 'nickname' => $app->user['nickname'],
46 'lockstate' => ((is_array($app->user) && ((strlen($app->user['allow_cid'])) || (strlen($app->user['allow_gid'])) || (strlen($app->user['deny_cid'])) || (strlen($app->user['deny_gid'])))) ? 'lock' : 'unlock'),
47 'default_perms' => ACL::getDefaultUserPermissions($app->user),
48 'acl' => ACL::getFullSelectorHTML(DI::page(), $app->user, true),
51 'profile_uid' => local_user(),
52 'title' => trim($_REQUEST['title'] ?? '', '*'),
55 $output = status_editor($app, $x, 0, false);
56 $output .= "<script>window.resizeTo(800,550);</script>";
58 $output = '<h2>' . DI::l10n()->t('The post was created') . '</h2>';
59 $output .= "<script>window.close()</script>";