Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1577 lines
48 KiB

9 years ago
9 years ago
10 years ago
3 years ago
  1. <?php
  2. /**
  3. * @file include/conversation.php
  4. */
  5. use Friendica\App;
  6. use Friendica\Content\ContactSelector;
  7. use Friendica\Content\Feature;
  8. use Friendica\Content\Pager;
  9. use Friendica\Content\Text\BBCode;
  10. use Friendica\Core\Config;
  11. use Friendica\Core\Hook;
  12. use Friendica\Core\L10n;
  13. use Friendica\Core\Logger;
  14. use Friendica\Core\PConfig;
  15. use Friendica\Core\Protocol;
  16. use Friendica\Core\Renderer;
  17. use Friendica\Core\Session;
  18. use Friendica\Core\System;
  19. use Friendica\Database\DBA;
  20. use Friendica\Model\Contact;
  21. use Friendica\Model\Item;
  22. use Friendica\Model\Profile;
  23. use Friendica\Model\Term;
  24. use Friendica\Object\Post;
  25. use Friendica\Object\Thread;
  26. use Friendica\Util\DateTimeFormat;
  27. use Friendica\Util\Proxy as ProxyUtils;
  28. use Friendica\Util\Temporal;
  29. use Friendica\Util\Strings;
  30. use Friendica\Util\XML;
  31. use Friendica\Util\Crypto;
  32. function item_extract_images($body) {
  33. $saved_image = [];
  34. $orig_body = $body;
  35. $new_body = '';
  36. $cnt = 0;
  37. $img_start = strpos($orig_body, '[img');
  38. $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
  39. $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
  40. while (($img_st_close !== false) && ($img_end !== false)) {
  41. $img_st_close++; // make it point to AFTER the closing bracket
  42. $img_end += $img_start;
  43. if (!strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
  44. // This is an embedded image
  45. $saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close));
  46. $new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]';
  47. $cnt++;
  48. } else {
  49. $new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
  50. }
  51. $orig_body = substr($orig_body, $img_end + strlen('[/img]'));
  52. if ($orig_body === false) {
  53. // in case the body ends on a closing image tag
  54. $orig_body = '';
  55. }
  56. $img_start = strpos($orig_body, '[img');
  57. $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
  58. $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
  59. }
  60. $new_body = $new_body . $orig_body;
  61. return ['body' => $new_body, 'images' => $saved_image];
  62. }
  63. function item_redir_and_replace_images($body, $images, $cid) {
  64. $origbody = $body;
  65. $newbody = '';
  66. $cnt = 1;
  67. $pos = BBCode::getTagPosition($origbody, 'url', 0);
  68. while ($pos !== false && $cnt < 1000) {
  69. $search = '/\[url\=(.*?)\]\[!#saved_image([0-9]*)#!\]\[\/url\]' . '/is';
  70. $replace = '[url=' . System::baseUrl() . '/redir/' . $cid
  71. . '?f=1&url=' . '$1' . '][!#saved_image' . '$2' .'#!][/url]';
  72. $newbody .= substr($origbody, 0, $pos['start']['open']);
  73. $subject = substr($origbody, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']);
  74. $origbody = substr($origbody, $pos['end']['close']);
  75. if ($origbody === false) {
  76. $origbody = '';
  77. }
  78. $subject = preg_replace($search, $replace, $subject);
  79. $newbody .= $subject;
  80. $cnt++;
  81. // Isn't this supposed to use $cnt value for $occurrences? - @MrPetovan
  82. $pos = BBCode::getTagPosition($origbody, 'url', 0);
  83. }
  84. $newbody .= $origbody;
  85. $cnt = 0;
  86. foreach ($images as $image) {
  87. /*
  88. * We're depending on the property of 'foreach' (specified on the PHP website) that
  89. * it loops over the array starting from the first element and going sequentially
  90. * to the last element.
  91. */
  92. $newbody = str_replace('[!#saved_image' . $cnt . '#!]', '[img]' . $image . '[/img]', $newbody);
  93. $cnt++;
  94. }
  95. return $newbody;
  96. }
  97. /**
  98. * Render actions localized
  99. *
  100. * @param $item
  101. * @throws ImagickException
  102. * @throws \Friendica\Network\HTTPException\InternalServerErrorException
  103. */
  104. function localize_item(&$item)
  105. {
  106. $extracted = item_extract_images($item['body']);
  107. if ($extracted['images']) {
  108. $item['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $item['contact-id']);
  109. }
  110. /*
  111. heluecht 2018-06-19: from my point of view this whole code part is useless.
  112. It just renders the body message of technical posts (Like, dislike, ...).
  113. But: The body isn't visible at all. So we do this stuff just because we can.
  114. Even if these messages were visible, this would only mean that something went wrong.
  115. During the further steps of the database restructuring I would like to address this issue.
  116. */
  117. $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
  118. if (activity_match($item['verb'], ACTIVITY_LIKE)
  119. || activity_match($item['verb'], ACTIVITY_DISLIKE)
  120. || activity_match($item['verb'], ACTIVITY_ATTEND)
  121. || activity_match($item['verb'], ACTIVITY_ATTENDNO)
  122. || activity_match($item['verb'], ACTIVITY_ATTENDMAYBE)) {
  123. $fields = ['author-link', 'author-name', 'verb', 'object-type', 'resource-id', 'body', 'plink'];
  124. $obj = Item::selectFirst($fields, ['uri' => $item['parent-uri']]);
  125. if (!DBA::isResult($obj)) {
  126. return;
  127. }
  128. $author = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
  129. $objauthor = '[url=' . $obj['author-link'] . ']' . $obj['author-name'] . '[/url]';
  130. switch ($obj['verb']) {
  131. case ACTIVITY_POST:
  132. switch ($obj['object-type']) {
  133. case ACTIVITY_OBJ_EVENT:
  134. $post_type = L10n::t('event');
  135. break;
  136. default:
  137. $post_type = L10n::t('status');
  138. }
  139. break;
  140. default:
  141. if ($obj['resource-id']) {
  142. $post_type = L10n::t('photo');
  143. $m = [];
  144. preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
  145. $rr['plink'] = $m[1];
  146. } else {
  147. $post_type = L10n::t('status');
  148. }
  149. }
  150. $plink = '[url=' . $obj['plink'] . ']' . $post_type . '[/url]';
  151. $bodyverb = '';
  152. if (activity_match($item['verb'], ACTIVITY_LIKE)) {
  153. $bodyverb = L10n::t('%1$s likes %2$s\'s %3$s');
  154. } elseif (activity_match($item['verb'], ACTIVITY_DISLIKE)) {
  155. $bodyverb = L10n::t('%1$s doesn\'t like %2$s\'s %3$s');
  156. } elseif (activity_match($item['verb'], ACTIVITY_ATTEND)) {
  157. $bodyverb = L10n::t('%1$s attends %2$s\'s %3$s');
  158. } elseif (activity_match($item['verb'], ACTIVITY_ATTENDNO)) {
  159. $bodyverb = L10n::t('%1$s doesn\'t attend %2$s\'s %3$s');
  160. } elseif (activity_match($item['verb'], ACTIVITY_ATTENDMAYBE)) {
  161. $bodyverb = L10n::t('%1$s attends maybe %2$s\'s %3$s');
  162. }
  163. $item['body'] = sprintf($bodyverb, $author, $objauthor, $plink);
  164. }
  165. if (activity_match($item['verb'], ACTIVITY_FRIEND)) {
  166. if ($item['object-type']=="" || $item['object-type']!== ACTIVITY_OBJ_PERSON) return;
  167. $Aname = $item['author-name'];
  168. $Alink = $item['author-link'];
  169. $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
  170. $obj = XML::parseString($xmlhead.$item['object']);
  171. $links = XML::parseString($xmlhead."<links>".XML::unescape($obj->link)."</links>");
  172. $Bname = $obj->title;
  173. $Blink = "";
  174. $Bphoto = "";
  175. foreach ($links->link as $l) {
  176. $atts = $l->attributes();
  177. switch ($atts['rel']) {
  178. case "alternate": $Blink = $atts['href']; break;
  179. case "photo": $Bphoto = $atts['href']; break;
  180. }
  181. }
  182. $A = '[url=' . Contact::magicLink($Alink) . ']' . $Aname . '[/url]';
  183. $B = '[url=' . Contact::magicLink($Blink) . ']' . $Bname . '[/url]';
  184. if ($Bphoto != "") {
  185. $Bphoto = '[url=' . Contact::magicLink($Blink) . '][img]' . $Bphoto . '[/img][/url]';
  186. }
  187. $item['body'] = L10n::t('%1$s is now friends with %2$s', $A, $B)."\n\n\n".$Bphoto;
  188. }
  189. if (stristr($item['verb'], ACTIVITY_POKE)) {
  190. $verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
  191. if (!$verb) {
  192. return;
  193. }
  194. if ($item['object-type']=="" || $item['object-type']!== ACTIVITY_OBJ_PERSON) {
  195. return;
  196. }
  197. $Aname = $item['author-name'];
  198. $Alink = $item['author-link'];
  199. $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
  200. $obj = XML::parseString($xmlhead.$item['object']);
  201. $Bname = $obj->title;
  202. $Blink = $obj->id;
  203. $Bphoto = "";
  204. foreach ($obj->link as $l) {
  205. $atts = $l->attributes();
  206. switch ($atts['rel']) {
  207. case "alternate": $Blink = $atts['href'];
  208. case "photo": $Bphoto = $atts['href'];
  209. }
  210. }
  211. $A = '[url=' . Contact::magicLink($Alink) . ']' . $Aname . '[/url]';
  212. $B = '[url=' . Contact::magicLink($Blink) . ']' . $Bname . '[/url]';
  213. if ($Bphoto != "") {
  214. $Bphoto = '[url=' . Contact::magicLink($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]';
  215. }
  216. /*
  217. * we can't have a translation string with three positions but no distinguishable text
  218. * So here is the translate string.
  219. */
  220. $txt = L10n::t('%1$s poked %2$s');
  221. // now translate the verb
  222. $poked_t = trim(sprintf($txt, "", ""));
  223. $txt = str_replace($poked_t, L10n::t($verb), $txt);
  224. // then do the sprintf on the translation string
  225. $item['body'] = sprintf($txt, $A, $B). "\n\n\n" . $Bphoto;
  226. }
  227. if (activity_match($item['verb'], ACTIVITY_TAG)) {
  228. $fields = ['author-id', 'author-link', 'author-name', 'author-network',
  229. 'verb', 'object-type', 'resource-id', 'body', 'plink'];
  230. $obj = Item::selectFirst($fields, ['uri' => $item['parent-uri']]);
  231. if (!DBA::isResult($obj)) {
  232. return;
  233. }
  234. $author_arr = ['uid' => 0, 'id' => $item['author-id'],
  235. 'network' => $item['author-network'], 'url' => $item['author-link']];
  236. $author = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $item['author-name'] . '[/url]';
  237. $author_arr = ['uid' => 0, 'id' => $obj['author-id'],
  238. 'network' => $obj['author-network'], 'url' => $obj['author-link']];
  239. $objauthor = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $obj['author-name'] . '[/url]';
  240. switch ($obj['verb']) {
  241. case ACTIVITY_POST:
  242. switch ($obj['object-type']) {
  243. case ACTIVITY_OBJ_EVENT:
  244. $post_type = L10n::t('event');
  245. break;
  246. default:
  247. $post_type = L10n::t('status');
  248. }
  249. break;
  250. default:
  251. if ($obj['resource-id']) {
  252. $post_type = L10n::t('photo');
  253. $m=[]; preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
  254. $rr['plink'] = $m[1];
  255. } else {
  256. $post_type = L10n::t('status');
  257. }
  258. // Let's break everthing ... ;-)
  259. break;
  260. }
  261. $plink = '[url=' . $obj['plink'] . ']' . $post_type . '[/url]';
  262. $parsedobj = XML::parseString($xmlhead.$item['object']);
  263. $tag = sprintf('#[url=%s]%s[/url]', $parsedobj->id, $parsedobj->content);
  264. $item['body'] = L10n::t('%1$s tagged %2$s\'s %3$s with %4$s', $author, $objauthor, $plink, $tag);
  265. }
  266. if (activity_match($item['verb'], ACTIVITY_FAVORITE)) {
  267. if ($item['object-type'] == "") {
  268. return;
  269. }
  270. $Aname = $item['author-name'];
  271. $Alink = $item['author-link'];
  272. $xmlhead = "<" . "?xml version='1.0' encoding='UTF-8' ?" . ">";
  273. $obj = XML::parseString($xmlhead.$item['object']);
  274. if (strlen($obj->id)) {
  275. $fields = ['author-link', 'author-name', 'plink'];
  276. $target = Item::selectFirst($fields, ['uri' => $obj->id, 'uid' => $item['uid']]);
  277. if (DBA::isResult($target) && $target['plink']) {
  278. $Bname = $target['author-name'];
  279. $Blink = $target['author-link'];
  280. $A = '[url=' . Contact::magicLink($Alink) . ']' . $Aname . '[/url]';
  281. $B = '[url=' . Contact::magicLink($Blink) . ']' . $Bname . '[/url]';
  282. $P = '[url=' . $target['plink'] . ']' . L10n::t('post/item') . '[/url]';
  283. $item['body'] = L10n::t('%1$s marked %2$s\'s %3$s as favorite', $A, $B, $P)."\n";
  284. }
  285. }
  286. }
  287. $matches = null;
  288. if (preg_match_all('/@\[url=(.*?)\]/is', $item['body'], $matches, PREG_SET_ORDER)) {
  289. foreach ($matches as $mtch) {
  290. if (!strpos($mtch[1], 'zrl=')) {
  291. $item['body'] = str_replace($mtch[0], '@[url=' . Contact::magicLink($mtch[1]) . ']', $item['body']);
  292. }
  293. }
  294. }
  295. // add zrl's to public images
  296. $photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is";
  297. if (preg_match($photo_pattern, $item['body'])) {
  298. $photo_replace = '[url=' . Profile::zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]';
  299. $item['body'] = BBCode::pregReplaceInTag($photo_pattern, $photo_replace, 'url', $item['body']);
  300. }
  301. // add sparkle links to appropriate permalinks
  302. $author = ['uid' => 0, 'id' => $item['author-id'],
  303. 'network' => $item['author-network'], 'url' => $item['author-link']];
  304. // Only create a redirection to a magic link when logged in
  305. if (!empty($item['plink']) && Session::isAuthenticated()) {
  306. $item['plink'] = Contact::magicLinkByContact($author, $item['plink']);
  307. }
  308. }
  309. /**
  310. * Count the total of comments on this item and its desendants
  311. * @TODO proper type-hint + doc-tag
  312. * @param $item
  313. * @return int
  314. */
  315. function count_descendants($item) {
  316. $total = count($item['children']);
  317. if ($total > 0) {
  318. foreach ($item['children'] as $child) {
  319. if (!visible_activity($child)) {
  320. $total --;
  321. }
  322. $total += count_descendants($child);
  323. }
  324. }
  325. return $total;
  326. }
  327. function visible_activity($item) {
  328. /*
  329. * likes (etc.) can apply to other things besides posts. Check if they are post children,
  330. * in which case we handle them specially
  331. */
  332. $hidden_activities = [ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE, ACTIVITY_FOLLOW, ACTIVITY2_ANNOUNCE];
  333. foreach ($hidden_activities as $act) {
  334. if (activity_match($item['verb'], $act)) {
  335. return false;
  336. }
  337. }
  338. // @TODO below if() block can be rewritten to a single line: $isVisible = allConditionsHere;
  339. if (activity_match($item['verb'], ACTIVITY_FOLLOW) && $item['object-type'] === ACTIVITY_OBJ_NOTE && empty($item['self']) && $item['uid'] == local_user()) {
  340. return false;
  341. }
  342. return true;
  343. }
  344. function conv_get_blocklist()
  345. {
  346. if (!local_user()) {
  347. return [];
  348. }
  349. $str_blocked = PConfig::get(local_user(), 'system', 'blocked');
  350. if (empty($str_blocked)) {
  351. return [];
  352. }
  353. $blocklist = [];
  354. foreach (explode(',', $str_blocked) as $entry) {
  355. // The 4th parameter guarantees that there always will be a public contact entry
  356. $cid = Contact::getIdForURL(trim($entry), 0, true, ['url' => trim($entry)]);
  357. if (!empty($cid)) {
  358. $blocklist[] = $cid;
  359. }
  360. }
  361. return $blocklist;
  362. }
  363. /**
  364. * "Render" a conversation or list of items for HTML display.
  365. * There are two major forms of display:
  366. * - Sequential or unthreaded ("New Item View" or search results)
  367. * - conversation view
  368. * The $mode parameter decides between the various renderings and also
  369. * figures out how to determine page owner and other contextual items
  370. * that are based on unique features of the calling module.
  371. * @param App $a
  372. * @param array $items
  373. * @param Pager $pager
  374. * @param $mode
  375. * @param $update
  376. * @param bool $preview
  377. * @param string $order
  378. * @param int $uid
  379. * @return string
  380. * @throws ImagickException
  381. * @throws \Friendica\Network\HTTPException\InternalServerErrorException
  382. */
  383. function conversation(App $a, array $items, Pager $pager, $mode, $update, $preview = false, $order = 'commented', $uid = 0)
  384. {
  385. $ssl_state = (local_user() ? true : false);
  386. $profile_owner = 0;
  387. $live_update_div = '';
  388. $blocklist = conv_get_blocklist();
  389. $previewing = (($preview) ? ' preview ' : '');
  390. if ($mode === 'network') {
  391. $items = conversation_add_children($items, false, $order, $uid);
  392. $profile_owner = local_user();
  393. if (!$update) {
  394. /*
  395. * The special div is needed for liveUpdate to kick in for this page.
  396. * We only launch liveUpdate if you aren't filtering in some incompatible
  397. * way and also you aren't writing a comment (discovered in javascript).
  398. */
  399. $live_update_div = '<div id="live-network"></div>' . "\r\n"
  400. . "<script> var profile_uid = " . $_SESSION['uid']
  401. . "; var netargs = '" . substr($a->cmd, 8)
  402. . '?f='
  403. . (!empty($_GET['cid']) ? '&cid=' . rawurlencode($_GET['cid']) : '')
  404. . (!empty($_GET['search']) ? '&search=' . rawurlencode($_GET['search']) : '')
  405. . (!empty($_GET['star']) ? '&star=' . rawurlencode($_GET['star']) : '')
  406. . (!empty($_GET['order']) ? '&order=' . rawurlencode($_GET['order']) : '')
  407. . (!empty($_GET['bmark']) ? '&bmark=' . rawurlencode($_GET['bmark']) : '')
  408. . (!empty($_GET['liked']) ? '&liked=' . rawurlencode($_GET['liked']) : '')
  409. . (!empty($_GET['conv']) ? '&conv=' . rawurlencode($_GET['conv']) : '')
  410. . (!empty($_GET['nets']) ? '&nets=' . rawurlencode($_GET['nets']) : '')
  411. . (!empty($_GET['cmin']) ? '&cmin=' . rawurlencode($_GET['cmin']) : '')
  412. . (!empty($_GET['cmax']) ? '&cmax=' . rawurlencode($_GET['cmax']) : '')
  413. . (!empty($_GET['file']) ? '&file=' . rawurlencode($_GET['file']) : '')
  414. . "'; var profile_page = " . $pager->getPage() . "; </script>\r\n";
  415. }
  416. } elseif ($mode === 'profile') {
  417. $items = conversation_add_children($items, false, $order, $uid);
  418. $profile_owner = $a->profile['profile_uid'];
  419. if (!$update) {
  420. $tab = 'posts';
  421. if (!empty($_GET['tab'])) {
  422. $tab = Strings::escapeTags(trim($_GET['tab']));
  423. }
  424. if ($tab === 'posts') {
  425. /*
  426. * This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
  427. * because browser prefetching might change it on us. We have to deliver it with the page.
  428. */
  429. $live_update_div = '<div id="live-profile"></div>' . "\r\n"
  430. . "<script> var profile_uid = " . $a->profile['profile_uid']
  431. . "; var netargs = '?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
  432. }
  433. }
  434. } elseif ($mode === 'notes') {
  435. $items = conversation_add_children($items, false, $order, local_user());
  436. $profile_owner = local_user();
  437. if (!$update) {
  438. $live_update_div = '<div id="live-notes"></div>' . "\r\n"
  439. . "<script> var profile_uid = " . local_user()
  440. . "; var netargs = '/?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
  441. }
  442. } elseif ($mode === 'display') {
  443. $items = conversation_add_children($items, false, $order, $uid);
  444. $profile_owner = $a->profile['uid'];
  445. if (!$update) {
  446. $live_update_div = '<div id="live-display"></div>' . "\r\n"
  447. . "<script> var profile_uid = " . Session::get('uid', 0) . ";"
  448. . " var profile_page = 1; </script>";
  449. }
  450. } elseif ($mode === 'community') {
  451. $items = conversation_add_children($items, true, $order, $uid);
  452. $profile_owner = 0;
  453. if (!$update) {
  454. $live_update_div = '<div id="live-community"></div>' . "\r\n"
  455. . "<script> var profile_uid = -1; var netargs = '" . substr($a->cmd, 10)
  456. ."/?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
  457. }
  458. } elseif ($mode === 'contacts') {
  459. $items = conversation_add_children($items, false, $order, $uid);
  460. $profile_owner = 0;
  461. if (!$update) {
  462. $live_update_div = '<div id="live-contacts"></div>' . "\r\n"
  463. . "<script> var profile_uid = -1; var netargs = '" . substr($a->cmd, 9)
  464. ."/?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
  465. }
  466. } elseif ($mode === 'search') {
  467. $live_update_div = '<div id="live-search"></div>' . "\r\n";
  468. }
  469. $page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false);
  470. if (!$update) {
  471. $_SESSION['return_path'] = $a->query_string;
  472. }
  473. $cb = ['items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview];
  474. Hook::callAll('conversation_start',$cb);
  475. $items = $cb['items'];
  476. $conv_responses = [
  477. 'like' => ['title' => L10n::t('Likes','title')],
  478. 'dislike' => ['title' => L10n::t('Dislikes','title')],
  479. 'attendyes' => ['title' => L10n::t('Attending','title')],
  480. 'attendno' => ['title' => L10n::t('Not attending','title')],
  481. 'attendmaybe' => ['title' => L10n::t('Might attend','title')],
  482. 'announce' => ['title' => L10n::t('Reshares','title')]
  483. ];
  484. // array with html for each thread (parent+comments)
  485. $threads = [];
  486. $threadsid = -1;
  487. $page_template = Renderer::getMarkupTemplate("conversation.tpl");
  488. if (!empty($items)) {
  489. if (in_array($mode, ['community', 'contacts'])) {
  490. $writable = true;
  491. } else {
  492. $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], Protocol::FEDERATED);
  493. }
  494. if (!local_user()) {
  495. $writable = false;
  496. }
  497. if (in_array($mode, ['network-new', 'search', 'contact-posts'])) {
  498. /*
  499. * "New Item View" on network page or search page results
  500. * - just loop through the items and format them minimally for display
  501. */
  502. $tpl = 'search_item.tpl';
  503. foreach ($items as $item) {
  504. if (!visible_activity($item)) {
  505. continue;
  506. }
  507. if (in_array($item['author-id'], $blocklist)) {
  508. continue;
  509. }
  510. $threadsid++;
  511. $owner_url = '';
  512. $owner_name = '';
  513. $sparkle = '';
  514. // prevent private email from leaking.
  515. if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
  516. continue;
  517. }
  518. $profile_name = $item['author-name'];
  519. if (!empty($item['author-link']) && empty($item['author-name'])) {
  520. $profile_name = $item['author-link'];
  521. }
  522. $tags = Term::populateTagsFromItem($item);
  523. $author = ['uid' => 0, 'id' => $item['author-id'],
  524. 'network' => $item['author-network'], 'url' => $item['author-link']];
  525. $profile_link = Contact::magicLinkByContact($author);
  526. if (strpos($profile_link, 'redir/') === 0) {
  527. $sparkle = ' sparkle';
  528. }
  529. $locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => ''];
  530. Hook::callAll('render_location',$locate);
  531. $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
  532. localize_item($item);
  533. if ($mode === 'network-new') {
  534. $dropping = true;
  535. } else {
  536. $dropping = false;
  537. }
  538. $drop = [
  539. 'dropping' => $dropping,
  540. 'pagedrop' => $page_dropping,
  541. 'select' => L10n::t('Select'),
  542. 'delete' => L10n::t('Delete'),
  543. ];
  544. $star = false;
  545. $isstarred = "unstarred";
  546. $lock = false;
  547. $likebuttons = false;
  548. $body = Item::prepareBody($item, true, $preview);
  549. list($categories, $folders) = get_cats_and_terms($item);
  550. if (!empty($item['content-warning']) && PConfig::get(local_user(), 'system', 'disable_cw', false)) {
  551. $title = ucfirst($item['content-warning']);
  552. } else {
  553. $title = $item['title'];
  554. }
  555. $tmp_item = [
  556. 'template' => $tpl,
  557. 'id' => ($preview ? 'P0' : $item['id']),
  558. 'guid' => ($preview ? 'Q0' : $item['guid']),
  559. 'network' => $item['network'],
  560. 'network_name' => ContactSelector::networkToName($item['network'], $item['author-link']),
  561. 'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link']),
  562. 'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, $item['author-link']),
  563. 'profile_url' => $profile_link,
  564. 'item_photo_menu' => item_photo_menu($item),
  565. 'name' => $profile_name,
  566. 'sparkle' => $sparkle,
  567. 'lock' => $lock,
  568. 'thumb' => System::removedBaseUrl(ProxyUtils::proxifyUrl($item['author-avatar'], false, ProxyUtils::SIZE_THUMB)),
  569. 'title' => $title,
  570. 'body' => $body,
  571. 'tags' => $tags['tags'],
  572. 'hashtags' => $tags['hashtags'],
  573. 'mentions' => $tags['mentions'],
  574. 'implicit_mentions' => $tags['implicit_mentions'],
  575. 'txt_cats' => L10n::t('Categories:'),
  576. 'txt_folders' => L10n::t('Filed under:'),
  577. 'has_cats' => ((count($categories)) ? 'true' : ''),
  578. 'has_folders' => ((count($folders)) ? 'true' : ''),
  579. 'categories' => $categories,
  580. 'folders' => $folders,
  581. 'text' => strip_tags($body),
  582. 'localtime' => DateTimeFormat::local($item['created'], 'r'),
  583. 'ago' => (($item['app']) ? L10n::t('%s from %s', Temporal::getRelativeDate($item['created']),$item['app']) : Temporal::getRelativeDate($item['created'])),
  584. 'location' => $location,
  585. 'indent' => '',
  586. 'owner_name' => $owner_name,
  587. 'owner_url' => $owner_url,
  588. 'owner_photo' => System::removedBaseUrl(ProxyUtils::proxifyUrl($item['owner-avatar'], false, ProxyUtils::SIZE_THUMB)),
  589. 'plink' => Item::getPlink($item),
  590. 'edpost' => false,
  591. 'isstarred' => $isstarred,
  592. 'star' => $star,
  593. 'drop' => $drop,
  594. 'vote' => $likebuttons,
  595. 'like' => '',
  596. 'dislike' => '',
  597. 'comment' => '',
  598. 'conv' => (($preview) ? '' : ['href'=> 'display/'.$item['guid'], 'title'=> L10n::t('View in context')]),
  599. 'previewing' => $previewing,
  600. 'wait' => L10n::t('Please wait'),
  601. 'thread_level' => 1,
  602. ];
  603. $arr = ['item' => $item, 'output' => $tmp_item];
  604. Hook::callAll('display_item', $arr);
  605. $threads[$threadsid]['id'] = $item['id'];
  606. $threads[$threadsid]['network'] = $item['network'];
  607. $threads[$threadsid]['items'] = [$arr['output']];
  608. }
  609. } else {
  610. // Normal View
  611. $page_template = Renderer::getMarkupTemplate("threaded_conversation.tpl");
  612. $conv = new Thread($mode, $preview, $writable);
  613. /*
  614. * get all the topmost parents
  615. * this shouldn't be needed, as we should have only them in our array
  616. * But for now, this array respects the old style, just in case
  617. */
  618. foreach ($items as $item) {
  619. if (in_array($item['author-id'], $blocklist)) {
  620. continue;
  621. }
  622. // Can we put this after the visibility check?
  623. builtin_activity_puller($item, $conv_responses);
  624. // Only add what is visible
  625. if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) {
  626. continue;
  627. }
  628. if (!visible_activity($item)) {
  629. continue;
  630. }
  631. /// @todo Check if this call is needed or not
  632. $arr = ['item' => $item];
  633. Hook::callAll('display_item', $arr);
  634. $item['pagedrop'] = $page_dropping;
  635. if ($item['id'] == $item['parent']) {
  636. $item_object = new Post($item);
  637. $conv->addParent($item_object);
  638. }
  639. }
  640. $threads = $conv->getTemplateData($conv_responses);
  641. if (!$threads) {
  642. Logger::log('[ERROR] conversation : Failed to get template data.', Logger::DEBUG);
  643. $threads = [];
  644. }
  645. }
  646. }
  647. $o = Renderer::replaceMacros($page_template, [
  648. '$baseurl' => System::baseUrl($ssl_state),
  649. '$return_path' => $a->query_string,
  650. '$live_update' => $live_update_div,
  651. '$remove' => L10n::t('remove'),
  652. '$mode' => $mode,
  653. '$user' => $a->user,
  654. '$threads' => $threads,
  655. '$dropping' => ($page_dropping ? L10n::t('Delete Selected Items') : False),
  656. ]);
  657. return $o;
  658. }
  659. /**
  660. * Fetch all comments from a query. Additionally set the newest resharer as thread owner.
  661. *
  662. * @param $thread_items Database statement with thread posts
  663. * @return array items with parents and comments
  664. */
  665. function conversation_fetch_comments($thread_items) {
  666. $comments = [];
  667. $parentlines = [];
  668. $lineno = 0;
  669. $actor = [];
  670. $received = '';
  671. while ($row = Item::fetch($thread_items)) {
  672. if (($row['verb'] == ACTIVITY2_ANNOUNCE) && !empty($row['contact-uid']) && ($row['received'] > $received) && ($row['thr-parent'] == $row['parent-uri'])) {
  673. $actor = ['link' => $row['author-link'], 'avatar' => $row['author-avatar'], 'name' => $row['author-name']];
  674. $received = $row['received'];
  675. }
  676. if ((($row['gravity'] == GRAVITY_PARENT) && !$row['origin'] && !in_array($row['network'], [Protocol::DIASPORA])) &&
  677. (empty($row['contact-uid']) || !in_array($row['network'], Protocol::NATIVE_SUPPORT))) {
  678. $parentlines[] = $lineno;
  679. }
  680. $comments[] = $row;
  681. $lineno++;
  682. }
  683. DBA::close($thread_items);
  684. if (!empty($actor)) {
  685. foreach ($parentlines as $line) {
  686. $comments[$line]['owner-link'] = $actor['link'];
  687. $comments[$line]['owner-avatar'] = $actor['avatar'];
  688. $comments[$line]['owner-name'] = $actor['name'];
  689. }
  690. }
  691. return $comments;
  692. }
  693. /**
  694. * @brief Add comments to top level entries that had been fetched before
  695. *
  696. * The system will fetch the comments for the local user whenever possible.
  697. * This behaviour is currently needed to allow commenting on Friendica posts.
  698. *
  699. * @param array $parents Parent items
  700. *
  701. * @param $block_authors
  702. * @param $order
  703. * @param $uid
  704. * @return array items with parents and comments
  705. * @throws \Friendica\Network\HTTPException\InternalServerErrorException
  706. */
  707. function conversation_add_children(array $parents, $block_authors, $order, $uid) {
  708. $max_comments = Config::get('system', 'max_comments', 100);
  709. $params = ['order' => ['uid', 'commented' => true]];
  710. if ($max_comments > 0) {
  711. $params['limit'] = $max_comments;
  712. }
  713. $items = [];
  714. foreach ($parents AS $parent) {
  715. $condition = ["`item`.`parent-uri` = ? AND `item`.`uid` IN (0, ?) ",
  716. $parent['uri'], $uid];
  717. if ($block_authors) {
  718. $condition[0] .= "AND NOT `author`.`hidden`";
  719. }
  720. $thread_items = Item::selectForUser(local_user(), array_merge(Item::DISPLAY_FIELDLIST, ['contact-uid', 'gravity']), $condition, $params);
  721. $comments = conversation_fetch_comments($thread_items);
  722. if (count($comments) != 0) {
  723. $items = array_merge($items, $comments);
  724. }
  725. }
  726. foreach ($items as $index => $item) {
  727. if ($item['uid'] == 0) {
  728. $items[$index]['writable'] = in_array($item['network'], Protocol::FEDERATED);
  729. }
  730. }
  731. $items = conv_sort($items, $order);
  732. return $items;
  733. }
  734. function item_photo_menu($item) {
  735. $sub_link = '';
  736. $poke_link = '';
  737. $contact_url = '';
  738. $pm_url = '';
  739. $status_link = '';
  740. $photos_link = '';
  741. $posts_link = '';
  742. $block_link = '';
  743. $ignore_link = '';
  744. if (local_user() && local_user() == $item['uid'] && $item['parent'] == $item['id'] && !$item['self']) {
  745. $sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;';
  746. }
  747. $author = ['uid' => 0, 'id' => $item['author-id'],
  748. 'network' => $item['author-network'], 'url' => $item['author-link']];
  749. $profile_link = Contact::magicLinkByContact($author, $item['author-link']);
  750. $sparkle = (strpos($profile_link, 'redir/') === 0);
  751. $cid = 0;
  752. $pcid = Contact::getIdForURL($item['author-link'], 0, true);
  753. $network = '';
  754. $rel = 0;
  755. $condition = ['uid' => local_user(), 'nurl' => Strings::normaliseLink($item['author-link'])];
  756. $contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
  757. if (DBA::isResult($contact)) {
  758. $cid = $contact['id'];
  759. $network = $contact['network'];
  760. $rel = $contact['rel'];
  761. }
  762. if ($sparkle) {
  763. $status_link = $profile_link . '?tab=status';
  764. $photos_link = str_replace('/profile/', '/photos/', $profile_link);
  765. $profile_link = $profile_link . '?=profile';
  766. }
  767. if (!empty($pcid)) {
  768. $contact_url = 'contact/' . $pcid;
  769. $posts_link = 'contact/' . $pcid . '/posts';
  770. $block_link = 'contact/' . $pcid . '/block';
  771. $ignore_link = 'contact/' . $pcid . '/ignore';
  772. }
  773. if ($cid && !$item['self']) {
  774. $poke_link = 'poke/?f=&c=' . $cid;
  775. $contact_url = 'contact/' . $cid;
  776. $posts_link = 'contact/' . $cid . '/posts';
  777. if (in_array($network, [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA])) {
  778. $pm_url = 'message/new/' . $cid;
  779. }
  780. }
  781. if (local_user()) {
  782. $menu = [
  783. L10n::t('Follow Thread') => $sub_link,
  784. L10n::t('View Status') => $status_link,
  785. L10n::t('View Profile') => $profile_link,
  786. L10n::t('View Photos') => $photos_link,
  787. L10n::t('Network Posts') => $posts_link,
  788. L10n::t('View Contact') => $contact_url,
  789. L10n::t('Send PM') => $pm_url,
  790. L10n::t('Block') => $block_link,
  791. L10n::t('Ignore') => $ignore_link
  792. ];
  793. if ($network == Protocol::DFRN) {
  794. $menu[L10n::t("Poke")] = $poke_link;
  795. }
  796. if ((($cid == 0) || ($rel == Contact::FOLLOWER)) &&
  797. in_array($item['network'], Protocol::FEDERATED)) {
  798. $menu[L10n::t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
  799. }
  800. } else {
  801. $menu = [L10n::t('View Profile') => $item['author-link']];
  802. }
  803. $args = ['item' => $item, 'menu' => $menu];
  804. Hook::callAll('item_photo_menu', $args);
  805. $menu = $args['menu'];
  806. $o = '';
  807. foreach ($menu as $k => $v) {
  808. if (strpos($v, 'javascript:') === 0) {
  809. $v = substr($v, 11);
  810. $o .= '<li role="menuitem"><a onclick="' . $v . '">' . $k . '</a></li>' . PHP_EOL;
  811. } elseif ($v!='') {
  812. $o .= '<li role="menuitem"><a href="' . $v . '">' . $k . '</a></li>' . PHP_EOL;
  813. }
  814. }
  815. return $o;
  816. }
  817. /**
  818. * @brief Checks item to see if it is one of the builtin activities (like/dislike, event attendance, consensus items, etc.)
  819. * Increments the count of each matching activity and adds a link to the author as needed.
  820. *
  821. * @param array $item
  822. * @param array &$conv_responses (already created with builtin activity structure)
  823. * @return void
  824. * @throws ImagickException
  825. * @throws \Friendica\Network\HTTPException\InternalServerErrorException
  826. */
  827. function builtin_activity_puller($item, &$conv_responses) {
  828. foreach ($conv_responses as $mode => $v) {
  829. $sparkle = '';
  830. switch ($mode) {
  831. case 'like':
  832. $verb = ACTIVITY_LIKE;
  833. break;
  834. case 'dislike':
  835. $verb = ACTIVITY_DISLIKE;
  836. break;
  837. case 'attendyes':
  838. $verb = ACTIVITY_ATTEND;
  839. break;
  840. case 'attendno':
  841. $verb = ACTIVITY_ATTENDNO;
  842. break;
  843. case 'attendmaybe':
  844. $verb = ACTIVITY_ATTENDMAYBE;
  845. break;
  846. case 'announce':
  847. $verb = ACTIVITY2_ANNOUNCE;
  848. break;
  849. default:
  850. return;
  851. }
  852. if (activity_match($item['verb'], $verb) && ($item['id'] != $item['parent'])) {
  853. $author = ['uid' => 0, 'id' => $item['author-id'],
  854. 'network' => $item['author-network'], 'url' => $item['author-link']];
  855. $url = Contact::magicLinkByContact($author);
  856. if (strpos($url, 'redir/') === 0) {
  857. $sparkle = ' class="sparkle" ';
  858. }
  859. $url = '<a href="'. $url . '"'. $sparkle .'>' . htmlentities($item['author-name']) . '</a>';
  860. if (empty($item['thr-parent'])) {
  861. $item['thr-parent'] = $item['parent-uri'];
  862. }
  863. if (!(isset($conv_responses[$mode][$item['thr-parent'] . '-l'])
  864. && is_array($conv_responses[$mode][$item['thr-parent'] . '-l']))) {
  865. $conv_responses[$mode][$item['thr-parent'] . '-l'] = [];
  866. }
  867. // only list each unique author once
  868. if (in_array($url,$conv_responses[$mode][$item['thr-parent'] . '-l'])) {
  869. continue;
  870. }
  871. if (!isset($conv_responses[$mode][$item['thr-parent']])) {
  872. $conv_responses[$mode][$item['thr-parent']] = 1;
  873. } else {
  874. $conv_responses[$mode][$item['thr-parent']] ++;
  875. }
  876. if (public_contact() == $item['author-id']) {
  877. $conv_responses[$mode][$item['thr-parent'] . '-self'] = 1;
  878. }
  879. $conv_responses[$mode][$item['thr-parent'] . '-l'][] = $url;
  880. // there can only be one activity verb per item so if we found anything, we can stop looking
  881. return;
  882. }
  883. }
  884. }
  885. /**
  886. * Format the vote text for a profile item
  887. *
  888. * @param int $cnt = number of people who vote the item
  889. * @param array $arr = array of pre-linked names of likers/dislikers
  890. * @param string $type = one of 'like, 'dislike', 'attendyes', 'attendno', 'attendmaybe'
  891. * @param int $id = item id
  892. * @return string formatted text
  893. * @throws \Friendica\Network\HTTPException\InternalServerErrorException
  894. */
  895. function format_like($cnt, array $arr, $type, $id) {
  896. $o = '';
  897. $expanded = '';
  898. $phrase = '';
  899. if ($cnt == 1) {
  900. $likers = $arr[0];
  901. // Phrase if there is only one liker. In other cases it will be uses for the expanded
  902. // list which show all likers
  903. switch ($type) {
  904. case 'like' :
  905. $phrase = L10n::t('%s likes this.', $likers);
  906. break;
  907. case 'dislike' :
  908. $phrase = L10n::t('%s doesn\'t like this.', $likers);
  909. break;
  910. case 'attendyes' :
  911. $phrase = L10n::t('%s attends.', $likers);
  912. break;
  913. case 'attendno' :
  914. $phrase = L10n::t('%s doesn\'t attend.', $likers);
  915. break;
  916. case 'attendmaybe' :
  917. $phrase = L10n::t('%s attends maybe.', $likers);
  918. break;
  919. case 'announce' :
  920. $phrase = L10n::t('%s reshared this.', $likers);
  921. break;
  922. }
  923. }
  924. if ($cnt > 1) {
  925. $total = count($arr);
  926. if ($total < MAX_LIKERS) {
  927. $last = L10n::t('and') . ' ' . $arr[count($arr)-1];
  928. $arr2 = array_slice($arr, 0, -1);
  929. $likers = implode(', ', $arr2) . ' ' . $last;
  930. } else {
  931. $arr = array_slice($arr, 0, MAX_LIKERS - 1);
  932. $likers = implode(', ', $arr);
  933. $likers .= L10n::t('and %d other people', $total - MAX_LIKERS);
  934. }
  935. $spanatts = "class=\"fakelink\" onclick=\"openClose('{$type}list-$id');\"";
  936. $explikers = '';
  937. switch ($type) {
  938. case 'like':
  939. $phrase = L10n::t('<span %1$s>%2$d people</span> like this', $spanatts, $cnt);
  940. $explikers = L10n::t('%s like this.', $likers);
  941. break;
  942. case 'dislike':
  943. $phrase = L10n::t('<span %1$s>%2$d people</span> don\'t like this', $spanatts, $cnt);
  944. $explikers = L10n::t('%s don\'t like this.', $likers);
  945. break;
  946. case 'attendyes':
  947. $phrase = L10n::t('<span %1$s>%2$d people</span> attend', $spanatts, $cnt);
  948. $explikers = L10n::t('%s attend.', $likers);
  949. break;
  950. case 'attendno':
  951. $phrase = L10n::t('<span %1$s>%2$d people</span> don\'t attend', $spanatts, $cnt);
  952. $explikers = L10n::t('%s don\'t attend.', $likers);
  953. break;
  954. case 'attendmaybe':
  955. $phrase = L10n::t('<span %1$s>%2$d people</span> attend maybe', $spanatts, $cnt);
  956. $explikers = L10n::t('%s attend maybe.', $likers);
  957. break;
  958. case 'announce':
  959. $phrase = L10n::t('<span %1$s>%2$d people</span> reshared this', $spanatts, $cnt);
  960. $explikers = L10n::t('%s reshared this.', $likers);
  961. break;
  962. }
  963. $expanded .= "\t" . '<p class="wall-item-' . $type . '-expanded" id="' . $type . 'list-' . $id . '" style="display: none;" >' . $explikers . EOL . '</p>';
  964. }
  965. $o .= Renderer::replaceMacros(Renderer::getMarkupTemplate('voting_fakelink.tpl'), [
  966. '$phrase' => $phrase,
  967. '$type' => $type,
  968. '$id' => $id
  969. ]);
  970. $o .= $expanded;
  971. return $o;
  972. }
  973. function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
  974. {
  975. $o = '';
  976. $geotag = !empty($x['allow_location']) ? Renderer::replaceMacros(Renderer::getMarkupTemplate('jot_geotag.tpl'), []) : '';
  977. $tpl = Renderer::getMarkupTemplate('jot-header.tpl');
  978. $a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
  979. '$newpost' => 'true',
  980. '$baseurl' => System::baseUrl(true),
  981. '$geotag' => $geotag,
  982. '$nickname' => $x['nickname'],
  983. '$ispublic' => L10n::t('Visible to <strong>everybody</strong>'),
  984. '$linkurl' => L10n::t('Please enter a image/video/audio/webpage URL:'),
  985. '$term' => L10n::t('Tag term:'),
  986. '$fileas' => L10n::t('Save to Folder:'),
  987. '$whereareu' => L10n::t('Where are you right now?'),
  988. '$delitems' => L10n::t("Delete item\x28s\x29?")
  989. ]);
  990. $jotplugins = '';
  991. Hook::callAll('jot_tool', $jotplugins);
  992. // Private/public post links for the non-JS ACL form
  993. $private_post = 1;
  994. if (!empty($_REQUEST['public'])) {
  995. $private_post = 0;
  996. }
  997. $query_str = $a->query_string;
  998. if (strpos($query_str, 'public=1') !== false) {
  999. $query_str = str_replace(['?public=1', '&public=1'], ['', ''], $query_str);
  1000. }
  1001. /*
  1002. * I think $a->query_string may never have ? in it, but I could be wrong
  1003. * It looks like it's from the index.php?q=[etc] rewrite that the web
  1004. * server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
  1005. */
  1006. if (strpos($query_str, '?') === false) {
  1007. $public_post_link = '?public=1';
  1008. } else {
  1009. $public_post_link = '&public=1';
  1010. }
  1011. // $tpl = Renderer::replaceMacros($tpl,array('$jotplugins' => $jotplugins));
  1012. $tpl = Renderer::getMarkupTemplate("jot.tpl");
  1013. $o .= Renderer::replaceMacros($tpl,[
  1014. '$new_post' => L10n::t('New Post'),
  1015. '$return_path' => $query_str,
  1016. '$action' => 'item',
  1017. '$share' => defaults($x, 'button', L10n::t('Share')),
  1018. '$upload' => L10n::t('Upload photo'),
  1019. '$shortupload' => L10n::t('upload photo'),
  1020. '$attach' => L10n::t('Attach file'),
  1021. '$shortattach' => L10n::t('attach file'),
  1022. '$edbold' => L10n::t('Bold'),
  1023. '$editalic' => L10n::t('Italic'),
  1024. '$eduline' => L10n::t('Underline'),
  1025. '$edquote' => L10n::t('Quote'),
  1026. '$edcode' => L10n::t('Code'),
  1027. '$edimg' => L10n::t('Image'),
  1028. '$edurl' => L10n::t('Link'),
  1029. '$edattach' => L10n::t('Link or Media'),
  1030. '$setloc' => L10n::t('Set your location'),
  1031. '$shortsetloc' => L10n::t('set location'),
  1032. '$noloc' => L10n::t('Clear browser location'),
  1033. '$shortnoloc' => L10n::t('clear location'),
  1034. '$title' => defaults($x, 'title', ''),
  1035. '$placeholdertitle' => L10n::t('Set title'),
  1036. '$category' => defaults($x, 'category', ''),
  1037. '$placeholdercategory' => Feature::isEnabled(local_user(), 'categories') ? L10n::t("Categories \x28comma-