]> git.mxchange.org Git - friendica.git/blobdiff - mod/message.php
Frost-mobile: media query in css for tablets
[friendica.git] / mod / message.php
index 4ffdebb1210637992b3e31350aec64640eeb5dc0..83bad29d43647fea02fe1107e175a71dff5b59b4 100644 (file)
@@ -18,24 +18,17 @@ function message_init(&$a) {
        ));
        $base = $a->get_baseurl();
 
-       $a->page['htmlhead'] .= '<script src="' . $a->get_baseurl(true) . '/library/jquery_ac/friendica.complete.js" ></script>';
-       $a->page['htmlhead'] .= <<< EOT
-
-<script>$(document).ready(function() { 
-       var a; 
-       a = $("#recip").autocomplete({ 
-               serviceUrl: '$base/acl',
-               minChars: 2,
-               width: 350,
-               onSelect: function(value,data) {
-                       $("#recip-complete").val(data);
-               }                       
-       });
-
-}); 
-
-</script>
-EOT;
+       $head_tpl = get_markup_template('message-head.tpl');
+       $a->page['htmlhead'] .= replace_macros($head_tpl,array(
+               '$baseurl' => $a->get_baseurl(true),
+               '$base' => $base
+       ));
+
+       $end_tpl = get_markup_template('message-end.tpl');
+       $a->page['end'] .= replace_macros($end_tpl,array(
+               '$baseurl' => $a->get_baseurl(true),
+               '$base' => $base
+       ));
        
 }
 
@@ -109,10 +102,10 @@ function item_extract_images($body) {
                if(! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
                        // This is an embedded image
 
-                       $saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - $img_start);
-                       $cnt++;
-
+                       $saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close));
                        $new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]';
+
+                       $cnt++;
                }
                else
                        $new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
@@ -135,22 +128,29 @@ function item_extract_images($body) {
 if(! function_exists('item_redir_and_replace_images')) {
 function item_redir_and_replace_images($body, $images, $cid) {
 
-       $newbody = $body;
+       $origbody = $body;
+       $newbody = '';
 
        for($i = 0; $i < count($images); $i++) {
                $search = '/\[url\=(.*?)\]\[!#saved_image' . $i . '#!\]\[\/url\]' . '/is';
                $replace = '[url=' . z_path() . '/redir/' . $cid 
                           . '?f=1&url=' . '$1' . '][!#saved_image' . $i . '#!][/url]' ;
 
-               $newbody = preg_replace($search, $replace, $newbody);
+               $img_end = strpos($origbody, '[!#saved_image' . $i . '#!][/url]') + strlen('[!#saved_image' . $i . '#!][/url]');
+               $process_part = substr($origbody, 0, $img_end);
+               $origbody = substr($origbody, $img_end);
+
+               $process_part = preg_replace($search, $replace, $process_part);
+               $newbody = $newbody . $process_part;
        }
+       $newbody = $newbody . $origbody;
 
        $cnt = 0;
        foreach($images as $image) {
                // We're depending on the property of 'foreach' (specified on the PHP website) that
                // it loops over the array starting from the first element and going sequentially
                // to the last element
-               $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '[img]' . $image . '[/img]', $newbody);
+               $newbody = str_replace('[!#saved_image' . $cnt . '#!]', '[img]' . $image . '[/img]', $newbody);
                $cnt++;
        }
 
@@ -235,7 +235,6 @@ function message_content(&$a) {
 
 
                $tpl = get_markup_template('msg-header.tpl');
-
                $a->page['htmlhead'] .= replace_macros($tpl, array(
                        '$baseurl' => $a->get_baseurl(true),
                        '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
@@ -243,6 +242,14 @@ function message_content(&$a) {
                        '$linkurl' => t('Please enter a link URL:')
                ));
        
+               $tpl = get_markup_template('msg-end.tpl');
+               $a->page['end'] .= replace_macros($tpl, array(
+                       '$baseurl' => $a->get_baseurl(true),
+                       '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
+                       '$nickname' => $a->user['nickname'],
+                       '$linkurl' => t('Please enter a link URL:')
+               ));
+       
                $preselect = (isset($a->argv[2])?array($a->argv[2]):false);
                        
 
@@ -392,12 +399,17 @@ function message_content(&$a) {
                require_once("include/bbcode.php");
 
                $tpl = get_markup_template('msg-header.tpl');
-       
                $a->page['htmlhead'] .= replace_macros($tpl, array(
                        '$nickname' => $a->user['nickname'],
                        '$baseurl' => $a->get_baseurl(true)
                ));
 
+               $tpl = get_markup_template('msg-end.tpl');
+               $a->page['end'] .= replace_macros($tpl, array(
+                       '$nickname' => $a->user['nickname'],
+                       '$baseurl' => $a->get_baseurl(true)
+               ));
+
 
                $mails = array();
                $seen = 0;