3 * @copyright Copyright (C) 2020, Friendica
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Module;
24 use Friendica\BaseModule;
25 use Friendica\Content\PageInfo;
26 use Friendica\Core\ACL;
28 use Friendica\Module\Security\Login;
29 use Friendica\Network\HTTPException;
30 use Friendica\Util\Strings;
33 * Creates a bookmarklet
34 * Shows either a editor browser or adds the given bookmarklet to the current user
36 class Bookmarklet extends BaseModule
38 public static function content(array $parameters = [])
40 $_GET['mode'] = 'minimal';
43 $config = DI::config();
46 $output = '<h2>' . DI::l10n()->t('Login') . '</h2>';
47 $output .= Login::form(DI::args()->getQueryString(), intval($config->get('config', 'register_policy')) === Register::CLOSED ? false : true);
51 $referer = Strings::normaliseLink($_SERVER['HTTP_REFERER'] ?? '');
52 $page = Strings::normaliseLink(DI::baseUrl()->get() . "/bookmarklet");
54 if (!strstr($referer, $page)) {
55 if (empty($_REQUEST["url"])) {
56 throw new HTTPException\BadRequestException(DI::l10n()->t('This page is missing a url parameter.'));
59 $content = "\n" . PageInfo::getFooterFromUrl($_REQUEST['url']);
63 'allow_location' => $app->user['allow_location'],
64 'default_location' => $app->user['default-location'],
65 'nickname' => $app->user['nickname'],
66 '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'),
67 'default_perms' => ACL::getDefaultUserPermissions($app->user),
68 'acl' => ACL::getFullSelectorHTML(DI::page(), $app->user, true),
71 'profile_uid' => local_user(),
72 'title' => trim($_REQUEST['title'] ?? '', '*'),
75 $output = status_editor($app, $x, 0, false);
76 $output .= "<script>window.resizeTo(800,550);</script>";
78 $output = '<h2>' . DI::l10n()->t('The post was created') . '</h2>';
79 $output .= "<script>window.close()</script>";