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 init()
19 $_GET['mode'] = 'minimal';
22 public static function content()
24 $app = self::getApp();
25 $config = $app->getConfig();
28 $output = '<h2>' . L10n::t('Login') . '</h2>';
29 $output .= Login::form($app->query_string, intval($config->get('config', 'register_policy')) === Register::CLOSED ? false : true);
33 $referer = Strings::normaliseLink(defaults($_SERVER, 'HTTP_REFERER', ''));
34 $page = Strings::normaliseLink($app->getBaseURL() . "/bookmarklet");
36 if (!strstr($referer, $page)) {
37 if (empty($_REQUEST["url"])) {
38 throw new HTTPException\BadRequestException(L10n::t('This page is missing a url parameter.'));
41 $content = add_page_info($_REQUEST["url"]);
45 'allow_location' => $app->user['allow_location'],
46 'default_location' => $app->user['default-location'],
47 'nickname' => $app->user['nickname'],
48 'lockstate' => ((is_array($app->user) && ((strlen($app->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($app->user['deny_cid'])) || (strlen($app->user['deny_gid'])))) ? 'lock' : 'unlock'),
49 'default_perms' => ACL::getDefaultUserPermissions($app->user),
50 'acl' => ACL::getFullSelectorHTML($app->user, true),
53 'profile_uid' => local_user(),
54 'title' => trim(defaults($_REQUEST, 'title', ''), '*'),
57 $output = status_editor($app, $x, 0, false);
58 $output .= "<script>window.resizeTo(800,550);</script>";
60 $output = '<h2>' . L10n::t('The post was created') . '</h2>';
61 $output .= "<script>window.close()</script>";