X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fconversation.php;h=521b4623b89bf7fb9383c39b768af2875d2b4559;hb=3c6cf1f19ce783fe1b3b735cc405bf052d25aad7;hp=526c6ea0052c5dc5c7fdbf4fe3bf51e2b2e05e53;hpb=ecc9f4ba70fc1bf2fae89ead5772110df238de58;p=friendica.git diff --git a/include/conversation.php b/include/conversation.php old mode 100755 new mode 100644 index 526c6ea005..521b4623b8 --- a/include/conversation.php +++ b/include/conversation.php @@ -94,9 +94,9 @@ function localize_item(&$item){ } - $A = '[url=' . $Alink . ']' . $Aname . '[/url]'; - $B = '[url=' . $Blink . ']' . $Bname . '[/url]'; - if ($Bphoto!="") $Bphoto = '[url=' . $Blink . '][img]' . $Bphoto . '[/img][/url]'; + $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]'; + $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]'; + if ($Bphoto!="") $Bphoto = '[url=' . zrl($Blink) . '][img]' . $Bphoto . '[/img][/url]'; $item['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$Bphoto; @@ -108,8 +108,8 @@ function localize_item(&$item){ if(count($r)==0) return; $obj=$r[0]; - $author = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; - $objauthor = '[url=' . $obj['author-link'] . ']' . $obj['author-name'] . '[/url]'; + $author = '[url=' . zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]'; + $objauthor = '[url=' . zrl($obj['author-link']) . ']' . $obj['author-name'] . '[/url]'; switch($obj['verb']){ case ACTIVITY_POST: @@ -158,14 +158,21 @@ function localize_item(&$item){ $target = $r[0]; $Bname = $target['author-name']; $Blink = $target['author-link']; - $A = '[url=' . $Alink . ']' . $Aname . '[/url]'; - $B = '[url=' . $Blink . ']' . $Bname . '[/url]'; + $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]'; + $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]'; $P = '[url=' . $target['plink'] . ']' . t('post/item') . '[/url]'; $item['body'] = sprintf( t('%1$s marked %2$s\'s %3$s as favorite'), $A, $B, $P)."\n"; } } } + $matches = null; + if(preg_match_all('/@\[url=(.*?)\]/is',$item['body'],$matches,PREG_SET_ORDER)) { + foreach($matches as $mtch) { + if(! strpos($mtch[1],'zrl=')) + $item['body'] = str_replace($mtch[0],'@[url=' . zrl($mtch[1]). ']',$item['body']); + } + } } @@ -186,6 +193,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { require_once('bbcode.php'); + $ssl_state = ((local_user()) ? true : false); + $profile_owner = 0; $page_writeable = false; @@ -241,7 +250,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $threads = array(); $threadsid = -1; - if(count($items)) { + if($items && count($items)) { if($mode === 'network-new' || $mode === 'search' || $mode === 'community') { @@ -274,13 +283,16 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if($item['author-link'] && (! $item['author-name'])) $profile_name = $item['author-link']; + + $sp = false; $profile_link = best_link_url($item,$sp); - if($sp) - $sparkle = ' sparkle'; if($profile_link === 'mailbox') $profile_link = ''; - + if($sp) + $sparkle = ' sparkle'; + else + $profile_link = zrl($profile_link); $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); if(($normalised != 'mailbox') && (x($a->contacts[$normalised]))) @@ -330,7 +342,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { 'body' => template_escape($body), 'text' => strip_tags(template_escape($body)), 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), - 'lock' => $lock, 'location' => template_escape($location), 'indent' => '', 'owner_name' => template_escape($owner_name), @@ -345,7 +356,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { 'like' => '', 'dislike' => '', 'comment' => '', - 'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), + 'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl($ssl_state) . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), 'previewing' => $previewing, 'wait' => t('Please wait'), ); @@ -375,7 +386,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $comments[$item['parent']] = 1; else $comments[$item['parent']] += 1; - } + } elseif(! x($comments,$item['parent'])) + $comments[$item['parent']] = 0; // avoid notices later on } // map all the like/dislike activities for each parent item @@ -387,6 +399,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { } $comments_collapsed = false; + $comments_seen = 0; $comment_lastcollapsed = false; $comment_firstcollapsed = false; $blowhard = 0; @@ -460,7 +473,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $comment_lastcollapsed = true; } - $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; + $redirect_url = $a->get_baseurl($ssl_state) . '/redir/' . $item['cid'] ; $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) @@ -481,7 +494,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { // This will have been stored in $a->page_contact by our calling page. // Put this person on the left of the wall-to-wall notice. - $owner_url = $a->page_contact['url']; + $owner_url = zrl($a->page_contact['url']); $owner_photo = $a->page_contact['thumb']; $owner_name = $a->page_contact['name']; $template = $wallwall; @@ -498,10 +511,12 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $commentww = 'ww'; // If it is our contact, use a friendly redirect link if((link_compare($item['owner-link'],$item['url'])) - && ($item['network'] === 'dfrn')) { + && ($item['network'] === NETWORK_DFRN)) { $owner_url = $redirect_url; $osparkle = ' sparkle'; } + else + $owner_url = zrl($owner_url); } } @@ -517,9 +532,12 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if ($shareable) $likebuttons['share'] = array( t('Share this'), t('share')); } + $qc = $qcomment = null; - $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null); - $qcomment = (($qc) ? explode("\n",$qc) : null); + if(in_array('qcomment',$a->plugins)) { + $qc = ((local_user()) ? get_pconfig(local_user(),'qcomment','words') : null); + $qcomment = (($qc) ? explode("\n",$qc) : null); + } if(($show_comment_box) || (($show_comment_box == false) && ($override_comment_box == false) && ($item['last-child']))) { $comment = replace_macros($cmnt_tpl,array( @@ -535,16 +553,24 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { '$myphoto' => $a->contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), + '$edbold' => t('Bold'), + '$editalic' => t('Italic'), + '$eduline' => t('Underline'), + '$edquote' => t('Quote'), + '$edcode' => t('Code'), + '$edimg' => t('Image'), + '$edurl' => t('Link'), + '$edvideo' => t('Video'), '$preview' => t('Preview'), '$ww' => (($mode === 'network') ? $commentww : '') )); } } - $edpost = (((($profile_owner == local_user()) && ($toplevelpost) && (intval($item['wall']) == 1)) || ($mode === 'notes')) - ? array($a->get_baseurl()."/editpost/".$item['id'], t("Edit")) - : False); - + if(local_user() && link_compare($a->contact['url'],$item['author-link'])) + $edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit")); + else + $edpost = false; $drop = ''; $dropping = false; @@ -559,24 +585,28 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { ); $star = false; + $filer = false; + $isstarred = "unstarred"; - if ($profile_owner == local_user() && $toplevelpost) { - $isstarred = (($item['starred']) ? "starred" : "unstarred"); - - $star = array( - 'do' => t("add star"), - 'undo' => t("remove star"), - 'toggle' => t("toggle star status"), - 'classdo' => (($item['starred']) ? "hidden" : ""), - 'classundo' => (($item['starred']) ? "" : "hidden"), - 'starred' => t('starred'), - 'tagger' => t("add tag"), - 'classtagger' => "", - ); + if ($profile_owner == local_user()) { + if($toplevelpost) { + $isstarred = (($item['starred']) ? "starred" : "unstarred"); + + $star = array( + 'do' => t("add star"), + 'undo' => t("remove star"), + 'toggle' => t("toggle star status"), + 'classdo' => (($item['starred']) ? "hidden" : ""), + 'classundo' => (($item['starred']) ? "" : "hidden"), + 'starred' => t('starred'), + 'tagger' => t("add tag"), + 'classtagger' => "", + ); + } + $filer = t("save to folder"); } - $photo = $item['photo']; $thumb = $item['thumb']; @@ -589,14 +619,14 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if($item['author-link'] && (! $item['author-name'])) $profile_name = $item['author-link']; - $sp = false; $profile_link = best_link_url($item,$sp); - if($sp) - $sparkle = ' sparkle'; - if($profile_link === 'mailbox') $profile_link = ''; + if($sp) + $sparkle = ' sparkle'; + else + $profile_link = zrl($profile_link); $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); if(($normalised != 'mailbox') && (x($a->contacts,$normalised))) @@ -604,10 +634,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { else $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $thumb); - - - - $like = ((x($alike,$item['id'])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : ''); $dislike = ((x($dlike,$item['id'])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : ''); @@ -642,7 +668,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { // template to use to render item (wall, walltowall, search) 'template' => $template, - 'type' => implode("",array_slice(split("/",$item['verb']),-1)), + 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), 'tags' => $tags, 'body' => template_escape($body), 'text' => strip_tags(template_escape($body)), @@ -670,6 +696,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { 'edpost' => $edpost, 'isstarred' => $isstarred, 'star' => $star, + 'filer' => $filer, 'drop' => $drop, 'vote' => $likebuttons, 'like' => $like, @@ -690,8 +717,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { } $page_template = get_markup_template("conversation.tpl"); - $o .= replace_macros($page_template, array( - '$baseurl' => $a->get_baseurl(), + $o = replace_macros($page_template, array( + '$baseurl' => $a->get_baseurl($ssl_state), '$mode' => $mode, '$user' => $a->user, '$threads' => $threads, @@ -701,7 +728,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { return $o; }} -function best_link_url($item,&$sparkle) { +function best_link_url($item,&$sparkle,$ssl_state = false) { $a = get_app(); @@ -713,7 +740,7 @@ function best_link_url($item,&$sparkle) { if((local_user()) && (local_user() == $item['uid'])) { if(isset($a->contacts) && x($a->contacts,$clean_url)) { if($a->contacts[$clean_url]['network'] === NETWORK_DFRN) { - $best_url = $a->get_baseurl() . '/redir/' . $a->contacts[$clean_url]['id']; + $best_url = $a->get_baseurl($ssl_state) . '/redir/' . $a->contacts[$clean_url]['id']; $sparkle = true; } else @@ -734,10 +761,14 @@ function best_link_url($item,&$sparkle) { if(! function_exists('item_photo_menu')){ function item_photo_menu($item){ $a = get_app(); - - if (local_user() && (! count($a->contacts))) - load_contact_links(local_user()); + $ssl_state = false; + + if(local_user()) { + $ssl_state = true; + if(! count($a->contacts)) + load_contact_links(local_user()); + } $contact_url=""; $pm_url=""; $status_link=""; @@ -745,7 +776,7 @@ function item_photo_menu($item){ $posts_link=""; $sparkle = false; - $profile_link = best_link_url($item,$sparkle); + $profile_link = best_link_url($item,$sparkle,$ssl_state); if($profile_link === 'mailbox') $profile_link = ''; @@ -754,9 +785,11 @@ function item_photo_menu($item){ $status_link = $profile_link . "?url=status"; $photos_link = $profile_link . "?url=photos"; $profile_link = $profile_link . "?url=profile"; - $pm_url = $a->get_baseurl() . '/message/new/' . $cid; + $pm_url = $a->get_baseurl($ssl_state) . '/message/new/' . $cid; + $zurl = ''; } else { + $profile_link = zrl($profile_link); if(local_user() && local_user() == $item['uid'] && link_compare($item['url'],$item['author-link'])) { $cid = $item['contact-id']; } @@ -765,16 +798,27 @@ function item_photo_menu($item){ } } if(($cid) && (! $item['self'])) { - $contact_url = $a->get_baseurl() . '/contacts/' . $cid; - $posts_link = $a->get_baseurl() . '/network/?cid=' . $cid; + $contact_url = $a->get_baseurl($ssl_state) . '/contacts/' . $cid; + $posts_link = $a->get_baseurl($ssl_state) . '/network/?cid=' . $cid; + + $clean_url = normalise_link($item['author-link']); + + if((local_user()) && (local_user() == $item['uid'])) { + if(isset($a->contacts) && x($a->contacts,$clean_url)) { + if($a->contacts[$clean_url]['network'] === NETWORK_DIASPORA) { + $pm_url = $a->get_baseurl($ssl_state) . '/message/new/' . $cid; + } + } + } + } $menu = Array( - t("View status") => $status_link, - t("View profile") => $profile_link, - t("View photos") => $photos_link, - t("View recent") => $posts_link, - t("Edit contact") => $contact_url, + t("View Status") => $status_link, + t("View Profile") => $profile_link, + t("View Photos") => $photos_link, + t("Network Posts") => $posts_link, + t("Edit Contact") => $contact_url, t("Send PM") => $pm_url, ); @@ -802,9 +846,11 @@ function like_puller($a,$item,&$arr,$mode) { if((activity_match($item['verb'],$verb)) && ($item['id'] != $item['parent'])) { $url = $item['author-link']; if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === 'dfrn') && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) { - $url = $a->get_baseurl() . '/redir/' . $item['contact-id']; + $url = $a->get_baseurl(true) . '/redir/' . $item['contact-id']; $sparkle = ' class="sparkle" '; } + else + $url = zrl($url); if(! ((isset($arr[$item['parent'] . '-l'])) && (is_array($arr[$item['parent'] . '-l'])))) $arr[$item['parent'] . '-l'] = array(); if(! isset($arr[$item['parent']])) @@ -864,7 +910,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { $a->page['htmlhead'] .= replace_macros($tpl, array( '$newpost' => 'true', - '$baseurl' => $a->get_baseurl(), + '$baseurl' => $a->get_baseurl(true), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$geotag' => $geotag, '$nickname' => $x['nickname'], @@ -873,8 +919,8 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { '$vidurl' => t("Please enter a video link/URL:"), '$audurl' => t("Please enter an audio link/URL:"), '$term' => t('Tag term:'), - '$whereareu' => t('Where are you right now?'), - '$title' => t('Enter a title for this item') + '$fileas' => t('Save to Folder:'), + '$whereareu' => t('Where are you right now?') )); @@ -914,8 +960,8 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { $o .= replace_macros($tpl,array( '$return_path' => $a->cmd, - '$action' => $a->get_baseurl().'/item', - '$share' => (($x['button']) ? $x['button'] : t('Share')), + '$action' => $a->get_baseurl(true) . '/item', + '$share' => (x($x,'button') ? $x['button'] : t('Share')), '$upload' => t('Upload photo'), '$shortupload' => t('upload photo'), '$attach' => t('Attach file'), @@ -932,13 +978,15 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) { '$shortnoloc' => t('clear location'), '$title' => "", '$placeholdertitle' => t('Set title'), + '$category' => "", + '$placeholdercategory' => t('Categories (comma-separated list)'), '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$shortpermset' => t('permissions'), '$ptyp' => (($notes_cid) ? 'note' : 'wall'), '$content' => '', '$post_id' => '', - '$baseurl' => $a->get_baseurl(), + '$baseurl' => $a->get_baseurl(true), '$defloc' => $x['default_location'], '$visitor' => $x['visitor'], '$pvisit' => (($notes_cid) ? 'none' : $x['visitor']), @@ -980,8 +1028,8 @@ function conv_sort($arr,$order) { usort($parents,'sort_thr_commented'); if(count($parents)) - foreach($parents as $x) - $x['children'] = array(); + foreach($parents as $i=>$_x) + $parents[$i]['children'] = array(); foreach($arr as $x) { if($x['id'] != $x['parent']) { @@ -1034,7 +1082,6 @@ function find_thread_parent_index($arr,$x) { } function render_location_google($item) { - $location = ''; $location = (($item['location']) ? '' . $item['location'] . '' : ''); $coord = (($item['coord']) ? '' . $item['coord'] . '' : ''); if($coord) { @@ -1045,4 +1092,3 @@ function render_location_google($item) { } return $location; } -