1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-19 04:41:53 +02:00

Bbcode test and parser cleanup.

This commit is contained in:
Cameron
2021-01-14 14:46:49 -08:00
parent 7e90b791ba
commit 62d6341303
19 changed files with 310 additions and 623 deletions

View File

@@ -101,7 +101,7 @@ class bb_code extends e_bb_base
// $highlighted_text = highlight_string($code_text, TRUE);
// highlighted_text = str_replace(array("<code>","</code>"),"",$highlighted_text);
$divClass = ($parm) ? $parm : 'code_highlight';
$ret = "<pre class='prettyprint linenums ".$tp -> toAttribute($divClass)." code-box {$class}' style='unicode-bidi: embed; direction: ltr'>".$code_text."</pre>";
$ret = "<pre class='prettyprint linenums ".e107::getParser()->toAttribute($divClass)." code-box {$class}' style='unicode-bidi: embed; direction: ltr'>".$code_text."</pre>";
}

View File

@@ -163,7 +163,7 @@
$text = '';
foreach($imgParms as $key => $val)
{
$text .= $key . "='" . $tp->toAttribute($val) . "' ";
$text .= $key . "='" . e107::getParser()->toAttribute($val) . "' ";
}
return $text;
@@ -223,7 +223,7 @@
$code_text = str_replace($search, $replace, $code_text);
$code_text = $tp->toAttribute($code_text);
$code_text = e107::getParser()->toAttribute($code_text);
$img_file = pathinfo($code_text); // 'External' file name. N.B. - might still contain a constant such as e_IMAGE

View File

@@ -202,8 +202,11 @@ class bb_youtube extends e_bb_base
{
if(empty($code_text)) return '';
list($dimensions,$tmp) = explode('|', $parm, 2);
$t = explode('|', $parm, 2);
$dimensions = varset($t[0]);
$tmp = varset($t[1]);
if($tmp)
{
parse_str(varset($tmp, ''), $bbparm);

View File

@@ -23,7 +23,7 @@ if($pref['make_clickable'])
}
// Old method that attracts SPAM.
if ($parm) {
return "<a class='{$class}' href='mailto:".$tp -> toAttribute($parm)."'>".$code_text."</a>";
return "<a class='{$class}' href='mailto:".e107::getParser()->toAttribute($parm)."'>".$code_text."</a>";
} else {
return "<a class='{$class}' href='mailto:".$tp -> toAttribute($code_text)."'>".$code_text."</a>";
return "<a class='{$class}' href='mailto:".e107::getParser()->toAttribute($code_text)."'>".$code_text."</a>";
}

View File

@@ -48,5 +48,5 @@ if ((e_PAGE === 'page.php') || (array_key_exists('forum_attach', $pref) && $pref
{
$fname = str_replace('{e_BASE}', SITEURL, $fname); // Translate into an absolute URL
}
return "<a class='{$class}' href='".$tp -> toAttribute($fname)."'><img src='".$image."' alt='' style='border:0; vertical-align:middle' /></a> <a href='".$tp -> toAttribute($fname)."'>".$code_text."</a>";
return "<a class='{$class}' href='".e107::getParser()->toAttribute($fname)."'><img src='".$image."' alt='' style='border:0; vertical-align:middle' /></a> <a href='".e107::getParser()->toAttribute($fname)."'>".$code_text."</a>";
}

View File

@@ -3,7 +3,7 @@ $class = e107::getBB()->getClass('flash');
// USAGE: [flash=width,height,param_name=value&param_name=value]http://www.example.com/file.swf[/flash]
$movie_path = $tp->toAttribute($code_text);
$movie_path = e107::getParser()->toAttribute($code_text);
$parm_array = explode(',', $parm);
$width = preg_replace('#[^0-9%]#', '', varsettrue($parm_array[0], 50));

View File

@@ -1,4 +1,4 @@
//<?
$class = e107::getBB()->getClass('justify');
return "<div class='{$justify}' style='text-align:justify'>$code_text</div>";
return "<div class='{$class}' style='text-align:justify'>$code_text</div>";

View File

@@ -3,7 +3,7 @@
$class = "bbcode ".e107::getBB()->getClass('link');
global $pref;
global $pref, $parm;
/**
* e107 BBCodes
@@ -28,7 +28,8 @@ global $pref;
*/
$tp = e107::getParser();
$parm = $tp->dataFilter(trim($parm),'link');
$parm = $tp->filter(trim($parm));
/* Fix for people using link=external= */
if(strpos($parm,"external=") !== FALSE)
@@ -70,5 +71,5 @@ global $pref;
$insert = ($pref['links_new_window'] && strpos($link,"{e_")===FALSE && substr($link,0,1) != "#" && substr($link,0,1) != "/" && strpos($extras,"rel=internal")===FALSE) ? "rel='external' " : "";
}
if (strtolower(substr($link,0,11)) == 'javascript:') return '';
return "<a class='{$class}' href='".$tp -> toAttribute($link)."' ".$insert.">".$code_text."</a>";
return "<a class='{$class}' href='".e107::getParser() -> toAttribute($link)."' ".$insert.">".$code_text."</a>";

View File

@@ -33,7 +33,7 @@ if (empty($parm))
}
else
{
$type = $tp -> toAttribute($parm);
$type = e107::getParser()->toAttribute($parm);
$listtext = "\n<ol class='bbcode ".$type."' style='list-style-type: $type'>";
$trailer = "</ol>";
}

