X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fconversation.php;h=3d13a1179882d6c269079c981e3adc62d47c6a88;hb=dd09c2d125a109de6089a2122faa4e9c2ecd8f5d;hp=d05b3be5cc9ddd72a7b0879c33a1c3f172bf69d0;hpb=8aa25523721303b6883e1a793f20997f8a33ec0a;p=friendica.git diff --git a/include/conversation.php b/include/conversation.php index d05b3be5cc..3d13a11798 100755 --- a/include/conversation.php +++ b/include/conversation.php @@ -4,6 +4,28 @@ * Render actions localized */ function localize_item(&$item){ + + $Text = $item['body']; + $saved_image = ''; + $img_start = strpos($Text,'[img]data:'); + $img_end = strpos($Text,'[/img]'); + + if($img_start !== false && $img_end !== false && $img_end > $img_start) { + $start_fragment = substr($Text,0,$img_start); + $img_start += strlen('[img]'); + $saved_image = substr($Text,$img_start,$img_end - $img_start); + $end_fragment = substr($Text,$img_end + strlen('[/img]')); + $Text = $start_fragment . '[!#saved_image#!]' . $end_fragment; + $search = '/\[url\=(.*?)\]\[!#saved_image#!\]\[\/url\]' . '/is'; + $replace = '[url=' . z_path() . '/redir/' . $item['contact-id'] + . '?f=1&url=' . '$1' . '][!#saved_image#!][/url]' ; + + $Text = preg_replace($search,$replace,$Text); + + if(strlen($saved_image)) + $item['body'] = str_replace('[!#saved_image#!]', '[img]' . $saved_image . '[/img]',$Text); + } + $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; if ($item['verb']=== ACTIVITY_LIKE || $item['verb']=== ACTIVITY_DISLIKE){ @@ -116,6 +138,34 @@ function localize_item(&$item){ $item['body'] = sprintf( t('%1$s tagged %2$s\'s %3$s with %4$s'), $author, $objauthor, $plink, $tag ); } + if ($item['verb']=== ACTIVITY_FAVORITE){ + + if ($item['object-type']== "") + return; + + $Aname = $item['author-name']; + $Alink = $item['author-link']; + + $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">"; + + $obj = parse_xml_string($xmlhead.$item['object']); + if(strlen($obj->id)) { + $r = q("select * from item where uri = '%s' and uid = %d limit 1", + dbesc($obj->id), + intval($item['uid']) + ); + if(count($r) && $r[0]['plink']) { + $target = $r[0]; + $Bname = $target['author-name']; + $Blink = $target['author-link']; + $A = '[url=' . $Alink . ']' . $Aname . '[/url]'; + $B = '[url=' . $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"; + + } + } + } } @@ -234,15 +284,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { else $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']); - $location = (($item['location']) ? '' . $item['location'] . '' : ''); - $coord = (($item['coord']) ? '' . $item['coord'] . '' : ''); - if($coord) { - if($location) - $location .= '
(' . $coord . ')'; - else - $location = '' . $coord . ''; - } + $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); + call_hooks('render_location',$locate); + $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate)); localize_item($item); if($mode === 'network-new') @@ -466,7 +511,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { } $likebuttons = ''; - $shareable = ((($profile_owner == local_user()) && ($mode != 'display') && (! $item['private'])) ? true : false); + $shareable = ((($profile_owner == local_user()) && (! $item['private'])) ? true : false); //($mode != 'display') && if($page_writeable) { if($toplevelpost) { @@ -477,6 +522,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if ($shareable) $likebuttons['share'] = array( t('Share this'), t('share')); } + + $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( '$return_path' => '', @@ -484,6 +533,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { '$type' => (($mode === 'profile') ? 'wall-comment' : 'net-comment'), '$id' => $item['item_id'], '$parent' => $item['parent'], + '$qcomment' => $qcomment, '$profile_uid' => $profile_owner, '$mylink' => $a->contact['url'], '$mytitle' => t('This is you'), @@ -566,16 +616,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $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']) : ''); - $location = (($item['location']) ? '' . $item['location'] . '' : ''); - $coord = (($item['coord']) ? '' . $item['coord'] . '' : ''); - if($coord) { - if($location) - $location .= '
(' . $coord . ')'; - else - $location = '' . $coord . ''; - } + $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); + call_hooks('render_location',$locate); + + $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate)); $indent = (($toplevelpost) ? '' : ' comment'); @@ -592,11 +636,9 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if ($tag!="") $tags[] = bbcode($tag); } - // Build the HTML $body = prepare_body($item,true); - $tmp_item = replace_macros($template,array( '$type' => implode("",array_slice(split("/",$item['verb']),-1)), @@ -804,104 +846,114 @@ function format_like($cnt,$arr,$type,$id) { }} -function status_editor($a,$x, $notes_cid = 0) { +function status_editor($a,$x, $notes_cid = 0, $popup=false) { $o = ''; $geotag = (($x['allow_location']) ? get_markup_template('jot_geotag.tpl') : ''); - $tpl = get_markup_template('jot-header.tpl'); - - $a->page['htmlhead'] .= replace_macros($tpl, array( - '$newpost' => 'true', - '$baseurl' => $a->get_baseurl(), - '$geotag' => $geotag, - '$nickname' => $x['nickname'], - '$ispublic' => t('Visible to everybody'), - '$linkurl' => t('Please enter a link URL:'), - '$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') - )); - - - $tpl = get_markup_template("jot.tpl"); - - $jotplugins = ''; - $jotnets = ''; + $plaintext = false; + if(local_user() && intval(get_pconfig(local_user(),'system','plaintext'))) + $plaintext = true; - $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); + $tpl = get_markup_template('jot-header.tpl'); + + $a->page['htmlhead'] .= replace_macros($tpl, array( + '$newpost' => 'true', + '$baseurl' => $a->get_baseurl(), + '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), + '$geotag' => $geotag, + '$nickname' => $x['nickname'], + '$ispublic' => t('Visible to everybody'), + '$linkurl' => t('Please enter a link URL:'), + '$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') + )); - $mail_enabled = false; - $pubmail_enabled = false; - if(($x['is_owner']) && (! $mail_disabled)) { - $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", - intval(local_user()) - ); - if(count($r)) { - $mail_enabled = true; - if(intval($r[0]['pubmail'])) - $pubmail_enabled = true; - } + $tpl = get_markup_template("jot.tpl"); + + $jotplugins = ''; + $jotnets = ''; + + $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1); + + $mail_enabled = false; + $pubmail_enabled = false; + + if(($x['is_owner']) && (! $mail_disabled)) { + $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", + intval(local_user()) + ); + if(count($r)) { + $mail_enabled = true; + if(intval($r[0]['pubmail'])) + $pubmail_enabled = true; } + } - if($mail_enabled) { - $selected = (($pubmail_enabled) ? ' checked="checked" ' : ''); - $jotnets .= '
' - . t("Post to Email") . '
'; - } + if($mail_enabled) { + $selected = (($pubmail_enabled) ? ' checked="checked" ' : ''); + $jotnets .= '
' . t("Post to Email") . '
'; + } + + call_hooks('jot_tool', $jotplugins); + call_hooks('jot_networks', $jotnets); + + if($notes_cid) + $jotnets .= ''; + + $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); + + $o .= replace_macros($tpl,array( + '$return_path' => $a->cmd, + '$action' => $a->get_baseurl().'/item', + '$share' => (($x['button']) ? $x['button'] : t('Share')), + '$upload' => t('Upload photo'), + '$shortupload' => t('upload photo'), + '$attach' => t('Attach file'), + '$shortattach' => t('attach file'), + '$weblink' => t('Insert web link'), + '$shortweblink' => t('web link'), + '$video' => t('Insert video link'), + '$shortvideo' => t('video link'), + '$audio' => t('Insert audio link'), + '$shortaudio' => t('audio link'), + '$setloc' => t('Set your location'), + '$shortsetloc' => t('set location'), + '$noloc' => t('Clear browser location'), + '$shortnoloc' => t('clear location'), + '$title' => "", + '$placeholdertitle' => t('Set title'), + '$wait' => t('Please wait'), + '$permset' => t('Permission settings'), + '$shortpermset' => t('permissions'), + '$ptyp' => (($notes_cid) ? 'note' : 'wall'), + '$content' => '', + '$post_id' => '', + '$baseurl' => $a->get_baseurl(), + '$defloc' => $x['default_location'], + '$visitor' => $x['visitor'], + '$pvisit' => (($notes_cid) ? 'none' : $x['visitor']), + '$emailcc' => t('CC: email addresses'), + '$public' => t('Public post'), + '$jotnets' => $jotnets, + '$emtitle' => t('Example: bob@example.com, mary@example.com'), + '$lockstate' => $x['lockstate'], + '$acl' => $x['acl'], + '$bang' => $x['bang'], + '$profile_uid' => $x['profile_uid'], + '$preview' => t('Preview'), + )); - call_hooks('jot_tool', $jotplugins); - call_hooks('jot_networks', $jotnets); - - if($notes_cid) - $jotnets .= ''; - - $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); - - $o .= replace_macros($tpl,array( - '$return_path' => $a->cmd, - '$action' => 'item', - '$share' => (($x['button']) ? $x['button'] : t('Share')), - '$upload' => t('Upload photo'), - '$shortupload' => t('upload photo'), - '$attach' => t('Attach file'), - '$shortattach' => t('attach file'), - '$weblink' => t('Insert web link'), - '$shortweblink' => t('web link'), - '$video' => t('Insert video link'), - '$shortvideo' => t('video link'), - '$audio' => t('Insert audio link'), - '$shortaudio' => t('audio link'), - '$setloc' => t('Set your location'), - '$shortsetloc' => t('set location'), - '$noloc' => t('Clear browser location'), - '$shortnoloc' => t('clear location'), - '$title' => "", - '$placeholdertitle' => t('Set title'), - '$wait' => t('Please wait'), - '$permset' => t('Permission settings'), - '$shortpermset' => t('permissions'), - '$ptyp' => (($notes_cid) ? 'note' : 'wall'), - '$content' => '', - '$post_id' => '', - '$baseurl' => $a->get_baseurl(), - '$defloc' => $x['default_location'], - '$visitor' => $x['visitor'], - '$pvisit' => (($notes_cid) ? 'none' : $x['visitor']), - '$emailcc' => t('CC: email addresses'), - '$public' => t('Public post'), - '$jotnets' => $jotnets, - '$emtitle' => t('Example: bob@example.com, mary@example.com'), - '$lockstate' => $x['lockstate'], - '$acl' => $x['acl'], - '$bang' => $x['bang'], - '$profile_uid' => $x['profile_uid'], - '$preview' => t('Preview'), - )); + + if ($popup==true){ + $o = ''; + + } return $o; } @@ -976,3 +1028,17 @@ function find_thread_parent_index($arr,$x) { return $k; return false; } + +function render_location_google($item) { + $location = ''; + $location = (($item['location']) ? '' . $item['location'] . '' : ''); + $coord = (($item['coord']) ? '' . $item['coord'] . '' : ''); + if($coord) { + if($location) + $location .= '
(' . $coord . ')'; + else + $location = '' . $coord . ''; + } + return $location; +} +