mirror of
https://github.com/e107inc/e107.git
synced 2025-08-07 15:16:30 +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 />";
|
//echo "Preprocess: ".htmlspecialchars($code_text).", params: {$param1}<br />";
|
||||||
return $this->bbList[$code]->bbPreSave($code_text, $param1);
|
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]->bbWYSIWYG($code_text, $param1);
|
||||||
}
|
// }
|
||||||
return $this->bbList[$code]->bbPreDisplay($code_text, $param1);
|
return $this->bbList[$code]->bbPreDisplay($code_text, $param1);
|
||||||
}
|
}
|
||||||
if ($this->preProcess == 'toDB') return $full_text; // No change
|
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 $type - bbcode eg. 'img' or 'youtube'
|
||||||
* @var string $text - text to be processed for bbcode content
|
* @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.
|
* @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='')
|
function getContent($type,$text,$path='')
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!in_array($type,$this->core_bb))
|
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.
|
if(substr(ltrim($text),0,6) == '[html]' && $type == 'img') // support for html img tags inside [html] bbcode.
|
||||||
{
|
{
|
||||||
|
|
||||||
$tmp = e107::getParser()->getTags($text,'img');
|
$tmp = e107::getParser()->getTags($text,'img');
|
||||||
|
|
||||||
if(!empty($tmp['img']))
|
if(!empty($tmp['img']))
|
||||||
@@ -436,7 +438,7 @@ class e_bbcode
|
|||||||
preg_match_all("/\[".$type."(?:[^\]]*)?]([^\[]*)(?:\[\/".$type."])/im",$text,$mtch);
|
preg_match_all("/\[".$type."(?:[^\]]*)?]([^\[]*)(?:\[\/".$type."])/im",$text,$mtch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
||||||
|
@@ -3898,7 +3898,7 @@ class e_parser
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
$this->domObj = new DOMDocument('1.0', 'utf-8');
|
||||||
$this->init();
|
$this->init();
|
||||||
$this->compileAttributeDefaults();
|
$this->compileAttributeDefaults();
|
||||||
|
|
||||||
@@ -5544,7 +5544,7 @@ return;
|
|||||||
$html = '<body>'.$html.'</body>';
|
$html = '<body>'.$html.'</body>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->domObj = $doc = new DOMDocument('1.0', 'utf-8');
|
|
||||||
|
|
||||||
if($this->scriptAccess === false)
|
if($this->scriptAccess === false)
|
||||||
{
|
{
|
||||||
@@ -5569,7 +5569,7 @@ return;
|
|||||||
// $fragment->appendXML($html);
|
// $fragment->appendXML($html);
|
||||||
// $doc->appendChild($fragment);
|
// $doc->appendChild($fragment);
|
||||||
// $doc->encoding = 'utf-8';
|
// $doc->encoding = 'utf-8';
|
||||||
|
$doc = $this->domObj;
|
||||||
$opts = defined('LIBXML_HTML_NOIMPLIED') ? LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD : 0;
|
$opts = defined('LIBXML_HTML_NOIMPLIED') ? LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD : 0;
|
||||||
$doc->loadHTML($html, $opts);
|
$doc->loadHTML($html, $opts);
|
||||||
|
|
||||||
|
@@ -787,12 +787,32 @@ while($row = $sql->fetch())
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public function testGetTags()
|
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()
|
public function testToGlyph()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user