Ejemplo n.º 1
0
 protected function _generateContent($code)
 {
     $form = $this->findParentByClass('lmbMacroFormTag')->getRuntimeVar();
     $to = $this->get('to');
     $code->writePhp("{$to} = {$form}->getErrorList();\n");
     parent::_generateContent($code);
 }
Ejemplo n.º 2
0
 function preParse($compiller)
 {
     if (!$this->has('name')) {
         throw new lmbMacroException('Tag {{mailpart}}, required attribute "name"');
     }
     parent::preParse($compiller);
 }
Ejemplo n.º 3
0
 function preParse($compiller)
 {
     if (!$this->has('text')) {
         throw new lmbMacroException('tag {{i18n}} required attribute "text"');
     }
     parent::preParse($compiller);
 }
Ejemplo n.º 4
0
 protected function _generateContent($code)
 {
     $pager = $this->findParentByClass('lmbMacroPagerTag')->getRuntimeVar();
     $code->writePhp("if (!{$pager}->hasNext()) {\n");
     parent::_generateContent($code);
     $code->writePhp("}\n");
 }
Ejemplo n.º 5
0
 function preParse($compiler)
 {
     if (!$this->has('using') && $this->has('for')) {
         $this->set('using', $this->get('for'));
     }
     return parent::preParse($compiler);
 }
Ejemplo n.º 6
0
 protected function _generateContent($code)
 {
     $code->writePHP("ob_start();\n");
     parent::_generateContent($code);
     $code->writePHP($this->get('into') . " = ob_get_contents();\n");
     $code->writePHP("ob_end_clean();\n");
 }
Ejemplo n.º 7
0
 function preParse($compiler)
 {
     if (!$this->has('var') && !$this->has('expr')) {
         throw new lmbMacroException("'var'( alias 'expr') attribute is required for 'elseif' tag");
     }
     parent::preParse($compiler);
 }
Ejemplo n.º 8
0
 protected function _generateContent($code)
 {
     $counter = $code->generateVar();
     $times = $this->get('times');
     $code->writePhp("for ({$counter} = 0; {$counter} < {$times}; {$counter}++ ){ \n");
     parent::_generateContent($code);
     $code->writePhp("}\n");
 }
Ejemplo n.º 9
0
 protected function _generateContent($code)
 {
     $list = $this->findParentByClass('lmbMacroListTag');
     $counter_var = $list->getCounterVar();
     $code->writePHP('if((' . $counter_var . '+1) % 2 == 0) {');
     parent::_generateContent($code);
     $code->writePHP('}');
 }
Ejemplo n.º 10
0
 protected function _generateContent($code)
 {
     $pager = $this->findParentByClass('lmbMacroPagerTag')->getRuntimeVar();
     $code->writePhp("if ({$pager}->isLast()) {\n");
     $code->writePhp("\$href = {$pager}->getLastPageUri();\n");
     parent::_generateContent($code);
     $code->writePhp("}\n");
 }
Ejemplo n.º 11
0
 protected function _generateContent($code)
 {
     $pager = $this->findParentByClass('lmbMacroPagerTag')->getRuntimeVar();
     $code->writePhp("if (!{$pager}->isDisplayedSection()) {\n");
     $code->writePhp("\$href = {$pager}->getSectionUri();\n");
     $code->writePhp("\$section_begin_page = {$pager}->getSectionBeginPage();\n");
     $code->writePhp("\$section_end_page = {$pager}->getSectionEndPage();\n");
     parent::_generateContent($code);
     $code->writePhp("}\n");
 }
Ejemplo n.º 12
0
 protected function _generateContent($code)
 {
     $form = $this->findParentByClass('lmbMacroFormTag')->getRuntimeVar();
     $to = $this->get('to');
     if ($this->has('for')) {
         $for = $this->getEscaped('for');
     } else {
         $for = "";
     }
     $code->writePhp("{$to} = {$form}->getErrorsListForFields({$for});\n");
     parent::_generateContent($code);
 }
