Commit 9cf6ad5f by Seldaek

* Changed all class names to be PEAR compliant

git-svn-id: svn://dwoo.org/dwoo/trunk@33 0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent 5f3d81ca
[2008-04-] 0.4.0 (Happy Getty)
! BC Break: changed all class names to be PEAR compliant (aka use underscores
to separate words/paths), sorry about that but I better do it now than in
six months
! BC Break: $dwoo->output() and get() have been swapped internally, but it
doesn't change anything for you unless you called output(*, *, *, true)
directly to emulate get(). This was done to reduce some overhead
......@@ -20,10 +23,10 @@
+ Syntax: Added support for {$foo+=5}, {$foo="a"}, {$foo++} and {$foo--}
+ Syntax: Added shortcut for $dwoo.*, you can now use {$.foreach.foo} instead
of {$dwoo.foreach.foo} for example, applies to all $dwoo.* vars
+ API: Added getSource(), getUid() and getResourceIdentifier() to DwooITemplate
+ API: Added setSecurityPolicy() too DwooICompiler and modified the arguments
+ API: Added getSource(), getUid() and getResourceIdentifier() to Dwoo_ITemplate
+ API: Added setSecurityPolicy() too Dwoo_ICompiler and modified the arguments
of its compile() method
+ API: Added a bunch of utility functions to DwooCompiler, allowing compiled
+ API: Added a bunch of utility functions to Dwoo_Compiler, allowing compiled
plugins to access more of the compiler internals
* Moved all files to Dwoo/Class.php excepted for the core Dwoo.php file
* Fixed a classpath rebuilding bug that occured on some UNIX platforms due to
......@@ -33,18 +36,19 @@
doing {foreach $foo}..{/foreach} will not however, that way you don't have
to do {if isset($foo)} before the foreach, but automated isset() calls don't
impact performance as much as they did before.
* API: DwooITemplate->clearCache now requires a Dwoo instance as its first arg,
* API: Dwoo_ITemplate->clearCache now requires a Dwoo instance as its first arg,
should not affect you unless you built a custom template class from scratch
* Reworked Dwoo template rendering to avoid variable conflicts with plugins
* {include} now uses the current resource if none is provided instead of using
file as it did before
* Dwoo uses include path instead of absolute includes
* Fixed a regression in the handling of custom class plugins
* Fixed a bug in DwooSecurityPolicy->getAllowedDirectories(), no security
* Fixed a bug in Dwoo_Security_Policy->getAllowedDirectories(), no security
issue though
* Changed all line endings to Unix (line feed only) and all spaces left have
been converted to tabs (tabspace 4)
* TestFest happened early for Dwoo, lots of new tests and more code covered
* Fixed a bug in Dwoo::setScope affecting {loop} and {with}
[2008-04-09] 0.3.4
! BC Break: DWOO_PATH constant changed to DWOO_DIRECTORY
......
......@@ -20,7 +20,7 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooData implements DwooIDataProvider
class Dwoo_Data implements Dwoo_IDataProvider
{
/**
* data array
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
interface DwooIDataProvider
interface Dwoo_IDataProvider
{
/**
* returns the data as an associative array that will be used in the template
......@@ -48,7 +48,7 @@ interface DwooIDataProvider
* @date 2008-04-09
* @package Dwoo
*/
interface DwooITemplate
interface Dwoo_ITemplate
{
/**
* returns the cache duration for this template
......@@ -89,10 +89,10 @@ interface DwooITemplate
* returns the compiled template file name
*
* @param Dwoo $dwoo the dwoo instance that requests it
* @param DwooICompiler $compiler the compiler that must be used
* @param Dwoo_ICompiler $compiler the compiler that must be used
* @return string
*/
public function getCompiledTemplate(Dwoo $dwoo, DwooICompiler $compiler = null);
public function getCompiledTemplate(Dwoo $dwoo, Dwoo_ICompiler $compiler = null);
/**
* returns the template name
......@@ -133,7 +133,7 @@ interface DwooITemplate
/**
* returns the compiler used by this template, if it was just compiled, or null
*
* @return DwooICompiler
* @return Dwoo_ICompiler
*/
public function getCompiler();
......@@ -150,7 +150,7 @@ interface DwooITemplate
* to the current url
* @param string $compileId the unique compiled identifier, which is used to distinguish this
* template from others, if null it defaults to the filename+bits of the path
* @return DwooITemplate|null|false
* @return Dwoo_ITemplate|null|false
*/
public static function templateFactory(Dwoo $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null);
}
......@@ -158,8 +158,8 @@ interface DwooITemplate
/**
* interface that represents a dwoo compiler
*
* while implementing this is enough to interact with Dwoo/DwooTemplates, it is not
* sufficient to interact with DwooPlugins, however the main purpose of creating a
* while implementing this is enough to interact with Dwoo/Dwoo_Templates, it is not
* sufficient to interact with Dwoo_Plugins, however the main purpose of creating a
* new compiler would be to interact with other/different plugins, that is why this
* interface has been left with the minimum requirements.
*
......@@ -179,7 +179,7 @@ interface DwooITemplate
* @date 2008-04-09
* @package Dwoo
*/
interface DwooICompiler
interface Dwoo_ICompiler
{
/**
* compiles the provided string down to php code
......@@ -187,7 +187,7 @@ interface DwooICompiler
* @param string $templateStr the template to compile
* @return string a compiled php code string
*/
public function compile(Dwoo $dwoo, DwooITemplate $template);
public function compile(Dwoo $dwoo, Dwoo_ITemplate $template);
/**
* adds the custom plugins loaded into Dwoo to the compiler so it can load them
......@@ -203,9 +203,9 @@ interface DwooICompiler
* use this if untrusted persons can modify templates,
* set it on the Dwoo object as it will be passed onto the compiler automatically
*
* @param DwooSecurityPolicy $policy the security policy object
* @param Dwoo_Security_Policy $policy the security policy object
*/
public function setSecurityPolicy(DwooSecurityPolicy $policy = null);
public function setSecurityPolicy(Dwoo_Security_Policy $policy = null);
}
?>
......@@ -22,7 +22,7 @@
* @date 2008-04-09
* @package Dwoo
*/
abstract class DwooPlugin
abstract class Dwoo_Plugin
{
/**
* the dwoo instance that runs this plugin
......@@ -75,7 +75,7 @@ abstract class DwooPlugin
* @date 2008-04-09
* @package Dwoo
*/
abstract class DwooBlockPlugin extends DwooPlugin
abstract class Dwoo_Block_Plugin extends Dwoo_Plugin
{
/**
* stores the contents of the block while it runs
......@@ -123,7 +123,7 @@ abstract class DwooBlockPlugin extends DwooPlugin
*
* basically this will replace the {block arg arg arg} tag in the template
*
* @param DwooCompiler $compiler the compiler instance that calls this function
* @param Dwoo_Compiler $compiler the compiler instance that calls this function
* @param array $params an array containing original and compiled parameters
* @param string $prepend that is just meant to allow a child class to call
* parent::postProcessing($compiler, $params, "foo();") to add a command before the
......@@ -133,9 +133,9 @@ abstract class DwooBlockPlugin extends DwooPlugin
* default commands are executed
* @param string $type the type is the plugin class name used
*/
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
return DwooCompiler::PHP_OPEN.$prepend.'$this->addStack("'.$type.'", array('.implode(', ', $compiler->getCompiledParams($params)).'));'.$append.DwooCompiler::PHP_CLOSE;
return Dwoo_Compiler::PHP_OPEN.$prepend.'$this->addStack("'.$type.'", array('.implode(', ', $compiler->getCompiledParams($params)).'));'.$append.Dwoo_Compiler::PHP_CLOSE;
}
/**
......@@ -144,7 +144,7 @@ abstract class DwooBlockPlugin extends DwooPlugin
* basically this will replace the {/block} tag in the template
*
* @see preProcessing
* @param DwooCompiler $compiler the compiler instance that calls this function
* @param Dwoo_Compiler $compiler the compiler instance that calls this function
* @param array $params an array containing original and compiled parameters, see preProcessing() for more details
* @param string $prepend that is just meant to allow a child class to call
* parent::postProcessing($compiler, $params, "foo();") to add a command before the
......@@ -153,9 +153,9 @@ abstract class DwooBlockPlugin extends DwooPlugin
* parent::postProcessing($compiler, $params, null, "foo();") to add a command after the
* default commands are executed
*/
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
return DwooCompiler::PHP_OPEN.$prepend.'$this->delStack();'.$append.DwooCompiler::PHP_CLOSE;
return Dwoo_Compiler::PHP_OPEN.$prepend.'$this->delStack();'.$append.Dwoo_Compiler::PHP_CLOSE;
}
}
......@@ -178,7 +178,7 @@ abstract class DwooBlockPlugin extends DwooPlugin
* @date 2008-04-09
* @package Dwoo
*/
abstract class DwooFilter
abstract class Dwoo_Filter
{
/**
* the dwoo instance that runs this filter
......@@ -226,7 +226,7 @@ abstract class DwooFilter
* @date 2008-04-09
* @package Dwoo
*/
abstract class DwooProcessor
abstract class Dwoo_Processor
{
/**
* the compiler instance that runs this processor
......@@ -241,7 +241,7 @@ abstract class DwooProcessor
*
* @param Dwoo $dwoo the dwoo instance that runs this plugin
*/
public function __construct(DwooCompiler $compiler)
public function __construct(Dwoo_Compiler $compiler)
{
$this->compiler = $compiler;
}
......@@ -260,7 +260,7 @@ abstract class DwooProcessor
*
* implement this to notify the compiler that this plugin does not need to be loaded at runtime.
*
* to implement it right, you must implement <em>public static function compile(DwooCompiler $compiler, $arg, $arg, ...)</em>,
* to implement it right, you must implement <em>public static function compile(Dwoo_Compiler $compiler, $arg, $arg, ...)</em>,
* which replaces the <em>process()</em> method (that means <em>compile()</em> should have all arguments it requires).
*
* This software is provided 'as-is', without any express or implied warranty.
......@@ -279,10 +279,10 @@ abstract class DwooProcessor
* @date 2008-04-09
* @package Dwoo
*/
interface DwooICompilable
interface Dwoo_ICompilable
{
// this replaces the process function
//public static function compile(DwooCompiler $compiler, $arg, $arg, ...);
//public static function compile(Dwoo_Compiler $compiler, $arg, $arg, ...);
}
/**
......@@ -306,7 +306,7 @@ interface DwooICompilable
* @date 2008-04-09
* @package Dwoo
*/
interface DwooICompilableBlock
interface Dwoo_ICompilable_Block
{
}
......
......@@ -12,7 +12,7 @@ if(!defined('SMARTY_PHP_PASSTHRU'))
define('SMARTY_PHP_ALLOW', 3);
}
if(class_exists('DwooCompiler', false) === false)
if(class_exists('Dwoo_Compiler', false) === false)
require 'Dwoo/Compiler.php';
/**
......@@ -34,7 +34,7 @@ if(class_exists('DwooCompiler', false) === false)
* @date 2008-04-09
* @package Dwoo
*/
class DwooSmarty_Adapter extends Dwoo
class Dwoo_Smarty__Adapter extends Dwoo
{
// magic get/set/call functions that handle unsupported features
public function __set($p, $v)
......@@ -42,13 +42,13 @@ class DwooSmarty_Adapter extends Dwoo
if(array_key_exists($p, $this->compat['properties']) !== false)
{
if($this->show_compat_errors)
$this->triggerError('Property '.$p.' is not available in the DwooSmartyAdapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
$this->triggerError('Property '.$p.' is not available in the Dwoo_Smarty_Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
$this->compat['properties'][$p] = $v;
}
else
{
if($this->show_compat_errors)
$this->triggerError('Property '.$p.' is not available in the DwooSmartyAdapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
$this->triggerError('Property '.$p.' is not available in the Dwoo_Smarty_Adapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
}
}
......@@ -57,13 +57,13 @@ class DwooSmarty_Adapter extends Dwoo
if(array_key_exists($p, $this->compat['properties']) !== false)
{
if($this->show_compat_errors)
$this->triggerError('Property '.$p.' is not available in the DwooSmartyAdapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
$this->triggerError('Property '.$p.' is not available in the Dwoo_Smarty_Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
return $this->compat['properties'][$p];
}
else
{
if($this->show_compat_errors)
$this->triggerError('Property '.$p.' is not available in the DwooSmartyAdapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
$this->triggerError('Property '.$p.' is not available in the Dwoo_Smarty_Adapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
}
}
......@@ -74,9 +74,9 @@ class DwooSmarty_Adapter extends Dwoo
elseif($this->show_compat_errors)
{
if(array_search($m, $this->compat['methods']) !== false)
$this->triggerError('Method '.$m.' is not available in the DwooSmartyAdapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
$this->triggerError('Method '.$m.' is not available in the Dwoo_Smarty_Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
else
$this->triggerError('Method '.$m.' is not available in the DwooSmartyAdapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
$this->triggerError('Method '.$m.' is not available in the Dwoo_Smarty_Adapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
}
}
......@@ -159,8 +159,8 @@ class DwooSmarty_Adapter extends Dwoo
{
parent::__construct();
$this->charset = 'iso-8859-1';
$this->dataProvider = new DwooData();
$this->compiler = new DwooCompiler();
$this->dataProvider = new Dwoo_Data();
$this->compiler = new Dwoo_Compiler();
$this->compiler->smartyCompat = true;
}
......@@ -173,7 +173,7 @@ class DwooSmarty_Adapter extends Dwoo
{
if($this->security)
{
$policy = new DwooSecurityPolicy();
$policy = new Dwoo_Security_Policy();
$policy->addPhpFunction(array_merge($this->security_settings['IF_FUNCS'], $this->security_settings['MODIFIER_FUNCS']));
$phpTags = $this->security_settings['PHP_HANDLING'] ? SMARTY_PHP_ALLOW : $this->php_handling;
......@@ -183,14 +183,14 @@ class DwooSmarty_Adapter extends Dwoo
{
case SMARTY_PHP_ALLOW:
case SMARTY_PHP_PASSTHRU:
$phpTags = DwooSecurityPolicy::PHP_ALLOW;
$phpTags = Dwoo_Security_Policy::PHP_ALLOW;
break;
case SMARTY_PHP_QUOTE:
$phpTags = DwooSecurityPolicy::PHP_ENCODE;
$phpTags = Dwoo_Security_Policy::PHP_ENCODE;
break;
case SMARTY_PHP_REMOVE:
default:
$phpTags = DwooSecurityPolicy::PHP_REMOVE;
$phpTags = Dwoo_Security_Policy::PHP_REMOVE;
break;
}
$policy->setPhpHandling($phpTags);
......@@ -207,7 +207,7 @@ class DwooSmarty_Adapter extends Dwoo
if(!empty($this->plugins_dir))
foreach($this->plugins_dir as $dir)
DwooLoader::addDirectory(rtrim($dir, '\\/'));
Dwoo_Loader::addDirectory(rtrim($dir, '\\/'));
$tpl = $this->makeTemplate($filename, $cacheId, $compileId);
if($this->force_compile)
......@@ -238,7 +238,7 @@ class DwooSmarty_Adapter extends Dwoo
public function register_function($name, $callback, $cacheable=true, $cache_attrs=null)
{
if(isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_FUNCTION)
throw new DwooException('Multiple plugins of different types can not share the same name');
throw new Dwoo_Exception('Multiple plugins of different types can not share the same name');
$this->plugins[$name] = array('type'=>self::SMARTY_FUNCTION, 'callback'=>$callback);
}
......@@ -250,7 +250,7 @@ class DwooSmarty_Adapter extends Dwoo
public function register_block($name, $callback, $cacheable=true, $cache_attrs=null)
{
if(isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_BLOCK)
throw new DwooException('Multiple plugins of different types can not share the same name');
throw new Dwoo_Exception('Multiple plugins of different types can not share the same name');
$this->plugins[$name] = array('type'=>self::SMARTY_BLOCK, 'callback'=>$callback);
}
......@@ -262,7 +262,7 @@ class DwooSmarty_Adapter extends Dwoo
public function register_modifier($name, $callback)
{
if(isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_MODIFIER)
throw new DwooException('Multiple plugins of different types can not share the same name');
throw new Dwoo_Exception('Multiple plugins of different types can not share the same name');
$this->plugins[$name] = array('type'=>self::SMARTY_MODIFIER, 'callback'=>$callback);
}
......@@ -273,7 +273,7 @@ class DwooSmarty_Adapter extends Dwoo
public function register_prefilter($callback)
{
$processor = new DwooSmartyProcessorAdapter($this->compiler);
$processor = new Dwoo_SmartyProcessorAdapter($this->compiler);
$processor->registerCallback($callback);
$this->_filters['pre'][] = $processor;
$this->compiler->addPreProcessor($processor);
......@@ -291,7 +291,7 @@ class DwooSmarty_Adapter extends Dwoo
public function register_postfilter($callback)
{
$processor = new DwooSmartyProcessorAdapter($this->compiler);
$processor = new Dwoo_SmartyProcessorAdapter($this->compiler);
$processor->registerCallback($callback);
$this->_filters['post'][] = $processor;
$this->compiler->addPostProcessor($processor);
......@@ -309,7 +309,7 @@ class DwooSmarty_Adapter extends Dwoo
public function register_outputfilter($callback)
{
$filter = new DwooSmartyFilterAdapter($this);
$filter = new Dwoo_SmartyFilterAdapter($this);
$filter->registerCallback($callback);
$this->_filters['output'][] = $filter;
$this->addFilter($filter);
......@@ -353,7 +353,7 @@ class DwooSmarty_Adapter extends Dwoo
if(isset($data[$name]) && is_object($data[$name]))
return $data[$name];
else
trigger_error('DwooCompiler: object "'.$name.'" was not registered or is not an object', E_USER_ERROR);
trigger_error('Dwoo_Compiler: object "'.$name.'" was not registered or is not an object', E_USER_ERROR);
}
public function template_exists($filename)
......@@ -414,7 +414,7 @@ class DwooSmarty_Adapter extends Dwoo
$this->triggerError($error_msg, $error_type);
}
protected function initGlobals(DwooITemplate $tpl)
protected function initGlobals(Dwoo_ITemplate $tpl)
{
parent::initGlobals($tpl);
$this->globals['ldelim'] = '{';
......@@ -431,12 +431,12 @@ class DwooSmarty_Adapter extends Dwoo
$hash = bin2hex(md5($file.$cacheId.$compileId, true));
if(!isset(self::$tplCache[$hash]))
self::$tplCache[$hash] = new DwooTemplateFile($this->template_dir.DIRECTORY_SEPARATOR.$file, null, $cacheId, $compileId);
self::$tplCache[$hash] = new Dwoo_Template_File($this->template_dir.DIRECTORY_SEPARATOR.$file, null, $cacheId, $compileId);
return self::$tplCache[$hash];
}
}
class DwooSmartyFilterAdapter extends DwooFilter
class Dwoo_Smarty_Filter_Adapter extends Dwoo_Filter
{
public $callback;
......@@ -451,7 +451,7 @@ class DwooSmartyFilterAdapter extends DwooFilter
}
}
class DwooSmartyProcessorAdapter extends DwooProcessor
class Dwoo_Smarty_Processor_Adapter extends Dwoo_Processor
{
public $callback;
......@@ -470,11 +470,11 @@ class DwooSmartyProcessorAdapter extends DwooProcessor
if(class_exists('Smarty', false) === false)
{
interface Smarty {}
class DwooSmartyAdapter extends DwooSmarty_Adapter implements Smarty {}
class Dwoo_Smarty_Adapter extends Dwoo_Smarty__Adapter implements Smarty {}
}
else
{
class DwooSmartyAdapter extends DwooSmarty_Adapter {}
class Dwoo_Smarty_Adapter extends Dwoo_Smarty__Adapter {}
}
?>
\ No newline at end of file
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooTemplateFile extends DwooTemplateString
class Dwoo_Template_File extends Dwoo_Template_String
{
/**
* template filename
......@@ -72,10 +72,10 @@ class DwooTemplateFile extends DwooTemplateString
* returns the compiled template file name
*
* @param Dwoo $dwoo the dwoo instance that requests it
* @param DwooICompiler $compiler the compiler that must be used
* @param Dwoo_ICompiler $compiler the compiler that must be used
* @return string
*/
public function getCompiledTemplate(Dwoo $dwoo, DwooICompiler $compiler = null)
public function getCompiledTemplate(Dwoo $dwoo, Dwoo_ICompiler $compiler = null)
{
$compiledFile = $dwoo->getCompileDir() . $this->compileId.'.dwoo'.Dwoo::RELEASE_TAG.'.php';
......@@ -97,11 +97,11 @@ class DwooTemplateFile extends DwooTemplateString
{
$compiler = $dwoo->getDefaultCompilerFactory('string');
if($compiler === null || $compiler === array('DwooCompiler', 'compilerFactory'))
if($compiler === null || $compiler === array('Dwoo_Compiler', 'compilerFactory'))
{
if(class_exists('DwooCompiler', false) === false)
if(class_exists('Dwoo_Compiler', false) === false)
include 'Dwoo/Compiler.php';
$compiler = DwooCompiler::compilerFactory();
$compiler = Dwoo_Compiler::compilerFactory();
}
else
$compiler = call_user_func($compiler);
......@@ -175,7 +175,7 @@ class DwooTemplateFile extends DwooTemplateString
* to the current url
* @param string $compileId the unique compiled identifier, which is used to distinguish this
* template from others, if null it defaults to the filename+bits of the path
* @return DwooTemplateFile|null
* @return Dwoo_Template_File|null
*/
public static function templateFactory(Dwoo $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null)
{
......@@ -183,7 +183,7 @@ class DwooTemplateFile extends DwooTemplateString
if(file_exists($resourceId) === false)
{
$tpl = $dwoo->getTemplate();
if($tpl instanceof DwooTemplateFile)
if($tpl instanceof Dwoo_Template_File)
{
$resourceId = dirname($tpl->getResourceIdentifier()).DIRECTORY_SEPARATOR.$resourceId;
if(file_exists($resourceId) === false)
......@@ -201,7 +201,7 @@ class DwooTemplateFile extends DwooTemplateString
return $dwoo->triggerError('You can not include a template into itself', E_USER_WARNING);
}
return new DwooTemplateFile($resourceId, $cacheTime, $cacheId, $compileId);
return new Dwoo_Template_File($resourceId, $cacheTime, $cacheId, $compileId);
}
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooTemplateString implements DwooITemplate
class Dwoo_Template_String implements Dwoo_ITemplate
{
/**
* template name
......@@ -76,7 +76,7 @@ class DwooTemplateString implements DwooITemplate
/**
* holds the compiler that built this template
*
* @var DwooICompiler
* @var Dwoo_ICompiler
*/
protected $compiler;
......@@ -183,7 +183,7 @@ class DwooTemplateString implements DwooITemplate
/**
* returns the compiler used by this template, if it was just compiled, or null
*
* @return DwooICompiler
* @return Dwoo_ICompiler
*/
public function getCompiler()
{
......@@ -246,12 +246,36 @@ class DwooTemplateString implements DwooITemplate
*/
public function cache(Dwoo $dwoo, $output)
{
$cachedFile = $dwoo->getCacheDir() . $this->cacheId.'.html';
$cacheDir = $dwoo->getCacheDir();
$cachedFile = $cacheDir . $this->cacheId.'.html';
// the code below is courtesy of Rasmus Schultz,
// thanks for his help on avoiding concurency issues
$temp = tempnam($cacheDir, 'temp');
if(!($file = @fopen($temp, 'wb')))
{
$temp = $cacheDir . DIRECTORY_SEPARATOR . uniqid('temp');
if(!($file = @fopen($temp, 'wb')))
{
trigger_error('Error writing temporary file \''.$temp.'\'', E_USER_WARNING);
return false;
}
}
file_put_contents($cachedFile, $output);
touch($cachedFile, $_SERVER['REQUEST_TIME']);
fwrite($file, $output);
fclose($file);
if(!@rename($temp, $cachedFile))
{
@unlink($cachedFile);
@rename($temp, $cachedFile);
}
@chmod($cachedFile, 0777);
self::$cache['cached'][$this->cacheId] = true;
return true;
}
/**
......@@ -272,10 +296,10 @@ class DwooTemplateString implements DwooITemplate
* returns the compiled template file name
*
* @param Dwoo $dwoo the dwoo instance that requests it
* @param DwooICompiler $compiler the compiler that must be used
* @param Dwoo_ICompiler $compiler the compiler that must be used
* @return string
*/
public function getCompiledTemplate(Dwoo $dwoo, DwooICompiler $compiler = null)
public function getCompiledTemplate(Dwoo $dwoo, Dwoo_ICompiler $compiler = null)
{
$compiledFile = $dwoo->getCompileDir() . $this->compileId.'.dwoo'.Dwoo::RELEASE_TAG.'.php';
......@@ -297,11 +321,11 @@ class DwooTemplateString implements DwooITemplate
{
$compiler = $dwoo->getDefaultCompilerFactory('string');
if($compiler === null || $compiler === array('DwooCompiler', 'compilerFactory'))
if($compiler === null || $compiler === array('Dwoo_Compiler', 'compilerFactory'))
{
if(class_exists('DwooCompiler', false) === false)
if(class_exists('Dwoo_Compiler', false) === false)
include 'Dwoo/Compiler.php';
$compiler = DwooCompiler::compilerFactory();
$compiler = Dwoo_Compiler::compilerFactory();
}
else
$compiler = call_user_func($compiler);
......
......@@ -19,18 +19,18 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_block extends DwooBlockPlugin implements DwooICompilableBlock
class Dwoo_Plugin_block extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
{
public function init($name='')
{
}
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
return '';
}
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
return '';
}
......
......@@ -19,29 +19,29 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_capture extends DwooBlockPlugin implements DwooICompilableBlock
class Dwoo_Plugin_capture extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
{
public function init($name = 'default', $assign = null, $cat = false)
{
}
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
return DwooCompiler::PHP_OPEN.$prepend.'ob_start();'.$append.DwooCompiler::PHP_CLOSE;
return Dwoo_Compiler::PHP_OPEN.$prepend.'ob_start();'.$append.Dwoo_Compiler::PHP_CLOSE;
}
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
$params = $compiler->getCompiledParams($params);
$out = DwooCompiler::PHP_OPEN.$prepend."\n".'$tmp = ob_get_clean();';
$out = Dwoo_Compiler::PHP_OPEN.$prepend."\n".'$tmp = ob_get_clean();';
if($params['cat'] === 'true') {
$out .= "\n".'$tmp = $this->readVar(\'dwoo.capture.\'.'.$params['name'].') . $tmp;';
}
if($params['assign'] !== "null") {
$out .= "\n".'$this->scope['.$params['assign'].'] = $tmp;';
}
return $out . "\n".'$this->globals[\'capture\']['.$params['name'].'] = $tmp;'.$append.DwooCompiler::PHP_CLOSE;
return $out . "\n".'$this->globals[\'capture\']['.$params['name'].'] = $tmp;'.$append.Dwoo_Compiler::PHP_CLOSE;
}
}
......
......@@ -19,13 +19,13 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_else extends DwooBlockPlugin implements DwooICompilableBlock
class Dwoo_Plugin_else extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
{
public function init()
{
}
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
$block =& $compiler->getCurrentBlock();
$out = '';
......@@ -37,15 +37,15 @@ class DwooPlugin_else extends DwooBlockPlugin implements DwooICompilableBlock
$out .= $block['params']['postOutput'];
$block['params']['postOutput'] = '';
$out = substr($out, 0, -strlen(DwooCompiler::PHP_CLOSE));
$out = substr($out, 0, -strlen(Dwoo_Compiler::PHP_CLOSE));
$currentBlock =& $compiler->getCurrentBlock();
$currentBlock['params']['postOutput'] = DwooCompiler::PHP_OPEN."\n}".DwooCompiler::PHP_CLOSE;
$currentBlock['params']['postOutput'] = Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE;
return $out . "else {\n".DwooCompiler::PHP_CLOSE;
return $out . "else {\n".Dwoo_Compiler::PHP_CLOSE;
}
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
if(isset($params['postOutput']))
return $params['postOutput'];
......
......@@ -19,13 +19,13 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_elseif extends DwooPlugin_if implements DwooICompilableBlock
class Dwoo_Plugin_elseif extends Dwoo_Plugin_if implements Dwoo_ICompilable_Block
{
public function init(array $rest)
{
}
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
$if =& $compiler->findBlock('if', true);
$out = $if['params']['postOutput'];
......@@ -33,17 +33,17 @@ class DwooPlugin_elseif extends DwooPlugin_if implements DwooICompilableBlock
$compiler->injectBlock($type, $params, 1);
$currentBlock =& $compiler->getCurrentBlock();
$currentBlock['params']['postOutput'] = DwooCompiler::PHP_OPEN."\n}".DwooCompiler::PHP_CLOSE;
$currentBlock['params']['postOutput'] = Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE;
if($out === '')
$out = DwooCompiler::PHP_OPEN."\n}";
$out = Dwoo_Compiler::PHP_OPEN."\n}";
else
$out = substr($out, 0, -strlen(DwooCompiler::PHP_CLOSE));
$out = substr($out, 0, -strlen(Dwoo_Compiler::PHP_CLOSE));
return $out . " elseif(".implode(' ', self::replaceKeywords($params, $compiler)).") {\n" . DwooCompiler::PHP_CLOSE;
return $out . " elseif(".implode(' ', self::replaceKeywords($params, $compiler)).") {\n" . Dwoo_Compiler::PHP_CLOSE;
}
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
if(isset($params['postOutput']))
return $params['postOutput'];
......
......@@ -18,7 +18,7 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_for extends DwooBlockPlugin implements DwooICompilableBlock
class Dwoo_Plugin_for extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
{
public static $cnt=0;
......@@ -26,7 +26,7 @@ class DwooPlugin_for extends DwooBlockPlugin implements DwooICompilableBlock
{
}
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
$params = $compiler->getCompiledParams($params);
$tpl = $compiler->getTemplateSource(true);
......@@ -53,7 +53,7 @@ class DwooPlugin_for extends DwooBlockPlugin implements DwooICompilableBlock
$cnt = self::$cnt++;
// builds pre processing output for
$out = DwooCompiler::PHP_OPEN . "\n".'$_for'.$cnt.'_from = $_for'.$cnt.'_src = '.$from.';'.
$out = Dwoo_Compiler::PHP_OPEN . "\n".'$_for'.$cnt.'_from = $_for'.$cnt.'_src = '.$from.';'.
"\n".'$_for'.$cnt.'_to = '.$to.';'.
"\n".'$_for'.$cnt.'_step = abs('.$step.');'.
"\n".'$_for'.$cnt.'_skip = abs('.$skip.');'.
......@@ -93,11 +93,11 @@ class DwooPlugin_for extends DwooBlockPlugin implements DwooICompilableBlock
$out .= "\n\t\t".'$_for'.$cnt.'_glob["first"] = (string) ($_for'.$cnt.'_glob["iteration"] === 1);';
if($usesLast)
$out .= "\n\t\t".'$_for'.$cnt.'_glob["last"] = (string) ($_for'.$cnt.'_glob["iteration"] === $_for'.$cnt.'_glob["total"]);';
$out .= "\n// -- for start output\n".DwooCompiler::PHP_CLOSE;
$out .= "\n// -- for start output\n".Dwoo_Compiler::PHP_CLOSE;
// build post processing output and cache it
$postOut = DwooCompiler::PHP_OPEN . '// -- for end output';
$postOut = Dwoo_Compiler::PHP_OPEN . '// -- for end output';
// update properties
if($usesIteration)
$postOut.="\n\t\t".'$_for'.$cnt.'_glob["iteration"]+=1;';
......@@ -106,12 +106,12 @@ class DwooPlugin_for extends DwooBlockPlugin implements DwooICompilableBlock
// get block params and save the post-processing output already
$currentBlock =& $compiler->getCurrentBlock();
$currentBlock['params']['postOutput'] = $postOut . DwooCompiler::PHP_CLOSE;
$currentBlock['params']['postOutput'] = $postOut . Dwoo_Compiler::PHP_CLOSE;
return $out;
}
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
return $params['postOutput'];
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_foreach extends DwooBlockPlugin implements DwooICompilableBlock
class Dwoo_Plugin_foreach extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
{
public static $cnt=0;
......@@ -27,7 +27,7 @@ class DwooPlugin_foreach extends DwooBlockPlugin implements DwooICompilableBlock
{
}
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
$params = $compiler->getCompiledParams($params);
$tpl = $compiler->getTemplateSource(true);
......@@ -69,7 +69,7 @@ class DwooPlugin_foreach extends DwooBlockPlugin implements DwooICompilableBlock
$cnt = self::$cnt++;
// builds pre processing output
$out = DwooCompiler::PHP_OPEN . "\n".'$_fh'.$cnt.'_data = '.$src.';';
$out = Dwoo_Compiler::PHP_OPEN . "\n".'$_fh'.$cnt.'_data = '.$src.';';
// adds foreach properties
if($usesAny)
{
......@@ -91,10 +91,10 @@ class DwooPlugin_foreach extends DwooBlockPlugin implements DwooICompilableBlock
$out .= "\n\t\t".'$_fh'.$cnt.'_glob["first"] = (string) ($_fh'.$cnt.'_glob["index"] === 0);';
if($usesLast)
$out .= "\n\t\t".'$_fh'.$cnt.'_glob["last"] = (string) ($_fh'.$cnt.'_glob["iteration"] === $_fh'.$cnt.'_glob["total"]);';
$out .= "\n// -- foreach start output\n".DwooCompiler::PHP_CLOSE;
$out .= "\n// -- foreach start output\n".Dwoo_Compiler::PHP_CLOSE;
// build post processing output and cache it
$postOut = DwooCompiler::PHP_OPEN . "\n".'// -- foreach end output';
$postOut = Dwoo_Compiler::PHP_OPEN . "\n".'// -- foreach end output';
// update properties
if($usesIndex)
$postOut.="\n\t\t".'$_fh'.$cnt.'_glob["index"]+=1;';
......@@ -105,12 +105,12 @@ class DwooPlugin_foreach extends DwooBlockPlugin implements DwooICompilableBlock
// get block params and save the post-processing output already
$currentBlock =& $compiler->getCurrentBlock();
$currentBlock['params']['postOutput'] = $postOut . DwooCompiler::PHP_CLOSE;
$currentBlock['params']['postOutput'] = $postOut . Dwoo_Compiler::PHP_CLOSE;
return $out;
}
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
return $params['postOutput'];
}
......
......@@ -18,13 +18,13 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_foreachelse extends DwooBlockPlugin implements DwooICompilableBlock
class Dwoo_Plugin_foreachelse extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
{
public function init()
{
}
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
$foreach =& $compiler->findBlock('foreach', true);
$out = $foreach['params']['postOutput'];
......@@ -32,17 +32,17 @@ class DwooPlugin_foreachelse extends DwooBlockPlugin implements DwooICompilableB
$compiler->injectBlock($type, $params, 1);
if(substr($out, -strlen(DwooCompiler::PHP_CLOSE)) === DwooCompiler::PHP_CLOSE)
$out = substr($out, 0, -strlen(DwooCompiler::PHP_CLOSE));
if(substr($out, -strlen(Dwoo_Compiler::PHP_CLOSE)) === Dwoo_Compiler::PHP_CLOSE)
$out = substr($out, 0, -strlen(Dwoo_Compiler::PHP_CLOSE));
else
$out .= DwooCompiler::PHP_OPEN;
$out .= Dwoo_Compiler::PHP_OPEN;
return $out . "else\n{" . DwooCompiler::PHP_CLOSE;
return $out . "else\n{" . Dwoo_Compiler::PHP_CLOSE;
}
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
return DwooCompiler::PHP_OPEN.'}'.DwooCompiler::PHP_CLOSE;
return Dwoo_Compiler::PHP_OPEN.'}'.Dwoo_Compiler::PHP_CLOSE;
}
}
......
......@@ -18,13 +18,13 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_forelse extends DwooBlockPlugin implements DwooICompilableBlock
class Dwoo_Plugin_forelse extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
{
public function init()
{
}
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
$foreach =& $compiler->findBlock('for', true);
$out = $foreach['params']['postOutput'];
......@@ -32,17 +32,17 @@ class DwooPlugin_forelse extends DwooBlockPlugin implements DwooICompilableBlock
$compiler->injectBlock($type, $params, 1);
if(substr($out, -strlen(DwooCompiler::PHP_CLOSE)) === DwooCompiler::PHP_CLOSE)
$out = substr($out, 0, -strlen(DwooCompiler::PHP_CLOSE));
if(substr($out, -strlen(Dwoo_Compiler::PHP_CLOSE)) === Dwoo_Compiler::PHP_CLOSE)
$out = substr($out, 0, -strlen(Dwoo_Compiler::PHP_CLOSE));
else
$out .= DwooCompiler::PHP_OPEN;
$out .= Dwoo_Compiler::PHP_OPEN;
return $out . "else\n{" . DwooCompiler::PHP_CLOSE;
return $out . "else\n{" . Dwoo_Compiler::PHP_CLOSE;
}
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
return DwooCompiler::PHP_OPEN.'}'.DwooCompiler::PHP_CLOSE;
return Dwoo_Compiler::PHP_OPEN.'}'.Dwoo_Compiler::PHP_CLOSE;
}
}
......
......@@ -18,11 +18,11 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_if extends DwooBlockPlugin implements DwooICompilableBlock
class Dwoo_Plugin_if extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
{
public function init(array $rest) {}
public static function replaceKeywords($params, DwooCompiler $compiler)
public static function replaceKeywords($params, Dwoo_Compiler $compiler)
{
$params = $compiler->getCompiledParams($params);
......@@ -157,15 +157,15 @@ class DwooPlugin_if extends DwooBlockPlugin implements DwooICompilableBlock
return $p;
}
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
$currentBlock =& $compiler->getCurrentBlock();
$currentBlock['params']['postOutput'] = DwooCompiler::PHP_OPEN."\n}".DwooCompiler::PHP_CLOSE;
$currentBlock['params']['postOutput'] = Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE;
return DwooCompiler::PHP_OPEN.'if('.implode(' ', self::replaceKeywords($params, $compiler)).") {\n".DwooCompiler::PHP_CLOSE;
return Dwoo_Compiler::PHP_OPEN.'if('.implode(' ', self::replaceKeywords($params, $compiler)).") {\n".Dwoo_Compiler::PHP_CLOSE;
}
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
return $params['postOutput'];
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_loop extends DwooBlockPlugin implements DwooICompilableBlock
class Dwoo_Plugin_loop extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
{
public static $cnt=0;
......@@ -27,7 +27,7 @@ class DwooPlugin_loop extends DwooBlockPlugin implements DwooICompilableBlock
{
}
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
$params = $compiler->getCompiledParams($params);
$tpl = $compiler->getTemplateSource(true);
......@@ -51,7 +51,7 @@ class DwooPlugin_loop extends DwooBlockPlugin implements DwooICompilableBlock
$cnt = self::$cnt++;
// builds pre processing output
$out = DwooCompiler::PHP_OPEN . "\n".'$_loop'.$cnt.'_data = '.$src.';';
$out = Dwoo_Compiler::PHP_OPEN . "\n".'$_loop'.$cnt.'_data = '.$src.';';
// adds foreach properties
if($usesAny)
{
......@@ -73,10 +73,10 @@ class DwooPlugin_loop extends DwooBlockPlugin implements DwooICompilableBlock
$out .= "\n\t\t".'$_loop'.$cnt.'_glob["first"] = (string) ($_loop'.$cnt.'_glob["index"] === 0);';
if($usesLast)
$out .= "\n\t\t".'$_loop'.$cnt.'_glob["last"] = (string) ($_loop'.$cnt.'_glob["iteration"] === $_loop'.$cnt.'_glob["total"]);';
$out .= "\n\t\t".'$_loop'.$cnt.'_scope = $this->setScope("-loop-");'."\n// -- loop start output\n".DwooCompiler::PHP_CLOSE;
$out .= "\n\t\t".'$_loop'.$cnt.'_scope = $this->setScope("-loop-");'."\n// -- loop start output\n".Dwoo_Compiler::PHP_CLOSE;
// build post processing output and cache it
$postOut = DwooCompiler::PHP_OPEN . "\n".'// -- loop end output'."\n\t\t".'$this->forceScope($_loop'.$cnt.'_scope);';
$postOut = Dwoo_Compiler::PHP_OPEN . "\n".'// -- loop end output'."\n\t\t".'$this->forceScope($_loop'.$cnt.'_scope);';
// update properties
if($usesIndex)
$postOut.="\n\t\t".'$_loop'.$cnt.'_glob["index"]+=1;';
......@@ -87,12 +87,12 @@ class DwooPlugin_loop extends DwooBlockPlugin implements DwooICompilableBlock
// get block params and save the post-processing output already
$currentBlock =& $compiler->getCurrentBlock();
$currentBlock['params']['postOutput'] = $postOut . DwooCompiler::PHP_CLOSE;
$currentBlock['params']['postOutput'] = $postOut . Dwoo_Compiler::PHP_CLOSE;
return $out;
}
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
return $params['postOutput'];
}
......
......@@ -19,11 +19,11 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_smartyinterface extends DwooPlugin
class Dwoo_Plugin_smartyinterface extends Dwoo_Plugin
{
public function init($__funcname, $__functype, array $rest=array()) {}
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
$params = $compiler->getCompiledParams($params);
$func = $params['__funcname'];
......@@ -46,12 +46,12 @@ class DwooPlugin_smartyinterface extends DwooPlugin
else
$callback = 'smarty_block_'.$func.'(';
$compiler->curBlock['params']['postOut'] = DwooCompiler::PHP_OPEN.' $_block_content = ob_get_clean(); $_block_repeat=false; echo '.$callback.'$_tag_stack[count($_tag_stack)-1], $_block_content, $this, $_block_repeat); } array_pop($_tag_stack);'.DwooCompiler::PHP_CLOSE;
$compiler->curBlock['params']['postOut'] = Dwoo_Compiler::PHP_OPEN.' $_block_content = ob_get_clean(); $_block_repeat=false; echo '.$callback.'$_tag_stack[count($_tag_stack)-1], $_block_content, $this, $_block_repeat); } array_pop($_tag_stack);'.Dwoo_Compiler::PHP_CLOSE;
return DwooCompiler::PHP_OPEN.$prepend.' if(!isset($_tag_stack)){ $_tag_stack = array(); } $_tag_stack[] = '.var_export($params,true).'; $_block_repeat=true; '.$callback.'$_tag_stack[count($_tag_stack)-1], null, $this, $_block_repeat); while ($_block_repeat) { ob_start();'.DwooCompiler::PHP_CLOSE;
return Dwoo_Compiler::PHP_OPEN.$prepend.' if(!isset($_tag_stack)){ $_tag_stack = array(); } $_tag_stack[] = '.var_export($params,true).'; $_block_repeat=true; '.$callback.'$_tag_stack[count($_tag_stack)-1], null, $this, $_block_repeat); while ($_block_repeat) { ob_start();'.Dwoo_Compiler::PHP_CLOSE;
}
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
return $params['postOut'];
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_textformat extends DwooBlockPlugin
class Dwoo_Plugin_textformat extends Dwoo_Block_Plugin
{
protected $wrap;
protected $wrapChar;
......
......@@ -18,20 +18,20 @@
* @date 2008-04-09
* @package Dwoo
*/
final class DwooPlugin_topLevelBlock extends DwooBlockPlugin
final class Dwoo_Plugin_topLevelBlock extends Dwoo_Block_Plugin
{
public function init()
{
}
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
return 'ob_start(); '.DwooCompiler::PHP_CLOSE;
return 'ob_start(); '.Dwoo_Compiler::PHP_CLOSE;
}
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
return DwooCompiler::PHP_OPEN.'return $this->buffer . ob_get_clean();';
return Dwoo_Compiler::PHP_OPEN.'return $this->buffer . ob_get_clean();';
}
}
......
......@@ -18,7 +18,7 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_with extends DwooBlockPlugin implements DwooICompilableBlock
class Dwoo_Plugin_with extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
{
protected static $cnt=0;
......@@ -26,7 +26,7 @@ class DwooPlugin_with extends DwooBlockPlugin implements DwooICompilableBlock
{
}
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
$rparams = $compiler->getRealParams($params);
$cparams = $compiler->getCompiledParams($params);
......@@ -34,12 +34,12 @@ class DwooPlugin_with extends DwooBlockPlugin implements DwooICompilableBlock
$compiler->setScope($rparams['var']);
$params =& $compiler->getCurrentBlock();
$params['params']['postOutput'] = DwooCompiler::PHP_OPEN."\n// -- end with output\n".'$this->forceScope($_with'.(self::$cnt).');'."\n}\n".DwooCompiler::PHP_CLOSE;
$params['params']['postOutput'] = Dwoo_Compiler::PHP_OPEN."\n// -- end with output\n".'$this->forceScope($_with'.(self::$cnt).');'."\n}\n".Dwoo_Compiler::PHP_CLOSE;
return DwooCompiler::PHP_OPEN.'if('.$cparams['var'].')'."\n{\n".'$_with'.(self::$cnt++).' = $this->setScope("'.$rparams['var'].'");'."\n// -- start with output\n".DwooCompiler::PHP_CLOSE;
return Dwoo_Compiler::PHP_OPEN.'if('.$cparams['var'].')'."\n{\n".'$_with'.(self::$cnt++).' = $this->setScope("'.$rparams['var'].'");'."\n// -- start with output\n".Dwoo_Compiler::PHP_CLOSE;
}
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
return $params['postOutput'];
}
......
......@@ -18,13 +18,13 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_withelse extends DwooBlockPlugin implements DwooICompilableBlock
class Dwoo_Plugin_withelse extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block
{
public function init()
{
}
public static function preProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='', $type)
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='', $type)
{
$foreach =& $compiler->findBlock('with', true);
$out = $foreach['params']['postOutput'];
......@@ -32,17 +32,17 @@ class DwooPlugin_withelse extends DwooBlockPlugin implements DwooICompilableBloc
$compiler->injectBlock($type, $params, 1);
if(substr($out, -strlen(DwooCompiler::PHP_CLOSE)) === DwooCompiler::PHP_CLOSE)
$out = substr($out, 0, -strlen(DwooCompiler::PHP_CLOSE));
if(substr($out, -strlen(Dwoo_Compiler::PHP_CLOSE)) === Dwoo_Compiler::PHP_CLOSE)
$out = substr($out, 0, -strlen(Dwoo_Compiler::PHP_CLOSE));
else
$out .= DwooCompiler::PHP_OPEN;
$out .= Dwoo_Compiler::PHP_OPEN;
return $out . "else\n{" . DwooCompiler::PHP_CLOSE;
return $out . "else\n{" . Dwoo_Compiler::PHP_CLOSE;
}
public static function postProcessing(DwooCompiler $compiler, array $params, $prepend='', $append='')
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend='', $append='')
{
return DwooCompiler::PHP_OPEN.'}'.DwooCompiler::PHP_CLOSE;
return Dwoo_Compiler::PHP_OPEN.'}'.Dwoo_Compiler::PHP_CLOSE;
}
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooFilter_html_format extends DwooFilter
class Dwoo_Filter_html_format extends Dwoo_Filter
{
/**
* tab count to auto-indent the source
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_assign_compile(DwooCompiler $compiler, $value, $var)
function Dwoo_Plugin_assign_compile(Dwoo_Compiler $compiler, $value, $var)
{
return '$this->assignInScope('.$value.', '.$var.')';
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_capitalize(Dwoo $dwoo, $value, $numwords=false)
function Dwoo_Plugin_capitalize(Dwoo $dwoo, $value, $numwords=false)
{
if($numwords || preg_match('#^[^0-9]+$#',$value))
{
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_cat_compile(DwooCompiler $compiler, $value, array $rest)
function Dwoo_Plugin_cat_compile(Dwoo_Compiler $compiler, $value, array $rest)
{
return '('.$value.').('.implode(').(', $rest).')';
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_count_characters_compile(DwooCompiler $compiler, $value, $count_spaces=false)
function Dwoo_Plugin_count_characters_compile(Dwoo_Compiler $compiler, $value, $count_spaces=false)
{
if($count_spaces==='false')
return 'preg_match_all(\'#[^\s\pZ]#u\', '.$value.', $tmp)';
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_count_paragraphs_compile(DwooCompiler $compiler, $value)
function Dwoo_Plugin_count_paragraphs_compile(Dwoo_Compiler $compiler, $value)
{
return '(preg_match_all(\'#[\r\n]+#\', '.$value.', $tmp)+1)';
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_count_sentences_compile(DwooCompiler $compiler, $value)
function Dwoo_Plugin_count_sentences_compile(Dwoo_Compiler $compiler, $value)
{
return "preg_match_all('#[\w\pL]\.(?![\w\pL])#u', $value, \$tmp)";
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_count_words_compile(DwooCompiler $compiler, $value)
function Dwoo_Plugin_count_words_compile(Dwoo_Compiler $compiler, $value)
{
return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', '.$value.', $tmp)';
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_counter extends DwooPlugin
class Dwoo_Plugin_counter extends Dwoo_Plugin
{
protected $counters = array();
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_cycle extends DwooPlugin
class Dwoo_Plugin_cycle extends Dwoo_Plugin
{
protected $cycles = array();
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_date_format(Dwoo $dwoo, $value, $format='%b %e, %Y', $default=null)
function Dwoo_Plugin_date_format(Dwoo $dwoo, $value, $format='%b %e, %Y', $default=null)
{
if(!empty($value))
{
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_default_compile(DwooCompiler $compiler, $value, $default='')
function Dwoo_Plugin_default_compile(Dwoo_Compiler $compiler, $value, $default='')
{
return '(($tmp = '.$value.')===null||$tmp===\'\' ? '.$default.' : $tmp)';
}
......
......@@ -19,15 +19,15 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_dump extends DwooPlugin
class Dwoo_Plugin_dump extends Dwoo_Plugin
{
public function process($var = '$')
{
if ($var === '$') {
$var = $this->dwoo->getData();
$out = '<div style="background:#aaa; padding:5px; margin:5px;">data';
$out = '<div style="background:#aaa; padding:5px; margin:5px; color:#000;">data';
} else {
$out = '<div style="background:#aaa; padding:5px; margin:5px;">dump';
$out = '<div style="background:#aaa; padding:5px; margin:5px; color:#000;">dump';
}
if(!is_array($var)) {
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_escape(Dwoo $dwoo, $value='', $format='html', $charset=null)
function Dwoo_Plugin_escape(Dwoo $dwoo, $value='', $format='html', $charset=null)
{
if($charset === null)
$charset = $dwoo->getCharset();
......
......@@ -19,13 +19,13 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_eval(Dwoo $dwoo, $var, $assign = null)
function Dwoo_Plugin_eval(Dwoo $dwoo, $var, $assign = null)
{
// TOCOM eval is bad, warn people that they should not use it as a full template for DB-templates, they better extend DwooITemplate for that
// TOCOM eval is bad, warn people that they should not use it as a full template for DB-templates, they better extend Dwoo_ITemplate for that
if($var == '')
return;
$tpl = new DwooTemplateString($var);
$tpl = new Dwoo_Template_String($var);
$out = $dwoo->get($var, $dwoo->readVar('_parent'));
if($assign !== null)
......
......@@ -19,14 +19,14 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooPlugin_extends extends DwooPlugin implements DwooICompilable
class Dwoo_Plugin_extends extends Dwoo_Plugin implements Dwoo_ICompilable
{
protected static $childSource;
protected static $l;
protected static $r;
protected static $lastReplacement;
public static function compile(DwooCompiler $compiler, $file)
public static function compile(Dwoo_Compiler $compiler, $file)
{
list($l, $r) = $compiler->getDelimiters();
self::$l = preg_quote($l);
......@@ -78,7 +78,7 @@ class DwooPlugin_extends extends DwooPlugin implements DwooICompilable
try {
$parent = $compiler->getDwoo()->templateFactory($resource, $identifier);
} catch (DwooException $e) {
} catch (Dwoo_Exception $e) {
$compiler->triggerError('Extends : Resource <em>'.$resource.'</em> was not added to Dwoo, can not include <em>'.$identifier.'</em>', E_USER_ERROR);
}
......@@ -109,7 +109,7 @@ class DwooPlugin_extends extends DwooPlugin implements DwooICompilable
self::$lastReplacement = count($inheritanceTree) === 1;
if(!isset($newSource))
$newSource = $parent['source'];
$newSource = preg_replace_callback('/'.self::$l.'block (["\']?)(.+?)\1'.self::$r.'(?:\r?\n?)(.*?)(?:\r?\n?)'.self::$l.'\/block'.self::$r.'/is', array('DwooPlugin_extends', 'replaceBlock'), $newSource);
$newSource = preg_replace_callback('/'.self::$l.'block (["\']?)(.+?)\1'.self::$r.'(?:\r?\n?)(.*?)(?:\r?\n?)'.self::$l.'\/block'.self::$r.'/is', array('Dwoo_Plugin_extends', 'replaceBlock'), $newSource);
$newSource = $l.'do extendsCheck("'.$parent['resource'].':'.$parent['identifier'].'" "'.str_replace('"', '\\"', $parent['uid']).'")'.$r.$newSource;
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_extendsCheck_compile(DwooCompiler $compiler, $file, $uid)
function Dwoo_Plugin_extendsCheck_compile(Dwoo_Compiler $compiler, $file, $uid)
{
preg_match('#^["\']([a-z]{2,}):(.*?)["\']$#i', $file, $m);
$resource = $m[1];
......@@ -28,7 +28,7 @@ function DwooPlugin_extendsCheck_compile(DwooCompiler $compiler, $file, $uid)
return '// check for modification in '.$resource.':'.$identifier.'
try {
$tpl = $this->templateFactory("'.$resource.'", "'.$identifier.'");
} catch (DwooException $e) {
} catch (Dwoo_Exception $e) {
$this->triggerError(\'Extends : Resource <em>'.$resource.'</em> was not added to Dwoo, can not include <em>'.$identifier.'</em>\', E_USER_WARNING);
}
if($tpl === null)
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_fetch(Dwoo $dwoo, $file, $assign = null)
function Dwoo_Plugin_fetch(Dwoo $dwoo, $file, $assign = null)
{
if($file === '')
return;
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_include(Dwoo $dwoo, $file, $cache_time = null, $cache_id = null, $compile_id = null, $assign = null, array $rest = array())
function Dwoo_Plugin_include(Dwoo $dwoo, $file, $cache_time = null, $cache_id = null, $compile_id = null, $assign = null, array $rest = array())
{
if($file === '')
return;
......@@ -56,7 +56,7 @@ function DwooPlugin_include(Dwoo $dwoo, $file, $cache_time = null, $cache_id = n
try {
$include = $dwoo->templateFactory($resource, $identifier, $cache_time, $cache_id, $compile_id);
} catch (DwooException $e) {
} catch (Dwoo_Exception $e) {
$dwoo->triggerError('Include : Resource <em>'.$resource.'</em> was not added to Dwoo, can not include <em>'.$identifier.'</em>', E_USER_WARNING);
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_indent_compile(DwooCompiler $compiler, $value, $by=4, $char=' ')
function Dwoo_Plugin_indent_compile(Dwoo_Compiler $compiler, $value, $by=4, $char=' ')
{
return "preg_replace('#^#m', '".str_repeat(substr($char, 1, -1), trim($by, '"\''))."', $value)";
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_isset_compile(DwooCompiler $compiler, $var)
function Dwoo_Plugin_isset_compile(Dwoo_Compiler $compiler, $var)
{
return '('.$var.' !== null)';
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_lower_compile(DwooCompiler $compiler, $value)
function Dwoo_Plugin_lower_compile(Dwoo_Compiler $compiler, $value)
{
return 'mb_strtolower((string) '.$value.', $this->charset)';
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_mailto(Dwoo $dwoo, $address, $text=null, $subject=null, $encode=null, $cc=null, $bcc=null, $newsgroups=null, $followupto=null, $extra=null)
function Dwoo_Plugin_mailto(Dwoo $dwoo, $address, $text=null, $subject=null, $encode=null, $cc=null, $bcc=null, $newsgroups=null, $followupto=null, $extra=null)
{
if(empty($address))
return '';
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_math_compile(DwooCompiler $compiler, $equation, $format='', $assign='', array $rest=array())
function Dwoo_Plugin_math_compile(Dwoo_Compiler $compiler, $equation, $format='', $assign='', array $rest=array())
{
/**
* Holds the allowed function, characters, operators and constants
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_nl2br_compile(DwooCompiler $compiler, $value)
function Dwoo_Plugin_nl2br_compile(Dwoo_Compiler $compiler, $value)
{
return 'nl2br((string) '.$value.')';
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_regex_replace(Dwoo $dwoo, $value, $search, $replace)
function Dwoo_Plugin_regex_replace(Dwoo $dwoo, $value, $search, $replace)
{
// Credits for this to Monte Ohrt who made smarty's regex_replace modifier
if(($pos = strpos($search,"\0")) !== false)
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_replace_compile(DwooCompiler $compiler, $value, $search, $replace)
function Dwoo_Plugin_replace_compile(Dwoo_Compiler $compiler, $value, $search, $replace)
{
return 'str_replace('.$search.', '.$replace.', '.$value.')';
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_reverse(Dwoo $dwoo, $value, $preserve_keys=false)
function Dwoo_Plugin_reverse(Dwoo $dwoo, $value, $preserve_keys=false)
{
if(is_array($value) || ($value instanceof Iterator && $value instanceof ArrayAccess))
return array_reverse($value, $preserve_keys);
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_spacify_compile(DwooCompiler $compiler, $value, $space_char=' ')
function Dwoo_Plugin_spacify_compile(Dwoo_Compiler $compiler, $value, $space_char=' ')
{
return 'implode('.$space_char.', str_split('.$value.', 1))';
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_string_format_compile(DwooCompiler $compiler, $value, $format)
function Dwoo_Plugin_string_format_compile(Dwoo_Compiler $compiler, $value, $format)
{
return 'sprintf('.$format.','.$value.')';
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_strip_compile(DwooCompiler $compiler, $value, $with=' ')
function Dwoo_Plugin_strip_compile(Dwoo_Compiler $compiler, $value, $with=' ')
{
return "preg_replace('#\s+#'.(strcasecmp(\$this->charset, 'utf-8')===0?'u':''), $with, $value)";
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_strip_tags_compile(DwooCompiler $compiler, $value, $addspace=true)
function Dwoo_Plugin_strip_tags_compile(Dwoo_Compiler $compiler, $value, $addspace=true)
{
if($addspace==='true')
return "preg_replace('#<[^>]*>#', ' ', $value)";
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_truncate(Dwoo $dwoo, $value, $length=80, $etc='...', $break=false, $middle=false)
function Dwoo_Plugin_truncate(Dwoo $dwoo, $value, $length=80, $etc='...', $break=false, $middle=false)
{
if($length == 0)
return '';
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_upper_compile(DwooCompiler $compiler, $value)
function Dwoo_Plugin_upper_compile(Dwoo_Compiler $compiler, $value)
{
return 'mb_strtoupper((string) '.$value.', $this->charset)';
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_wordwrap_compile(DwooCompiler $compiler, $value, $length=80, $break="\n", $cut=false)
function Dwoo_Plugin_wordwrap_compile(Dwoo_Compiler $compiler, $value, $length=80, $break="\n", $cut=false)
{
return 'wordwrap('.$value.','.$length.','.$break.','.$cut.')';
}
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
function DwooPlugin_array_compile(DwooCompiler $compiler, array $rest=array())
function Dwoo_Plugin_array_compile(Dwoo_Compiler $compiler, array $rest=array())
{
$out = array();
foreach($rest as $k=>$v)
......
......@@ -19,7 +19,7 @@
* @date 2008-04-09
* @package Dwoo
*/
class DwooProcessor_smarty_compat extends DwooProcessor
class Dwoo_Processor_smarty_compat extends Dwoo_Processor
{
public function process($input)
{
......
......@@ -10,14 +10,14 @@ class CallTests extends PHPUnit_Framework_TestCase
public function __construct()
{
// extend this class and override this in your constructor to test a modded compiler
$this->compiler = new DwooCompiler();
$this->compiler = new Dwoo_Compiler();
$this->dwoo = new Dwoo();
}
public function testCustomFunctionPlugin()
{
$this->dwoo->addPlugin('test', 'plugin_custom_name');
$tpl = new DwooTemplateString('{test "xxx"}');
$tpl = new Dwoo_Template_String('{test "xxx"}');
$tpl->forceCompilation();
$this->assertEquals('xxxbar', $this->dwoo->get($tpl, array(), $this->compiler));
......@@ -27,7 +27,7 @@ class CallTests extends PHPUnit_Framework_TestCase
public function testHalfCustomClassPluginByClassMethodCallback()
{
$this->dwoo->addPlugin('test', array('plugin_half_custom', 'process'));
$tpl = new DwooTemplateString('{test "xxx"}');
$tpl = new Dwoo_Template_String('{test "xxx"}');
$tpl->forceCompilation();
$this->assertEquals('xxxbar', $this->dwoo->get($tpl, array(), $this->compiler));
......@@ -37,7 +37,7 @@ class CallTests extends PHPUnit_Framework_TestCase
public function testFullCustomClassPluginByClassMethodCallback()
{
$this->dwoo->addPlugin('test', array('plugin_full_custom', 'process'));
$tpl = new DwooTemplateString('{test "xxx"}');
$tpl = new Dwoo_Template_String('{test "xxx"}');
$tpl->forceCompilation();
$this->assertEquals('xxxbar', $this->dwoo->get($tpl, array(), $this->compiler));
......@@ -47,7 +47,7 @@ class CallTests extends PHPUnit_Framework_TestCase
public function testCustomClassPluginByClassname()
{
$this->dwoo->addPlugin('test', 'plugin_full_custom');
$tpl = new DwooTemplateString('{test "xxx"}');
$tpl = new Dwoo_Template_String('{test "xxx"}');
$tpl->forceCompilation();
$this->assertEquals('xxxbar', $this->dwoo->get($tpl, array(), $this->compiler));
......@@ -57,7 +57,7 @@ class CallTests extends PHPUnit_Framework_TestCase
public function testCustomObjectPluginByObjectMethodCallback()
{
$this->dwoo->addPlugin('test', array(new plugin_full_custom(), 'process'));
$tpl = new DwooTemplateString('{test "xxx"}');
$tpl = new Dwoo_Template_String('{test "xxx"}');
$tpl->forceCompilation();
$this->assertEquals('xxxbar', $this->dwoo->get($tpl, array(), $this->compiler));
......@@ -67,7 +67,7 @@ class CallTests extends PHPUnit_Framework_TestCase
public function testCustomBlockPluginByClassMethodCallback()
{
$this->dwoo->addPlugin('test', array('blockplugin_custom', 'process'));
$tpl = new DwooTemplateString('{test "xxx"}aaa{/test}');
$tpl = new Dwoo_Template_String('{test "xxx"}aaa{/test}');
$tpl->forceCompilation();
$this->assertEquals('xxxbaraaa', $this->dwoo->get($tpl, array(), $this->compiler));
......@@ -77,7 +77,7 @@ class CallTests extends PHPUnit_Framework_TestCase
public function testCustomBlockPluginByClassname()
{
$this->dwoo->addPlugin('test', 'blockplugin_custom');
$tpl = new DwooTemplateString('{test "xxx"}aaa{/test}');
$tpl = new Dwoo_Template_String('{test "xxx"}aaa{/test}');
$tpl->forceCompilation();
$this->assertEquals('xxxbaraaa', $this->dwoo->get($tpl, array(), $this->compiler));
......@@ -85,7 +85,7 @@ class CallTests extends PHPUnit_Framework_TestCase
}
/**
* @expectedException DwooException
* @expectedException Dwoo_Exception
*/
public function testCustomInvalidPlugin()
{
......@@ -98,7 +98,7 @@ function plugin_custom_name(Dwoo $dwoo, $foo, $bar="bar")
return $foo.$bar;
}
class plugin_half_custom extends DwooPlugin
class plugin_half_custom extends Dwoo_Plugin
{
public function process($foo, $bar="bar")
{
......@@ -114,7 +114,7 @@ class plugin_full_custom
}
}
class blockplugin_custom extends DwooBlockPlugin
class blockplugin_custom extends Dwoo_Block_Plugin
{
public function init($foo, $bar="bar")
{
......
......@@ -10,15 +10,15 @@ class DataTests extends PHPUnit_Framework_TestCase
public function __construct()
{
// extend this class and override this in your constructor to test a modded compiler
$this->compiler = new DwooCompiler();
$this->compiler = new Dwoo_Compiler();
$this->dwoo = new Dwoo();
$this->tpl = new DwooTemplateString('{$var}{$var2}{$var3}{$var4}');
$this->tpl = new Dwoo_Template_String('{$var}{$var2}{$var3}{$var4}');
$this->tpl->forceCompilation();
}
public function testSetMergeAndClear()
{
$data = new DwooData();
$data = new Dwoo_Data();
$data->setData(array('foo'));
$this->assertEquals(array('foo'), $data->getData());
......@@ -33,7 +33,7 @@ class DataTests extends PHPUnit_Framework_TestCase
public function testAssign()
{
$data = new DwooData();
$data = new Dwoo_Data();
$data->assign('var', '1');
$data->assign(array('var2'=>'1', 'var3'=>1));
......@@ -46,7 +46,7 @@ class DataTests extends PHPUnit_Framework_TestCase
public function testClear()
{
$data = new DwooData();
$data = new Dwoo_Data();
$data->assign(array('var2'=>'1', 'var3'=>1, 'var4'=>5));
$data->clear(array('var2', 'var4'));
......@@ -61,7 +61,7 @@ class DataTests extends PHPUnit_Framework_TestCase
public function testAppend()
{
$data = new DwooData();
$data = new Dwoo_Data();
$data->assign('var', 'val');
$data->append('var', 'moo');
......
......@@ -10,14 +10,8 @@ require dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'Dwoo.php';
class DwooTests {
public static function suite() {
PHPUnit_Util_Filter::addDirectoryToWhitelist(DWOO_DIRECTORY.'plugins/builtin');
PHPUnit_Util_Filter::addDirectoryToWhitelist(DWOO_DIRECTORY.'Dwoo');
PHPUnit_Util_Filter::addFileToWhitelist(DWOO_DIRECTORY.'Dwoo.php');
PHPUnit_Util_Filter::addFileToWhitelist(DWOO_DIRECTORY.'DwooCompiler.php');
PHPUnit_Util_Filter::addFileToWhitelist(DWOO_DIRECTORY.'DwooData.php');
PHPUnit_Util_Filter::addFileToWhitelist(DWOO_DIRECTORY.'DwooInterfaces.php');
PHPUnit_Util_Filter::addFileToWhitelist(DWOO_DIRECTORY.'DwooPlugin.php');
PHPUnit_Util_Filter::addFileToWhitelist(DWOO_DIRECTORY.'DwooSmartyAdapter.php');
PHPUnit_Util_Filter::addFileToWhitelist(DWOO_DIRECTORY.'DwooTemplateFile.php');
PHPUnit_Util_Filter::addFileToWhitelist(DWOO_DIRECTORY.'DwooTemplateString.php');
$suite = new PHPUnit_Framework_TestSuite('Dwoo - Unit Tests Report');
......
......@@ -10,13 +10,13 @@ class FiltersTests extends PHPUnit_Framework_TestCase
public function __construct()
{
// extend this class and override this in your constructor to test a modded compiler
$this->compiler = new DwooCompiler();
$this->compiler = new Dwoo_Compiler();
$this->dwoo = new Dwoo();
}
public function testHtmlFormat()
{
$tpl = new DwooTemplateString("<html><body><div><p>a<em>b</em>c<hr /></p><textarea>a\n b</textarea></div></body><html>");
$tpl = new Dwoo_Template_String("<html><body><div><p>a<em>b</em>c<hr /></p><textarea>a\n b</textarea></div></body><html>");
$tpl->forceCompilation();
$dwoo = new Dwoo();
......@@ -41,9 +41,9 @@ SNIPPET
public function testSmartyCompat()
{
$tpl = new DwooTemplateString('{ldelim}{$smarty.version}{rdelim}');
$tpl = new Dwoo_Template_String('{ldelim}{$smarty.version}{rdelim}');
$tpl->forceCompilation();
$cmp = new DwooCompiler();
$cmp = new Dwoo_Compiler();
$cmp->addPreProcessor('smarty_compat', true);
$this->assertEquals('{'.Dwoo::VERSION.'}', $this->dwoo->get($tpl, array(), $cmp));
......
......@@ -10,13 +10,13 @@ class HelperTests extends PHPUnit_Framework_TestCase
public function __construct()
{
// extend this class and override this in your constructor to test a modded compiler
$this->compiler = new DwooCompiler();
$this->compiler = new Dwoo_Compiler();
$this->dwoo = new Dwoo();
}
public function testArray()
{
$tpl = new DwooTemplateString('{if array(3,foo, "bar",$baz|upper) === $test}true{/if}');
$tpl = new Dwoo_Template_String('{if array(3,foo, "bar",$baz|upper) === $test}true{/if}');
$tpl->forceCompilation();
$this->assertEquals('true', $this->dwoo->get($tpl, array('test'=>array(3, "foo", "bar", "BAZ"), 'baz'=>'baz'), $this->compiler));
......@@ -24,7 +24,7 @@ class HelperTests extends PHPUnit_Framework_TestCase
public function testAssociativeArray()
{
$tpl = new DwooTemplateString('{if array(hoy=3,5="foo",bar=moo) === $test}true{/if}');
$tpl = new Dwoo_Template_String('{if array(hoy=3,5="foo",bar=moo) === $test}true{/if}');
$tpl->forceCompilation();
$this->assertEquals('true', $this->dwoo->get($tpl, array('test'=>array("hoy"=>3, 5=>"foo", "bar"=>"moo"), 'baz'=>'baz'), $this->compiler));
......
......@@ -12,22 +12,22 @@ class SecurityTests extends PHPUnit_Framework_TestCase
public function __construct()
{
$this->compiler = new DwooCompiler();
$this->compiler = new Dwoo_Compiler();
$this->dwoo = new Dwoo();
$this->policy = new DwooSecurityPolicy();
$this->policy = new Dwoo_Security_Policy();
$this->dwoo->setSecurityPolicy($this->policy);
}
public function testConstantHandling()
{
$tpl = new DwooTemplateString('{$dwoo.const.DWOO_DIRECTORY}');
$tpl = new Dwoo_Template_String('{$dwoo.const.DWOO_DIRECTORY}');
$tpl->forceCompilation();
$this->assertEquals("", $this->dwoo->get($tpl, array(), $this->compiler));
$this->policy->setConstantHandling(DwooSecurityPolicy::CONST_ALLOW);
$this->policy->setConstantHandling(Dwoo_Security_Policy::CONST_ALLOW);
$tpl = new DwooTemplateString('{$dwoo.const.DWOO_DIRECTORY}');
$tpl = new Dwoo_Template_String('{$dwoo.const.DWOO_DIRECTORY}');
$tpl->forceCompilation();
$this->assertEquals(DWOO_DIRECTORY, $this->dwoo->get($tpl, array(), $this->compiler));
......@@ -35,25 +35,25 @@ class SecurityTests extends PHPUnit_Framework_TestCase
public function testPhpHandling()
{
$this->policy->setPhpHandling(DwooSecurityPolicy::PHP_ALLOW);
$this->policy->setPhpHandling(Dwoo_Security_Policy::PHP_ALLOW);
$tpl = new DwooTemplateString('<?php echo "moo"; ?>');
$tpl = new Dwoo_Template_String('<?php echo "moo"; ?>');
$tpl->forceCompilation();
$this->assertEquals("moo", $this->dwoo->get($tpl, array(), $this->compiler));
$this->policy->setPhpHandling(DwooSecurityPolicy::PHP_ENCODE);
$this->policy->setPhpHandling(Dwoo_Security_Policy::PHP_ENCODE);
$tpl = new DwooTemplateString('<?php echo "moo"; ?>');
$tpl = new Dwoo_Template_String('<?php echo "moo"; ?>');
$tpl->forceCompilation();
$this->assertEquals(htmlspecialchars('<?php echo "moo"; ?>'), $this->dwoo->get($tpl, array(), $this->compiler));
$this->policy->setPhpHandling(DwooSecurityPolicy::PHP_REMOVE);
$this->policy->setPhpHandling(Dwoo_Security_Policy::PHP_REMOVE);
$tpl = new DwooTemplateString('<?php echo "moo"; ?>');
$tpl = new Dwoo_Template_String('<?php echo "moo"; ?>');
$tpl->forceCompilation();
$this->assertEquals('', $this->dwoo->get($tpl, array(), $this->compiler));
......@@ -63,7 +63,7 @@ class SecurityTests extends PHPUnit_Framework_TestCase
{
$this->policy->allowPhpFunction('testphpfunc');
$tpl = new DwooTemplateString('{testphpfunc("foo")}');
$tpl = new Dwoo_Template_String('{testphpfunc("foo")}');
$tpl->forceCompilation();
$this->assertEquals("fooOK", $this->dwoo->get($tpl, array(), $this->compiler));
......
......@@ -10,12 +10,12 @@ class SmartyTests extends PHPUnit_Framework_TestCase
public function __construct()
{
// extend this class and override this in your constructor to test a modded compiler
$this->dwoo = new DwooSmartyAdapter();
$this->dwoo = new Dwoo_Smarty_Adapter();
$this->dwoo->template_dir = DWOO_DIRECTORY.'tests/resources/';
$this->dwoo->compile_dir = DWOO_DIRECTORY.'tests/temp/compiled/';
$this->dwoo->cache_dir = DWOO_DIRECTORY.'tests/temp/cache/';
$this->dwoo->config_dir = DWOO_DIRECTORY.'tests/resources/configs/';
$this->compiler = new DwooCompiler();
$this->compiler = new Dwoo_Compiler();
$this->compiler->addPreProcessor('smarty_compat', true);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment