/**
  * Constructor
  *
  * @param string $markup
  * @param array $tokens
  * @param LiquidFileSystem $file_system
  * @return TableRowLiquidTag
  */
 public function __construct($markup, &$tokens, &$file_system)
 {
     parent::__construct($markup, $tokens, $file_system);
     $syntax = new LiquidRegexp("/(\\w+)\\s+in\\s+(" . LIQUID_ALLOWED_VARIABLE_CHARS . "+)/");
     if ($syntax->match($markup)) {
         $this->variable_name = $syntax->matches[1];
         $this->collection_name = $syntax->matches[2];
         $this->extract_attributes($markup);
     } else {
         throw new LiquidException("Syntax Error in 'table_row loop' - Valid syntax: table_row [item] in [collection] cols=3");
     }
 }
예제 #2
0
 /**
  * Constructor
  *
  * @param string $markup
  * @param array $tokens
  * @param LiquidFileSystem $file_system
  * @return TableRowLiquidTag
  */
 function TableRowLiquidTag($markup, &$tokens, &$file_system)
 {
     parent::LiquidTag($markup, $tokens, $file_system);
     $syntax = new LiquidRegexp("/(\\w+)\\s+in\\s+(" . LIQUID_ALLOWED_VARIABLE_CHARS . "+)/");
     if ($syntax->match($markup)) {
         $this->variable_name = $syntax->matches[1];
         $this->collection_name = $syntax->matches[2];
         $this->extract_attributes($markup);
     } else {
         trigger_error("Syntax Error in 'table_row loop' - Valid syntax: table_row [item] in [collection] cols=3", E_USER_ERROR);
     }
 }
예제 #3
0
 /**
  * Constructor
  *
  * @param string $markup
  * @param array $tokens
  * @param LiquidFileSystem $fileSystem
  * @return ForLiquidTag
  */
 public function __construct($markup, &$tokens, &$fileSystem)
 {
     parent::__construct($markup, $tokens, $fileSystem);
     $syntaxRegexp = new LiquidRegexp('/(\\w+)\\s+in\\s+(' . LIQUID_ALLOWED_VARIABLE_CHARS . '+)/');
     if ($syntaxRegexp->match($markup)) {
         $this->_variableName = $syntaxRegexp->matches[1];
         $this->_collectionName = $syntaxRegexp->matches[2];
         $this->_name = $syntaxRegexp->matches[1] . '-' . $syntaxRegexp->matches[2];
         $this->extractAttributes($markup);
     } else {
         throw new LiquidException("Syntax Error in 'for loop' - Valid syntax: for [item] in [collection]");
     }
 }
예제 #4
0
 /**
  * Constructor
  *
  * @param string $markup
  * @param array $tokens
  * @param LiquidFileSystem $file_system
  * @return ForLiquidTag
  */
 public function __construct($markup, &$tokens, &$file_system)
 {
     parent::__construct($markup, $tokens, $file_system);
     $syntax_regexp = new LiquidRegexp('/(\\w+)\\s+in\\s+(' . LIQUID_ALLOWED_VARIABLE_CHARS . '+)/');
     if ($syntax_regexp->match($markup)) {
         $this->_variableName = $syntax_regexp->matches[1];
         $this->_collectionName = $syntax_regexp->matches[2];
         $this->_name = $syntax_regexp->matches[1] . '-' . $syntax_regexp->matches[2];
         $this->extractAttributes($markup);
     } else {
         $syntax_regexp = new LiquidRegexp('/(\\w+)\\s+in\\s+\\((\\d|' . LIQUID_ALLOWED_VARIABLE_CHARS . '+)\\s*..\\s*(\\d|' . LIQUID_ALLOWED_VARIABLE_CHARS . '+)\\)/');
         if ($syntax_regexp->match($markup)) {
             $this->_type = 'digit';
             $this->_variableName = $syntax_regexp->matches[1];
             $this->_start = $syntax_regexp->matches[2];
             $this->_collectionName = $syntax_regexp->matches[3];
             $this->_name = $syntax_regexp->matches[1] . '-digit';
             $this->extractAttributes($markup);
         } else {
             throw new LiquidException("Syntax Error in 'for loop' - Valid syntax: for [item] in [collection] OR for [int] in ([start]..[end])");
         }
     }
 }
 /**
  * Renders the block
  *
  * @param LiquidContext $context
  */
 public function render(&$context)
 {
     $output = parent::render($context);
     $context->set($this->_to, $output);
 }
예제 #6
0
 public function __construct($meta = 0)
 {
     parent::__construct(LAVA, $meta, "Lava");
     $this->hardness = 0;
 }
 /**
  * Renders the tag
  *
  * @param LiquidContext $context
  */
 public function render(&$context)
 {
     $this->_collection = $context->get($this->_collectionName);
     $this->_collectionSize = count($this->_collection);
     $this->_totalPages = ceil($this->_collectionSize / $this->_numberItems);
     $paginated_collection = array_slice($this->_collection, $this->_currentOffset, $this->_numberItems);
     // Sets the collection if it's a key of another collection (ie search.results, collection.products, blog.articles)
     $segments = explode('.', $this->_collectionName);
     if (count($segments) == 2) {
         $context->set($segments[0], array($segments[1] => $paginated_collection));
     } else {
         $context->set($this->_collectionName, $paginated_collection);
     }
     $paginate = array('page_size' => $this->_numberItems, 'current_page' => $this->_currentPage, 'current_offset' => $this->_currentOffset, 'pages' => $this->_totalPages, 'items' => $this->_collectionSize, 'previous' => false, 'next' => false);
     if ($this->_currentPage != 1) {
         $paginate['previous'] = array('title' => '« Previous', 'url' => $this->current_url() . '?page=' . ($this->_currentPage - 1));
     }
     if ($this->_currentPage != $this->_totalPages) {
         $paginate['next'] = array('title' => 'Next »', 'url' => $this->current_url() . '?page=' . ($this->_currentPage + 1));
     }
     $context->set('paginate', $paginate);
     return parent::render($context);
 }
예제 #8
0
 public function __construct($meta = 0)
 {
     parent::__construct(WATER, $meta, "Water");
     $this->hardness = 500;
 }
예제 #9
0
 public function __construct($meta = 0)
 {
     LiquidBlock::__construct(STILL_WATER, $meta, "Still Water");
     $this->hardness = 500;
 }
예제 #10
0
 /**
  * Renders the block
  *
  * @param LiquidContext $context
  */
 public function render(&$context)
 {
     return parent::render($context);
 }
예제 #11
0
 public function __construct($meta = 0)
 {
     parent::__construct(STILL_LAVA, $meta, "Still Lava");
     $this->hardness = 500;
 }
예제 #12
0
 /**
  * Constructor
  *
  * @param string $markup
  * @param array $tokens
  * @param LiquidFileSystem $file_system
  * @return ForLiquidTag
  */
 function ForLiquidTag($markup, &$tokens, &$file_system)
 {
     parent::LiquidTag($markup, $tokens, $file_system);
     $syntax_regexp = new LiquidRegexp('/(\\w+)\\s+in\\s+(' . LIQUID_ALLOWED_VARIABLE_CHARS . '+)/');
     if ($syntax_regexp->match($markup, $matches)) {
         $this->variable_name = $syntax_regexp->matches[1];
         $this->collection_name = $syntax_regexp->matches[2];
         $this->name = $syntax_regexp->matches[1] . '-' . $syntax_regexp->matches[2];
         $this->extract_attributes($markup);
     } else {
         trigger_error("Syntax Error in 'for loop' - Valid syntax: for [item] in [collection]", E_USER_ERROR);
     }
 }