Ejemplo n.º 13
0
 protected function _generateContent($code)
 {
     if ($this->get('as')) {
         $to = $this->get('as');
     }
     if ($this->get('to')) {
         $to = $this->get('to');
     } else {
         $to = '$flashbox';
     }
     $method = $code->beginMethod('__flashbox_container');
     $code->writePHP($to . '=$this->toolkit->getFlashBox()->getUnifiedList();');
     $code->writePHP('$this->toolkit->getFlashBox()->reset();');
     parent::_generateContent($code);
     $code->endMethod();
     $code->writePHP('$this->' . $method . '();');
 }
Ejemplo n.º 14
0
 protected function _generateContent($code)
 {
     $code->writePHP("if(lmbToolkit::instance()->getAcl()->isAllowed(");
     if (!($role = $this->getEscaped('role'))) {
         $role = self::DEFAULT_ROLE;
     }
     $code->writePHP($role);
     $code->writePHP(', ' . $this->getEscaped('resource'));
     if ($privilege = $this->getEscaped('privelege')) {
         $code->writePHP(', ' . $privilege);
     }
     if ($privilege = $this->getEscaped('privilege')) {
         $code->writePHP(', ' . $privilege);
     }
     $code->writePHP(')) {' . PHP_EOL);
     parent::_generateContent($code);
     $code->writePHP('}' . PHP_EOL);
 }
Ejemplo n.º 15
0
 protected function _generateContent($code)
 {
     $step_var = $this->getStepVar($code);
     $helper_var = $this->getHelperVar($code);
     $code->writePhp($helper_var . "->next();\n");
     $code->writePhp("if ( " . $helper_var . "->shouldDisplay()){\n");
     $code->writePhp($helper_var . "->reset();\n");
     $separators = $this->parent->findImmediateChildrenByClass('lmbMacroListGlueTag');
     if (array($separators) && count($separators)) {
         foreach ($separators as $separator) {
             if (!$separator->isIndependent() && $separator->getNodeId() != $this->getNodeId()) {
                 $code->writePhp('if (' . $separator->getStepVar($code) . ' < ' . $step_var . ') ');
                 $code->writePhp($separator->getHelperVar($code) . "->skipNext();\n");
             }
         }
     }
     parent::_generateContent($code);
     $code->writePhp("}\n");
 }
Ejemplo n.º 16
0
 protected function _generateContent($code)
 {
     parent::_generateContent($code);
     $tree_tag = $this->findParentByClass('lmbMacroTreeTag');
     if (!($level = $tree_tag->get('level'))) {
         $level = '$level';
     }
     if (!($as = $tree_tag->get('as'))) {
         $as = '$item';
     }
     if (!($kids_prop = $tree_tag->get('kids_prop'))) {
         $kids_prop = 'kids';
     }
     $arg_str = $this->attributesIntoArrayString();
     $code->writePHP('if(isset(' . $as . '["' . $kids_prop . '"])) {');
     $method = $tree_tag->getRecursionMethod();
     $code->writePHP('$this->' . $method . '(' . $as . '["' . $kids_prop . '"], ' . $level . ' + 1, ' . $arg_str . ");\n");
     $code->writePHP('}');
 }
Ejemplo n.º 17
0
 protected function _generateContent($code)
 {
     $slot = $this->getNodeId();
     //calling slot handler in case of dynamic wrapping
     $code->writePHP('if(isset($this->__slot_handlers_' . $slot . ')) {');
     $arg_str = $this->attributesIntoArrayString($skip = array('id', 'inline'));
     $code->writePHP('foreach($this->__slot_handlers_' . $slot . ' as $__slot_handler_' . $slot . ') {');
     $code->writePHP('call_user_func_array($__slot_handler_' . $slot . ', array(' . $arg_str . '));');
     $code->writePHP('}}');
     if (!$this->getBool('inline')) {
         $args = $code->generateVar();
         $method = $code->beginMethod('__slotHandler' . self::generateUniqueId(), array($args . '= array()'));
         $code->writePHP("if({$args}) extract({$args});");
         parent::_generateContent($code);
         $code->endMethod();
         //$arg_str = $this->attributesIntoArrayString($skip = array('id', 'inline'));
         $code->writePHP('$this->' . $method . '(' . $arg_str . ');');
     } else {
         parent::_generateContent($code);
     }
 }
