mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 14:46:56 +02:00
Tweak last parser commit and added getTags() test.
This commit is contained in:
@@ -375,10 +375,10 @@ class e_bbcode
|
||||
//echo "Preprocess: ".htmlspecialchars($code_text).", params: {$param1}<br />";
|
||||
return $this->bbList[$code]->bbPreSave($code_text, $param1);
|
||||
}
|
||||
if($this->preProcess == 'toWYSIWYG')//XXX FixMe NOT working - messes with default toHTML behavior.
|
||||
{
|
||||
// if($this->preProcess == 'toWYSIWYG')//XXX FixMe NOT working - messes with default toHTML behavior.
|
||||
// {
|
||||
// return $this->bbList[$code]->bbWYSIWYG($code_text, $param1);
|
||||
}
|
||||
// }
|
||||
return $this->bbList[$code]->bbPreDisplay($code_text, $param1);
|
||||
}
|
||||
if ($this->preProcess == 'toDB') return $full_text; // No change
|
||||
@@ -406,17 +406,19 @@ class e_bbcode
|
||||
* @var string $type - bbcode eg. 'img' or 'youtube'
|
||||
* @var string $text - text to be processed for bbcode content
|
||||
* @var string $path - optional path to prepend to output if http or {e_xxxx} is not found.
|
||||
* @return array
|
||||
* @return array|null
|
||||
*/
|
||||
function getContent($type,$text,$path='')
|
||||
{
|
||||
|
||||
if(!in_array($type,$this->core_bb))
|
||||
{
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if(substr(ltrim($text),0,6) == '[html]' && $type == 'img') // support for html img tags inside [html] bbcode.
|
||||
{
|
||||
|
||||
$tmp = e107::getParser()->getTags($text,'img');
|
||||
|
||||
if(!empty($tmp['img']))
|
||||
@@ -436,7 +438,7 @@ class e_bbcode
|
||||
preg_match_all("/\[".$type."(?:[^\]]*)?]([^\[]*)(?:\[\/".$type."])/im",$text,$mtch);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$ret = array();
|
||||
|
||||
|
@@ -3898,7 +3898,7 @@ class e_parser
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->domObj = new DOMDocument('1.0', 'utf-8');
|
||||
$this->init();
|
||||
$this->compileAttributeDefaults();
|
||||
|
||||
@@ -5544,7 +5544,7 @@ return;
|
||||
$html = '<body>'.$html.'</body>';
|
||||
}
|
||||
|
||||
$this->domObj = $doc = new DOMDocument('1.0', 'utf-8');
|
||||
|
||||
|
||||
if($this->scriptAccess === false)
|
||||
{
|
||||
@@ -5569,7 +5569,7 @@ return;
|
||||
// $fragment->appendXML($html);
|
||||
// $doc->appendChild($fragment);
|
||||
// $doc->encoding = 'utf-8';
|
||||
|
||||
$doc = $this->domObj;
|
||||
$opts = defined('LIBXML_HTML_NOIMPLIED') ? LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD : 0;
|
||||
$doc->loadHTML($html, $opts);
|
||||
|
||||
|
@@ -787,12 +787,32 @@ while($row = $sql->fetch())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
public function testGetTags()
|
||||
{
|
||||
$html = "<div><img src='#' alt='whatever' /></div>";
|
||||
$result = $this->tp->getTags($html, 'img');
|
||||
$expected = array (
|
||||
'img' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'src' => '#',
|
||||
'alt' => 'whatever',
|
||||
'@value' => '<img alt="whatever" src="#"></img>',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if(empty($expected['img'][0]))
|
||||
{
|
||||
$this->assertTrue(false, "getTags() didn't return the correct value");
|
||||
}
|
||||
|
||||
$this->assertSame($expected['img'][0]['src'], $result['img'][0]['src']);
|
||||
$this->assertSame($expected['img'][0]['alt'], $result['img'][0]['alt']);
|
||||
}
|
||||
*/
|
||||
|
||||
public function testToGlyph()
|
||||
{
|
||||
|
||||
|
Reference in New Issue
Block a user