X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fitem.php;h=6b294b93e5bd1ddcd6b8c218f5c8104817be1c0c;hb=291a82c4a465c6c3b1db7087682cb050d1943a08;hp=ece92f0f3d74a873ac23f4fd1eed63335db83f5f;hpb=aca8c8a13a8c3a850cad26efbc1e262b99c7b8a3;p=friendica.git diff --git a/mod/item.php b/mod/item.php index ece92f0f3d..6b294b93e5 100644 --- a/mod/item.php +++ b/mod/item.php @@ -54,6 +54,8 @@ function item_post(&$a) { $parid = 0; $r = false; + $preview = ((x($_POST,'preview')) ? intval($_POST['preview']) : 0); + if($parent || $parent_uri) { if(! x($_POST,'type')) @@ -280,7 +282,7 @@ function item_post(&$a) { $match = null; - if(preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) { + if((! $preview) && preg_match_all("/\[img\](.*?)\[\/img\]/",$body,$match)) { $images = $match[1]; if(count($images)) { foreach($images as $image) { @@ -323,7 +325,7 @@ function item_post(&$a) { $match = false; - if(preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",$body,$match)) { + if((! $preview) && preg_match_all("/\[attachment\](.*?)\[\/attachment\]/",$body,$match)) { $attaches = $match[1]; if(count($attaches)) { foreach($attaches as $attach) { @@ -351,13 +353,6 @@ function item_post(&$a) { $bookmark = 0; if(preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$body,$match,PREG_SET_ORDER)) { $bookmark = 1; -// foreach($match as $mtch) { -// $body = str_replace( -// '[bookmark=' . $mtch[1] . ']' . $mtch[2] . '[/bookmark]', -// '[url=' . $mtch[1] . ']' . $mtch[2] . '[/url]', -// $body -// ); -// } } $body = bb_translate_video($body); @@ -588,6 +583,15 @@ function item_post(&$a) { else $datarray['guid'] = get_guid(); + // preview mode - prepare the body for display and send it via json + + if($preview) { + require_once('include/conversation.php'); + $o = conversation(&$a,array(array_merge($contact_record,$datarray)),'search',false,true); + echo json_encode(array('preview' => $o)); + killme(); + } + call_hooks('post_local',$datarray); @@ -691,7 +695,9 @@ function item_post(&$a) { 'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id, 'source_name' => $datarray['author-name'], 'source_link' => $datarray['author-link'], - 'source_photo' => $datarray['author-avatar'] + 'source_photo' => $datarray['author-avatar'], + 'verb' => ACTIVITY_POST, + 'otype' => 'item' )); } @@ -731,7 +737,9 @@ function item_post(&$a) { 'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id, 'source_name' => $datarray['author-name'], 'source_link' => $datarray['author-link'], - 'source_photo' => $datarray['author-avatar'] + 'source_photo' => $datarray['author-avatar'], + 'verb' => ACTIVITY_POST, + 'otype' => 'item' )); } }