function xbbcode_basic_render_code in Extensible BBCode 6
Same name and namespace in other branches
- 8 xbbcode_basic/xbbcode_basic.module \xbbcode_basic_render_code()
- 8.2 xbbcode_basic/xbbcode_basic.module \xbbcode_basic_render_code()
- 5 xbbcode_basic/xbbcode_basic.module \xbbcode_basic_render_code()
- 7 xbbcode_basic/xbbcode_basic.module \xbbcode_basic_render_code()
1 call to xbbcode_basic_render_code()
- xbbcode_basic_render in xbbcode_basic/
xbbcode_basic.module
File
- xbbcode_basic/
xbbcode_basic.module, line 263
Code
function xbbcode_basic_render_code($delta, $text) {
$text = _xbbcode_revert_tags($text);
if (!strpos("-{$text}-", "\n") && !strpos("-{$text}-", "<br")) {
return "<code>{$text}</code>";
}
$text = str_replace('<br />', '', $text);
$text = str_replace(array(
'<?',
'?>',
), array(
'<?',
'?>',
), $text);
$text = trim($text);
if ($delta == 'php') {
if (!preg_match('/<\\? .* \\?>/', $text)) {
$adding_tags = true;
$text = '<?php ' . $text . ' ?>';
}
$text = highlight_string($text, true);
if ($adding_tags) {
$text = str_replace(">\n<", "><", $text);
$text = str_replace('<?php', '', $text);
$text = str_replace('?>', '', $text);
$text = str_replace(' ', ' ', $text);
$text = preg_replace('/<\\/?code>/', '', $text);
}
$inside_tag = false;
for ($i = 0; $i < strlen($text); $i++) {
if (!$inside_tag) {
if ($text[$i] == ' ') {
$text = substr($text, 0, $i) . substr($text, $i + 1);
break;
}
else {
if ($text[$i] == '<') {
$inside_tag = true;
}
}
}
else {
if ($text[$i] == '>') {
$inside_tag = false;
}
}
}
}
$text = '<object><div class="codeblock">' . trim($text) . '</div></object>';
return $text;
}