]> git.mxchange.org Git - friendica.git/commitdiff
backend support for post preview
authorfriendica <info@friendica.com>
Thu, 5 Jan 2012 23:02:44 +0000 (15:02 -0800)
committerfriendica <info@friendica.com>
Thu, 5 Jan 2012 23:02:44 +0000 (15:02 -0800)
mod/item.php
view/jot.tpl
view/theme/dispy/jot.tpl
view/theme/quattro/jot.tpl
view/theme/testbubble/jot.tpl

index c4e66ebeb0601d884260f2a6cd345773a97fa7fc..d4d337584c2617939d3834c5254f64bb431c975b 100644 (file)
@@ -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,17 @@ function item_post(&$a) {
        else
                $datarray['guid']      = get_guid();
 
+       // preview mode - prepare the body for display and send it via json
+
+       if($preview) {
+               $b = prepare_body($datarray,true);
+               require_once('include/conversation.php');
+               $o = conversation(&$a,array(array_merge($datarray,$contact_record)),'search',false);
+               $json = array('preview' => $o);
+               echo json_encode($json);
+               killme();
+       }
+
 
        call_hooks('post_local',$datarray);
 
index 66621db5eb738b2476e55e8bc2203ee714ed1ddb..e81c8eb3f727f9465ec9ebfdfe8d81a96251f3c3 100644 (file)
@@ -13,6 +13,7 @@
                <input type="hidden" name="location" id="jot-location" value="$defloc" />
                <input type="hidden" name="coord" id="jot-coord" value="" />
                <input type="hidden" name="post_id" value="$post_id" />
+               <input type="hidden" name="preview" id="jot-preview" value="0" />
                <div id="jot-title-wrapper">
                <span id="jot-title-desc" style="display: none;">$addtitle</span>
                <span id="jot-title-display" style="display: none;"></span>
index 57f320d4ce6eaced30db0eafb5343af091384d45..0ceddb3b7be39aeaeddd143974114c29afe8047b 100644 (file)
@@ -15,6 +15,7 @@
                <input type="hidden" name="location" id="jot-location" value="$defloc" />
                <input type="hidden" name="coord" id="jot-coord" value="" />
                <input type="hidden" name="post_id" value="$post_id" />
+               <input type="hidden" name="preview" id="jot-preview" value="0" />
                <div id="jot-title-wrapper">
                <span id="jot-title-desc" style="display: none;">$addtitle</span>
                <span id="jot-title-display" style="display: none;"></span>
index 61ba75234be606db30ec1d5ac89a9e9f7f1b4ab0..36008c5a1e7923ac34418bbddb1e46f1471e2fbe 100644 (file)
@@ -13,6 +13,7 @@
                <input type="hidden" name="location" id="jot-location" value="$defloc" />
                <input type="hidden" name="coord" id="jot-coord" value="" />
                <input type="hidden" name="post_id" value="$post_id" />
+               <input type="hidden" name="preview" id="jot-preview" value="0" />
                <div id="jot-title-wrapper">
                <span id="jot-title-desc" style="display: none;">$addtitle</span>
                <span id="jot-title-display" style="display: none;"></span>
index be536aff404506736512b1e7795e6c3da495d8d1..fa655a13e28eb62895030f54d2aabbb312139838 100644 (file)
@@ -15,6 +15,7 @@
                <input type="hidden" name="location" id="jot-location" value="$defloc" />
                <input type="hidden" name="coord" id="jot-coord" value="" />
                <input type="hidden" name="post_id" value="$post_id" />
+               <input type="hidden" name="preview" id="jot-preview" value="0" />
 
                <div id="jot-title-wrapper">
         <span id="jot-title-desc" style="display: none;">$addtitle</span>