Inheritance: extends latte\Object
コード例 #1
0
ファイル: MacroSet.php プロジェクト: richard-ejem/latte
 /**
  * New node is found.
  * @return bool
  */
 public function nodeOpened(MacroNode $node)
 {
     list($begin, $end, $attr) = $this->macros[$node->name];
     $node->isEmpty = !$end;
     if ($node->modifiers && (!$begin || is_string($begin) && strpos($begin, '%modify') === FALSE) && (!$end || is_string($end) && strpos($end, '%modify') === FALSE) && (!$attr || is_string($attr) && strpos($attr, '%modify') === FALSE)) {
         throw new Latte\CompileException("Modifiers are not allowed in {{$node->name}}");
     }
     if ($node->args && (!$begin || is_string($begin) && strpos($begin, '%node') === FALSE) && (!$end || is_string($end) && strpos($end, '%node') === FALSE) && (!$attr || is_string($attr) && strpos($attr, '%node') === FALSE)) {
         throw new Latte\CompileException("Arguments are not allowed in {{$node->name}}");
     }
     if ($attr && $node->prefix === $node::PREFIX_NONE) {
         $node->isEmpty = TRUE;
         $this->compiler->setContext(Latte\Compiler::CONTEXT_QUOTED_ATTRIBUTE);
         $res = $this->compile($node, $attr);
         if ($res === FALSE) {
             return FALSE;
         } elseif (!$node->attrCode) {
             $node->attrCode = "<?php {$res} ?>";
         }
         $this->compiler->setContext(NULL);
     } elseif ($begin) {
         $res = $this->compile($node, $begin);
         if ($res === FALSE || $node->isEmpty && $node->prefix) {
             return FALSE;
         } elseif (!$node->openingCode) {
             $node->openingCode = "<?php {$res} ?>";
         }
     } elseif (!$end) {
         return FALSE;
     }
 }
コード例 #2
0
ファイル: MacroSet.php プロジェクト: vol0054/vizitky
 /**
  * New node is found.
  * @return bool
  */
 public function nodeOpened(MacroNode $node)
 {
     list($begin, $end, $attr) = $this->macros[$node->name];
     $node->isEmpty = !$end;
     if ($attr && $node->prefix === $node::PREFIX_NONE) {
         $node->isEmpty = TRUE;
         $this->compiler->setContext(Latte\Compiler::CONTEXT_DOUBLE_QUOTED_ATTR);
         $res = $this->compile($node, $attr);
         if ($res === FALSE) {
             return FALSE;
         } elseif (!$node->attrCode) {
             $node->attrCode = "<?php {$res} ?>";
         }
         $this->compiler->setContext(NULL);
     } elseif ($begin) {
         $res = $this->compile($node, $begin);
         if ($res === FALSE || $node->isEmpty && $node->prefix) {
             return FALSE;
         } elseif (!$node->openingCode) {
             $node->openingCode = "<?php {$res} ?>";
         }
     } elseif (!$end) {
         return FALSE;
     }
 }
コード例 #3
0
 /**
  * New node is found.
  * @return bool
  */
 public function nodeOpened(MacroNode $node)
 {
     list($begin, $end, $attr) = $this->macros[$node->name];
     $node->isEmpty = !$end;
     if ($node->modifiers && (!$begin || is_string($begin) && strpos($begin, '%modify') === FALSE) && (!$end || is_string($end) && strpos($end, '%modify') === FALSE) && (!$attr || is_string($attr) && strpos($attr, '%modify') === FALSE)) {
         trigger_error('Modifiers are not allowed here.', E_USER_WARNING);
     }
     if ($attr && $node->prefix === $node::PREFIX_NONE) {
         $node->isEmpty = TRUE;
         $this->compiler->setContext(Latte\Compiler::CONTEXT_DOUBLE_QUOTED_ATTR);
         $res = $this->compile($node, $attr);
         if ($res === FALSE) {
             return FALSE;
         } elseif (!$node->attrCode) {
             $node->attrCode = "<?php {$res} ?>";
         }
         $this->compiler->setContext(NULL);
     } elseif ($begin) {
         $res = $this->compile($node, $begin);
         if ($res === FALSE || $node->isEmpty && $node->prefix) {
             return FALSE;
         } elseif (!$node->openingCode) {
             $node->openingCode = "<?php {$res} ?>";
         }
     } elseif (!$end) {
         return FALSE;
     }
 }
コード例 #4
0
ファイル: MacroSet.php プロジェクト: nette/latte
 public function addMacro($name, $begin, $end = NULL, $attr = NULL, $flags = NULL)
 {
     if (!$begin && !$end && !$attr) {
         throw new \InvalidArgumentException("At least one argument must be specified for macro '{$name}'.");
     }
     foreach ([$begin, $end, $attr] as $arg) {
         if ($arg && !is_string($arg)) {
             Latte\Helpers::checkCallback($arg);
         }
     }
     $this->macros[$name] = [$begin, $end, $attr];
     $this->compiler->addMacro($name, $this, $flags);
     return $this;
 }
コード例 #5
0
 /**
  * New node is found. Returns FALSE to reject.
  * @return bool
  */
 public function nodeOpened(MacroNode $node)
 {
     $node->isEmpty = FALSE;
     $this->compiler->setContext(Compiler::CONTEXT_DOUBLE_QUOTED_ATTR);
     $res1 = $this->compile($node, array($this, 'macroHref'));
     $this->compiler->setContext(NULL);
     if (!$node->attrCode) {
         $node->attrCode = "<?php {$res1} ?>";
     }
     $res2 = $this->compile($node, array('Foowie\\PermissionChecker\\Latte\\PermissionMacros', 'macroIfAllowedLink'));
     if (!$node->openingCode) {
         $node->openingCode = "<?php {$res2} ?>";
     }
     return $res1 !== false && $res2 !== false;
 }