mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
fix Scope
This commit is contained in:
@@ -14,8 +14,8 @@ namespace Fenom;
|
|||||||
*
|
*
|
||||||
* @author Ivan Shalganov <a.cobest@gmail.com>
|
* @author Ivan Shalganov <a.cobest@gmail.com>
|
||||||
*/
|
*/
|
||||||
class Scope extends \ArrayObject {
|
class Scope extends \ArrayObject
|
||||||
|
{
|
||||||
public $line = 0;
|
public $line = 0;
|
||||||
public $name;
|
public $name;
|
||||||
public $level = 0;
|
public $level = 0;
|
||||||
@@ -37,15 +37,16 @@ class Scope extends \ArrayObject {
|
|||||||
* @param int $line
|
* @param int $line
|
||||||
* @param array $action
|
* @param array $action
|
||||||
* @param int $level
|
* @param int $level
|
||||||
* @param $body
|
* @param $body
|
||||||
*/
|
*/
|
||||||
public function __construct($name, $tpl, $line, $action, $level, &$body) {
|
public function __construct($name, $tpl, $line, $action, $level, &$body)
|
||||||
$this->line = $line;
|
{
|
||||||
$this->name = $name;
|
$this->line = $line;
|
||||||
$this->tpl = $tpl;
|
$this->name = $name;
|
||||||
|
$this->tpl = $tpl;
|
||||||
$this->_action = $action;
|
$this->_action = $action;
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
$this->_body = &$body;
|
$this->_body = & $body;
|
||||||
$this->_offset = strlen($body);
|
$this->_offset = strlen($body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,8 +54,9 @@ class Scope extends \ArrayObject {
|
|||||||
*
|
*
|
||||||
* @param string $function
|
* @param string $function
|
||||||
*/
|
*/
|
||||||
public function setFuncName($function) {
|
public function setFuncName($function)
|
||||||
$this["function"] = $function;
|
{
|
||||||
|
$this["function"] = $function;
|
||||||
$this->is_compiler = false;
|
$this->is_compiler = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +66,8 @@ class Scope extends \ArrayObject {
|
|||||||
* @param Tokenizer $tokenizer
|
* @param Tokenizer $tokenizer
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function open($tokenizer) {
|
public function open($tokenizer)
|
||||||
|
{
|
||||||
return call_user_func($this->_action["open"], $tokenizer, $this);
|
return call_user_func($this->_action["open"], $tokenizer, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,28 +75,31 @@ class Scope extends \ArrayObject {
|
|||||||
* Check, has the block this tag
|
* Check, has the block this tag
|
||||||
*
|
*
|
||||||
* @param string $tag
|
* @param string $tag
|
||||||
* @param int $level
|
* @param int $level
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasTag($tag, $level) {
|
public function hasTag($tag, $level)
|
||||||
if(isset($this->_action["tags"][$tag])) {
|
{
|
||||||
if($level) {
|
if (isset($this->_action["tags"][$tag])) {
|
||||||
|
if ($level) {
|
||||||
return isset($this->_action["float_tags"][$tag]);
|
return isset($this->_action["float_tags"][$tag]);
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call tag callback
|
* Call tag callback
|
||||||
*
|
*
|
||||||
* @param string $tag
|
* @param string $tag
|
||||||
* @param Tokenizer $tokenizer
|
* @param Tokenizer $tokenizer
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function tag($tag, $tokenizer) {
|
public function tag($tag, $tokenizer)
|
||||||
|
{
|
||||||
return call_user_func($this->_action["tags"][$tag], $tokenizer, $this);
|
return call_user_func($this->_action["tags"][$tag], $tokenizer, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +109,8 @@ class Scope extends \ArrayObject {
|
|||||||
* @param Tokenizer $tokenizer
|
* @param Tokenizer $tokenizer
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function close($tokenizer) {
|
public function close($tokenizer)
|
||||||
|
{
|
||||||
return call_user_func($this->_action["close"], $tokenizer, $this);
|
return call_user_func($this->_action["close"], $tokenizer, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +120,8 @@ class Scope extends \ArrayObject {
|
|||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getContent() {
|
public function getContent()
|
||||||
|
{
|
||||||
return substr($this->_body, $this->_offset);
|
return substr($this->_body, $this->_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,9 +131,11 @@ class Scope extends \ArrayObject {
|
|||||||
* @return string
|
* @return string
|
||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
*/
|
*/
|
||||||
public function cutContent() {
|
public function cutContent()
|
||||||
$content = substr($this->_body, $this->_offset + 1);
|
{
|
||||||
|
$content = substr($this->_body, $this->_offset + 1);
|
||||||
$this->_body = substr($this->_body, 0, $this->_offset);
|
$this->_body = substr($this->_body, 0, $this->_offset);
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +144,8 @@ class Scope extends \ArrayObject {
|
|||||||
*
|
*
|
||||||
* @param $new_content
|
* @param $new_content
|
||||||
*/
|
*/
|
||||||
public function replaceContent($new_content) {
|
public function replaceContent($new_content)
|
||||||
|
{
|
||||||
$this->cutContent();
|
$this->cutContent();
|
||||||
$this->_body .= $new_content;
|
$this->_body .= $new_content;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user