]> git.mxchange.org Git - friendica.git/commitdiff
API: beautify the output of repeated items
authorMichael Vogel <icarus@dabo.de>
Fri, 15 Feb 2013 19:14:45 +0000 (20:14 +0100)
committerMichael Vogel <icarus@dabo.de>
Fri, 15 Feb 2013 19:14:45 +0000 (20:14 +0100)
Vier: Birthday reminder looks better

include/api.php
include/bbcode.php
view/theme/vier/style.css

index 4efb0c614a32523fd1502c07e59a43e682dea8be..81255ca37ffe7fdaa1ecedc25ac59b4a842e5e40 100644 (file)
                         $txt = $purifier->purify($txt);
                }
                $txt = html2bbcode($txt);
-               
+
                 $a->argv[1]=$user_info['screen_name']; //should be set to username?
-               
+
                $_REQUEST['hush']='yeah'; //tell wall_upload function to return img info instead of echo
                 require_once('mod/wall_upload.php');
                $bebop = wall_upload_post($a);
-                
+
                //now that we have the img url in bbcode we can add it to the status and insert the wall item.
                 $_REQUEST['body']=$txt."\n\n".$bebop;
                 require_once('mod/item.php');
 
                if (count($lastwall)>0){
                        $lastwall = $lastwall[0];
-                       
+
                        $in_reply_to_status_id = '';
                        $in_reply_to_user_id = '';
                        $in_reply_to_screen_name = '';
                                $in_reply_to_status_id=$lastwall['parent'];
                                $in_reply_to_user_id = $lastwall['reply_uid'];
                                $in_reply_to_screen_name = $lastwall['reply_author'];
-                       }  
+                       }
                        $status_info = array(
-                               'text' => html2plain(bbcode($lastwall['body']), 0),
+                               'text' => html2plain(bbcode($lastwall['body'], false, false, true), 0),
                                'truncated' => false,
                                'created_at' => api_date($lastwall['created']),
                                'in_reply_to_status_id' => $in_reply_to_status_id,
                                $in_reply_to_status_id=$lastwall['parent'];
                                $in_reply_to_user_id = $lastwall['reply_uid'];
                                $in_reply_to_screen_name = $lastwall['reply_author'];
-                       }  
+                       }
                        $user_info['status'] = array(
                                'created_at' => api_date($lastwall['created']),
                                'id' => $lastwall['contact-id'],
-                               'text' => html2plain(bbcode($lastwall['body']), 0),
+                               'text' => html2plain(bbcode($lastwall['body'], false, false, true), 0),
                                'source' => (($lastwall['app']) ? $lastwall['app'] : 'web'),
                                'truncated' => false,
                                'in_reply_to_status_id' => $in_reply_to_status_id,
                                $ret['text'] = bbcode($item['body']);
                        }
                        elseif ($_GET["getText"] == "plain") {
-                               $ret['text'] = html2plain(bbcode($item['body']), 0);
+                               $ret['text'] = html2plain(bbcode($item['body'], false, false, true), 0);
                        }
                }
                else {
-                       $ret['text'] = $item['title']."\n".html2plain(bbcode($item['body']), 0);
+                       $ret['text'] = $item['title']."\n".html2plain(bbcode($item['body'], false, false, true), 0);
                }
                if (isset($_GET["getUserObjects"]) && $_GET["getUserObjects"] == "false") {
                        unset($ret['sender']);
                        }
 
                        // Workaround for ostatus messages where the title is identically to the body
-                       $statusbody = trim(html2plain(bbcode($item['body']), 0));
+                       $statusbody = trim(html2plain(bbcode($item['body'], false, false, true), 0));
                        $statustitle = trim($item['title']);
 
                        if (($statustitle != '') and (strpos($statusbody, $statustitle) !== false))
index 45213cc3b75f3812020a3c148616fe85943bb204..a587d8c38075e5f6da2dfc066801492d8f6f8eaa 100644 (file)
@@ -278,10 +278,37 @@ function bb_ShareAttributes($match) {
         return($text);
 }
 
+function bb_ShareAttributesSimple($match) {
+
+        $attributes = $match[1];
+
+        $author = "";
+        preg_match("/author='(.*?)'/ism", $attributes, $matches);
+        if ($matches[1] != "")
+                $author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
+
+        preg_match('/author="(.*?)"/ism', $attributes, $matches);
+        if ($matches[1] != "")
+                $author = $matches[1];
+
+        $profile = "";
+        preg_match("/profile='(.*?)'/ism", $attributes, $matches);
+        if ($matches[1] != "")
+                $profile = $matches[1];
+
+        preg_match('/profile="(.*?)"/ism', $attributes, $matches);
+        if ($matches[1] != "")
+                $profile = $matches[1];
+
+        $text = "<br />".html_entity_decode("&#x2672; ", ENT_QUOTES, 'UTF-8').' <a href="'.$profile.'">'.$author."</a>: <br />»".$match[2]."«";
+
+        return($text);
+}
+
        // BBcode 2 HTML was written by WAY2WEB.net
        // extended to work with Mistpark/Friendica - Mike Macgirvin
 
-function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
+function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = false) {
 
        $stamp1 = microtime(true);
 
@@ -342,13 +369,14 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
        $Text = str_replace("\r\n","\n", $Text);
 
        // removing multiplicated newlines
-//     $search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]");
-//     $replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]");
-//     do {
-//             $oldtext = $Text;
-//             $Text = str_replace($search, $replace, $Text);
-//     } while ($oldtext != $Text);
-
+       if (get_config("system", "remove_multiplicated_lines")) {
+               $search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]");
+               $replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]");
+               do {
+                       $oldtext = $Text;
+                       $Text = str_replace($search, $replace, $Text);
+               } while ($oldtext != $Text);
+       }
 
        $Text = str_replace(array("\r","\n"), array('<br />','<br />'), $Text);
 
@@ -517,7 +545,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
        $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text);
 
        // Shared content
-       $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributes",$Text);
+       if (!$simplehtml)
+               $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributes",$Text);
+       else
+               $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributesSimple",$Text);
 
        $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />', $Text);
        $Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
index aa66769db2b4dc57ec25192931d8113c66b6f472..4a116c5b7286bcada1d268dc19d8b5557f9cdca6 100644 (file)
@@ -1020,6 +1020,9 @@ section {
   max-width: 766px;
   padding: 10px 10px 10px 10px;
   background-color: white;
+  border-bottom: 1px solid lightgray;
+  border-right: 1px solid lightgray;
+  border-left: 1px solid lightgray;
 }
 /* wall item */
 .tread-wrapper {
@@ -1727,7 +1730,7 @@ div.pager, .birthday-notice, ul.tabs a, #jot-preview-link, .comment-edit-submit-
     background: linear-gradient(top, #ffffff 0%,#ececf2 100%);*/
 }
 
-#event-notice:hover, ul.tabs li .active, ul.tabs a:hover, #jot-preview-link:hover, .comment-edit-submit-wrapper .fakelink:hover {
+#event-notice:hover, #birthday-notice:hover, ul.tabs li .active, ul.tabs a:hover, #jot-preview-link:hover, .comment-edit-submit-wrapper .fakelink:hover {
     color: black;
     background-color: #e5e5e5;
     text-decoration: none;