mirror of
https://github.com/friendica/friendica
synced 2024-11-20 06:23:41 +00:00
New bbcode element: "spoiler". Mail: Top post quotes are now embraced in "spoiler" elements
This commit is contained in:
parent
b5120888cf
commit
8a1f175df0
6 changed files with 39 additions and 5 deletions
|
@ -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;
|
||||
|
|
|
@ -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']);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue