]> git.mxchange.org Git - friendica.git/commitdiff
New bbcode element: "spoiler". Mail: Top post quotes are now embraced in "spoiler...
authorMichael Vogel <icarus@dabo.de>
Sat, 17 Mar 2012 10:07:49 +0000 (11:07 +0100)
committerMichael Vogel <icarus@dabo.de>
Sat, 17 Mar 2012 10:07:49 +0000 (11:07 +0100)
include/bbcode.php
include/email.php
include/msgclean.php
include/poller.php
include/quoteconvert.php
include/text.php

index d69cb263f8ecad945c95652f9e320a67fb243537..9fce895b8d1cf56494b671211a6599edd17c0294 100644 (file)
@@ -189,8 +189,18 @@ function bbcode($Text,$preserve_nl = false) {
        // Check for [code] text
        $Text = preg_replace("/\[code\](.*?)\[\/code\]/ism","$CodeLayout", $Text);
 
+       // Declare the format for [spoiler] layout
+       $SpoilerLayout = '<blockquote class="spoiler">$1</blockquote>';
+
+       // Check for [spoiler] text
+       // handle nested quotes
+       $endlessloop = 0;
+       while ((strpos($Text, "[/spoiler]") !== false) and (strpos($Text, "[spoiler]") !== false) and (++$endlessloop < 20))
+               $Text = preg_replace("/\[spoiler\](.*?)\[\/spoiler\]/ism","$SpoilerLayout", $Text);
+
        // Declare the format for [quote] layout
        $QuoteLayout = '<blockquote>$1</blockquote>';
+
        // Check for [quote] text
        // handle nested quotes
        $endlessloop = 0;
index a3449a4249934bd965f49c031cb3d8cb90ad77e5..43f04d7c2010f27f7d0ebcdfd4562322b7111c9d 100755 (executable)
@@ -74,7 +74,7 @@ function email_msg_headers($mbox,$uid) {
 }
 
 
-function email_get_msg($mbox,$uid) {
+function email_get_msg($mbox,$uid, $reply) {
        $ret = array();
 
        $struc = (($mbox && $uid) ? @imap_fetchstructure($mbox,$uid,FT_UID) : null);
@@ -114,7 +114,7 @@ function email_get_msg($mbox,$uid) {
        $ret['body'] = removegpg($ret['body']);
        $msg = removesig($ret['body']);
        $ret['body'] = $msg['body'];
-       $ret['body'] = convertquote($ret['body'], false);
+       $ret['body'] = convertquote($ret['body'], $reply);
 
        if (trim($html) != '')
                $ret['body'] = removelinebreak($ret['body']);
index 284ad1ce4b232e9066251481c7d4b9018e5bff5e..eabb47788a9b622775c4a1f26a1ab7d400b81922 100644 (file)
@@ -13,7 +13,7 @@ function savereplace($pattern, $replace, $text)
 
 function unifyattributionline($message)
 {
-       $quotestr = array('quote', 'collapsed');
+       $quotestr = array('quote', 'spoiler');
        foreach ($quotestr as $quote) {
 
                $message = savereplace('/----- Original Message -----\s.*?From: "([^<"].*?)" <(.*?)>\s.*?To: (.*?)\s*?Cc: (.*?)\s*?Sent: (.*?)\s.*?Subject: ([^\n].*)\s*\['.$quote.'\]/i', "[".$quote."='$1']\n", $message);
index 3bc98e36ff2f479ca53dec54eefd63186381f357..085e95a6ae1842c421e9c7eb6d341dbde72a1578 100755 (executable)
@@ -504,7 +504,12 @@ function poller_run($argv, $argc){
                                                        //$datarray['title'] = notags(trim($meta->subject));
                                                        $datarray['created'] = datetime_convert('UTC','UTC',$meta->date);
 
-                                                       $r = email_get_msg($mbox,$msg_uid);
+                                                       // Is it  reply?
+                                                       $reply = ((substr(strtolower($datarray['title']), 0, 3) == "re:") or
+                                                               (substr(strtolower($datarray['title']), 0, 3) == "re-") or
+                                                               (raw_refs != ""));
+
+                                                       $r = email_get_msg($mbox,$msg_uid, $reply);
                                                        if(! $r) {
                                                                logger("Mail: can't fetch msg ".$msg_uid);
                                                                continue;
index 3aee93234fdc1b4ee0e1cd7f96ee595abb9f7ec5..2a6d28370a3910cbb4a34fc470526fb48a20eb16 100644 (file)
@@ -124,7 +124,7 @@ function removetofu($message)
        }
 
        if ($quotestart != 0) {
-               $message = trim(substr($message, 0, $quotestart))."\n[collapsed]\n".substr($message, $quotestart+7, -8).'[/collapsed]';
+               $message = trim(substr($message, 0, $quotestart))."\n[spoiler]".substr($message, $quotestart+7, -8).'[/spoiler]';
        }
 
        return($message);
index d34fd7fbeec35bcacfb5a1bd2fa201a3e770d692..bcd567a15411a3490880c1ce77fd3b1647514c75 100644 (file)
@@ -955,6 +955,25 @@ function prepare_body($item,$attach = false) {
                        $s .= '<div class="filesavetags"><span>' . t('Filed under:') . ' </span>' . $x . '</div>'; 
        }
 
+       // Look for spoiler
+       $spoilersearch = '<blockquote class="spoiler">';
+
+       // Remove line breaks before the spoiler
+       while ((strpos($s, "\n".$spoilersearch) !== false))
+               $s = str_replace("\n".$spoilersearch, $spoilersearch, $s);
+       while ((strpos($s, "<br />".$spoilersearch) !== false))
+               $s = str_replace("<br />".$spoilersearch, $spoilersearch, $s);
+
+       while ((strpos($s, $spoilersearch) !== false)) {
+
+               $pos = strpos($s, $spoilersearch);
+               $rnd = random_string(8);
+               $spoilerreplace = '<span id="spoiler-wrap-'.$rnd.'" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'spoiler-'.$rnd.'\');">'.sprintf(t('Click to open/close')).'</span>'.
+                                       '<blockquote class="spoiler" id="spoiler-'.$rnd.'" style="display: none;">';
+               //$s = str_replace($spoilersearch, $spoilerreplace, $s);
+               $s = substr($s, 0, $pos).$spoilerreplace.substr($s, $pos+strlen($spoilersearch));
+       }
+
        $prep_arr = array('item' => $item, 'html' => $s);
        call_hooks('prepare_body_final', $prep_arr);