]> git.mxchange.org Git - friendica.git/blob - mod/bookmarklet.php
Docs: add a note on adding `use` on theme.php
[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\L10n;
9 use Friendica\Core\System;
10 use Friendica\Module\Login;
11
12 require_once 'include/conversation.php';
13 require_once 'include/items.php';
14
15 function bookmarklet_init()
16 {
17         $_GET["mode"] = "minimal";
18 }
19
20 function bookmarklet_content(App $a)
21 {
22         if (!local_user()) {
23                 $o = '<h2>' . L10n::t('Login') . '</h2>';
24                 $o .= Login::form($a->query_string, $a->config['register_policy'] == REGISTER_CLOSED ? false : true);
25                 return $o;
26         }
27
28         $referer = normalise_link($_SERVER["HTTP_REFERER"]);
29         $page = normalise_link(System::baseUrl() . "/bookmarklet");
30
31         if (!strstr($referer, $page)) {
32                 $content = add_page_info($_REQUEST["url"]);
33
34                 $x = [
35                         'is_owner' => true,
36                         'allow_location' => $a->user['allow_location'],
37                         'default_location' => $a->user['default-location'],
38                         'nickname' => $a->user['nickname'],
39                         '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'),
40                         'default_perms' => ACL::getDefaultUserPermissions($a->user),
41                         'acl' => ACL::getFullSelectorHTML($a->user, true),
42                         'bang' => '',
43                         'visitor' => 'block',
44                         'profile_uid' => local_user(),
45                         'title' => trim($_REQUEST["title"], "*"),
46                         'content' => $content
47                 ];
48                 $o = status_editor($a, $x, 0, false);
49                 $o .= "<script>window.resizeTo(800,550);</script>";
50         } else {
51                 $o = '<h2>' . L10n::t('The post was created') . '</h2>';
52                 $o .= "<script>window.close()</script>";
53         }
54
55         return $o;
56 }