[limb-svn] r6342 - in 3.x/trunk/limb: core fs/src macro/src macro/tests/cases macro/tests/cases/tags view/src/toolkit
svn at limb-project.com
svn at limb-project.com
Mon Oct 1 01:07:11 MSD 2007
Author: pachanga
Date: 2007-10-01 01:07:11 +0400 (Mon, 01 Oct 2007)
New Revision: 6342
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6342
Modified:
3.x/trunk/limb/core/common.inc.php
3.x/trunk/limb/fs/src/lmbFsTools.class.php
3.x/trunk/limb/macro/src/lmbMacroParser.class.php
3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php
3.x/trunk/limb/macro/src/lmbMacroTagParsingState.class.php
3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php
3.x/trunk/limb/macro/src/lmbMacroTemplateExecutor.class.php
3.x/trunk/limb/macro/src/lmbMacroTemplateLocator.class.php
3.x/trunk/limb/macro/tests/cases/lmbMacroTagAcceptanceTest.class.php
3.x/trunk/limb/macro/tests/cases/lmbMacroTemplateExecutorTest.class.php
3.x/trunk/limb/macro/tests/cases/lmbMacroTemplateTest.class.php
3.x/trunk/limb/macro/tests/cases/tags/lmbMacroIncludeTagTest.class.php
3.x/trunk/limb/macro/tests/cases/tags/lmbMacroListTagTest.class.php
3.x/trunk/limb/macro/tests/cases/tags/lmbMacroOutputTagTest.class.php
3.x/trunk/limb/macro/tests/cases/tags/lmbMacroWrapTagTest.class.php
3.x/trunk/limb/view/src/toolkit/lmbViewTools.class.php
Log:
-- lmbFsTools :: getFileLocator(..) can accept paths as array
Modified: 3.x/trunk/limb/core/common.inc.php
===================================================================
--- 3.x/trunk/limb/core/common.inc.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/core/common.inc.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -1,187 +1,187 @@
-<?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
- */
-
-/**
- * @package core
- * @version $Id$
- */
-$GLOBALS['LIMB_LAZY_CLASS_PATHS'] = array();
-
-function lmb_resolve_include_path($path)
-{
- //this will be replaced with stream_resolve_include_path() in the future versions of PHP
- foreach(lmb_get_include_path_items() as $dir)
- {
- $full_path = "$dir/$path";
- if(is_file($full_path) || is_dir($full_path))
- return $full_path;
- }
-}
-
-function lmb_is_readable($file)
-{
- $fh = @fopen($file, 'r', true);
- if(!is_resource($fh))
- return false;
-
- fclose($fh);
- return true;
-}
-
-function lmb_glob($path)
-{
- if(lmb_is_path_absolute($path))
- return glob($path);
-
- foreach(lmb_get_include_path_items() as $dir)
- {
- if($res = glob("$dir/$path"))
- return $res;
- }
- return array();
-}
-
-function lmb_get_include_path_items()
-{
- return explode(PATH_SEPARATOR, get_include_path());
-}
-
-function lmb_is_path_absolute($path)
-{
- if(!$path)
- return false;
-
- //very trivial check, is more comprehensive required?
- return (($path{0} == '/' || $path{0} == '\\') ||
- (strlen($path) > 2 && $path{1} == ':'));
-}
-
-function lmb_require($file_path, $optional = false)
-{
- static $tried = array();
-
- if(isset($tried[$file_path]))
- return;
- else
- $tried[$file_path] = true;
-
- if(strpos($file_path, '*') !== false)
- {
- foreach(lmb_glob($file_path) as $path)
- lmb_require($path, $optional);
- return;
- }
-
- if($optional && !lmb_is_readable($file_path))
- return;
-
- $file = basename($file_path);
- $items = explode('.', $file);
-
- if(isset($items[1]))
- {
- if($items[1] == 'class' || $items[1] == 'interface')
- {
- $GLOBALS['LIMB_LAZY_CLASS_PATHS'][$items[0]] = $file_path;
- return;
- }
- }
- else
- {
- if($items[1] == 'class' && class_exists($items[0], false))
- return;
- if($items[1] == 'interface' && interface_exists($items[0], false))
- return;
- }
-
- if(!include_once($file_path))
- throw new lmbException("Could not include source file '$file_path'");
-}
-
-function lmb_require_optional($file_path)
-{
- lmb_require($file_path, true);
-}
-
-function lmb_autoload($name)
-{
- if(isset($GLOBALS['LIMB_LAZY_CLASS_PATHS'][$name]))
- {
- $file_path = $GLOBALS['LIMB_LAZY_CLASS_PATHS'][$name];
- if(!include($file_path))
- throw new lmbException("Could not include source file '$file_path'");
- }
-}
-
-function lmb_var_dump($obj, $echo = false)
-{
- ob_start();
- var_dump($obj);
- $dump = ob_get_contents();
- ob_end_clean();
-
- if($echo)
- {
- if(PHP_SAPI != 'cli')
- {
- echo '<pre>';
- echo $dump;
- echo '</pre>';
- }
- else
- echo $dump;
- }
- else
- return $dump;
-}
-
-function lmb_camel_case($str, $ucfirst = true)
-{
- $items = explode('_', $str);
- $len = sizeof($items);
- $first = true;
- $res = '';
- for($i=0;$i<$len;$i++)
- {
- $item = $items[$i];
- if($item)
- {
- //we don't ucfirst first word by default
- $res .= ($first && !$ucfirst ? $item : ucfirst($item));
- $first = false;
- //skipping next "_" if it's not last
- if($i+1 < $len-1 && !$items[$i+1])
- $i++;
- }
- else
- $res .= '_';
- }
-
- return ($ucfirst) ? ucfirst($res) : $res;
-}
-
-function lmb_under_scores($str)
-{
- $items = preg_split('~([A-Z][a-z0-9]+)~', $str, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
- $res = '';
- foreach($items as $item)
- $res .= ($item == '_' ? '' : '_') . strtolower($item);
- return substr($res, 1);
-}
-
-function lmb_humanize($str)
-{
- return str_replace('_', ' ', lmb_uder_scores($str));
-}
-
-lmb_require('limb/core/src/exception/lmbException.class.php');
-
-spl_autoload_register('lmb_autoload');
-
-
+<?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
+ */
+
+/**
+ * @package core
+ * @version $Id$
+ */
+$GLOBALS['LIMB_LAZY_CLASS_PATHS'] = array();
+
+function lmb_resolve_include_path($path)
+{
+ //this will be replaced with stream_resolve_include_path() in the future versions of PHP
+ foreach(lmb_get_include_path_items() as $dir)
+ {
+ $full_path = "$dir/$path";
+ if(is_file($full_path) || is_dir($full_path))
+ return $full_path;
+ }
+}
+
+function lmb_is_readable($file)
+{
+ $fh = @fopen($file, 'r', true);
+ if(!is_resource($fh))
+ return false;
+
+ fclose($fh);
+ return true;
+}
+
+function lmb_glob($path)
+{
+ if(lmb_is_path_absolute($path))
+ return glob($path);
+
+ foreach(lmb_get_include_path_items() as $dir)
+ {
+ if($res = glob("$dir/$path"))
+ return $res;
+ }
+ return array();
+}
+
+function lmb_get_include_path_items()
+{
+ return explode(PATH_SEPARATOR, get_include_path());
+}
+
+function lmb_is_path_absolute($path)
+{
+ if(!$path)
+ return false;
+
+ //very trivial check, is more comprehensive required?
+ return (($path{0} == '/' || $path{0} == '\\') ||
+ (strlen($path) > 2 && $path{1} == ':'));
+}
+
+function lmb_require($file_path, $optional = false)
+{
+ static $tried = array();
+
+ if(isset($tried[$file_path]))
+ return;
+ else
+ $tried[$file_path] = true;
+
+ if(strpos($file_path, '*') !== false)
+ {
+ foreach(lmb_glob($file_path) as $path)
+ lmb_require($path, $optional);
+ return;
+ }
+
+ if($optional && !lmb_is_readable($file_path))
+ return;
+
+ $file = basename($file_path);
+ $items = explode('.', $file);
+
+ if(isset($items[1]))
+ {
+ if($items[1] == 'class' || $items[1] == 'interface')
+ {
+ $GLOBALS['LIMB_LAZY_CLASS_PATHS'][$items[0]] = $file_path;
+ return;
+ }
+ }
+ else
+ {
+ if($items[1] == 'class' && class_exists($items[0], false))
+ return;
+ if($items[1] == 'interface' && interface_exists($items[0], false))
+ return;
+ }
+
+ if(!include_once($file_path))
+ throw new lmbException("Could not include source file '$file_path'");
+}
+
+function lmb_require_optional($file_path)
+{
+ lmb_require($file_path, true);
+}
+
+function lmb_autoload($name)
+{
+ if(isset($GLOBALS['LIMB_LAZY_CLASS_PATHS'][$name]))
+ {
+ $file_path = $GLOBALS['LIMB_LAZY_CLASS_PATHS'][$name];
+ if(!include($file_path))
+ throw new lmbException("Could not include source file '$file_path'");
+ }
+}
+
+function lmb_var_dump($obj, $echo = false)
+{
+ ob_start();
+ var_dump($obj);
+ $dump = ob_get_contents();
+ ob_end_clean();
+
+ if($echo)
+ {
+ if(PHP_SAPI != 'cli')
+ {
+ echo '<pre>';
+ echo $dump;
+ echo '</pre>';
+ }
+ else
+ echo $dump;
+ }
+ else
+ return $dump;
+}
+
+function lmb_camel_case($str, $ucfirst = true)
+{
+ $items = explode('_', $str);
+ $len = sizeof($items);
+ $first = true;
+ $res = '';
+ for($i=0;$i<$len;$i++)
+ {
+ $item = $items[$i];
+ if($item)
+ {
+ //we don't ucfirst first word by default
+ $res .= ($first && !$ucfirst ? $item : ucfirst($item));
+ $first = false;
+ //skipping next "_" if it's not last
+ if($i+1 < $len-1 && !$items[$i+1])
+ $i++;
+ }
+ else
+ $res .= '_';
+ }
+
+ return ($ucfirst) ? ucfirst($res) : $res;
+}
+
+function lmb_under_scores($str)
+{
+ $items = preg_split('~([A-Z][a-z0-9]+)~', $str, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+ $res = '';
+ foreach($items as $item)
+ $res .= ($item == '_' ? '' : '_') . strtolower($item);
+ return substr($res, 1);
+}
+
+function lmb_humanize($str)
+{
+ return str_replace('_', ' ', lmb_uder_scores($str));
+}
+
+lmb_require('limb/core/src/exception/lmbException.class.php');
+
+spl_autoload_register('lmb_autoload');
+
+
Modified: 3.x/trunk/limb/fs/src/lmbFsTools.class.php
===================================================================
--- 3.x/trunk/limb/fs/src/lmbFsTools.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/fs/src/lmbFsTools.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -1,51 +1,54 @@
-<?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/toolkit/src/lmbAbstractTools.class.php');
-lmb_require('limb/fs/src/lmbFileLocator.class.php');
-lmb_require('limb/fs/src/lmbCachingFileLocator.class.php');
-lmb_require('limb/fs/src/lmbIncludePathFileLocations.class.php');
-
-/**
- * class lmbFsTools.
- *
- * @package fs
- * @version $Id$
- */
-class lmbFsTools extends lmbAbstractTools
-{
- protected $file_locators = array();
-
- function findFileByAlias($alias, $paths, $locator_name = null)
- {
- $locator = $this->toolkit->getFileLocator($paths, $locator_name);
- return $locator->locate($alias);
- }
-
- function getFileLocator($paths, $locator_name = null)
- {
- if(!$locator_name)
- $locator_name = md5($paths);
-
- if(isset($this->file_locators[$locator_name]))
- return $this->file_locators[$locator_name];
-
- $file_locations = new lmbIncludePathFileLocations(explode(';', $paths));
-
- if(defined('LIMB_VAR_DIR'))
- $locator = new lmbCachingFileLocator(new lmbFileLocator($file_locations),
- LIMB_VAR_DIR . '/locators/',
- $locator_name);
- else
- $locator = new lmbFileLocator($file_locations);
-
- $this->file_locators[$locator_name] = $locator;
- return $locator;
- }
-}
-
+<?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/toolkit/src/lmbAbstractTools.class.php');
+lmb_require('limb/fs/src/lmbFileLocator.class.php');
+lmb_require('limb/fs/src/lmbCachingFileLocator.class.php');
+lmb_require('limb/fs/src/lmbIncludePathFileLocations.class.php');
+
+/**
+ * class lmbFsTools.
+ *
+ * @package fs
+ * @version $Id$
+ */
+class lmbFsTools extends lmbAbstractTools
+{
+ protected $file_locators = array();
+
+ function findFileByAlias($alias, $paths, $locator_name = null)
+ {
+ $locator = $this->toolkit->getFileLocator($paths, $locator_name);
+ return $locator->locate($alias);
+ }
+
+ function getFileLocator($paths, $locator_name = null)
+ {
+ if(!$locator_name)
+ $locator_name = md5($paths);
+
+ if(isset($this->file_locators[$locator_name]))
+ return $this->file_locators[$locator_name];
+
+ if(is_array($paths))
+ $file_locations = new lmbIncludePathFileLocations($paths);
+ else
+ $file_locations = new lmbIncludePathFileLocations(explode(';', $paths));
+
+ if(defined('LIMB_VAR_DIR'))
+ $locator = new lmbCachingFileLocator(new lmbFileLocator($file_locations),
+ LIMB_VAR_DIR . '/locators/',
+ $locator_name);
+ else
+ $locator = new lmbFileLocator($file_locations);
+
+ $this->file_locators[$locator_name] = $locator;
+ return $locator;
+ }
+}
+
Modified: 3.x/trunk/limb/macro/src/lmbMacroParser.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroParser.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/macro/src/lmbMacroParser.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -77,7 +77,7 @@
$this->setTemplateLocator($this->template_locator);
- $content = $this->template_locator->readTemplateFile($source_file_path);
+ $content = file_get_contents($source_file_path);
$this->preprocessor->process($content);
Modified: 3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/macro/src/lmbMacroTagDictionary.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -30,6 +30,20 @@
return self :: $instance;
}
+ static function load(lmbMacroConfig $config)
+ {
+ $dictionary = self :: instance();
+
+ $dirs = $config->getTagsScanDirectories();
+ foreach($dirs as $dir)
+ {
+ foreach(lmb_glob($dir . '/*.tag.php') as $file)
+ $dictionary->registerFromFile($file);
+ }
+
+ return $dictionary;
+ }
+
function register($taginfo, $file)
{
$tag_to_lower = strtolower($taginfo->getTag());
Modified: 3.x/trunk/limb/macro/src/lmbMacroTagParsingState.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTagParsingState.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/macro/src/lmbMacroTagParsingState.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -20,7 +20,7 @@
{
protected $tag_dictionary;
- function __construct($parser, $tree_builder, $tag_dictionary)
+ function __construct(lmbMacroParser $parser, lmbMacroTreeBuilder $tree_builder, lmbMacroTagDictionary $tag_dictionary)
{
parent :: __construct($parser, $tree_builder);
$this->tag_dictionary = $tag_dictionary;
@@ -32,7 +32,8 @@
$lower_attributes = $this->normalizeAttributes($attrs, $location);
- $tag_info = $this->tag_dictionary->findTagInfo($tag);
+ if(!$tag_info = $this->tag_dictionary->findTagInfo($tag))
+ throw new lmbMacroException("Tag '$tag' not found in dictionary");
if($tag_info->isEndTagForbidden())
{
@@ -71,7 +72,8 @@
$location = $this->parser->getCurrentLocation();
$lower_attributes = $this->normalizeAttributes($attrs, $location);
- $tag_info = $this->tag_dictionary->findTagInfo($tag);
+ if(!$tag_info = $this->tag_dictionary->findTagInfo($tag))
+ throw new lmbMacroException("Tag '$tag' not found in dictionary");
$tag_info->load();
$tag_node = $this->buildTagNode($tag_info, $tag, $attrs, $self_closed_tag = true);
Modified: 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/macro/src/lmbMacroTemplate.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -10,6 +10,7 @@
lmb_require('limb/macro/src/lmbMacroTemplateLocator.class.php');
lmb_require('limb/macro/src/lmbMacroCompiler.class.php');
lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
+lmb_require('limb/macro/src/lmbMacroConfig.class.php');
/**
* class lmbMacroTemplate.
@@ -20,26 +21,18 @@
class lmbMacroTemplate
{
protected $file;
- protected $cache_dir;
protected $vars = array();
protected $child_executor;
- protected $tag_dictionary;
- function __construct($file, $cache_dir = null, $locator = null, $tag_dictionary = null)
+ function __construct($file, lmbMacroConfig $config = null)
{
$this->file = $file;
- if(!$cache_dir)
- $cache_dir = LIMB_VAR_DIR . '/compiled';
- $this->cache_dir = $cache_dir;
+ $this->config = $config ? $config : new lmbMacroConfig();
- if(!$locator)
- $locator = new lmbMacroTemplateLocator();
- $this->locator = $locator;
+ $this->locator = new lmbMacroTemplateLocator($this->config);
- if(!$tag_dictionary)
- $tag_dictionary = lmbMacroTagDictionary :: instance();
- $this->tag_dictionary = $tag_dictionary;
+ $this->tag_dictionary = lmbMacroTagDictionary :: load($this->config);
}
function setVars($vars)
@@ -70,7 +63,7 @@
$compiler->compile($source_file, $compiled_file, $class, 'render');
include($compiled_file);
- $executor = new $class($this->vars, $this->cache_dir, $this->locator);
+ $executor = new $class($this->config, $this->vars);
//in case of dynamic wrapping we need to ask parent for all unknown variables
if($this->child_executor)
Modified: 3.x/trunk/limb/macro/src/lmbMacroTemplateExecutor.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTemplateExecutor.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/macro/src/lmbMacroTemplateExecutor.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -15,17 +15,17 @@
*/
class lmbMacroTemplateExecutor
{
- protected $cache_dir;
- protected $locator;
- protected $context;
+ //we add prefixes in order to avoid possible conflict
+ //since variables are added directly
+ protected $__config;
+ protected $__context;
- function __construct($vars = array(), $cache_dir = null, $locator = null)
+ function __construct(lmbMacroConfig $config = null, $vars = array())
{
+ $this->__config = $config ? $config : new lmbMacroConfig();
+
foreach($vars as $name => $value)
$this->$name = $value;
-
- $this->cache_dir = $cache_dir;
- $this->locator = $locator;
}
function set($name, $value)
@@ -35,15 +35,15 @@
function setContext(lmbMacroTemplateExecutor $context)
{
- $this->context = $context;
+ $this->__context = $context;
}
function __get($name)
{
//we can have parent variable context which should be consulted for all missing variables
//actually, it's quite a dirty hack for a deeper problem which should be addressed later
- if($this->context)
- return $this->context->$name;
+ if($this->__context)
+ return $this->__context->$name;
//we definitely want to supress warnings, make it some sort of a NullObject?
return '';
@@ -56,14 +56,14 @@
function includeTemplate($file, $vars = array())
{
- $template = new lmbMacroTemplate($file, $this->cache_dir, $this->locator);
+ $template = new lmbMacroTemplate($file, $this->__config);
$template->setVars(get_object_vars($this));//global template vars
echo $template->render($vars);//local template vars
}
function wrapTemplate($file, $slots_handlers)
{
- $template = new lmbMacroTemplate($file, $this->cache_dir, $this->locator);
+ $template = new lmbMacroTemplate($file, $this->__config);
$template->setVars(get_object_vars($this));//global template vars
foreach($slots_handlers as $name => $handler)
$template->set('__slot_handler_' . $name, $handler);
Modified: 3.x/trunk/limb/macro/src/lmbMacroTemplateLocator.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/lmbMacroTemplateLocator.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/macro/src/lmbMacroTemplateLocator.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -7,6 +7,8 @@
* @license LGPL http://www.gnu.org/copyleft/lesser.html
*/
+lmb_require('limb/fs/toolkit.inc.php');
+
/**
* class lmbMacroTemplateLocator.
*
@@ -15,35 +17,30 @@
*/
class lmbMacroTemplateLocator
{
+ protected $config;
protected $cache_dir;
- protected $base_dir;
+ protected $scan_dirs;
+ protected $toolkit;
- function __construct($base_dir = null, $cache_dir = null)
+ function __construct(lmbMacroConfig $config)
{
- if(!$cache_dir)
- $cache_dir = LIMB_VAR_DIR . '/compiled';
-
- $this->cache_dir = $cache_dir;
- $this->base_dir = $base_dir;
+ $this->config = $config;
+ $this->cache_dir = $config->getCacheDir();
+ $this->scan_dirs = $config->getTemplateScanDirectories();
+ $this->toolkit = lmbToolkit :: instance();
}
- function locateCompiledTemplate($file_name)
- {
- return $this->cache_dir . '/' . md5($file_name) . '.php';
- }
-
function locateSourceTemplate($file_name)
{
- //fix this later
- if(lmbFs :: isPathAbsolute($file_name))
- return $file_name;
+ if(!lmbFs :: isPathAbsolute($file_name))
+ return $this->toolkit->findFileByAlias($file_name, $this->scan_dirs, 'macro');
else
- return $this->base_dir . '/' . $file_name;
+ return $file_name;
}
- function readTemplateFile($file_name)
- {
- return file_get_contents($file_name);
+ function locateCompiledTemplate($file_name)
+ {
+ return $this->cache_dir . '/' . md5($file_name) . '.php';
}
}
Modified: 3.x/trunk/limb/macro/tests/cases/lmbMacroTagAcceptanceTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbMacroTagAcceptanceTest.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/macro/tests/cases/lmbMacroTagAcceptanceTest.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -9,6 +9,7 @@
lmb_require('limb/macro/src/lmbMacroTemplate.class.php');
lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
+lmb_require('limb/macro/src/lmbMacroConfig.class.php');
lmb_require('limb/macro/src/lmbMacroTag.class.php');
lmb_require('limb/macro/src/lmbMacroTagInfo.class.php');
lmb_require('limb/fs/src/lmbFs.class.php');
@@ -56,7 +57,7 @@
$file = LIMB_VAR_DIR . '/tpl/' . mt_rand() . '.html';
file_put_contents($file, $code);
$cache_dir = LIMB_VAR_DIR . '/tpl/compiled';
- $tpl = new lmbMacroTemplate($file, $cache_dir);
+ $tpl = new lmbMacroTemplate($file, new lmbMacroConfig($cache_dir));
return $tpl;
}
}
Modified: 3.x/trunk/limb/macro/tests/cases/lmbMacroTemplateExecutorTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbMacroTemplateExecutorTest.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/macro/tests/cases/lmbMacroTemplateExecutorTest.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -13,7 +13,7 @@
{
function testPassVars()
{
- $tpl = new lmbMacroTemplateExecutor(array('foo' => 'foo', 'bar' => 'bar'));
+ $tpl = new lmbMacroTemplateExecutor(new lmbMacroConfig(), array('foo' => 'foo', 'bar' => 'bar'));
$tpl->set('zoo', 'zoo');
$this->assertEqual($tpl->foo, 'foo');
$this->assertEqual($tpl->bar, 'bar');
@@ -22,7 +22,7 @@
function testMissingVarIsEmpty()
{
- $tpl = new lmbMacroTemplateExecutor();
+ $tpl = new lmbMacroTemplateExecutor(new lmbMacroConfig());
$this->assertNoErrors();
$this->assertIdentical($tpl->junk, '');
}
Modified: 3.x/trunk/limb/macro/tests/cases/lmbMacroTemplateTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/lmbMacroTemplateTest.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/macro/tests/cases/lmbMacroTemplateTest.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -46,7 +46,7 @@
function _createView($tpl)
{
$file = $this->_createTemplate($tpl);
- $view = new lmbMacroTemplate($file, LIMB_VAR_DIR . '/view/compiled');
+ $view = new lmbMacroTemplate($file, new lmbMacroConfig(LIMB_VAR_DIR . '/view/compiled'));
return $view;
}
Modified: 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroIncludeTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroIncludeTagTest.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroIncludeTagTest.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -11,8 +11,6 @@
lmb_require('limb/fs/src/lmbFs.class.php');
lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
-lmbMacroTagDictionary :: instance()->registerFromFile(dirname(__FILE__) . '/../../../src/tags/include.tag.php');
-
class lmbMacroTagIncludeTest extends UnitTestCase
{
function setUp()
@@ -130,9 +128,7 @@
{
$base_dir = LIMB_VAR_DIR . '/tpl';
$cache_dir = LIMB_VAR_DIR . '/tpl/compiled';
- $macro = new lmbMacroTemplate($file,
- $cache_dir,
- new lmbMacroTemplateLocator($base_dir, $cache_dir));
+ $macro = new lmbMacroTemplate($file, new lmbMacroConfig($cache_dir, true, true, null, array($base_dir)));
return $macro;
}
Modified: 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroListTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroListTagTest.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroListTagTest.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -11,11 +11,6 @@
lmb_require('limb/macro/src/lmbMacroTemplate.class.php');
lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
-lmbMacroTagDictionary :: instance()->registerFromFile(dirname(__FILE__) . '/../../../src/tags/list.tag.php');
-lmbMacroTagDictionary :: instance()->registerFromFile(dirname(__FILE__) . '/../../../src/tags/list_item.tag.php');
-lmbMacroTagDictionary :: instance()->registerFromFile(dirname(__FILE__) . '/../../../src/tags/list_empty.tag.php');
-lmbMacroTagDictionary :: instance()->registerFromFile(dirname(__FILE__) . '/../../../src/tags/list_glue.tag.php');
-
class lmbMacroListTagTest extends UnitTestCase
{
function setUp()
@@ -122,9 +117,7 @@
{
$base_dir = LIMB_VAR_DIR . '/tpl';
$cache_dir = LIMB_VAR_DIR . '/tpl/compiled';
- $macro = new lmbMacroTemplate($file,
- $cache_dir,
- new lmbMacroTemplateLocator($base_dir, $cache_dir));
+ $macro = new lmbMacroTemplate($file, new lmbMacroConfig($cache_dir, true, true, array($base_dir)));
return $macro;
}
Modified: 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroOutputTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroOutputTagTest.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroOutputTagTest.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -10,10 +10,7 @@
lmb_require('limb/macro/src/lmbMacroTemplate.class.php');
lmb_require('limb/core/src/lmbObject.class.php');
lmb_require('limb/fs/src/lmbFs.class.php');
-lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
-//output tag is a special case, it's always registered in lmbMacroTagDictionary
-
class lmbMacroOutputTagTest extends UnitTestCase
{
function setUp()
@@ -133,9 +130,7 @@
{
$base_dir = LIMB_VAR_DIR . '/tpl';
$cache_dir = LIMB_VAR_DIR . '/tpl/compiled';
- $macro = new lmbMacroTemplate($file,
- $cache_dir,
- new lmbMacroTemplateLocator($base_dir, $cache_dir));
+ $macro = new lmbMacroTemplate($file, new lmbMacroConfig($cache_dir, true, true, array($base_dir)));
return $macro;
}
Modified: 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroWrapTagTest.class.php
===================================================================
--- 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroWrapTagTest.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/macro/tests/cases/tags/lmbMacroWrapTagTest.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -11,10 +11,6 @@
lmb_require('limb/macro/src/lmbMacroTemplate.class.php');
lmb_require('limb/macro/src/lmbMacroTagDictionary.class.php');
-lmbMacroTagDictionary :: instance()->registerFromFile(dirname(__FILE__) . '/../../../src/tags/wrap.tag.php');
-lmbMacroTagDictionary :: instance()->registerFromFile(dirname(__FILE__) . '/../../../src/tags/slot.tag.php');
-lmbMacroTagDictionary :: instance()->registerFromFile(dirname(__FILE__) . '/../../../src/tags/into.tag.php');
-
class lmbMacroWrapTagTest extends UnitTestCase
{
function setUp()
@@ -212,9 +208,7 @@
{
$base_dir = LIMB_VAR_DIR . '/tpl';
$cache_dir = LIMB_VAR_DIR . '/tpl/compiled';
- $macro = new lmbMacroTemplate($file,
- $cache_dir,
- new lmbMacroTemplateLocator($base_dir, $cache_dir));
+ $macro = new lmbMacroTemplate($file, new lmbMacroConfig($cache_dir, true, true, array($base_dir)));
return $macro;
}
Modified: 3.x/trunk/limb/view/src/toolkit/lmbViewTools.class.php
===================================================================
--- 3.x/trunk/limb/view/src/toolkit/lmbViewTools.class.php 2007-09-28 20:33:45 UTC (rev 6341)
+++ 3.x/trunk/limb/view/src/toolkit/lmbViewTools.class.php 2007-09-30 21:07:11 UTC (rev 6342)
@@ -10,6 +10,9 @@
@define('LIMB_TEMPLATES_INCLUDE_PATH', 'template;limb/*/template');
@define('LIMB_WACT_TAGS_INCLUDE_PATH', 'src/template/tags;limb/*/src/template/tags;limb/wact/src/tags');
+//TODO: migrate to settings below
+//@define('LIMB_WACT_TAGS_INCLUDE_PATH', 'src/wact;limb/*/src/wact;limb/wact/src/tags');
+ at define('LIMB_MACRO_TAGS_INCLUDE_PATH', 'src/macro;limb/*/src/macro;limb/macro/src/tags');
/**
* class lmbViewTools.
More information about the limb-svn
mailing list