Improve Markdown::convert panel display in mod/babel
[friendica.git/.git] / mod / editpost.php
1 <?php
2 /**
3  * @file mod/editpost.php
4  */
5
6 use Friendica\App;
7 use Friendica\Content\Feature;
8 use Friendica\Core\Hook;
9 use Friendica\Core\L10n;
10 use Friendica\Core\Renderer;
11 use Friendica\Core\System;
12 use Friendica\Model\FileTag;
13 use Friendica\Model\Item;
14 use Friendica\Database\DBA;
15 use Friendica\Util\Crypto;
16
17 function editpost_content(App $a)
18 {
19         $o = '';
20
21         if (!local_user()) {
22                 notice(L10n::t('Permission denied.') . EOL);
23                 return;
24         }
25
26         $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
27
28         if (!$post_id) {
29                 notice(L10n::t('Item not found') . EOL);
30                 return;
31         }
32
33         $fields = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
34                 'type', 'body', 'title', 'file', 'wall', 'post-type', 'guid'];
35
36         $item = Item::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]);
37
38         if (!DBA::isResult($item)) {
39                 notice(L10n::t('Item not found') . EOL);
40                 return;
41         }
42
43         $geotag = '';
44
45         $o .= Renderer::replaceMacros(Renderer::getMarkupTemplate("section_title.tpl"), [
46                 '$title' => L10n::t('Edit post')
47         ]);
48
49         $tpl = Renderer::getMarkupTemplate('jot-header.tpl');
50         $a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
51                 '$baseurl' => System::baseUrl(),
52                 '$ispublic' => '&nbsp;', // L10n::t('Visible to <strong>everybody</strong>'),
53                 '$geotag' => $geotag,
54                 '$nickname' => $a->user['nickname']
55         ]);
56
57         if (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) {
58                 $lockstate = 'lock';
59         } else {
60                 $lockstate = 'unlock';
61         }
62
63         $jotplugins = '';
64         $jotnets = '';
65
66         Hook::callAll('jot_tool', $jotplugins);
67
68         $tpl = Renderer::getMarkupTemplate("jot.tpl");
69         $o .= Renderer::replaceMacros($tpl, [
70                 '$is_edit' => true,
71                 '$return_path' => '/display/' . $item['guid'],
72                 '$action' => 'item',
73                 '$share' => L10n::t('Save'),
74                 '$upload' => L10n::t('Upload photo'),
75                 '$shortupload' => L10n::t('upload photo'),
76                 '$attach' => L10n::t('Attach file'),
77                 '$shortattach' => L10n::t('attach file'),
78                 '$weblink' => L10n::t('Insert web link'),
79                 '$shortweblink' => L10n::t('web link'),
80                 '$video' => L10n::t('Insert video link'),
81                 '$shortvideo' => L10n::t('video link'),
82                 '$audio' => L10n::t('Insert audio link'),
83                 '$shortaudio' => L10n::t('audio link'),
84                 '$setloc' => L10n::t('Set your location'),
85                 '$shortsetloc' => L10n::t('set location'),
86                 '$noloc' => L10n::t('Clear browser location'),
87                 '$shortnoloc' => L10n::t('clear location'),
88                 '$wait' => L10n::t('Please wait'),
89                 '$permset' => L10n::t('Permission settings'),
90                 '$wall' => $item['wall'],
91                 '$posttype' => $item['post-type'],
92                 '$content' => undo_post_tagging($item['body']),
93                 '$post_id' => $post_id,
94                 '$baseurl' => System::baseUrl(),
95                 '$defloc' => $a->user['default-location'],
96                 '$visitor' => 'none',
97                 '$pvisit' => 'none',
98                 '$emailcc' => L10n::t('CC: email addresses'),
99                 '$public' => L10n::t('Public post'),
100                 '$jotnets' => $jotnets,
101                 '$title' => $item['title'],
102                 '$placeholdertitle' => L10n::t('Set title'),
103                 '$category' => FileTag::fileToList($item['file'], 'category'),
104                 '$placeholdercategory' => (Feature::isEnabled(local_user(),'categories') ? L10n::t("Categories \x28comma-separated list\x29") : ''),
105                 '$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'),
106                 '$lockstate' => $lockstate,
107                 '$acl' => '', // populate_acl((($group) ? $group_acl : $a->user)),
108                 '$bang' => ($lockstate === 'lock' ? '!' : ''),
109                 '$profile_uid' => $_SESSION['uid'],
110                 '$preview' => L10n::t('Preview'),
111                 '$jotplugins' => $jotplugins,
112                 '$sourceapp' => L10n::t($a->sourcename),
113                 '$cancel' => L10n::t('Cancel'),
114                 '$rand_num' => Crypto::randomDigits(12),
115
116                 //jot nav tab (used in some themes)
117                 '$message' => L10n::t('Message'),
118                 '$browser' => L10n::t('Browser'),
119                 '$shortpermset' => L10n::t('permissions'),
120         ]);
121
122         return $o;
123 }