Beispiel #1
0
 /**
  * Buffers the layout
  *
  * @return $this
  */
 protected function addLayout()
 {
     if ($this->parent->configHas('layout')) {
         $name = $this->parent->getName();
         $layout = secure_string(config('cms.path.layouts') . '/' . $this->parent->getConfig('layout'));
         $this->parent->setLayout($layout);
         Helper::setBufferKey($layout, 'page', $name);
     }
     return $this;
 }
Beispiel #2
0
 public function compile(\Twig_Compiler $compiler)
 {
     $compiler->addDebugInfo($this);
     try {
         $template = $compiler->getFilename();
         if (Helper::hasBufferKey($template, $this->tag)) {
             $string = Helper::getBufferKey($template, $this->tag);
         } else {
             $string = "[{$this->tag}]";
             // display a placeholder
         }
     } catch (\Exception $e) {
         $string = "[{$this->tag}]";
         // display a placeholder
     }
     $compiler->raw("echo secure_string('{$string}');");
 }
Beispiel #3
0
 public function parse(\Twig_Token $token)
 {
     if (!$this->parser->isMainScope()) {
         throw new \Twig_Error_Syntax('Cannot extend from a block.', $token->getLine(), $this->parser->getFilename());
     }
     if (null !== $this->parser->getParent()) {
         throw new \Twig_Error_Syntax('Multiple extends tags are forbidden.', $token->getLine(), $this->parser->getFilename());
     }
     $this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
     $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
     if (Helper::hasBuffer($this->parser->getFilename())) {
         $parentName = $this->parser->getParent()->getAttribute('value');
         $name = $this->parser->getFilename();
         // If the parent has no buffer values, transfer them from the child template
         if (is_null(Helper::getBuffer($parentName))) {
             Helper::setBuffer($parentName, Helper::getBuffer($name));
         }
     }
 }
Beispiel #4
0
 public function page_navigator($view, $pagenum, $numpages, $url)
 {
     $app = CMS::app_path('views/helpers');
     $lib = CMS::tao_view('helpers');
     $templates = array();
     if (CMS::admin()) {
         $templates[] = "{$app}/page-navigator-admin.phtml";
         $templates[] = "{$lib}/page-navigator-admin.phtml";
     } else {
         $templates[] = "{$app}/page-navigator-site.phtml";
         $templates[] = "{$app}/page-navigator.phtml";
     }
     $templates[] = "{$lib}/page-navigator.phtml";
     foreach ($templates as $template) {
         if (IO_FS::exists($template)) {
             break;
         }
     }
     self::$pn_url = $url;
     self::$pn_current = $pagenum;
     return $view->partial($template, array('tpl' => $url, 'page' => $pagenum, 'numpages' => $numpages));
 }
Beispiel #5
0
 public function setAttribute($key, $value)
 {
     Helper::setAttribute($this->getName(), $key, $value);
 }
Beispiel #6
0
 public function display(array $context, array $blocks = [])
 {
     $attr = Helper::getAttributes($this->getTemplateName());
     parent::display(array_merge($context, $attr), $blocks);
 }