3 * @file mod/editpost.php
7 use Friendica\Content\Feature;
8 use Friendica\Core\Hook;
9 use Friendica\Core\L10n;
10 use Friendica\Core\Renderer;
11 use Friendica\Database\DBA;
12 use Friendica\Model\Contact;
13 use Friendica\Model\FileTag;
14 use Friendica\Model\Item;
15 use Friendica\Util\Crypto;
17 function editpost_content(App $a)
22 notice(L10n::t('Permission denied.') . EOL);
26 $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
29 notice(L10n::t('Item not found') . EOL);
33 $fields = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
34 'type', 'body', 'title', 'file', 'wall', 'post-type', 'guid'];
36 $item = Item::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]);
38 if (!DBA::isResult($item)) {
39 notice(L10n::t('Item not found') . EOL);
45 $o .= Renderer::replaceMacros(Renderer::getMarkupTemplate("section_title.tpl"), [
46 '$title' => L10n::t('Edit post')
49 $tpl = Renderer::getMarkupTemplate('jot-header.tpl');
50 $a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
51 '$ispublic' => ' ', // L10n::t('Visible to <strong>everybody</strong>'),
53 '$nickname' => $a->user['nickname']
56 if (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) {
59 $lockstate = 'unlock';
65 Hook::callAll('jot_tool', $jotplugins);
67 $tpl = Renderer::getMarkupTemplate("jot.tpl");
68 $o .= Renderer::replaceMacros($tpl, [
70 '$return_path' => '/display/' . $item['guid'],
72 '$share' => L10n::t('Save'),
73 '$upload' => L10n::t('Upload photo'),
74 '$shortupload' => L10n::t('upload photo'),
75 '$attach' => L10n::t('Attach file'),
76 '$shortattach' => L10n::t('attach file'),
77 '$weblink' => L10n::t('Insert web link'),
78 '$shortweblink' => L10n::t('web link'),
79 '$video' => L10n::t('Insert video link'),
80 '$shortvideo' => L10n::t('video link'),
81 '$audio' => L10n::t('Insert audio link'),
82 '$shortaudio' => L10n::t('audio link'),
83 '$setloc' => L10n::t('Set your location'),
84 '$shortsetloc' => L10n::t('set location'),
85 '$noloc' => L10n::t('Clear browser location'),
86 '$shortnoloc' => L10n::t('clear location'),
87 '$wait' => L10n::t('Please wait'),
88 '$permset' => L10n::t('Permission settings'),
89 '$wall' => $item['wall'],
90 '$posttype' => $item['post-type'],
91 '$content' => undo_post_tagging($item['body']),
92 '$post_id' => $post_id,
93 '$defloc' => $a->user['default-location'],
96 '$emailcc' => L10n::t('CC: email addresses'),
97 '$public' => L10n::t('Public post'),
98 '$jotnets' => $jotnets,
99 '$title' => $item['title'],
100 '$placeholdertitle' => L10n::t('Set title'),
101 '$category' => FileTag::fileToList($item['file'], 'category'),
102 '$placeholdercategory' => (Feature::isEnabled(local_user(),'categories') ? L10n::t("Categories \x28comma-separated list\x29") : ''),
103 '$emtitle' => L10n::t('Example: bob@example.com, mary@example.com'),
104 '$lockstate' => $lockstate,
105 '$acl' => '', // populate_acl((($group) ? $group_acl : $a->user)),
106 '$bang' => ($lockstate === 'lock' ? '!' : ''),
107 '$profile_uid' => $_SESSION['uid'],
108 '$preview' => L10n::t('Preview'),
109 '$jotplugins' => $jotplugins,
110 '$sourceapp' => L10n::t($a->sourcename),
111 '$cancel' => L10n::t('Cancel'),
112 '$rand_num' => Crypto::randomDigits(12),
114 //jot nav tab (used in some themes)
115 '$message' => L10n::t('Message'),
116 '$browser' => L10n::t('Browser'),
117 '$shortpermset' => L10n::t('permissions'),
123 function undo_post_tagging($s) {
125 $cnt = preg_match_all('/([!#@])\[url=(.*?)\](.*?)\[\/url\]/ism', $s, $matches, PREG_SET_ORDER);
127 foreach ($matches as $mtch) {
128 if (in_array($mtch[1], ['!', '@'])) {
129 $contact = Contact::getDetailsByURL($mtch[2]);
130 $mtch[3] = empty($contact['addr']) ? $mtch[2] : $contact['addr'];
132 $s = str_replace($mtch[0], $mtch[1] . $mtch[3],$s);