Ejemplo n.º 1
0
 public function testIssue9()
 {
     $stream = new InputStream('page(6) | page(7) | page(9) | page(10) | depth(>1)');
     $parser = new Parser();
     $node = $parser->parse($stream);
     $this->assertEquals(new OrNode(new CallNode('page', array(new StringNode('6'))), new OrNode(new CallNode('page', array(new StringNode('7'))), new OrNode(new CallNode('page', array(new StringNode('9'))), new OrNode(new CallNode('page', array(new StringNode('10'))), new CallNode('depth', array(new StringNode('>1'))))))), $node);
 }
Ejemplo n.º 2
0
 /**
  * Generate content.
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 protected function generateContent()
 {
     $modules = deserialize($this->merger_data);
     $buffer = '';
     foreach ($modules as $module) {
         if ($module['disabled']) {
             continue;
         }
         $result = null;
         $condition = trim(html_entity_decode($module['condition']));
         if (strlen($condition)) {
             $input = new InputStream($condition);
             $parser = new Parser();
             $node = $parser->parse($input);
             $result = $node->evaluate();
         }
         if ($result || $result === null) {
             $content = '';
             switch ($module['content']) {
                 case '-':
                     break;
                     /*
                      * Include the articles from current page.
                      */
                 /*
                  * Include the articles from current page.
                  */
                 case 'article':
                     $content = $this->getPageFrontendModule($GLOBALS['objPage'], 0, $this->strColumn);
                     break;
                     /*
                      * Inherit articles from one upper level that contains articles.
                      */
                 /*
                  * Inherit articles from one upper level that contains articles.
                  */
                 case 'inherit_articles':
                     $content = $this->inheritArticle($GLOBALS['objPage'], 1);
                     break;
                     /*
                      * Inherit articles from all upper levels.
                      */
                 /*
                  * Inherit articles from all upper levels.
                  */
                 case 'inherit_all_articles':
                     $content = $this->inheritArticle($GLOBALS['objPage']);
                     break;
                     /*
                      * Include the articles from current page or inherit from one upper level that contains articles.
                      */
                 /*
                  * Include the articles from current page or inherit from one upper level that contains articles.
                  */
                 case 'inherit_articles_fallback':
                     $content = $this->getPageFrontendModule($GLOBALS['objPage'], 0, $this->strColumn);
                     if (!strlen($content)) {
                         $content = $this->inheritArticle($GLOBALS['objPage'], 1);
                     }
                     break;
                     /*
                      * Include the articles from current page or inherit from upper all upper levels.
                      */
                 /*
                  * Include the articles from current page or inherit from upper all upper levels.
                  */
                 case 'inherit_all_articles_fallback':
                     $content = $this->getPageFrontendModule($GLOBALS['objPage'], 0, $this->strColumn);
                     if (!strlen($content)) {
                         $content = $this->inheritArticle($GLOBALS['objPage']);
                     }
                     break;
                     /*
                      * Include a module.
                      */
                 /*
                  * Include a module.
                  */
                 default:
                     $content = $this->getPageFrontendModule($GLOBALS['objPage'], $module['content'], $this->strColumn);
             }
             $buffer .= $content;
             if ($result === null) {
                 $result = strlen($content) > 0;
             }
         }
         if ($result && $this->isModeUpFirstTrue() || !$result && $this->isModeUpFirstFalse()) {
             break;
         }
     }
     $tpl = new \FrontendTemplate($this->merger_template);
     $tpl->content = $buffer;
     return $tpl->parse();
 }
Ejemplo n.º 3
0
 public function testPageFunctionChildrenFail()
 {
     $stream = new InputStream('children(1)');
     $parser = new Parser();
     $node = $parser->parse($stream);
     $this->assertFalse($node->evaluate());
 }
Ejemplo n.º 4
0
<?php

/**
 * Merger² - Module Merger for Contao Open Source CMS
 *
 * @copyright 2013,2014 bit3 UG
 * @author    Tristan Lins <*****@*****.**>
 * @author    David Molineus <*****@*****.**>
 * @link      http://bit3.de
 * @package   bit3/contao-merger2
 * @license   LGPL-3.0+
 */
require "bootstrap.php";
use Bit3\Contao\Merger2\Constraint\Parser\InputStream;
use Bit3\Contao\Merger2\Constraint\Parser\Parser;
$GLOBALS['objPage'] = (object) array('language' => 'en');
$stream = new InputStream('language(de)');
$parser = new Parser();
$node = $parser->parse($stream);
var_dump($node->evaluate());