Zeile 17 | Zeile 17 |
---|
* #2. INPUT: [quote=a][quote=b][quote=c][quote=d][/quote][quote=e][/quote][/quote][quote=f][/quote][/quote] * OUTPUT: [quote=a][quote=b][/quote][quote=f][/quote][/quote] *
|
* #2. INPUT: [quote=a][quote=b][quote=c][quote=d][/quote][quote=e][/quote][/quote][quote=f][/quote][/quote] * OUTPUT: [quote=a][quote=b][/quote][quote=f][/quote][/quote] *
|
* @param string the message from which quotes are to be removed * @param integer nested depth at which quotes should be removed; if none supplied, will use MyBB's default; must be at least 0
| * @param string $text the message from which quotes are to be removed * @param integer $rmdepth nested depth at which quotes should be removed; if none supplied, will use MyBB's default; must be at least 0
|
* @return string the original message passed in $text, but with quote tags selectively removed */ function remove_message_quotes(&$text, $rmdepth=null)
| * @return string the original message passed in $text, but with quote tags selectively removed */ function remove_message_quotes(&$text, $rmdepth=null)
|
Zeile 49 | Zeile 49 |
---|
foreach($smatches[0] as $id => $match) { $soffsets[] = $match[1];
|
foreach($smatches[0] as $id => $match) { $soffsets[] = $match[1];
|
| } $first_token = 0; if(isset($soffsets[0])) { $first_token = $soffsets[0];
|
} // whilst we loop, also remove unnecessary end tokens at the start of string
|
} // whilst we loop, also remove unnecessary end tokens at the start of string
|
$first_token = $soffsets[0];
| |
foreach($ematches[0] as $id => $match) { if($match[1] > $first_token)
| foreach($ematches[0] as $id => $match) { if($match[1] > $first_token)
|
Zeile 126 | Zeile 129 |
---|
if($depth == $rmdepth && $dincr == -1) { $remove_regions[] = array($tmp_start, $offset);
|
if($depth == $rmdepth && $dincr == -1) { $remove_regions[] = array($tmp_start, $offset);
|
} }
| } }
|
if(empty($remove_regions)) { return $text;
| if(empty($remove_regions)) { return $text;
|
Zeile 142 | Zeile 145 |
---|
$newtext .= substr($text, $cpy_start, $region[0]-$cpy_start); $cpy_start = $region[1]+8; // 8 = strlen('[/quote]') // clean up newlines
|
$newtext .= substr($text, $cpy_start, $region[0]-$cpy_start); $cpy_start = $region[1]+8; // 8 = strlen('[/quote]') // clean up newlines
|
$next_char = $text{$region[1]+8};
| $next_char = $text[$region[1]+8];
|
if($next_char == "\r" || $next_char == "\n") { ++$cpy_start;
|
if($next_char == "\r" || $next_char == "\n") { ++$cpy_start;
|
if($next_char == "\r" && $text{$region[1]+9} == "\n")
| if($next_char == "\r" && $text[$region[1]+9] == "\n")
|
{ ++$cpy_start; }
|
{ ++$cpy_start; }
|
}
| }
|
} // append remaining end text if(strlen($text) != $cpy_start)
| } // append remaining end text if(strlen($text) != $cpy_start)
|
Zeile 165 | Zeile 168 |
---|
/** * Performs cleanup of a quoted message, such as replacing /me commands, before presenting quoted post to the user. *
|
/** * Performs cleanup of a quoted message, such as replacing /me commands, before presenting quoted post to the user. *
|
* @param array quoted post info, taken from the DB (requires the 'message', 'username', 'pid' and 'dateline' entries to be set; will use 'userusername' if present. requires 'quote_is_pm' if quote message is from a private message) * @param boolean whether to call remove_message_quotes() on the quoted message
| * @param array $quoted_post quoted post info, taken from the DB (requires the 'message', 'username', 'pid' and 'dateline' entries to be set; will use 'userusername' if present. requires 'quote_is_pm' if quote message is from a private message) * @param boolean $remove_message_quotes whether to call remove_message_quotes() on the quoted message
|
* @return string the cleaned up message, wrapped in a quote tag */
| * @return string the cleaned up message, wrapped in a quote tag */
|
Zeile 180 | Zeile 183 |
---|
}
// Swap username over if we have a registered user
|
}
// Swap username over if we have a registered user
|
if($quoted_post['userusername'])
| if(isset($quoted_post['userusername']))
|
{ $quoted_post['username'] = $quoted_post['userusername'];
|
{ $quoted_post['username'] = $quoted_post['userusername'];
|
| } else { if(empty($quoted_post['username'])) { $quoted_post['username'] = htmlspecialchars_uni($lang->guest); }
|
} // Clean up the message $quoted_post['message'] = preg_replace(array(
| } // Clean up the message $quoted_post['message'] = preg_replace(array(
|
Zeile 214 | Zeile 224 |
---|
$extra = " pid='{$quoted_post['pid']}' dateline='{$quoted_post['dateline']}'"; }
|
$extra = " pid='{$quoted_post['pid']}' dateline='{$quoted_post['dateline']}'"; }
|
return "[quote='{$quoted_post['username']}'{$extra}]\n{$quoted_post['message']}\n[/quote]\n\n";
| $quote_char = '"'; if(strpos($quoted_post['username'], '"') !== false) { $quote_char = "'"; }
return "[quote={$quote_char}{$quoted_post['username']}{$quote_char}{$extra}]\n{$quoted_post['message']}\n[/quote]\n\n";
|
}
| }
|