3 namespace Friendica\Module;
5 use Friendica\BaseModule;
6 use Friendica\Core\ACL;
7 use Friendica\Core\L10n;
9 use Friendica\Module\Security\Login;
10 use Friendica\Network\HTTPException;
11 use Friendica\Util\Strings;
14 * Creates a bookmarklet
15 * Shows either a editor browser or adds the given bookmarklet to the current user
17 class Bookmarklet extends BaseModule
19 public static function content(array $parameters = [])
21 $_GET['mode'] = 'minimal';
24 $config = DI::config();
27 $output = '<h2>' . L10n::t('Login') . '</h2>';
28 $output .= Login::form(DI::args()->getQueryString(), intval($config->get('config', 'register_policy')) === Register::CLOSED ? false : true);
32 $referer = Strings::normaliseLink($_SERVER['HTTP_REFERER'] ?? '');
33 $page = Strings::normaliseLink(DI::baseUrl()->get() . "/bookmarklet");
35 if (!strstr($referer, $page)) {
36 if (empty($_REQUEST["url"])) {
37 throw new HTTPException\BadRequestException(L10n::t('This page is missing a url parameter.'));
40 $content = add_page_info($_REQUEST["url"]);
44 'allow_location' => $app->user['allow_location'],
45 'default_location' => $app->user['default-location'],
46 'nickname' => $app->user['nickname'],
47 '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'),
48 'default_perms' => ACL::getDefaultUserPermissions($app->user),
49 'acl' => ACL::getFullSelectorHTML(DI::page(), $app->user, true),
52 'profile_uid' => local_user(),
53 'title' => trim($_REQUEST['title'] ?? '', '*'),
56 $output = status_editor($app, $x, 0, false);
57 $output .= "<script>window.resizeTo(800,550);</script>";
59 $output = '<h2>' . L10n::t('The post was created') . '</h2>';
60 $output .= "<script>window.close()</script>";