3 namespace Friendica\Module;
5 use Friendica\BaseModule;
6 use Friendica\Core\ACL;
7 use Friendica\Core\L10n;
8 use Friendica\Network\HTTPException;
9 use Friendica\Util\Strings;
12 * Creates a bookmarklet
13 * Shows either a editor browser or adds the given bookmarklet to the current user
15 class Bookmarklet extends BaseModule
17 public static function content(array $parameters = [])
19 $_GET['mode'] = 'minimal';
21 $app = self::getApp();
22 $config = $app->getConfig();
25 $output = '<h2>' . L10n::t('Login') . '</h2>';
26 $output .= Login::form($app->query_string, intval($config->get('config', 'register_policy')) === Register::CLOSED ? false : true);
30 $referer = Strings::normaliseLink($_SERVER['HTTP_REFERER'] ?? '');
31 $page = Strings::normaliseLink($app->getBaseURL() . "/bookmarklet");
33 if (!strstr($referer, $page)) {
34 if (empty($_REQUEST["url"])) {
35 throw new HTTPException\BadRequestException(L10n::t('This page is missing a url parameter.'));
38 $content = add_page_info($_REQUEST["url"]);
42 'allow_location' => $app->user['allow_location'],
43 'default_location' => $app->user['default-location'],
44 'nickname' => $app->user['nickname'],
45 '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'),
46 'default_perms' => ACL::getDefaultUserPermissions($app->user),
47 'acl' => ACL::getFullSelectorHTML($app->page, $app->user, true),
50 'profile_uid' => local_user(),
51 'title' => trim($_REQUEST['title'] ?? '', '*'),
54 $output = status_editor($app, $x, 0, false);
55 $output .= "<script>window.resizeTo(800,550);</script>";
57 $output = '<h2>' . L10n::t('The post was created') . '</h2>';
58 $output .= "<script>window.close()</script>";