X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fconversation.php;h=fd7303fa46f4d97090c539ea0df68d6eca2306f4;hb=2bfd53bf092cd97ad96df9406b40b16362a56fc9;hp=c668e53d9da656d3549c6328d54f7c86f6d0510f;hpb=4841ac7dc57830f1d50e29f371afdd8f6af449a4;p=friendica.git diff --git a/include/conversation.php b/include/conversation.php index c668e53d9d..fd7303fa46 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -28,6 +28,7 @@ use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Core\Session; +use Friendica\Core\Theme; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; @@ -354,6 +355,13 @@ function conv_get_blocklist() */ function conversation(App $a, array $items, $mode, $update, $preview = false, $order = 'commented', $uid = 0) { + $page = DI::page(); + + $page->registerFooterScript(Theme::getPathForFile('asset/typeahead.js/dist/typeahead.bundle.js')); + $page->registerFooterScript(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.js')); + $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput.css')); + $page->registerStylesheet(Theme::getPathForFile('js/friendica-tagsinput/friendica-tagsinput-typeahead.css')); + $ssl_state = (local_user() ? true : false); $profile_owner = 0; @@ -538,8 +546,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o $locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => '']; Hook::callAll('render_location',$locate); - - $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate)); + $location_html = $locate['html'] ?: Strings::escapeHtml($locate['location'] ?: $locate['coord'] ?: ''); localize_item($item); if ($mode === 'network-new') { @@ -569,7 +576,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o unset($likebuttons['dislike']); } - $body = Item::prepareBody($item, true, $preview); + $body_html = Item::prepareBody($item, true, $preview); list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item); @@ -594,7 +601,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'lock' => $lock, 'thumb' => DI::baseUrl()->remove($item['author-avatar']), 'title' => $title, - 'body' => $body, + 'body_html' => $body_html, 'tags' => $tags['tags'], 'hashtags' => $tags['hashtags'], 'mentions' => $tags['mentions'], @@ -605,10 +612,10 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'has_folders' => ((count($folders)) ? 'true' : ''), 'categories' => $categories, 'folders' => $folders, - 'text' => strip_tags($body), + 'text' => strip_tags($body_html), 'localtime' => DateTimeFormat::local($item['created'], 'r'), 'ago' => (($item['app']) ? DI::l10n()->t('%s from %s', Temporal::getRelativeDate($item['created']),$item['app']) : Temporal::getRelativeDate($item['created'])), - 'location' => $location, + 'location_html' => $location_html, 'indent' => '', 'owner_name' => $owner_name, 'owner_url' => $owner_url, @@ -719,21 +726,52 @@ function conversation_fetch_comments($thread_items, $pinned) { && ($row['thr-parent'] == $row['parent-uri']) && ($row['received'] > $received) && Contact::isSharing($row['author-id'], $row['uid'])) { $direction = ['direction' => 3, 'title' => DI::l10n()->t('%s reshared this.', $row['author-name'])]; - $actor = ['link' => $row['author-link'], 'avatar' => $row['author-avatar'], 'name' => $row['author-name']]; + + $author = ['uid' => 0, 'id' => $row['author-id'], + 'network' => $row['author-network'], 'url' => $row['author-link']]; + $url = '' . htmlentities($row['author-name']) . ''; + + $actor = ['url' => $url, 'link' => $row['author-link'], 'avatar' => $row['author-avatar'], 'name' => $row['author-name']]; $received = $row['received']; } if (!empty($parentlines) && empty($direction) && ($row['gravity'] == GRAVITY_COMMENT) && Contact::isSharing($row['author-id'], $row['uid'])) { - $direction = ['direction' => 2, 'title' => DI::l10n()->t('%s commented this.', $row['author-name'])]; + $direction = ['direction' => 5, 'title' => DI::l10n()->t('%s commented on this.', $row['author-name'])]; } - if (($row['gravity'] == GRAVITY_PARENT) && !$row['origin'] && ($row['author-id'] == $row['owner-id']) - && !Contact::isSharing($row['author-id'], $row['uid'])) { - if ($row['post-type'] == Item::PT_TAG) { + switch ($row['post-type']) { + case Item::PT_TO: + $row['direction'] = ['direction' => 7, 'title' => DI::l10n()->t('You had been addressed (%s).', 'to')]; + break; + case Item::PT_CC: + $row['direction'] = ['direction' => 7, 'title' => DI::l10n()->t('You had been addressed (%s).', 'cc')]; + break; + case Item::PT_BTO: + $row['direction'] = ['direction' => 7, 'title' => DI::l10n()->t('You had been addressed (%s).', 'bto')]; + break; + case Item::PT_BCC: + $row['direction'] = ['direction' => 7, 'title' => DI::l10n()->t('You had been addressed (%s).', 'bcc')]; + break; + case Item::PT_FOLLOWER: + $row['direction'] = ['direction' => 6, 'title' => DI::l10n()->t('You are following %s.', $row['author-name'])]; + break; + case Item::PT_TAG: $row['direction'] = ['direction' => 4, 'title' => DI::l10n()->t('Tagged')]; - } - + break; + case Item::PT_ANNOUNCEMENT: + $row['direction'] = ['direction' => 3, 'title' => DI::l10n()->t('Reshared')]; + break; + case Item::PT_COMMENT: + $row['direction'] = ['direction' => 5, 'title' => DI::l10n()->t('%s is participating in this thread.', $row['author-name'])]; + break; + case Item::PT_STORED: + $row['direction'] = ['direction' => 8, 'title' => DI::l10n()->t('Stored')]; + break; + } + + if (($row['gravity'] == GRAVITY_PARENT) && !$row['origin'] && ($row['author-id'] == $row['owner-id']) && + !Contact::isSharing($row['author-id'], $row['uid'])) { $parentlines[] = $lineno; } @@ -750,10 +788,13 @@ function conversation_fetch_comments($thread_items, $pinned) { if (!empty($direction)) { foreach ($parentlines as $line) { $comments[$line]['direction'] = $direction; - if (!empty($actor) && DI::pConfig()->get(local_user(), 'system', 'display_resharer') ) { - $comments[$line]['owner-link'] = $actor['link']; - $comments[$line]['owner-avatar'] = $actor['avatar']; - $comments[$line]['owner-name'] = $actor['name']; + if (!empty($actor)) { + $comments[$line]['reshared'] = DI::l10n()->t('%s reshared this.', $actor['url']); + if (DI::pConfig()->get(local_user(), 'system', 'display_resharer') ) { + $comments[$line]['owner-link'] = $actor['link']; + $comments[$line]['owner-avatar'] = $actor['avatar']; + $comments[$line]['owner-name'] = $actor['name']; + } } } } @@ -1129,34 +1170,12 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) $jotplugins = ''; Hook::callAll('jot_tool', $jotplugins); - // Private/public post links for the non-JS ACL form - $private_post = 1; - if (!empty($_REQUEST['public'])) { - $private_post = 0; - } - - $query_str = DI::args()->getQueryString(); - if (strpos($query_str, 'public=1') !== false) { - $query_str = str_replace(['?public=1', '&public=1'], ['', ''], $query_str); - } - - /* - * I think $a->query_string may never have ? in it, but I could be wrong - * It looks like it's from the index.php?q=[etc] rewrite that the web - * server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61 - */ - if (strpos($query_str, '?') === false) { - $public_post_link = '?public=1'; - } else { - $public_post_link = '&public=1'; - } - // $tpl = Renderer::replaceMacros($tpl,array('$jotplugins' => $jotplugins)); $tpl = Renderer::getMarkupTemplate("jot.tpl"); $o .= Renderer::replaceMacros($tpl,[ '$new_post' => DI::l10n()->t('New Post'), - '$return_path' => $query_str, + '$return_path' => DI::args()->getQueryString(), '$action' => 'item', '$share' => ($x['button'] ?? '') ?: DI::l10n()->t('Share'), '$loading' => DI::l10n()->t('Loading...'), @@ -1182,7 +1201,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) '$placeholdercategory' => Feature::isEnabled(local_user(), 'categories') ? DI::l10n()->t("Categories \x28comma-separated list\x29") : '', '$wait' => DI::l10n()->t('Please wait'), '$permset' => DI::l10n()->t('Permission settings'), - '$shortpermset' => DI::l10n()->t('permissions'), + '$shortpermset' => DI::l10n()->t('Permissions'), '$wall' => $notes_cid ? 0 : 1, '$posttype' => $notes_cid ? Item::PT_PERSONAL_NOTE : Item::PT_ARTICLE, '$content' => $x['content'] ?? '', @@ -1204,11 +1223,6 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) // ACL permissions box '$acl' => $x['acl'], - '$group_perms' => DI::l10n()->t('Post to Groups'), - '$contact_perms' => DI::l10n()->t('Post to Contacts'), - '$private' => DI::l10n()->t('Private post'), - '$is_private' => $private_post, - '$public_link' => $public_post_link, //jot nav tab (used in some themes) '$message' => DI::l10n()->t('Message'), @@ -1482,13 +1496,3 @@ function sort_thr_commented(array $a, array $b) { return strcmp($b['commented'], $a['commented']); } - -function render_location_dummy(array $item) { - if (!empty($item['location']) && !empty($item['location'])) { - return $item['location']; - } - - if (!empty($item['coord']) && !empty($item['coord'])) { - return $item['coord']; - } -}