[limb-svn] r6510 - in 3.x/trunk/limb/macro: src src/tags src/tags/core src/tags/list src/tags/tree tests/cases
svn at limb-project.com
svn at limb-project.com
Fri Nov 9 12:30:35 MSK 2007
Author: serega
Date: 2007-11-09 12:30:35 +0300 (Fri, 09 Nov 2007)
New Revision: 6510
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6510
Added:
3.x/trunk/limb/macro/src/tags/core/
3.x/trunk/limb/macro/src/tags/core/apply.tag.php
3.x/trunk/limb/macro/src/tags/core/include.tag.php
3.x/trunk/limb/macro/src/tags/core/into.tag.php
3.x/trunk/limb/macro/src/tags/core/slot.tag.php
3.x/trunk/limb/macro/src/tags/core/template.tag.php
3.x/trunk/limb/macro/src/tags/core/wrap.tag.php
3.x/trunk/limb/macro/src/tags/list/
3.x/trunk/limb/macro/src/tags/list/list.tag.php
3.x/trunk/limb/macro/src/tags/list/list_empty.tag.php
3.x/trunk/limb/macro/src/tags/list/list_even.tag.php
3.x/trunk/limb/macro/src/tags/list/list_fill.tag.php
3.x/trunk/limb/macro/src/tags/list/list_glue.tag.php
3.x/trunk/limb/macro/src/tags/list/list_item.tag.php
3.x/trunk/limb/macro/src/tags/list/list_odd.tag.php
3.x/trunk/limb/macro/src/tags/tree/
3.x/trunk/limb/macro/src/tags/tree/tree.tag.php
3.x/trunk/limb/macro/src/tags/tree/tree_branch.tag.php
3.x/trunk/limb/macro/src/tags/tree/tree_item.tag.php
Removed:
3.x/trunk/limb/macro/src/tags/apply.tag.php
3.x/trunk/limb/macro/src/tags/include.tag.php
3.x/trunk/limb/macro/src/tags/into.tag.php
3.x/trunk/limb/macro/src/tags/list.tag.php
3.x/trunk/limb/macro/src/tags/list_empty.tag.php
3.x/trunk/limb/macro/src/tags/list_even.tag.php
3.x/trunk/limb/macro/src/tags/list_fill.tag.php
3.x/trunk/limb/macro/src/tags/list_glue.tag.php
3.x/trunk/limb/macro/src/tags/list_item.tag.php
3.x/trunk/limb/macro/src/tags/list_odd.tag.php
3.x/trunk/limb/macro/src/tags/slot.tag.php
3.x/trunk/limb/macro/src/tags/template.tag.php
3.x/trunk/limb/macro/src/tags/tree.tag.php
3.x/trunk/limb/macro/src/tags/tree_branch.tag.php
3.x/trunk/limb/macro/src/tags/tree_item.tag.php
3.x/trunk/limb/macro/src/tags/wrap.tag.php
Modified:
3.x/trunk/limb/macro/src/lmbMacroConfig.class.php
3.x/trunk/limb/macro/src/lmbMacroFilterDictionary.class.php
3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php
3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php
3.x/trunk/limb/macro/tests/cases/lmbMacroTagDictionaryTest.class.php
Log:
-- lmbMacroTagDictionary now recursively scans dirs for tags
-- macro tags now moved to appropriate folders inside /limb/macro/src/tags/
-- lmbMacroTagDictionary :: load() and lmbMacroFilterDictionary :: load() are not static methods anymore
Modified: 3.x/trunk/limb/macro/src/lmbMacroConfig.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroConfig.class.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/lmbMacroConfig.class.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -51,15 +51,30 @@
{
return $this->tags_scan_dirs;
}
+
+ function setTagsScanDirectories($dirs)
+ {
+ $this->tags_scan_dirs = $dirs;
+ }
function getFiltersScanDirectories()
{
return $this->filters_scan_dirs;
}
+ function setFiltersScanDirectories($dirs)
+ {
+ $this->filters_scan_dirs = $dirs;
+ }
+
function getTemplateScanDirectories()
{
return $this->tpl_scan_dirs;
}
+
+ function setTemplateScanDirectories($dirs)
+ {
+ $this->tpl_scan_dirs = $dirs;
+ }
}
Modified: 3.x/trunk/limb/macro/src/lmbMacroFilterDictionary.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroFilterDictionary.class.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/lmbMacroFilterDictionary.class.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -31,18 +31,14 @@
return self :: $instance;
}
- static function load(lmbMacroConfig $config)
+ function load(lmbMacroConfig $config)
{
- $dictionary = self :: instance();
-
$dirs = $config->getFiltersScanDirectories();
foreach($dirs as $dir)
{
foreach(lmb_glob($dir . '/*.filter.php') as $file)
- $dictionary->registerFromFile($file);
+ $this->registerFromFile($file);
}
-
- return $dictionary;
}
function register($filter_info)
Modified: 3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -31,20 +31,37 @@
return self :: $instance;
}
- static function load(lmbMacroConfig $config)
+ function load(lmbMacroConfig $config)
{
- $dictionary = self :: instance();
-
- $dirs = $config->getTagsScanDirectories();
- foreach($dirs as $dir)
+ $config_scan_dirs = $config->getTagsScanDirectories();
+ $real_scan_dirs = array();
+
+ foreach($config_scan_dirs as $dir)
{
- foreach(lmb_glob($dir . '/*.tag.php') as $file)
- $dictionary->registerFromFile($file);
+ foreach($this->_getThisAndImmediateDirectories($dir) as $item)
+ $real_scan_dirs[] = $item;
}
-
- return $dictionary;
+
+ foreach($real_scan_dirs as $scan_dir)
+ {
+ foreach(lmb_glob($scan_dir . '/*.tag.php') as $file)
+ $this->registerFromFile($file);
+ }
}
+ function _getThisAndImmediateDirectories($dir)
+ {
+ $dirs = array();
+ foreach(lmb_glob("$dir/*") as $item) {
+ if($item{0} != '.' && is_dir($item))
+ $dirs[] = $item;
+ }
+
+ $dirs[] = $dir;
+
+ return $dirs;
+ }
+
function register($taginfo)
{
$tag_to_lower = strtolower($taginfo->getTag());
Modified: 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -96,8 +96,11 @@
protected function _createCompiler()
{
- $tag_dictionary = lmbMacroTagDictionary :: load($this->config);
- $filter_dictionary = lmbMacroFilterDictionary :: load($this->config);
+ $tag_dictionary = lmbMacroTagDictionary :: instance();
+ $filter_dictionary = lmbMacroFilterDictionary :: instance();
+ $tag_dictionary->load($this->config);
+ $filter_dictionary->load($this->config);
+
return new lmbMacroCompiler($tag_dictionary, $this->locator, $filter_dictionary);
}
}
Deleted: 3.x/trunk/limb/macro/src/tags/apply.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/apply.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/apply.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,41 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * @tag apply
- * @package macro
- * @version $Id$
- */
-class lmbMacroApplyTag extends lmbMacroTag
-{
- function generateContents($code)
- {
- $name = $this->get('template');
-
- $args = $this->_attributesIntoArray();
-
- $arg_str = 'array(';
- foreach($args as $key => $value)
- $arg_str .= "'$key' => $value,";
- $arg_str .= ')';
-
- $code->writePHP('$this->_template'. $name . '(' . $arg_str . ');');
- }
-
- protected function _attributesIntoArray()
- {
- $arr = array();
- foreach($this->attributes as $k => $attribute)
- $arr[$k] = $this->getEscaped($k);
- return $arr;
- }
-}
-
Copied: 3.x/trunk/limb/macro/src/tags/core/apply.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/apply.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/apply.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/core/apply.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,41 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * @tag apply
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroApplyTag extends lmbMacroTag
+{
+ function generateContents($code)
+ {
+ $name = $this->get('template');
+
+ $args = $this->_attributesIntoArray();
+
+ $arg_str = 'array(';
+ foreach($args as $key => $value)
+ $arg_str .= "'$key' => $value,";
+ $arg_str .= ')';
+
+ $code->writePHP('$this->_template'. $name . '(' . $arg_str . ');');
+ }
+
+ protected function _attributesIntoArray()
+ {
+ $arr = array();
+ foreach($this->attributes as $k => $attribute)
+ $arr[$k] = $this->getEscaped($k);
+ return $arr;
+ }
+}
+
Copied: 3.x/trunk/limb/macro/src/tags/core/include.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/include.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/include.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/core/include.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,98 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * class lmbMacroIncludeTag.
+ *
+ * @tag include
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroIncludeTag extends lmbMacroTag
+{
+ function preParse($compiler)
+ {
+ parent :: preParse($compiler);
+
+ $locator = $compiler->getTemplateLocator();
+
+ if(!$file = $this->get('file'))
+ $this->raiseRequiredAttributeError($file);
+
+ if(!$this->_isDynamic())
+ {
+ $source_file = $locator->locateSourceTemplate($file);
+ if(empty($source_file))
+ $this->raise('Template source file not found', array('file_name' => $file));
+
+ $compiler->parseTemplate($file, $this);
+ }
+ }
+
+ function _isDynamic()
+ {
+ return $this->isDynamic('file');
+ }
+
+ function generateContents($code)
+ {
+ if($this->_isDynamic())
+ $this->_generateDynamicContents($code);
+ else
+ $this->_generateStaticContents($code);
+ }
+
+ function _generateDynamicContents($code)
+ {
+ $args = $this->_attributesIntoArray();
+
+ $arg_str = 'array(';
+ foreach($args as $key => $value)
+ $arg_str .= "'$key' => $value,";
+ $arg_str .= ')';
+
+ $code->writePHP('$this->includeTemplate(' . $this->get('file') . ',' . $arg_str . ');');
+ }
+
+ function _generateStaticContents($code)
+ {
+ static $counter = 1;
+
+ list($keys, $vals) = $this->_attributesIntoArgs();
+
+ $method = $code->beginMethod('__staticInclude' . ($counter++), $keys);
+ parent :: generateContents($code);
+ $code->endMethod();
+
+ $code->writePHP('$this->' . $method . '(' . implode(', ', $vals) . ');');
+ }
+
+ protected function _attributesIntoArgs()
+ {
+ $keys = array();
+ $vals = array();
+ foreach($this->attributes as $k => $attribute)
+ {
+ $keys[] = '$' . $k;
+ $vals[] = $this->getEscaped($k);
+ }
+ return array($keys, $vals);
+ }
+
+ protected function _attributesIntoArray()
+ {
+ $arr = array();
+ foreach($this->attributes as $k => $attribute)
+ $arr[$k] = $this->getEscaped($k);
+ return $arr;
+ }
+}
+
Copied: 3.x/trunk/limb/macro/src/tags/core/into.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/into.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/into.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/core/into.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,50 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * class lmbMacroIntoTag.
+ *
+ * @tag into
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroIntoTag extends lmbMacroTag
+{
+ function preParse($compiler)
+ {
+ parent :: preParse($compiler);
+
+ if(!$this->parent->isDynamicWrap())
+ {
+ $tree_builder = $compiler->getTreeBuilder();
+ $this->_insert($this->parent, $tree_builder, $this->get('slot'));
+ }
+ }
+
+ function _insert($wrapper, $tree_builder, $point)
+ {
+ $insertionPoint = $wrapper->findChild($point);
+ if(empty($insertionPoint))
+ {
+ $params = array('slot' => $point);
+ if($wrapper !== $this)
+ {
+ $params['parent_wrap_tag_file'] = $wrapper->getTemplateFile();
+ $params['parent_wrap_tag_line'] = $wrapper->getTemplateLine();
+ }
+
+ $this->raise('Wrap slot not found', $params);
+ }
+
+ $tree_builder->pushCursor($insertionPoint, $this->location);
+ }
+}
+
Copied: 3.x/trunk/limb/macro/src/tags/core/slot.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/slot.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/slot.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/core/slot.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,40 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * class lmbMacroSlotTag.
+ *
+ * @tag slot
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroSlotTag extends lmbMacroTag
+{
+ function generateContents($code)
+ {
+ $slot = $this->getId();
+ //calling slot handler in case of dynamic wrapping
+ $code->writePHP('if(isset($this->__slot_handler_' . $slot . ')) {');
+ $code->writePHP('call_user_func_array($this->__slot_handler_' . $slot . ', array());');
+ $code->writePHP('}');
+
+ //we need to isolate statically wrapped template variables via method call
+ //in case of dynamic call we don't have children, hence the check
+ if($this->children)
+ {
+ $method = $code->beginMethod('__slotHandler' . uniqid());
+ parent :: generateContents($code);
+ $code->endMethod();
+ $code->writePHP('$this->' . $method . '()');
+ }
+ }
+}
+
Copied: 3.x/trunk/limb/macro/src/tags/core/template.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/template.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/template.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/core/template.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,30 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * @tag template
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroTemplateTag extends lmbMacroTag
+{
+ function generateContents($code)
+ {
+ $name = $this->get('name');
+
+ $args = $code->generateVar();
+ $code->beginMethod('_template'. $name, array($args . '= array()'));
+ $code->writePHP("if($args) extract($args);");
+ parent :: generateContents($code);
+ $code->endMethod();
+ }
+}
+
Copied: 3.x/trunk/limb/macro/src/tags/core/wrap.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/wrap.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/core/wrap.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/core/wrap.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,117 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * class lmbMacroWrapTag.
+ *
+ * @tag wrap
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroWrapTag extends lmbMacroTag
+{
+ protected $is_dynamic = false;
+
+ function preParse($compiler)
+ {
+ parent :: preParse($compiler);
+
+ if($this->isDynamic('with'))
+ $this->is_dynamic = true;
+
+ if(!$this->is_dynamic)
+ {
+ $file = $this->get('with');
+ $this->_compileSourceFileName($file, $compiler);
+
+ //if there's no 'into' attribute we consider that {{into}} tags used instead
+ if($into = $this->get('into'))
+ {
+ $tree_builder = $compiler->getTreeBuilder();
+ $this->_insert($this, $tree_builder, $into);
+ }
+ }
+ }
+
+ protected function _compileSourceFileName($file, $compiler)
+ {
+ $this->sourcefile = $compiler->getTemplateLocator()->locateSourceTemplate($file);
+
+ if(empty($this->sourcefile))
+ $this->raise('Template source file not found', array('file_name' => $file));
+
+ $compiler->parseTemplate($file, $this);
+ }
+
+ function _insert($wrapper, $tree_builder, $point)
+ {
+ $insertionPoint = $wrapper->findChild($point);
+ if(empty($insertionPoint))
+ {
+ $params = array('slot' => $point);
+ if($wrapper !== $this)
+ {
+ $params['parent_wrap_tag_file'] = $wrapper->getTemplateFile();
+ $params['parent_wrap_tag_line'] = $wrapper->getTemplateLine();
+ }
+
+ $this->raise('Wrap slot not found', $params);
+ }
+
+ $tree_builder->pushCursor($insertionPoint, $this->location);
+ }
+
+ function isDynamicWrap()
+ {
+ return $this->is_dynamic;
+ }
+
+ protected function _collectIntos()
+ {
+ return $this->findImmediateChildrenByClass('lmbMacroIntoTag');
+ }
+
+ function generateContents($code)
+ {
+ if($this->is_dynamic)
+ {
+ $handlers_str = 'array(';
+ $methods = array();
+
+ //collecting {{into}} tags
+ if($intos = $this->_collectIntos())
+ {
+ foreach($intos as $into)
+ {
+ $methods[$into->get('slot')] = $code->beginMethod('__slotHandler'. uniqid());
+ $into->generateContents($code);
+ $code->endMethod();
+ }
+ }
+ else
+ {
+ $methods[$this->get('into')] = $code->beginMethod('__slotHandler'. uniqid());
+ parent :: generateContents($code);
+ $code->endMethod();
+ }
+
+ foreach($methods as $slot => $method)
+ $handlers_str .= '"' . $slot . '"' . ' => array($this, "' . $method . '"),';
+
+ $handlers_str .= ')';
+
+ $code->writePHP('$this->wrapTemplate(' . $this->getEscaped('with') . ', ' . $handlers_str . ');');
+ }
+ else
+ parent :: generateContents($code);
+ }
+}
+
Deleted: 3.x/trunk/limb/macro/src/tags/include.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/include.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/include.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,98 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * class lmbMacroIncludeTag.
- *
- * @tag include
- * @package macro
- * @version $Id$
- */
-class lmbMacroIncludeTag extends lmbMacroTag
-{
- function preParse($compiler)
- {
- parent :: preParse($compiler);
-
- $locator = $compiler->getTemplateLocator();
-
- if(!$file = $this->get('file'))
- $this->raiseRequiredAttributeError($file);
-
- if(!$this->_isDynamic())
- {
- $source_file = $locator->locateSourceTemplate($file);
- if(empty($source_file))
- $this->raise('Template source file not found', array('file_name' => $file));
-
- $compiler->parseTemplate($file, $this);
- }
- }
-
- function _isDynamic()
- {
- return $this->isDynamic('file');
- }
-
- function generateContents($code)
- {
- if($this->_isDynamic())
- $this->_generateDynamicContents($code);
- else
- $this->_generateStaticContents($code);
- }
-
- function _generateDynamicContents($code)
- {
- $args = $this->_attributesIntoArray();
-
- $arg_str = 'array(';
- foreach($args as $key => $value)
- $arg_str .= "'$key' => $value,";
- $arg_str .= ')';
-
- $code->writePHP('$this->includeTemplate(' . $this->get('file') . ',' . $arg_str . ');');
- }
-
- function _generateStaticContents($code)
- {
- static $counter = 1;
-
- list($keys, $vals) = $this->_attributesIntoArgs();
-
- $method = $code->beginMethod('__staticInclude' . ($counter++), $keys);
- parent :: generateContents($code);
- $code->endMethod();
-
- $code->writePHP('$this->' . $method . '(' . implode(', ', $vals) . ');');
- }
-
- protected function _attributesIntoArgs()
- {
- $keys = array();
- $vals = array();
- foreach($this->attributes as $k => $attribute)
- {
- $keys[] = '$' . $k;
- $vals[] = $this->getEscaped($k);
- }
- return array($keys, $vals);
- }
-
- protected function _attributesIntoArray()
- {
- $arr = array();
- foreach($this->attributes as $k => $attribute)
- $arr[$k] = $this->getEscaped($k);
- return $arr;
- }
-}
-
Deleted: 3.x/trunk/limb/macro/src/tags/into.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/into.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/into.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,50 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * class lmbMacroIntoTag.
- *
- * @tag into
- * @package macro
- * @version $Id$
- */
-class lmbMacroIntoTag extends lmbMacroTag
-{
- function preParse($compiler)
- {
- parent :: preParse($compiler);
-
- if(!$this->parent->isDynamicWrap())
- {
- $tree_builder = $compiler->getTreeBuilder();
- $this->_insert($this->parent, $tree_builder, $this->get('slot'));
- }
- }
-
- function _insert($wrapper, $tree_builder, $point)
- {
- $insertionPoint = $wrapper->findChild($point);
- if(empty($insertionPoint))
- {
- $params = array('slot' => $point);
- if($wrapper !== $this)
- {
- $params['parent_wrap_tag_file'] = $wrapper->getTemplateFile();
- $params['parent_wrap_tag_line'] = $wrapper->getTemplateLine();
- }
-
- $this->raise('Wrap slot not found', $params);
- }
-
- $tree_builder->pushCursor($insertionPoint, $this->location);
- }
-}
-
Copied: 3.x/trunk/limb/macro/src/tags/list/list.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/list.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list/list.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/list/list.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,139 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * The parent compile time component for lists
+ * @tag list
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroListTag extends lmbMacroTag
+{
+ protected $counter_var_var;
+ protected $count_source = false;
+
+ function countSource()
+ {
+ $this->count_source = true;
+ }
+
+ function generateContents($code)
+ {
+ if(!$as = $this->get('as'))
+ $as = '$item';
+
+ //internal list counter
+ $this->counter_var = $code->generateVar();
+ $code->writePHP($this->counter_var . ' = 0;');
+
+ $this->_prepareSourceVar($code);
+
+ $code->writePHP('foreach(' . $this->source_var . ' as ' . $as . ') {');
+
+ if($user_counter = $this->get('counter'))
+ $code->writePHP($user_counter . ' = ' . $this->counter_var . '+1;');
+
+ if($parity = $this->get('parity'))
+ $code->writePHP($parity . ' = (( (' . $this->counter_var . ' + 1) % 2) ? "odd" : "even");');
+
+ $found_item_tag = false;
+ $postponed_nodes = array();
+
+ foreach($this->children as $child)
+ {
+ //we want to skip some of {{list:*}} tags, since they are rendered manually
+ if(!$this->_isOneOfListTags($child))
+ {
+ //tags before {{list:item}} should be rendered only once when counter is 0
+ if(!$found_item_tag)
+ {
+ $code->writePHP('if(' . $this->counter_var . ' == 0) {');
+ $child->generateContents($code);
+ $code->writePHP('}');
+ }
+ //otherwise we collect them to display later
+ else
+ $postponed_nodes[] = $child;
+ }
+ elseif(is_a($child, 'lmbMacroListItemTag'))
+ {
+ $found_item_tag = true;
+ $child->generateContents($code);
+ }
+ }
+
+ $code->writePHP($this->counter_var . '++;');
+ $code->writePHP('}');
+
+ //tags after {{list:item}} should be rendered only if there were any items
+ foreach($postponed_nodes as $node)
+ {
+ $code->writePHP('if(' . $this->counter_var . ' > 0) {');
+ $node->generateContents($code);
+ $code->writePHP('}');
+ }
+
+ $this->_renderEmptyTag($code);
+ }
+
+ function getCounterVar()
+ {
+ return $this->counter_var;
+ }
+
+ function getSourceVar()
+ {
+ return $this->source_var;
+ }
+
+ protected function _isOneOfListTags($node)
+ {
+ $classes = array('lmbMacroListEmptyTag',
+ 'lmbMacroListItemTag');
+
+ foreach($classes as $class)
+ {
+ if(is_a($node, $class))
+ return true;
+ }
+ return false;
+ }
+
+ protected function _prepareSourceVar($code)
+ {
+ if(!$using = $this->get('for'))
+ $using = $this->get('using');
+
+ $this->source_var = $code->generateVar();
+ $item_var = $code->generateVar();
+
+ if($this->count_source)
+ {
+ $code->writePHP($this->source_var . " = array();\n");
+ $code->writePHP('foreach(' . $using . " as $item_var) {\n");
+ $code->writePHP($this->source_var . "[] = $item_var;\n");
+ $code->writePHP("}\n;");
+ }
+ else
+ $code->writePHP($this->source_var . " = {$using};\n");
+ }
+
+ protected function _renderEmptyTag($code)
+ {
+ if($list_empty = $this->findImmediateChildByClass('lmbMacroListEmptyTag'))
+ {
+ $code->writePHP('if(' . $this->counter_var . ' == 0) {');
+ $list_empty->generateContents($code);
+ $code->writePHP('}');
+ }
+ }
+}
+
Copied: 3.x/trunk/limb/macro/src/tags/list/list_empty.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/list_empty.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list/list_empty.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/list/list_empty.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,21 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * Empty List tag for a list which failed to have any contents
+ * @tag list:empty
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroListEmptyTag extends lmbMacroTag
+{
+}
+
Copied: 3.x/trunk/limb/macro/src/tags/list/list_even.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/list_even.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list/list_even.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/list/list_even.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,30 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * Renders a portion of the template if the current list row is even
+ * @tag list:even
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroListRowEvenTag extends lmbMacroTag
+{
+ function generateContents($code)
+ {
+ $list = $this->findParentByClass('lmbMacroListTag');
+ $counter_var = $list->getCounterVar();
+
+ $code->writePHP('if(('. $counter_var . '+1) % 2 == 0) {');
+ parent :: generateContents($code);
+ $code->writePHP('}');
+ }
+}
+
Copied: 3.x/trunk/limb/macro/src/tags/list/list_fill.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/list_fill.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list/list_fill.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/list/list_fill.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,50 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * Compile time component for output finalizers in a list
+ * Allows to generate valid layout while output multicolumn lists
+ * Default ratio attribute is 1 * @tag list:fill
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroListFillTag extends lmbMacroTag
+{
+ function generateContents($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() . ');');
+
+ $code->writePhp("if ({$count_var}/{$ratio_var} > 1) \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 :: generateContents($code);
+
+ $code->writePhp('}'. "\n");
+ }
+}
+
Copied: 3.x/trunk/limb/macro/src/tags/list/list_glue.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/list_glue.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list/list_glue.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/list/list_glue.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,86 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * Compile time component for separators in a list
+ * @tag list:glue
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroListGlueTag extends lmbMacroTag
+{
+ protected $step_var;
+ protected $helper_var;
+
+ function preParse($compiler)
+ {
+ $list = $this->findParentByClass('lmbMacroListTag');
+ $list->countSource();
+ }
+
+ function generateContents($code)
+ {
+ $step_var = $this->getStepVar($code);
+ $helper_var = $this->getHelperVar($code);
+
+ $code->writePHP("if(!isset({$helper_var})){\n");
+ $code->registerInclude('limb/macro/src/helpers/lmbMacroListGlueHelper.class.php');
+ $code->writePHP($helper_var . " = new lmbMacroListGlueHelper();\n");
+
+ if($step = $this->get('step'))
+ $code->writePHP($step_var . " = {$step};\n");
+ else
+ $code->writePHP($step_var . " = 1;\n");
+
+ $code->writePhp($helper_var . "->setStep({$step_var});\n");
+ $list = $this->findParentByClass('lmbMacroListTag');
+ $source_var = $list->getSourceVar();
+ $code->writePhp($helper_var . "->setTotalItems(count($source_var));\n");
+
+ $code->writePHP("}\n");
+
+ $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)
+ {
+ $code->writePhp('if (' . $separator->getStepVar($code) . ' < ' . $step_var . ') ');
+ $code->writePhp($separator->getHelperVar($code) . "->skipNext();\n");
+ }
+ }
+
+ parent :: generateContents($code);
+
+ $code->writePhp("}\n");
+ }
+
+ function getStepVar($code)
+ {
+ if(!$this->step_var)
+ $this->step_var = $code->generateVar();
+
+ return $this->step_var;
+ }
+
+ function getHelperVar($code)
+ {
+ if(!$this->helper_var)
+ $this->helper_var = $code->generateVar();
+ return $this->helper_var;
+ }
+}
+
Copied: 3.x/trunk/limb/macro/src/tags/list/list_item.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/list_item.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list/list_item.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/list/list_item.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,21 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * Compile time component for items (rows) in the list
+ * @tag list:item
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroListItemTag extends lmbMacroTag
+{
+}
+
Copied: 3.x/trunk/limb/macro/src/tags/list/list_odd.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/list_odd.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list/list_odd.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/list/list_odd.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,30 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * Renders a portion of the template if the current list row is odd
+ * @tag list:odd
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroListRowOddTag extends lmbMacroTag
+{
+ function generateContents($code)
+ {
+ $list = $this->findParentByClass('lmbMacroListTag');
+ $counter_var = $list->getCounterVar();
+
+ $code->writePHP('if(('. $counter_var . ' + 1) % 2 != 0) {');
+ parent :: generateContents($code);
+ $code->writePHP('}');
+ }
+}
+
Deleted: 3.x/trunk/limb/macro/src/tags/list.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/list.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,139 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * The parent compile time component for lists
- * @tag list
- * @package macro
- * @version $Id$
- */
-class lmbMacroListTag extends lmbMacroTag
-{
- protected $counter_var_var;
- protected $count_source = false;
-
- function countSource()
- {
- $this->count_source = true;
- }
-
- function generateContents($code)
- {
- if(!$as = $this->get('as'))
- $as = '$item';
-
- //internal list counter
- $this->counter_var = $code->generateVar();
- $code->writePHP($this->counter_var . ' = 0;');
-
- $this->_prepareSourceVar($code);
-
- $code->writePHP('foreach(' . $this->source_var . ' as ' . $as . ') {');
-
- if($user_counter = $this->get('counter'))
- $code->writePHP($user_counter . ' = ' . $this->counter_var . '+1;');
-
- if($parity = $this->get('parity'))
- $code->writePHP($parity . ' = (( (' . $this->counter_var . ' + 1) % 2) ? "odd" : "even");');
-
- $found_item_tag = false;
- $postponed_nodes = array();
-
- foreach($this->children as $child)
- {
- //we want to skip some of {{list:*}} tags, since they are rendered manually
- if(!$this->_isOneOfListTags($child))
- {
- //tags before {{list:item}} should be rendered only once when counter is 0
- if(!$found_item_tag)
- {
- $code->writePHP('if(' . $this->counter_var . ' == 0) {');
- $child->generateContents($code);
- $code->writePHP('}');
- }
- //otherwise we collect them to display later
- else
- $postponed_nodes[] = $child;
- }
- elseif(is_a($child, 'lmbMacroListItemTag'))
- {
- $found_item_tag = true;
- $child->generateContents($code);
- }
- }
-
- $code->writePHP($this->counter_var . '++;');
- $code->writePHP('}');
-
- //tags after {{list:item}} should be rendered only if there were any items
- foreach($postponed_nodes as $node)
- {
- $code->writePHP('if(' . $this->counter_var . ' > 0) {');
- $node->generateContents($code);
- $code->writePHP('}');
- }
-
- $this->_renderEmptyTag($code);
- }
-
- function getCounterVar()
- {
- return $this->counter_var;
- }
-
- function getSourceVar()
- {
- return $this->source_var;
- }
-
- protected function _isOneOfListTags($node)
- {
- $classes = array('lmbMacroListEmptyTag',
- 'lmbMacroListItemTag');
-
- foreach($classes as $class)
- {
- if(is_a($node, $class))
- return true;
- }
- return false;
- }
-
- protected function _prepareSourceVar($code)
- {
- if(!$using = $this->get('for'))
- $using = $this->get('using');
-
- $this->source_var = $code->generateVar();
- $item_var = $code->generateVar();
-
- if($this->count_source)
- {
- $code->writePHP($this->source_var . " = array();\n");
- $code->writePHP('foreach(' . $using . " as $item_var) {\n");
- $code->writePHP($this->source_var . "[] = $item_var;\n");
- $code->writePHP("}\n;");
- }
- else
- $code->writePHP($this->source_var . " = {$using};\n");
- }
-
- protected function _renderEmptyTag($code)
- {
- if($list_empty = $this->findImmediateChildByClass('lmbMacroListEmptyTag'))
- {
- $code->writePHP('if(' . $this->counter_var . ' == 0) {');
- $list_empty->generateContents($code);
- $code->writePHP('}');
- }
- }
-}
-
Deleted: 3.x/trunk/limb/macro/src/tags/list_empty.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list_empty.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/list_empty.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,21 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * Empty List tag for a list which failed to have any contents
- * @tag list:empty
- * @package macro
- * @version $Id$
- */
-class lmbMacroListEmptyTag extends lmbMacroTag
-{
-}
-
Deleted: 3.x/trunk/limb/macro/src/tags/list_even.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list_even.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/list_even.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,30 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * Renders a portion of the template if the current list row is even
- * @tag list:even
- * @package macro
- * @version $Id$
- */
-class lmbMacroListRowEvenTag extends lmbMacroTag
-{
- function generateContents($code)
- {
- $list = $this->findParentByClass('lmbMacroListTag');
- $counter_var = $list->getCounterVar();
-
- $code->writePHP('if(('. $counter_var . '+1) % 2 == 0) {');
- parent :: generateContents($code);
- $code->writePHP('}');
- }
-}
-
Deleted: 3.x/trunk/limb/macro/src/tags/list_fill.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list_fill.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/list_fill.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,50 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * Compile time component for output finalizers in a list
- * Allows to generate valid layout while output multicolumn lists
- * Default ratio attribute is 1 * @tag list:fill
- * @package macro
- * @version $Id$
- */
-class lmbMacroListFillTag extends lmbMacroTag
-{
- function generateContents($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() . ');');
-
- $code->writePhp("if ({$count_var}/{$ratio_var} > 1) \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 :: generateContents($code);
-
- $code->writePhp('}'. "\n");
- }
-}
-
Deleted: 3.x/trunk/limb/macro/src/tags/list_glue.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list_glue.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/list_glue.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,86 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * Compile time component for separators in a list
- * @tag list:glue
- * @package macro
- * @version $Id$
- */
-class lmbMacroListGlueTag extends lmbMacroTag
-{
- protected $step_var;
- protected $helper_var;
-
- function preParse($compiler)
- {
- $list = $this->findParentByClass('lmbMacroListTag');
- $list->countSource();
- }
-
- function generateContents($code)
- {
- $step_var = $this->getStepVar($code);
- $helper_var = $this->getHelperVar($code);
-
- $code->writePHP("if(!isset({$helper_var})){\n");
- $code->registerInclude('limb/macro/src/helpers/lmbMacroListGlueHelper.class.php');
- $code->writePHP($helper_var . " = new lmbMacroListGlueHelper();\n");
-
- if($step = $this->get('step'))
- $code->writePHP($step_var . " = {$step};\n");
- else
- $code->writePHP($step_var . " = 1;\n");
-
- $code->writePhp($helper_var . "->setStep({$step_var});\n");
- $list = $this->findParentByClass('lmbMacroListTag');
- $source_var = $list->getSourceVar();
- $code->writePhp($helper_var . "->setTotalItems(count($source_var));\n");
-
- $code->writePHP("}\n");
-
- $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)
- {
- $code->writePhp('if (' . $separator->getStepVar($code) . ' < ' . $step_var . ') ');
- $code->writePhp($separator->getHelperVar($code) . "->skipNext();\n");
- }
- }
-
- parent :: generateContents($code);
-
- $code->writePhp("}\n");
- }
-
- function getStepVar($code)
- {
- if(!$this->step_var)
- $this->step_var = $code->generateVar();
-
- return $this->step_var;
- }
-
- function getHelperVar($code)
- {
- if(!$this->helper_var)
- $this->helper_var = $code->generateVar();
- return $this->helper_var;
- }
-}
-
Deleted: 3.x/trunk/limb/macro/src/tags/list_item.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list_item.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/list_item.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,21 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * Compile time component for items (rows) in the list
- * @tag list:item
- * @package macro
- * @version $Id$
- */
-class lmbMacroListItemTag extends lmbMacroTag
-{
-}
-
Deleted: 3.x/trunk/limb/macro/src/tags/list_odd.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list_odd.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/list_odd.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,30 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * Renders a portion of the template if the current list row is odd
- * @tag list:odd
- * @package macro
- * @version $Id$
- */
-class lmbMacroListRowOddTag extends lmbMacroTag
-{
- function generateContents($code)
- {
- $list = $this->findParentByClass('lmbMacroListTag');
- $counter_var = $list->getCounterVar();
-
- $code->writePHP('if(('. $counter_var . ' + 1) % 2 != 0) {');
- parent :: generateContents($code);
- $code->writePHP('}');
- }
-}
-
Deleted: 3.x/trunk/limb/macro/src/tags/slot.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/slot.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/slot.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,40 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * class lmbMacroSlotTag.
- *
- * @tag slot
- * @package macro
- * @version $Id$
- */
-class lmbMacroSlotTag extends lmbMacroTag
-{
- function generateContents($code)
- {
- $slot = $this->getId();
- //calling slot handler in case of dynamic wrapping
- $code->writePHP('if(isset($this->__slot_handler_' . $slot . ')) {');
- $code->writePHP('call_user_func_array($this->__slot_handler_' . $slot . ', array());');
- $code->writePHP('}');
-
- //we need to isolate statically wrapped template variables via method call
- //in case of dynamic call we don't have children, hence the check
- if($this->children)
- {
- $method = $code->beginMethod('__slotHandler' . uniqid());
- parent :: generateContents($code);
- $code->endMethod();
- $code->writePHP('$this->' . $method . '()');
- }
- }
-}
-
Deleted: 3.x/trunk/limb/macro/src/tags/template.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/template.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/template.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,30 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * @tag template
- * @package macro
- * @version $Id$
- */
-class lmbMacroTemplateTag extends lmbMacroTag
-{
- function generateContents($code)
- {
- $name = $this->get('name');
-
- $args = $code->generateVar();
- $code->beginMethod('_template'. $name, array($args . '= array()'));
- $code->writePHP("if($args) extract($args);");
- parent :: generateContents($code);
- $code->endMethod();
- }
-}
-
Copied: 3.x/trunk/limb/macro/src/tags/tree/tree.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/tree.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/tree/tree.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/tree/tree.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,93 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * @tag tree
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroTreeTag extends lmbMacroTag
+{
+ function generateContents($code)
+ {
+ if(!$level = $this->get('level'))
+ $level = '$level';
+
+ if(!$as = $this->get('as'))
+ $as = '$item';
+
+ if(!$kids_prop = $this->get('kids_prop'))
+ $kids_prop = 'kids';
+
+ $before_branch = $this->_getTagsBeforeBranch();
+ $after_branch = $this->_getTagsAfterBranch();
+ $branch = $this->findImmediateChildByClass('lmbMacroTreeBranchTag');
+
+ $tree = $this->get('using');
+
+ $items = $code->generateVar();
+ $counter = $code->generateVar();
+
+ $method = $code->beginMethod('_render_tree'. uniqid(), array($items, $level));
+ $code->writePHP($counter . '=0;');
+
+ $code->writePHP('foreach(' . $items . ' as ' . $as . ') {');
+
+ //rendering tags before branch
+ $code->writePHP('if(!' . $counter . ') {');
+ foreach($before_branch as $tag)
+ $tag->generateContents($code);
+ $code->writePHP('}');
+
+ $branch->setRecursionMethod($method);
+ $branch->generateContents($code);
+
+ $code->writePHP($counter . '++;');
+ $code->writePHP('}');//foreach
+
+ //rendering tags after branch
+ $code->writePHP('if(' . $counter . ') {');
+ foreach($after_branch as $tag)
+ $tag->generateContents($code);
+ $code->writePHP('}');
+
+ $code->endMethod();
+
+ $code->writePHP('$this->' . $method . '(' . $tree . ', 0);');
+ }
+
+ protected function _getTagsBeforeBranch()
+ {
+ $tags = array();
+ foreach($this->children as $child)
+ {
+ if(is_a($child, 'lmbMacroTreeBranchTag'))
+ break;
+ $tags[] = $child;
+ }
+ return $tags;
+ }
+
+ protected function _getTagsAfterBranch()
+ {
+ $tags = array();
+ $collect = false;
+ foreach($this->children as $child)
+ {
+ if($collect)
+ $tags[] = $child;
+ if(is_a($child, 'lmbMacroTreeBranchTag'))
+ $collect = true;
+ }
+ return $tags;
+ }
+}
+
Copied: 3.x/trunk/limb/macro/src/tags/tree/tree_branch.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/tree_branch.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/tree/tree_branch.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/tree/tree_branch.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,86 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * @tag tree:branch
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroTreeBranchTag extends lmbMacroTag
+{
+ protected $method;
+
+ function setRecursionMethod($name)
+ {
+ $this->method = $name;
+ }
+
+ function generateContents($code)
+ {
+ if(!$level = $this->parent->get('level'))
+ $level = '$level';
+
+ if(!$as = $this->parent->get('as'))
+ $as = '$item';
+
+ if(!$kids_prop = $this->parent->get('kids_prop'))
+ $kids_prop = 'kids';
+
+ $before_item = $this->_getTagsBeforeItem();
+ $after_item = $this->_getTagsAfterItem();
+ $item = $this->findImmediateChildByClass('lmbMacroTreeItemTag');
+
+ $code->writePHP('if(isset(' . $as . '["' . $kids_prop . '"])) {');
+
+ foreach($before_item as $tag)
+ $tag->generateContents($code);
+
+ $item->generateContents($code);
+
+ $code->writePHP('$this->' . $this->method . '(' . $as . '["' . $kids_prop . '"], ' . $level . ' + 1);');
+
+ foreach($after_item as $tag)
+ $tag->generateContents($code);
+
+ $code->writePHP('} else {');
+
+ parent :: generateContents($code);
+
+ $code->writePHP('}');
+ }
+
+ protected function _getTagsBeforeItem()
+ {
+ $tags = array();
+ foreach($this->children as $child)
+ {
+ if(is_a($child, 'lmbMacroTreeItemTag'))
+ break;
+ $tags[] = $child;
+ }
+ return $tags;
+ }
+
+ protected function _getTagsAfterItem()
+ {
+ $tags = array();
+ $collect = false;
+ foreach($this->children as $child)
+ {
+ if($collect)
+ $tags[] = $child;
+ if(is_a($child, 'lmbMacroTreeItemTag'))
+ $collect = true;
+ }
+ return $tags;
+ }
+}
+
Copied: 3.x/trunk/limb/macro/src/tags/tree/tree_item.tag.php (from rev 6506, 3.x/trunk/limb/macro/src/tags/tree_item.tag.php)
===================================================================
--- 3.x/trunk/limb/macro/src/tags/tree/tree_item.tag.php (rev 0)
+++ 3.x/trunk/limb/macro/src/tags/tree/tree_item.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -0,0 +1,20 @@
+<?php
+/*
+ * Limb PHP Framework
+ *
+ * @link http://limb-project.com
+ * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ */
+
+lmb_require('limb/macro/src/lmbMacroTag.class.php');
+
+/**
+ * @tag tree:item
+ * @package macro
+ * @version $Id$
+ */
+class lmbMacroTreeItemTag extends lmbMacroTag
+{
+}
+
Deleted: 3.x/trunk/limb/macro/src/tags/tree.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/tree.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/tree.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,93 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * @tag tree
- * @package macro
- * @version $Id$
- */
-class lmbMacroTreeTag extends lmbMacroTag
-{
- function generateContents($code)
- {
- if(!$level = $this->get('level'))
- $level = '$level';
-
- if(!$as = $this->get('as'))
- $as = '$item';
-
- if(!$kids_prop = $this->get('kids_prop'))
- $kids_prop = 'kids';
-
- $before_branch = $this->_getTagsBeforeBranch();
- $after_branch = $this->_getTagsAfterBranch();
- $branch = $this->findImmediateChildByClass('lmbMacroTreeBranchTag');
-
- $tree = $this->get('using');
-
- $items = $code->generateVar();
- $counter = $code->generateVar();
-
- $method = $code->beginMethod('_render_tree'. uniqid(), array($items, $level));
- $code->writePHP($counter . '=0;');
-
- $code->writePHP('foreach(' . $items . ' as ' . $as . ') {');
-
- //rendering tags before branch
- $code->writePHP('if(!' . $counter . ') {');
- foreach($before_branch as $tag)
- $tag->generateContents($code);
- $code->writePHP('}');
-
- $branch->setRecursionMethod($method);
- $branch->generateContents($code);
-
- $code->writePHP($counter . '++;');
- $code->writePHP('}');//foreach
-
- //rendering tags after branch
- $code->writePHP('if(' . $counter . ') {');
- foreach($after_branch as $tag)
- $tag->generateContents($code);
- $code->writePHP('}');
-
- $code->endMethod();
-
- $code->writePHP('$this->' . $method . '(' . $tree . ', 0);');
- }
-
- protected function _getTagsBeforeBranch()
- {
- $tags = array();
- foreach($this->children as $child)
- {
- if(is_a($child, 'lmbMacroTreeBranchTag'))
- break;
- $tags[] = $child;
- }
- return $tags;
- }
-
- protected function _getTagsAfterBranch()
- {
- $tags = array();
- $collect = false;
- foreach($this->children as $child)
- {
- if($collect)
- $tags[] = $child;
- if(is_a($child, 'lmbMacroTreeBranchTag'))
- $collect = true;
- }
- return $tags;
- }
-}
-
Deleted: 3.x/trunk/limb/macro/src/tags/tree_branch.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/tree_branch.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/tree_branch.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,86 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * @tag tree:branch
- * @package macro
- * @version $Id$
- */
-class lmbMacroTreeBranchTag extends lmbMacroTag
-{
- protected $method;
-
- function setRecursionMethod($name)
- {
- $this->method = $name;
- }
-
- function generateContents($code)
- {
- if(!$level = $this->parent->get('level'))
- $level = '$level';
-
- if(!$as = $this->parent->get('as'))
- $as = '$item';
-
- if(!$kids_prop = $this->parent->get('kids_prop'))
- $kids_prop = 'kids';
-
- $before_item = $this->_getTagsBeforeItem();
- $after_item = $this->_getTagsAfterItem();
- $item = $this->findImmediateChildByClass('lmbMacroTreeItemTag');
-
- $code->writePHP('if(isset(' . $as . '["' . $kids_prop . '"])) {');
-
- foreach($before_item as $tag)
- $tag->generateContents($code);
-
- $item->generateContents($code);
-
- $code->writePHP('$this->' . $this->method . '(' . $as . '["' . $kids_prop . '"], ' . $level . ' + 1);');
-
- foreach($after_item as $tag)
- $tag->generateContents($code);
-
- $code->writePHP('} else {');
-
- parent :: generateContents($code);
-
- $code->writePHP('}');
- }
-
- protected function _getTagsBeforeItem()
- {
- $tags = array();
- foreach($this->children as $child)
- {
- if(is_a($child, 'lmbMacroTreeItemTag'))
- break;
- $tags[] = $child;
- }
- return $tags;
- }
-
- protected function _getTagsAfterItem()
- {
- $tags = array();
- $collect = false;
- foreach($this->children as $child)
- {
- if($collect)
- $tags[] = $child;
- if(is_a($child, 'lmbMacroTreeItemTag'))
- $collect = true;
- }
- return $tags;
- }
-}
-
Deleted: 3.x/trunk/limb/macro/src/tags/tree_item.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/tree_item.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/tree_item.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,20 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * @tag tree:item
- * @package macro
- * @version $Id$
- */
-class lmbMacroTreeItemTag extends lmbMacroTag
-{
-}
-
Deleted: 3.x/trunk/limb/macro/src/tags/wrap.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/wrap.tag.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/src/tags/wrap.tag.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -1,117 +0,0 @@
-<?php
-/*
- * Limb PHP Framework
- *
- * @link http://limb-project.com
- * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- */
-
-lmb_require('limb/macro/src/lmbMacroTag.class.php');
-
-/**
- * class lmbMacroWrapTag.
- *
- * @tag wrap
- * @package macro
- * @version $Id$
- */
-class lmbMacroWrapTag extends lmbMacroTag
-{
- protected $is_dynamic = false;
-
- function preParse($compiler)
- {
- parent :: preParse($compiler);
-
- if($this->isDynamic('with'))
- $this->is_dynamic = true;
-
- if(!$this->is_dynamic)
- {
- $file = $this->get('with');
- $this->_compileSourceFileName($file, $compiler);
-
- //if there's no 'into' attribute we consider that {{into}} tags used instead
- if($into = $this->get('into'))
- {
- $tree_builder = $compiler->getTreeBuilder();
- $this->_insert($this, $tree_builder, $into);
- }
- }
- }
-
- protected function _compileSourceFileName($file, $compiler)
- {
- $this->sourcefile = $compiler->getTemplateLocator()->locateSourceTemplate($file);
-
- if(empty($this->sourcefile))
- $this->raise('Template source file not found', array('file_name' => $file));
-
- $compiler->parseTemplate($file, $this);
- }
-
- function _insert($wrapper, $tree_builder, $point)
- {
- $insertionPoint = $wrapper->findChild($point);
- if(empty($insertionPoint))
- {
- $params = array('slot' => $point);
- if($wrapper !== $this)
- {
- $params['parent_wrap_tag_file'] = $wrapper->getTemplateFile();
- $params['parent_wrap_tag_line'] = $wrapper->getTemplateLine();
- }
-
- $this->raise('Wrap slot not found', $params);
- }
-
- $tree_builder->pushCursor($insertionPoint, $this->location);
- }
-
- function isDynamicWrap()
- {
- return $this->is_dynamic;
- }
-
- protected function _collectIntos()
- {
- return $this->findImmediateChildrenByClass('lmbMacroIntoTag');
- }
-
- function generateContents($code)
- {
- if($this->is_dynamic)
- {
- $handlers_str = 'array(';
- $methods = array();
-
- //collecting {{into}} tags
- if($intos = $this->_collectIntos())
- {
- foreach($intos as $into)
- {
- $methods[$into->get('slot')] = $code->beginMethod('__slotHandler'. uniqid());
- $into->generateContents($code);
- $code->endMethod();
- }
- }
- else
- {
- $methods[$this->get('into')] = $code->beginMethod('__slotHandler'. uniqid());
- parent :: generateContents($code);
- $code->endMethod();
- }
-
- foreach($methods as $slot => $method)
- $handlers_str .= '"' . $slot . '"' . ' => array($this, "' . $method . '"),';
-
- $handlers_str .= ')';
-
- $code->writePHP('$this->wrapTemplate(' . $this->getEscaped('with') . ', ' . $handlers_str . ');');
- }
- else
- parent :: generateContents($code);
- }
-}
-
Modified: 3.x/trunk/limb/macro/tests/cases/lmbMacroTagDictionaryTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbMacroTagDictionaryTest.class.php 2007-11-08 15:09:59 UTC (rev 6509)
+++ 3.x/trunk/limb/macro/tests/cases/lmbMacroTagDictionaryTest.class.php 2007-11-09 09:30:35 UTC (rev 6510)
@@ -11,6 +11,7 @@
lmb_require('limb/macro/src/lmbMacroTag.class.php');
lmb_require('limb/macro/src/lmbMacroTagInfo.class.php');
lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
+lmb_require('limb/macro/src/lmbMacroConfig.class.php');
class lmbMacroTagDictionaryTest extends UnitTestCase
{
@@ -18,6 +19,7 @@
{
lmbFs :: rm(LIMB_VAR_DIR . '/tags/');
lmbFs :: mkdir(LIMB_VAR_DIR . '/tags/');
+ lmbFs :: mkdir(LIMB_VAR_DIR . '/tags/subfolder/');
}
function testFindTagInfo()
@@ -77,5 +79,43 @@
$this->assertEqual($dictionary->findTagInfo("foo_$rnd"), $tag_info1);
$this->assertEqual($dictionary->findTagInfo("bar_$rnd"), $tag_info2);
}
+
+ function testLoad()
+ {
+ $rnd = mt_rand();
+ $content1 = <<<EOD
+<?php
+/**
+ * @tag foo_{$rnd}
+ */
+class Foo{$rnd}Tag extends lmbMacroTag{}
+EOD;
+
+ $content2 = <<<EOD
+<?php
+/**
+ * @tag bar_{$rnd}
+ */
+class Bar{$rnd}Tag extends lmbMacroTag{}
+EOD;
+
+ file_put_contents($file1 = LIMB_VAR_DIR . '/tags/foo_' . $rnd . '.tag.php', $content1);
+ file_put_contents($file2 = LIMB_VAR_DIR . '/tags/subfolder/bar_' . $rnd . '.tag.php', $content2);
+
+ $tag_info1 = new lmbMacroTagInfo("foo_$rnd", "Foo{$rnd}Tag");
+ $tag_info1->setFile($file1);
+ $tag_info2 = new lmbMacroTagInfo("bar_$rnd", "Bar{$rnd}Tag");
+ $tag_info2->setFile($file2);
+
+ $config = new lmbMacroConfig();
+ $config->setTagsScanDirectories(array(LIMB_VAR_DIR . '/tags/'));
+
+ $dictionary = new lmbMacroTagDictionary();
+ $dictionary->load($config);
+
+ $this->assertEqual($dictionary->findTagInfo("foo_$rnd")->getTag(), $tag_info1->getTag());
+ $this->assertEqual($dictionary->findTagInfo("bar_$rnd")->getTag(), $tag_info2->getTag());
+ }
+
}
More information about the limb-svn
mailing list