View File

@@ -32,17 +32,19 @@ if (isset($stream_parms['height'])) {
}
$parmStr="";
$MozparmStr = '';
$IEparmStr = '';
foreach($stream_parms as $k => $v)
{
$MozparmStr .= "<param name='".$tp -> toAttribute($k)."' value='".$tp -> toAttribute($v)."'>\n";
$IEparmStr .= $tp -> toAttribute($k)."='".$tp -> toAttribute($v)."' ";
$MozparmStr .= "<param name='".e107::getParser()->toAttribute($k)."' value='".e107::getParser()->toAttribute($v)."'>\n";
$IEparmStr .= e107::getParser()->toAttribute($k)."='".e107::getParser()->toAttribute($v)."' ";
}
$ret = "
<object class='{$class}' id='MediaPlayer' classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' standby='Loading Microsoft<66> Windows<77> Media Player components...' type='application/x-oleobject' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112' width='".$tp -> toAttribute($width)."' height='".$tp -> toAttribute($height)."'>\n";
$ret .= "<param name='filename' value='".$tp -> toAttribute($code_text)."'>\n";
<object class='{$class}' id='MediaPlayer' classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' standby='Loading Microsoft<66> Windows<77> Media Player components...' type='application/x-oleobject' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112' width='".e107::getParser()->toAttribute($width)."' height='".e107::getParser()->toAttribute($height)."'>\n";
$ret .= "<param name='filename' value='".e107::getParser()->toAttribute($code_text)."'>\n";
$ret .= $MozparmStr;
$ret .= "<embed src='".$tp -> toAttribute($code_text)."' width='".$tp -> toAttribute($width)."' height='".$tp -> toAttribute($height)."' id='mediaPlayer' name='mediaPlayer' {$IEparmStr}>
$ret .= "<embed src='".e107::getParser()->toAttribute($code_text)."' width='".e107::getParser()->toAttribute($width)."' height='".e107::getParser()->toAttribute($height)."' id='mediaPlayer' name='mediaPlayer' {$IEparmStr}>
</object>
";

View File

@@ -8,6 +8,6 @@ parse_str($parm, $tmp);
foreach($tmp as $key => $p)
{
$tastr .= $tp -> toAttribute($key)." = '".$tp -> toAttribute($p)."' ";
$tastr .= e107::getParser()->toAttribute($key)." = '".e107::getParser()->toAttribute($p)."' ";
}
return "<textarea class='{$class}' $tastr>$code_text</textarea>";

View File

@@ -10,12 +10,12 @@ if ($parm && $parm != 'external' && strpos($parm, ' ') === FALSE)
$parm = preg_replace('#^external.#is', '', $parm);
if (strtolower(substr($parm, 0, 11)) === 'javascript:')
return '';
return '<a href="'.$tp->toAttribute($parm).'" class="bbcode '.$class.'"'.$external.'>'.$code_text.'</a>';
return '<a href="'.e107::getParser()->toAttribute($parm).'" class="bbcode '.$class.'"'.$external.'>'.$code_text.'</a>';
}
else
{
if (strtolower(substr($code_text, 0, 11)) === 'javascript:')
return '';
return '<a href="'.$tp->toAttribute($code_text).'" class="bbcode '.$class.'"'.$external.'>'.$code_text.'</a>';
return '<a href="'.e107::getParser()->toAttribute($code_text).'" class="bbcode '.$class.'"'.$external.'>'.$code_text.'</a>';
}