]> git.mxchange.org Git - friendica.git/blob - mod/bookmarklet.php
Merge pull request #6226 from annando/oembed-array
[friendica.git] / mod / bookmarklet.php
1 <?php
2 /**
3  * @file mod/bookmarklet.php
4  */
5
6 use Friendica\App;
7 use Friendica\Core\ACL;
8 use Friendica\Core\Config;
9 use Friendica\Core\L10n;
10 use Friendica\Core\System;
11 use Friendica\Module\Login;
12 use Friendica\Util\Strings;
13
14 require_once 'include/conversation.php';
15 require_once 'include/items.php';
16
17 function bookmarklet_init()
18 {
19         $_GET["mode"] = "minimal";
20 }
21
22 function bookmarklet_content(App $a)
23 {
24         if (!local_user()) {
25                 $o = '<h2>' . L10n::t('Login') . '</h2>';
26                 $o .= Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? false : true);
27                 return $o;
28         }
29
30         $referer = Strings::normaliseLink(defaults($_SERVER, 'HTTP_REFERER', ''));
31         $page = Strings::normaliseLink(System::baseUrl() . "/bookmarklet");
32
33         if (!strstr($referer, $page)) {
34                 if (empty($_REQUEST["url"])) {
35                         System::httpExit(400, ["title" => L10n::t('Bad Request')]);
36                 }
37
38                 $content = add_page_info($_REQUEST["url"]);
39
40                 $x = [
41                         'is_owner' => true,
42                         'allow_location' => $a->user['allow_location'],
43                         'default_location' => $a->user['default-location'],
44                         'nickname' => $a->user['nickname'],
45                         'lockstate' => ((is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid'])))) ? 'lock' : 'unlock'),
46                         'default_perms' => ACL::getDefaultUserPermissions($a->user),
47                         'acl' => ACL::getFullSelectorHTML($a->user, true),
48                         'bang' => '',
49                         'visitor' => 'block',
50                         'profile_uid' => local_user(),
51                         'title' => trim(defaults($_REQUEST, 'title', ''), "*"),
52                         'content' => $content
53                 ];
54                 $o = status_editor($a, $x, 0, false);
55                 $o .= "<script>window.resizeTo(800,550);</script>";
56         } else {
57                 $o = '<h2>' . L10n::t('The post was created') . '</h2>';
58                 $o .= "<script>window.close()</script>";
59         }
60
61         return $o;
62 }