Merge 7f6683e130
into 065ccaec23
This commit is contained in:
commit
d6827a0b30
|
@ -40,6 +40,7 @@ class Fenom
|
||||||
const AUTO_TRIM = 0x1000; // reserved
|
const AUTO_TRIM = 0x1000; // reserved
|
||||||
const DENY_PHP_CALLS = 0x2000;
|
const DENY_PHP_CALLS = 0x2000;
|
||||||
const AUTO_STRIP = 0x4000;
|
const AUTO_STRIP = 0x4000;
|
||||||
|
const MODX_SOFT_MODE = 0x8000; //This option for MODX, when compiling a Fenom tag error, enables the output of this tag as is. To inverse JS / JSON.
|
||||||
/**
|
/**
|
||||||
* Use DENY_PHP_CALLS
|
* Use DENY_PHP_CALLS
|
||||||
* @deprecated
|
* @deprecated
|
||||||
|
@ -87,6 +88,7 @@ class Fenom
|
||||||
"disable_php_calls" => self::DENY_PHP_CALLS,
|
"disable_php_calls" => self::DENY_PHP_CALLS,
|
||||||
"disable_statics" => self::DENY_STATICS,
|
"disable_statics" => self::DENY_STATICS,
|
||||||
"strip" => self::AUTO_STRIP,
|
"strip" => self::AUTO_STRIP,
|
||||||
|
"modx_soft_mode" => self::MODX_SOFT_MODE,
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -123,7 +123,9 @@ class Template extends Render
|
||||||
* @var int crc32 of the template name
|
* @var int crc32 of the template name
|
||||||
*/
|
*/
|
||||||
private $_crc = 0;
|
private $_crc = 0;
|
||||||
|
|
||||||
|
private $_log = ""; //for MODX log in MODX_SOFT_MODE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Fenom $fenom Template storage
|
* @param Fenom $fenom Template storage
|
||||||
* @param int $options
|
* @param int $options
|
||||||
|
@ -137,7 +139,24 @@ class Template extends Render
|
||||||
$this->_filters = $this->_fenom->getFilters();
|
$this->_filters = $this->_fenom->getFilters();
|
||||||
$this->_tag_filters = $this->_fenom->getTagFilters();
|
$this->_tag_filters = $this->_fenom->getTagFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add log for MODX log in MODX_SOFT_MODE
|
||||||
|
* @param string $message
|
||||||
|
*/
|
||||||
|
private function log($message)
|
||||||
|
{
|
||||||
|
$this->_log .= $message."\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get log for MODX log in MODX_SOFT_MODE
|
||||||
|
*/
|
||||||
|
public function getError()
|
||||||
|
{
|
||||||
|
return $this->_log;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get tag stack size
|
* Get tag stack size
|
||||||
* @return int
|
* @return int
|
||||||
|
@ -271,9 +290,24 @@ class Template extends Render
|
||||||
if ($tokens->isIncomplete()) { // all strings finished?
|
if ($tokens->isIncomplete()) { // all strings finished?
|
||||||
$need_more = true;
|
$need_more = true;
|
||||||
} else {
|
} else {
|
||||||
$this->_appendCode($this->parseTag($tokens), '{' . $tag . '}'); // start the tag lexer
|
$soft_mode = $this->_options & Fenom::MODX_SOFT_MODE;
|
||||||
if ($tokens->key()) { // if tokenizer have tokens - throws exceptions
|
if($soft_mode){
|
||||||
throw new CompileException("Unexpected token '" . $tokens->current() . "' in {$this} line {$this->_line}, near '{" . $tokens->getSnippetAsString(0, 0) . "' <- there", 0, E_ERROR, $this->_name, $this->_line);
|
try{
|
||||||
|
$code = $this->parseTag($tokens);
|
||||||
|
if ($tokens->key()) { // if tokenizer have tokens - throws exceptions
|
||||||
|
throw new CompileException("Unexpected token '" . $tokens->current() . "' in {$this} line {$this->_line}, near '{" . $tokens->getSnippetAsString(0, 0) . "' <- there", 0, E_ERROR, $this->_name, $this->_line);
|
||||||
|
}
|
||||||
|
$this->_appendCode($code, '{' . $tag . '}'); // start the tag lexer
|
||||||
|
}catch (\Exception $e){
|
||||||
|
$this->_appendText('{' . $tag . '}');
|
||||||
|
$this->log($e->getMessage());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$code = $this->parseTag($tokens);
|
||||||
|
$this->_appendCode($code, '{' . $tag . '}'); // start the tag lexer
|
||||||
|
if ($tokens->key()) { // if tokenizer have tokens - throws exceptions
|
||||||
|
throw new CompileException("Unexpected token '" . $tokens->current() . "' in {$this} line {$this->_line}, near '{" . $tokens->getSnippetAsString(0, 0) . "' <- there", 0, E_ERROR, $this->_name, $this->_line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while ($need_more);
|
} while ($need_more);
|
||||||
|
|
Loading…
Reference in New Issue