Ejemplo n.º 18
0
 protected function _generateContent($code)
 {
     $storage_var = $code->generateVar();
     $cache_key = $this->getEscaped('key');
     if (!($storage = $this->get('storage'))) {
         $storage = self::default_storage;
     }
     $code->writePHP($storage_var . " = " . $storage . ";");
     $ttl = $this->get('ttl');
     $cached_html = $code->generateVar();
     $code->writePHP("{$cached_html} = {$storage_var}->get(" . $cache_key . ");\n");
     $code->writePHP("if(!is_null({$cached_html})) {\n");
     $code->writePHP("  echo {$cached_html};\n");
     $code->writePHP("} else {\n");
     $code->writePHP("  ob_start();\n");
     parent::_generateContent($code);
     $rendered_html = $code->generateVar();
     $code->writePHP("  {$rendered_html} = ob_get_contents();\n");
     $code->writePHP("  ob_end_flush();\n");
     $ttl_text = $ttl ? ", '{$ttl}'" : '';
     $code->writePHP("{$storage_var}->set(" . $cache_key . ", {$rendered_html}" . $ttl_text . ");\n");
     $code->writePHP("}\n");
 }
Ejemplo n.º 19
0
 protected function _generateContent($code)
 {
     $ratio_var = $code->generateVar();
     if ($ratio = $this->get('upto')) {
         $code->writePHP($ratio_var . " = {$ratio};\n");
     } else {
         $code->writePHP($ratio_var . " = 1;\n");
     }
     $list = $this->findParentByClass('lmbMacroListTag');
     $count_var = $code->generateVar();
     $items_left_var = $code->generateVar();
     $code->writePhp($count_var . ' = count(' . $list->getSourceVar() . ');');
     $force = (int) $this->getBool('force');
     $code->writePhp("if (({$force} || ({$count_var}/{$ratio_var} > 1)) && {$count_var}) \n");
     $code->writePhp($items_left_var . " = ceil({$count_var}/{$ratio_var})*{$ratio_var} - {$count_var}; \n");
     $code->writePhp("else \n");
     $code->writePhp($items_left_var . " = 0;\n");
     $code->writePhp("if ({$items_left_var}){\n");
     if ($items_left = $this->get('items_left')) {
         $code->writePhp($items_left . " = {$items_left_var};");
     }
     parent::_generateContent($code);
     $code->writePhp('}' . "\n");
 }
Ejemplo n.º 20
0
 function testRestrictSelfNesting()
 {
     $tag_info = new lmbMacroTagInfo('CompilerTag', 'whatever');
     $tag_info->setRestrictSelfNesting(true);
     $node = new lmbMacroTag(new lmbMacroSourceLocation('my_file', 13), 'whatever', $tag_info);
     $parent = new lmbMacroTag(new lmbMacroSourceLocation('my_file', 10), 'whatEver', $tag_info);
     $node->setParent($parent);
     try {
         $node->preParse(new MockMacroCompiler());
         $this->assertTrue(false);
     } catch (lmbMacroException $e) {
         $this->assertPattern('/Tag cannot be nested within the same tag/', $e->getMessage());
         $this->assertEqual($e->getParam('same_tag_file'), 'my_file');
         $this->assertEqual($e->getParam('same_tag_line'), 10);
     }
 }
Ejemplo n.º 21
0
 function _generateStaticaly($code)
 {
     if ($this->getBool('inline')) {
         parent::_generateContent($code);
     } else {
         list($keys, $vals) = $this->attributesIntoArgs();
         $method = $code->beginMethod('__staticInclude' . ++self::$static_includes_counter, $keys);
         parent::_generateContent($code);
         $code->endMethod();
         $code->writePHP('$this->' . $method . '(' . implode(', ', $vals) . ');');
     }
 }
Ejemplo n.º 22
0
 function generateNow($code_writer)
 {
     parent::generate($code_writer);
 }
Ejemplo n.º 23
0
 function generateNow($code)
 {
     parent::generate($code);
 }
Ejemplo n.º 24
0
 protected function _generateContent($code)
 {
     lmbMacroTextNode::setTrim(true);
     parent::_generateContent($code);
     lmbMacroTextNode::setTrim(false);
 }