mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 11:11:39 +09:00
issue 512 : Template engine does not handle <marquee> from now.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9691 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
8ef97b7618
commit
59b7ce4d96
2 changed files with 22 additions and 4 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
var $xe_path = null; ///< XpressEngine base path
|
var $xe_path = null; ///< XpressEngine base path
|
||||||
var $web_path = null; ///< tpl file web path
|
var $web_path = null; ///< tpl file web path
|
||||||
var $compiled_file = null; ///< tpl file web path
|
var $compiled_file = null; ///< tpl file web path
|
||||||
|
var $skipTags = null;
|
||||||
|
|
||||||
var $handler_mtime = 0;
|
var $handler_mtime = 0;
|
||||||
|
|
||||||
|
|
@ -74,6 +75,8 @@
|
||||||
|
|
||||||
// compare various file's modified time for check changed
|
// compare various file's modified time for check changed
|
||||||
$this->handler_mtime = filemtime(__FILE__);
|
$this->handler_mtime = filemtime(__FILE__);
|
||||||
|
|
||||||
|
$skip = array('');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -169,6 +172,11 @@
|
||||||
$buff = FileHandler::readFile($this->file);
|
$buff = FileHandler::readFile($this->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTML tags to skip
|
||||||
|
if(is_null($this->skipTags)) {
|
||||||
|
$this->skipTags = array('marquee');
|
||||||
|
}
|
||||||
|
|
||||||
// replace comments
|
// replace comments
|
||||||
$buff = preg_replace('@<!--//.*?-->@s', '', $buff);
|
$buff = preg_replace('@<!--//.*?-->@s', '', $buff);
|
||||||
|
|
||||||
|
|
@ -297,7 +305,11 @@
|
||||||
{
|
{
|
||||||
if(preg_match_all('/<([a-zA-Z]+\d?)(?>(?!<[a-z]+\d?[\s>]).)*?(?:[ \|]cond| loop)="/s', $buff, $match) === false) return $buff;
|
if(preg_match_all('/<([a-zA-Z]+\d?)(?>(?!<[a-z]+\d?[\s>]).)*?(?:[ \|]cond| loop)="/s', $buff, $match) === false) return $buff;
|
||||||
|
|
||||||
$tags = '(?:'.implode('|',array_unique($match[1])).')';
|
$tags = array_diff(array_unique($match[1]), $this->skipTags);
|
||||||
|
|
||||||
|
if(!count($tags)) return $buff;
|
||||||
|
|
||||||
|
$tags = '(?:'.implode('|',$tags).')';
|
||||||
$split_regex = "@(<(?>/?{$tags})(?>[^<>\{\}\"']+|<!--.*?-->|{[^}]+}|\".*?\"|'.*?'|.)*?>)@s";
|
$split_regex = "@(<(?>/?{$tags})(?>[^<>\{\}\"']+|<!--.*?-->|{[^}]+}|\".*?\"|'.*?'|.)*?>)@s";
|
||||||
|
|
||||||
$nodes = preg_split($split_regex, $buff, -1, PREG_SPLIT_DELIM_CAPTURE);
|
$nodes = preg_split($split_regex, $buff, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||||
|
|
@ -309,6 +321,10 @@
|
||||||
if(!($node=$nodes[$idx])) continue;
|
if(!($node=$nodes[$idx])) continue;
|
||||||
|
|
||||||
if(preg_match_all('@\s(loop|cond)="([^"]+)"@', $node, $matches)) {
|
if(preg_match_all('@\s(loop|cond)="([^"]+)"@', $node, $matches)) {
|
||||||
|
// this tag
|
||||||
|
$tag = substr($node, 1, strpos($node, ' ')-1);
|
||||||
|
|
||||||
|
// if the vale of $closing is 0, it means 'skipping'
|
||||||
$closing = 0;
|
$closing = 0;
|
||||||
|
|
||||||
// process opening tag
|
// process opening tag
|
||||||
|
|
@ -338,9 +354,6 @@
|
||||||
}
|
}
|
||||||
$node = preg_replace('@\s(loop|cond)="([^"]+)"@', '', $node);
|
$node = preg_replace('@\s(loop|cond)="([^"]+)"@', '', $node);
|
||||||
|
|
||||||
// this tag
|
|
||||||
$tag = substr($node, 1, strpos($node, ' ')-1);
|
|
||||||
|
|
||||||
// find closing tag
|
// find closing tag
|
||||||
$close_php = '<?php '.str_repeat('}', $closing).' ?>';
|
$close_php = '<?php '.str_repeat('}', $closing).' ?>';
|
||||||
if($node{1} == '!' || substr($node,-2,1) == '/' || in_array($tag, $self_closing)) { // self closing tag
|
if($node{1} == '!' || substr($node,-2,1) == '/' || in_array($tag, $self_closing)) { // self closing tag
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,11 @@ class TemplateHandlerTest extends PHPUnit_Framework_TestCase
|
||||||
'<table><thead><tr><th loop="$vvvls => $vvv">{$vvv}</th></tr></thead>'."\n".'<tbody><tr><td>C</td><td>D</td></tr></tbody></table>',
|
'<table><thead><tr><th loop="$vvvls => $vvv">{$vvv}</th></tr></thead>'."\n".'<tbody><tr><td>C</td><td>D</td></tr></tbody></table>',
|
||||||
'<table><thead><tr><?php if($__Context->vvvls&&count($__Context->vvvls))foreach($__Context->vvvls as $__Context->vvv){ ?><th><?php echo $__Context->vvv ?></th><?php } ?></tr></thead>'."\n".'<tbody><tr><td>C</td><td>D</td></tr></tbody></table>'
|
'<table><thead><tr><?php if($__Context->vvvls&&count($__Context->vvvls))foreach($__Context->vvvls as $__Context->vvv){ ?><th><?php echo $__Context->vvv ?></th><?php } ?></tr></thead>'."\n".'<tbody><tr><td>C</td><td>D</td></tr></tbody></table>'
|
||||||
),
|
),
|
||||||
|
// issue 512 - ignores <marquee>
|
||||||
|
array(
|
||||||
|
'<div class="topimgContex"><marquee direction="up" scrollamount="1" height="130" loop="infinity" behavior="lscro">{$lang->sl_show_topimgtext}</marquee></div>',
|
||||||
|
'<div class="topimgContex"><marquee direction="up" scrollamount="1" height="130" loop="infinity" behavior="lscro"><?php echo $__Context->lang->sl_show_topimgtext ?></marquee></div>'
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue