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;
|
||||||
@@ -39,7 +39,8 @@ class Scope extends \ArrayObject {
|
|||||||
* @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->line = $line;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->tpl = $tpl;
|
$this->tpl = $tpl;
|
||||||
@@ -53,7 +54,8 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +78,8 @@ class Scope extends \ArrayObject {
|
|||||||
* @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 (isset($this->_action["tags"][$tag])) {
|
||||||
if ($level) {
|
if ($level) {
|
||||||
return isset($this->_action["float_tags"][$tag]);
|
return isset($this->_action["float_tags"][$tag]);
|
||||||
@@ -83,6 +87,7 @@ class Scope extends \ArrayObject {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +98,8 @@ class Scope extends \ArrayObject {
|
|||||||
* @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