@@ -23,23 +23,23 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class Adapter extends Processor |
| 25 | 25 | { |
| 26 | - public $callback; |
|
| 26 | + public $callback; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @param string $input |
|
| 30 | - * |
|
| 31 | - * @return mixed |
|
| 32 | - */ |
|
| 33 | - public function process($input) |
|
| 34 | - { |
|
| 35 | - return call_user_func($this->callback, $input); |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * @param string $input |
|
| 30 | + * |
|
| 31 | + * @return mixed |
|
| 32 | + */ |
|
| 33 | + public function process($input) |
|
| 34 | + { |
|
| 35 | + return call_user_func($this->callback, $input); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param $callback |
|
| 40 | - */ |
|
| 41 | - public function registerCallback($callback) |
|
| 42 | - { |
|
| 43 | - $this->callback = $callback; |
|
| 44 | - } |
|
| 38 | + /** |
|
| 39 | + * @param $callback |
|
| 40 | + */ |
|
| 41 | + public function registerCallback($callback) |
|
| 42 | + { |
|
| 43 | + $this->callback = $callback; |
|
| 44 | + } |
|
| 45 | 45 | } |
| 46 | 46 | \ No newline at end of file |
@@ -26,35 +26,35 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class Exception extends DwooException |
| 28 | 28 | { |
| 29 | - protected $compiler; |
|
| 30 | - protected $template; |
|
| 29 | + protected $compiler; |
|
| 30 | + protected $template; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Exception constructor. |
|
| 34 | - * |
|
| 35 | - * @param DwooCompiler $compiler |
|
| 36 | - * @param int $message |
|
| 37 | - */ |
|
| 38 | - public function __construct(DwooCompiler $compiler, $message) |
|
| 39 | - { |
|
| 40 | - $this->compiler = $compiler; |
|
| 41 | - $this->template = $compiler->getDwoo()->getTemplate(); |
|
| 42 | - parent::__construct('Compilation error at line ' . $compiler->getLine() . ' in "' . $this->template->getResourceName() . ':' . $this->template->getResourceIdentifier() . '" : ' . $message); |
|
| 43 | - } |
|
| 32 | + /** |
|
| 33 | + * Exception constructor. |
|
| 34 | + * |
|
| 35 | + * @param DwooCompiler $compiler |
|
| 36 | + * @param int $message |
|
| 37 | + */ |
|
| 38 | + public function __construct(DwooCompiler $compiler, $message) |
|
| 39 | + { |
|
| 40 | + $this->compiler = $compiler; |
|
| 41 | + $this->template = $compiler->getDwoo()->getTemplate(); |
|
| 42 | + parent::__construct('Compilation error at line ' . $compiler->getLine() . ' in "' . $this->template->getResourceName() . ':' . $this->template->getResourceIdentifier() . '" : ' . $message); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @return DwooCompiler |
|
| 47 | - */ |
|
| 48 | - public function getCompiler() |
|
| 49 | - { |
|
| 50 | - return $this->compiler; |
|
| 51 | - } |
|
| 45 | + /** |
|
| 46 | + * @return DwooCompiler |
|
| 47 | + */ |
|
| 48 | + public function getCompiler() |
|
| 49 | + { |
|
| 50 | + return $this->compiler; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @return \Dwoo\ITemplate|null |
|
| 55 | - */ |
|
| 56 | - public function getTemplate() |
|
| 57 | - { |
|
| 58 | - return $this->template; |
|
| 59 | - } |
|
| 53 | + /** |
|
| 54 | + * @return \Dwoo\ITemplate|null |
|
| 55 | + */ |
|
| 56 | + public function getTemplate() |
|
| 57 | + { |
|
| 58 | + return $this->template; |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | { |
| 40 | 40 | $this->compiler = $compiler; |
| 41 | 41 | $this->template = $compiler->getDwoo()->getTemplate(); |
| 42 | - parent::__construct('Compilation error at line ' . $compiler->getLine() . ' in "' . $this->template->getResourceName() . ':' . $this->template->getResourceIdentifier() . '" : ' . $message); |
|
| 42 | + parent::__construct('Compilation error at line '.$compiler->getLine().' in "'.$this->template->getResourceName().':'.$this->template->getResourceIdentifier().'" : '.$message); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -23,52 +23,52 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | interface IPluginProxy |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * Returns true or false to say whether the given plugin is handled by this proxy or not. |
|
| 28 | - * |
|
| 29 | - * @param string $name the plugin name |
|
| 30 | - * |
|
| 31 | - * @return bool true if the plugin is known and usable, otherwise false |
|
| 32 | - */ |
|
| 33 | - public function handles($name); |
|
| 26 | + /** |
|
| 27 | + * Returns true or false to say whether the given plugin is handled by this proxy or not. |
|
| 28 | + * |
|
| 29 | + * @param string $name the plugin name |
|
| 30 | + * |
|
| 31 | + * @return bool true if the plugin is known and usable, otherwise false |
|
| 32 | + */ |
|
| 33 | + public function handles($name); |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Returns the code (as a string) to call the plugin |
|
| 37 | - * (this will be executed at runtime inside the Dwoo class). |
|
| 38 | - * |
|
| 39 | - * @param string $name the plugin name |
|
| 40 | - * @param array $params a parameter array, array key "*" is the rest array |
|
| 41 | - * |
|
| 42 | - * @return string |
|
| 43 | - */ |
|
| 44 | - public function getCode($name, $params); |
|
| 35 | + /** |
|
| 36 | + * Returns the code (as a string) to call the plugin |
|
| 37 | + * (this will be executed at runtime inside the Dwoo class). |
|
| 38 | + * |
|
| 39 | + * @param string $name the plugin name |
|
| 40 | + * @param array $params a parameter array, array key "*" is the rest array |
|
| 41 | + * |
|
| 42 | + * @return string |
|
| 43 | + */ |
|
| 44 | + public function getCode($name, $params); |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Returns a callback to the plugin, this is used with the reflection API to |
|
| 48 | - * find out about the plugin's parameter names etc. |
|
| 49 | - * should you need a rest array without the possibility to edit the |
|
| 50 | - * plugin's code, you can provide a callback to some |
|
| 51 | - * other function with the correct parameter signature, i.e. : |
|
| 52 | - * <code> |
|
| 53 | - * return array($this, "callbackHelper"); |
|
| 54 | - * // and callbackHelper would be as such: |
|
| 55 | - * public function callbackHelper(array $rest=array()){} |
|
| 56 | - * </code> |
|
| 57 | - * |
|
| 58 | - * @param string $name the plugin name |
|
| 59 | - * |
|
| 60 | - * @return callback |
|
| 61 | - */ |
|
| 62 | - public function getCallback($name); |
|
| 46 | + /** |
|
| 47 | + * Returns a callback to the plugin, this is used with the reflection API to |
|
| 48 | + * find out about the plugin's parameter names etc. |
|
| 49 | + * should you need a rest array without the possibility to edit the |
|
| 50 | + * plugin's code, you can provide a callback to some |
|
| 51 | + * other function with the correct parameter signature, i.e. : |
|
| 52 | + * <code> |
|
| 53 | + * return array($this, "callbackHelper"); |
|
| 54 | + * // and callbackHelper would be as such: |
|
| 55 | + * public function callbackHelper(array $rest=array()){} |
|
| 56 | + * </code> |
|
| 57 | + * |
|
| 58 | + * @param string $name the plugin name |
|
| 59 | + * |
|
| 60 | + * @return callback |
|
| 61 | + */ |
|
| 62 | + public function getCallback($name); |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Returns some code that will check if the plugin is loaded and if not load it |
|
| 66 | - * this is optional, if your plugins are autoloaded or whatever, just return an |
|
| 67 | - * empty string. |
|
| 68 | - * |
|
| 69 | - * @param string $name the plugin name |
|
| 70 | - * |
|
| 71 | - * @return string |
|
| 72 | - */ |
|
| 73 | - public function getLoader($name); |
|
| 64 | + /** |
|
| 65 | + * Returns some code that will check if the plugin is loaded and if not load it |
|
| 66 | + * this is optional, if your plugins are autoloaded or whatever, just return an |
|
| 67 | + * empty string. |
|
| 68 | + * |
|
| 69 | + * @param string $name the plugin name |
|
| 70 | + * |
|
| 71 | + * @return string |
|
| 72 | + */ |
|
| 73 | + public function getLoader($name); |
|
| 74 | 74 | } |
@@ -23,137 +23,137 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | interface ITemplate |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * Returns the cache duration for this template. |
|
| 28 | - * defaults to null if it was not provided |
|
| 29 | - * |
|
| 30 | - * @return int|null |
|
| 31 | - */ |
|
| 32 | - public function getCacheTime(); |
|
| 26 | + /** |
|
| 27 | + * Returns the cache duration for this template. |
|
| 28 | + * defaults to null if it was not provided |
|
| 29 | + * |
|
| 30 | + * @return int|null |
|
| 31 | + */ |
|
| 32 | + public function getCacheTime(); |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Sets the cache duration for this template. |
|
| 36 | - * can be used to set it after the object is created if you did not provide |
|
| 37 | - * it in the constructor |
|
| 38 | - * |
|
| 39 | - * @param int $seconds duration of the cache validity for this template, if |
|
| 40 | - * null it defaults to the Dwoo instance's cache time. 0 = disable and |
|
| 41 | - * -1 = infinite cache |
|
| 42 | - */ |
|
| 43 | - public function setCacheTime($seconds = null); |
|
| 34 | + /** |
|
| 35 | + * Sets the cache duration for this template. |
|
| 36 | + * can be used to set it after the object is created if you did not provide |
|
| 37 | + * it in the constructor |
|
| 38 | + * |
|
| 39 | + * @param int $seconds duration of the cache validity for this template, if |
|
| 40 | + * null it defaults to the Dwoo instance's cache time. 0 = disable and |
|
| 41 | + * -1 = infinite cache |
|
| 42 | + */ |
|
| 43 | + public function setCacheTime($seconds = null); |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Returns the cached template output file name, true if it's cache-able but not cached |
|
| 47 | - * or false if it's not cached. |
|
| 48 | - * |
|
| 49 | - * @param Core $dwoo the dwoo instance that requests it |
|
| 50 | - * |
|
| 51 | - * @return string|bool |
|
| 52 | - */ |
|
| 53 | - public function getCachedTemplate(Core $dwoo); |
|
| 45 | + /** |
|
| 46 | + * Returns the cached template output file name, true if it's cache-able but not cached |
|
| 47 | + * or false if it's not cached. |
|
| 48 | + * |
|
| 49 | + * @param Core $dwoo the dwoo instance that requests it |
|
| 50 | + * |
|
| 51 | + * @return string|bool |
|
| 52 | + */ |
|
| 53 | + public function getCachedTemplate(Core $dwoo); |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Caches the provided output into the cache file. |
|
| 57 | - * |
|
| 58 | - * @param Core $dwoo the dwoo instance that requests it |
|
| 59 | - * @param string $output the template output |
|
| 60 | - * |
|
| 61 | - * @return mixed full path of the cached file or false upon failure |
|
| 62 | - */ |
|
| 63 | - public function cache(Core $dwoo, $output); |
|
| 55 | + /** |
|
| 56 | + * Caches the provided output into the cache file. |
|
| 57 | + * |
|
| 58 | + * @param Core $dwoo the dwoo instance that requests it |
|
| 59 | + * @param string $output the template output |
|
| 60 | + * |
|
| 61 | + * @return mixed full path of the cached file or false upon failure |
|
| 62 | + */ |
|
| 63 | + public function cache(Core $dwoo, $output); |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Clears the cached template if it's older than the given time. |
|
| 67 | - * |
|
| 68 | - * @param Core $dwoo the dwoo instance that was used to cache that template |
|
| 69 | - * @param int $olderThan minimum time (in seconds) required for the cache to be cleared |
|
| 70 | - * |
|
| 71 | - * @return bool true if the cache was not present or if it was deleted, false if it remains there |
|
| 72 | - */ |
|
| 73 | - public function clearCache(Core $dwoo, $olderThan = - 1); |
|
| 65 | + /** |
|
| 66 | + * Clears the cached template if it's older than the given time. |
|
| 67 | + * |
|
| 68 | + * @param Core $dwoo the dwoo instance that was used to cache that template |
|
| 69 | + * @param int $olderThan minimum time (in seconds) required for the cache to be cleared |
|
| 70 | + * |
|
| 71 | + * @return bool true if the cache was not present or if it was deleted, false if it remains there |
|
| 72 | + */ |
|
| 73 | + public function clearCache(Core $dwoo, $olderThan = - 1); |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Returns the compiled template file name. |
|
| 77 | - * |
|
| 78 | - * @param Core $dwoo the dwoo instance that requests it |
|
| 79 | - * @param ICompiler $compiler the compiler that must be used |
|
| 80 | - * |
|
| 81 | - * @return string |
|
| 82 | - */ |
|
| 83 | - public function getCompiledTemplate(Core $dwoo, ICompiler $compiler = null); |
|
| 75 | + /** |
|
| 76 | + * Returns the compiled template file name. |
|
| 77 | + * |
|
| 78 | + * @param Core $dwoo the dwoo instance that requests it |
|
| 79 | + * @param ICompiler $compiler the compiler that must be used |
|
| 80 | + * |
|
| 81 | + * @return string |
|
| 82 | + */ |
|
| 83 | + public function getCompiledTemplate(Core $dwoo, ICompiler $compiler = null); |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Returns the template name. |
|
| 87 | - * |
|
| 88 | - * @return string |
|
| 89 | - */ |
|
| 90 | - public function getName(); |
|
| 85 | + /** |
|
| 86 | + * Returns the template name. |
|
| 87 | + * |
|
| 88 | + * @return string |
|
| 89 | + */ |
|
| 90 | + public function getName(); |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Returns the resource name for this template class. |
|
| 94 | - * |
|
| 95 | - * @return string |
|
| 96 | - */ |
|
| 97 | - public function getResourceName(); |
|
| 92 | + /** |
|
| 93 | + * Returns the resource name for this template class. |
|
| 94 | + * |
|
| 95 | + * @return string |
|
| 96 | + */ |
|
| 97 | + public function getResourceName(); |
|
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * Returns the resource identifier for this template or false if it has no identifier. |
|
| 101 | - * |
|
| 102 | - * @return string|false |
|
| 103 | - */ |
|
| 104 | - public function getResourceIdentifier(); |
|
| 99 | + /** |
|
| 100 | + * Returns the resource identifier for this template or false if it has no identifier. |
|
| 101 | + * |
|
| 102 | + * @return string|false |
|
| 103 | + */ |
|
| 104 | + public function getResourceIdentifier(); |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Returns the template source of this template. |
|
| 108 | - * |
|
| 109 | - * @return string |
|
| 110 | - */ |
|
| 111 | - public function getSource(); |
|
| 106 | + /** |
|
| 107 | + * Returns the template source of this template. |
|
| 108 | + * |
|
| 109 | + * @return string |
|
| 110 | + */ |
|
| 111 | + public function getSource(); |
|
| 112 | 112 | |
| 113 | - /** |
|
| 114 | - * Returns an unique string identifying the current version of this template, |
|
| 115 | - * for example a timestamp of the last modified date or a hash of the template source. |
|
| 116 | - * |
|
| 117 | - * @return string |
|
| 118 | - */ |
|
| 119 | - public function getUid(); |
|
| 113 | + /** |
|
| 114 | + * Returns an unique string identifying the current version of this template, |
|
| 115 | + * for example a timestamp of the last modified date or a hash of the template source. |
|
| 116 | + * |
|
| 117 | + * @return string |
|
| 118 | + */ |
|
| 119 | + public function getUid(); |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * Returns the compiler used by this template, if it was just compiled, or null. |
|
| 123 | - * |
|
| 124 | - * @return ICompiler |
|
| 125 | - */ |
|
| 126 | - public function getCompiler(); |
|
| 121 | + /** |
|
| 122 | + * Returns the compiler used by this template, if it was just compiled, or null. |
|
| 123 | + * |
|
| 124 | + * @return ICompiler |
|
| 125 | + */ |
|
| 126 | + public function getCompiler(); |
|
| 127 | 127 | |
| 128 | - /** |
|
| 129 | - * Returns some php code that will check if this template has been modified or not. |
|
| 130 | - * if the function returns null, the template will be instanciated and then the Uid checked |
|
| 131 | - * |
|
| 132 | - * @return string |
|
| 133 | - */ |
|
| 134 | - public function getIsModifiedCode(); |
|
| 128 | + /** |
|
| 129 | + * Returns some php code that will check if this template has been modified or not. |
|
| 130 | + * if the function returns null, the template will be instanciated and then the Uid checked |
|
| 131 | + * |
|
| 132 | + * @return string |
|
| 133 | + */ |
|
| 134 | + public function getIsModifiedCode(); |
|
| 135 | 135 | |
| 136 | - /** |
|
| 137 | - * Returns a new template object from the given resource identifier, null if no include is |
|
| 138 | - * possible (resource not found), or false if include is not permitted by this resource type. |
|
| 139 | - * this method should also check if $dwoo->getSecurityPolicy() is null or not and do the |
|
| 140 | - * necessary permission checks if required, if the security policy prevents the template |
|
| 141 | - * generation it should throw a new Security\Exception with a relevant message |
|
| 142 | - * |
|
| 143 | - * @param mixed $resourceId the resource identifier |
|
| 144 | - * @param int $cacheTime duration of the cache validity for this template, if null it defaults to the |
|
| 145 | - * Dwoo instance that will render this template if null it defaults to the Dwoo |
|
| 146 | - * instance that will render this template |
|
| 147 | - * @param string $cacheId the unique cache identifier of this page or anything else that makes this |
|
| 148 | - * template's content unique, if null it defaults to the current url makes this |
|
| 149 | - * template's content unique, if null it defaults to the current url |
|
| 150 | - * @param string $compileId the unique compiled identifier, which is used to distinguish this template from |
|
| 151 | - * others, if null it defaults to the filename+bits of the path template from |
|
| 152 | - * others, if null it defaults to the filename+bits of the path |
|
| 153 | - * @param ITemplate $parentTemplate the template that is requesting a new template object (through an include, |
|
| 154 | - * extends or any other plugin) an include, extends or any other plugin) |
|
| 155 | - * |
|
| 156 | - * @return ITemplate|null|false |
|
| 157 | - */ |
|
| 158 | - public static function templateFactory(Core $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, ITemplate $parentTemplate = null); |
|
| 136 | + /** |
|
| 137 | + * Returns a new template object from the given resource identifier, null if no include is |
|
| 138 | + * possible (resource not found), or false if include is not permitted by this resource type. |
|
| 139 | + * this method should also check if $dwoo->getSecurityPolicy() is null or not and do the |
|
| 140 | + * necessary permission checks if required, if the security policy prevents the template |
|
| 141 | + * generation it should throw a new Security\Exception with a relevant message |
|
| 142 | + * |
|
| 143 | + * @param mixed $resourceId the resource identifier |
|
| 144 | + * @param int $cacheTime duration of the cache validity for this template, if null it defaults to the |
|
| 145 | + * Dwoo instance that will render this template if null it defaults to the Dwoo |
|
| 146 | + * instance that will render this template |
|
| 147 | + * @param string $cacheId the unique cache identifier of this page or anything else that makes this |
|
| 148 | + * template's content unique, if null it defaults to the current url makes this |
|
| 149 | + * template's content unique, if null it defaults to the current url |
|
| 150 | + * @param string $compileId the unique compiled identifier, which is used to distinguish this template from |
|
| 151 | + * others, if null it defaults to the filename+bits of the path template from |
|
| 152 | + * others, if null it defaults to the filename+bits of the path |
|
| 153 | + * @param ITemplate $parentTemplate the template that is requesting a new template object (through an include, |
|
| 154 | + * extends or any other plugin) an include, extends or any other plugin) |
|
| 155 | + * |
|
| 156 | + * @return ITemplate|null|false |
|
| 157 | + */ |
|
| 158 | + public static function templateFactory(Core $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, ITemplate $parentTemplate = null); |
|
| 159 | 159 | } |
@@ -23,30 +23,30 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | abstract class Filter |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * The dwoo instance that runs this filter. |
|
| 28 | - * |
|
| 29 | - * @var Core |
|
| 30 | - */ |
|
| 31 | - protected $dwoo; |
|
| 26 | + /** |
|
| 27 | + * The dwoo instance that runs this filter. |
|
| 28 | + * |
|
| 29 | + * @var Core |
|
| 30 | + */ |
|
| 31 | + protected $dwoo; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Constructor, if you override it, call parent::__construct($dwoo); or assign |
|
| 35 | - * the dwoo instance yourself if you need it. |
|
| 36 | - * |
|
| 37 | - * @param Core $dwoo the dwoo instance that runs this plugin |
|
| 38 | - */ |
|
| 39 | - public function __construct(Core $dwoo) |
|
| 40 | - { |
|
| 41 | - $this->dwoo = $dwoo; |
|
| 42 | - } |
|
| 33 | + /** |
|
| 34 | + * Constructor, if you override it, call parent::__construct($dwoo); or assign |
|
| 35 | + * the dwoo instance yourself if you need it. |
|
| 36 | + * |
|
| 37 | + * @param Core $dwoo the dwoo instance that runs this plugin |
|
| 38 | + */ |
|
| 39 | + public function __construct(Core $dwoo) |
|
| 40 | + { |
|
| 41 | + $this->dwoo = $dwoo; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Processes the input and returns it filtered. |
|
| 46 | - * |
|
| 47 | - * @param string $input the template to process |
|
| 48 | - * |
|
| 49 | - * @return string |
|
| 50 | - */ |
|
| 51 | - abstract public function process($input); |
|
| 44 | + /** |
|
| 45 | + * Processes the input and returns it filtered. |
|
| 46 | + * |
|
| 47 | + * @param string $input the template to process |
|
| 48 | + * |
|
| 49 | + * @return string |
|
| 50 | + */ |
|
| 51 | + abstract public function process($input); |
|
| 52 | 52 | } |
@@ -23,15 +23,15 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | interface ILoader |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * Loads a plugin file. |
|
| 28 | - * the second parameter is used to avoid permanent rehashing when using php functions, |
|
| 29 | - * however this means that if you have add a plugin that overrides a php function you have |
|
| 30 | - * to delete the classpath.cache file(s) by hand to force a rehash of the plugins |
|
| 31 | - * |
|
| 32 | - * @param string $class the plugin name, without the `Plugin` prefix |
|
| 33 | - * @param bool $forceRehash if true, the class path caches will be rebuilt if the plugin is not found, in case it |
|
| 34 | - * has just been added, defaults to true |
|
| 35 | - */ |
|
| 36 | - public function loadPlugin($class, $forceRehash = true); |
|
| 26 | + /** |
|
| 27 | + * Loads a plugin file. |
|
| 28 | + * the second parameter is used to avoid permanent rehashing when using php functions, |
|
| 29 | + * however this means that if you have add a plugin that overrides a php function you have |
|
| 30 | + * to delete the classpath.cache file(s) by hand to force a rehash of the plugins |
|
| 31 | + * |
|
| 32 | + * @param string $class the plugin name, without the `Plugin` prefix |
|
| 33 | + * @param bool $forceRehash if true, the class path caches will be rebuilt if the plugin is not found, in case it |
|
| 34 | + * has just been added, defaults to true |
|
| 35 | + */ |
|
| 36 | + public function loadPlugin($class, $forceRehash = true); |
|
| 37 | 37 | } |
@@ -26,6 +26,6 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | interface ICompilable |
| 28 | 28 | { |
| 29 | - // this replaces the process function |
|
| 30 | - //public static function compile(Compiler $compiler, $arg, $arg, ...); |
|
| 29 | + // this replaces the process function |
|
| 30 | + //public static function compile(Compiler $compiler, $arg, $arg, ...); |
|
| 31 | 31 | } |
@@ -42,118 +42,118 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | class DwooView extends View |
| 44 | 44 | { |
| 45 | - protected $_sv_template_dir; |
|
| 46 | - protected $_sv_layout_dir; |
|
| 47 | - protected $_sv_compile_dir; |
|
| 48 | - protected $_sv_cache_dir; |
|
| 49 | - protected $_sv_compile_id; |
|
| 50 | - |
|
| 51 | - protected $_dwoo; |
|
| 52 | - |
|
| 53 | - public $sv_processedTpl; |
|
| 45 | + protected $_sv_template_dir; |
|
| 46 | + protected $_sv_layout_dir; |
|
| 47 | + protected $_sv_compile_dir; |
|
| 48 | + protected $_sv_cache_dir; |
|
| 49 | + protected $_sv_compile_id; |
|
| 50 | + |
|
| 51 | + protected $_dwoo; |
|
| 52 | + |
|
| 53 | + public $sv_processedTpl; |
|
| 54 | 54 | |
| 55 | - public function __construct(&$controller) |
|
| 56 | - { |
|
| 57 | - parent::__construct($controller); |
|
| 58 | - |
|
| 59 | - $this->ext = '.tpl'; |
|
| 60 | - |
|
| 61 | - $this->_sv_template_dir = array( |
|
| 62 | - VIEWS.$this->viewPath.DS.$this->subDir, |
|
| 63 | - VIEWS.$this->viewPath, |
|
| 64 | - VIEWS, |
|
| 65 | - ); |
|
| 66 | - |
|
| 67 | - $this->_sv_layout_dir = array( |
|
| 68 | - LAYOUTS.$this->subDir, |
|
| 69 | - VIEWS, |
|
| 70 | - ); |
|
| 71 | - |
|
| 72 | - $this->_sv_compile_dir = TMP.'dwoo'.DS.'compile'; |
|
| 73 | - $this->_sv_cache_dir = TMP.'dwoo'.DS.'cache'; |
|
| 74 | - |
|
| 75 | - $this->_dwoo = new Dwoo_Core($this->_sv_compile_dir, $this->_sv_cache_dir); |
|
| 76 | - |
|
| 77 | - $this->_sv_compile_id = $controller->name; |
|
| 78 | - |
|
| 79 | - $this->_dwoo->sv_this = $this; |
|
| 80 | - $this->_dwoo->setSecurityPolicy(); |
|
| 81 | - |
|
| 82 | - return; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * changes the template directory. |
|
| 87 | - */ |
|
| 88 | - public function setTemplateDir($path = VIEW) |
|
| 89 | - { |
|
| 90 | - $old = $this->_sv_template_dir; |
|
| 91 | - $this->_sv_template_dir = $path; |
|
| 92 | - |
|
| 93 | - return $old; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - public function getTemplateDir() |
|
| 97 | - { |
|
| 98 | - return $this->_sv_template_dir; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - public function _render($___viewFn, $___data_for_view, $___play_safe = true, $loadHelpers = true) |
|
| 102 | - { |
|
| 103 | - // let's determine if this is a layout call or a template call |
|
| 104 | - // and change the template dir accordingly |
|
| 105 | - $layout = false; |
|
| 106 | - if (isset($___data_for_view['content_for_layout'])) { |
|
| 107 | - $this->_sv_template_dir = $this->_sv_layout_dir; |
|
| 108 | - $layout = true; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - $tpl = new Dwoo_Template_File($___viewFn); |
|
| 112 | - $data = $___data_for_view; |
|
| 113 | - |
|
| 114 | - $data['view'] = $this; |
|
| 115 | - |
|
| 116 | - if ($this->helpers != false && $loadHelpers === true) { |
|
| 117 | - $loadedHelpers = array(); |
|
| 118 | - $loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers); |
|
| 119 | - |
|
| 120 | - foreach (array_keys($loadedHelpers) as $helper) { |
|
| 121 | - $camelBackedHelper = strtolower(substr($helper, 0, 1)).substr($helper, 1); |
|
| 122 | - |
|
| 123 | - ${$camelBackedHelper} = $loadedHelpers[$helper]; |
|
| 124 | - |
|
| 125 | - if (is_array(${$camelBackedHelper}->helpers) && !empty(${$camelBackedHelper}->helpers)) { |
|
| 126 | - $subHelpers = ${$camelBackedHelper}->helpers; |
|
| 127 | - foreach ($subHelpers as $subHelper) { |
|
| 128 | - ${$camelBackedHelper}->{$subHelper} = $loadedHelpers[$subHelper]; |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - if (isset($this->passedArgs)) { |
|
| 133 | - ${$camelBackedHelper}->passedArgs = $this->passedArgs; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - $this->loaded[$camelBackedHelper] = ${$camelBackedHelper}; |
|
| 137 | - |
|
| 138 | - $data[$camelBackedHelper] = ${$camelBackedHelper}; |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - if ($this->helpers != false && $loadHelpers === true) { |
|
| 143 | - foreach ($loadedHelpers as $helper) { |
|
| 144 | - if (is_object($helper)) { |
|
| 145 | - if (is_subclass_of($helper, 'Helper') || is_subclass_of($helper, 'helper')) { |
|
| 146 | - $helper->beforeRender(); |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - return $this->_dwoo->get($tpl, $data); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - public function get() |
|
| 156 | - { |
|
| 157 | - return $this->_dwoo; |
|
| 158 | - } |
|
| 55 | + public function __construct(&$controller) |
|
| 56 | + { |
|
| 57 | + parent::__construct($controller); |
|
| 58 | + |
|
| 59 | + $this->ext = '.tpl'; |
|
| 60 | + |
|
| 61 | + $this->_sv_template_dir = array( |
|
| 62 | + VIEWS.$this->viewPath.DS.$this->subDir, |
|
| 63 | + VIEWS.$this->viewPath, |
|
| 64 | + VIEWS, |
|
| 65 | + ); |
|
| 66 | + |
|
| 67 | + $this->_sv_layout_dir = array( |
|
| 68 | + LAYOUTS.$this->subDir, |
|
| 69 | + VIEWS, |
|
| 70 | + ); |
|
| 71 | + |
|
| 72 | + $this->_sv_compile_dir = TMP.'dwoo'.DS.'compile'; |
|
| 73 | + $this->_sv_cache_dir = TMP.'dwoo'.DS.'cache'; |
|
| 74 | + |
|
| 75 | + $this->_dwoo = new Dwoo_Core($this->_sv_compile_dir, $this->_sv_cache_dir); |
|
| 76 | + |
|
| 77 | + $this->_sv_compile_id = $controller->name; |
|
| 78 | + |
|
| 79 | + $this->_dwoo->sv_this = $this; |
|
| 80 | + $this->_dwoo->setSecurityPolicy(); |
|
| 81 | + |
|
| 82 | + return; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * changes the template directory. |
|
| 87 | + */ |
|
| 88 | + public function setTemplateDir($path = VIEW) |
|
| 89 | + { |
|
| 90 | + $old = $this->_sv_template_dir; |
|
| 91 | + $this->_sv_template_dir = $path; |
|
| 92 | + |
|
| 93 | + return $old; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + public function getTemplateDir() |
|
| 97 | + { |
|
| 98 | + return $this->_sv_template_dir; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + public function _render($___viewFn, $___data_for_view, $___play_safe = true, $loadHelpers = true) |
|
| 102 | + { |
|
| 103 | + // let's determine if this is a layout call or a template call |
|
| 104 | + // and change the template dir accordingly |
|
| 105 | + $layout = false; |
|
| 106 | + if (isset($___data_for_view['content_for_layout'])) { |
|
| 107 | + $this->_sv_template_dir = $this->_sv_layout_dir; |
|
| 108 | + $layout = true; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + $tpl = new Dwoo_Template_File($___viewFn); |
|
| 112 | + $data = $___data_for_view; |
|
| 113 | + |
|
| 114 | + $data['view'] = $this; |
|
| 115 | + |
|
| 116 | + if ($this->helpers != false && $loadHelpers === true) { |
|
| 117 | + $loadedHelpers = array(); |
|
| 118 | + $loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers); |
|
| 119 | + |
|
| 120 | + foreach (array_keys($loadedHelpers) as $helper) { |
|
| 121 | + $camelBackedHelper = strtolower(substr($helper, 0, 1)).substr($helper, 1); |
|
| 122 | + |
|
| 123 | + ${$camelBackedHelper} = $loadedHelpers[$helper]; |
|
| 124 | + |
|
| 125 | + if (is_array(${$camelBackedHelper}->helpers) && !empty(${$camelBackedHelper}->helpers)) { |
|
| 126 | + $subHelpers = ${$camelBackedHelper}->helpers; |
|
| 127 | + foreach ($subHelpers as $subHelper) { |
|
| 128 | + ${$camelBackedHelper}->{$subHelper} = $loadedHelpers[$subHelper]; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + if (isset($this->passedArgs)) { |
|
| 133 | + ${$camelBackedHelper}->passedArgs = $this->passedArgs; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + $this->loaded[$camelBackedHelper] = ${$camelBackedHelper}; |
|
| 137 | + |
|
| 138 | + $data[$camelBackedHelper] = ${$camelBackedHelper}; |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + if ($this->helpers != false && $loadHelpers === true) { |
|
| 143 | + foreach ($loadedHelpers as $helper) { |
|
| 144 | + if (is_object($helper)) { |
|
| 145 | + if (is_subclass_of($helper, 'Helper') || is_subclass_of($helper, 'helper')) { |
|
| 146 | + $helper->beforeRender(); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + return $this->_dwoo->get($tpl, $data); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + public function get() |
|
| 156 | + { |
|
| 157 | + return $this->_dwoo; |
|
| 158 | + } |
|
| 159 | 159 | } |
@@ -16,157 +16,157 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class DwooRenderer extends AgaviRenderer implements AgaviIReusableRenderer |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * @constant string The directory inside the cache dir where templates will |
|
| 21 | - * be stored in compiled form. |
|
| 22 | - */ |
|
| 23 | - const COMPILE_DIR = 'templates'; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @constant string The subdirectory inside the compile dir where templates |
|
| 27 | - * will be stored in compiled form. |
|
| 28 | - */ |
|
| 29 | - const COMPILE_SUBDIR = 'dwoo'; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @constant string The directory inside the cache dir where cached content |
|
| 33 | - * will be stored. |
|
| 34 | - */ |
|
| 35 | - const CACHE_DIR = 'dwoo'; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @var Dwoo Dwoo template engine |
|
| 39 | - */ |
|
| 40 | - protected $dwoo = null; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @var string A string with the default template file extension, |
|
| 44 | - * including the dot |
|
| 45 | - */ |
|
| 46 | - protected $defaultExtension = '.html'; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * stores the (optional) plugin directories to add to the Dwoo_Loader. |
|
| 50 | - */ |
|
| 51 | - protected $plugin_dir = null; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Pre-serialization callback. |
|
| 55 | - * |
|
| 56 | - * Excludes the Dwoo instance to prevent excessive serialization load. |
|
| 57 | - */ |
|
| 58 | - public function __sleep() |
|
| 59 | - { |
|
| 60 | - $keys = parent::__sleep(); |
|
| 61 | - unset($keys[array_search('dwoo', $keys)]); |
|
| 62 | - |
|
| 63 | - return $keys; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Initialize this Renderer. |
|
| 68 | - * |
|
| 69 | - * @param AgaviContext The current application context |
|
| 70 | - * @param array An associative array of initialization parameters |
|
| 71 | - */ |
|
| 72 | - public function initialize(AgaviContext $context, array $parameters = array()) |
|
| 73 | - { |
|
| 74 | - parent::initialize($context, $parameters); |
|
| 75 | - |
|
| 76 | - $this->plugin_dir = $this->getParameter('plugin_dir', $this->plugin_dir); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * provides a custom compiler to the dwoo renderer with optional settings |
|
| 81 | - * you can set in the agavi output_types.xml config file. |
|
| 82 | - * |
|
| 83 | - * @return Dwoo_Compiler |
|
| 84 | - */ |
|
| 85 | - public function compilerFactory() |
|
| 86 | - { |
|
| 87 | - $compiler = Dwoo_Compiler::compilerFactory(); |
|
| 88 | - $compiler->setAutoEscape((bool) $this->getParameter('auto_escape', false)); |
|
| 89 | - |
|
| 90 | - return $compiler; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * Grab a cleaned up dwoo instance. |
|
| 95 | - * |
|
| 96 | - * @return Dwoo A Dwoo instance |
|
| 97 | - */ |
|
| 98 | - protected function getEngine() |
|
| 99 | - { |
|
| 100 | - if ($this->dwoo) { |
|
| 101 | - return $this->dwoo; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - // this triggers Agavi autoload |
|
| 105 | - if (!class_exists('Dwoo')) { |
|
| 106 | - if (file_exists(dirname(__FILE__).'/../../../dwooAutoload.php')) { |
|
| 107 | - // file was dropped with the entire dwoo package |
|
| 108 | - include dirname(__FILE__).'/../../../dwooAutoload.php'; |
|
| 109 | - } else { |
|
| 110 | - // assume the dwoo package is in the include path |
|
| 111 | - include 'dwooAutoload.php'; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - $parentMode = fileperms(AgaviConfig::get('core.cache_dir')); |
|
| 116 | - |
|
| 117 | - $compileDir = AgaviConfig::get('core.cache_dir').DIRECTORY_SEPARATOR.self::COMPILE_DIR.DIRECTORY_SEPARATOR.self::COMPILE_SUBDIR; |
|
| 118 | - AgaviToolkit::mkdir($compileDir, $parentMode, true); |
|
| 119 | - |
|
| 120 | - $cacheDir = AgaviConfig::get('core.cache_dir').DIRECTORY_SEPARATOR.self::CACHE_DIR; |
|
| 121 | - AgaviToolkit::mkdir($cacheDir, $parentMode, true); |
|
| 122 | - |
|
| 123 | - $this->dwoo = new Dwoo_Core($compileDir, $cacheDir); |
|
| 124 | - |
|
| 125 | - if (!empty($this->plugin_dir)) { |
|
| 126 | - foreach ((array) $this->plugin_dir as $dir) { |
|
| 127 | - $this->dwoo->getLoader()->addDirectory($dir); |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - $this->dwoo->setDefaultCompilerFactory('file', array($this, 'compilerFactory')); |
|
| 132 | - |
|
| 133 | - return $this->dwoo; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * Render the presentation and return the result. |
|
| 138 | - * |
|
| 139 | - * @param AgaviTemplateLayer The template layer to render |
|
| 140 | - * @param array The template variables |
|
| 141 | - * @param array The slots |
|
| 142 | - * @param array Associative array of additional assigns |
|
| 143 | - * |
|
| 144 | - * @return string A rendered result |
|
| 145 | - */ |
|
| 146 | - public function render(AgaviTemplateLayer $layer, array &$attributes = array(), array &$slots = array(), array &$moreAssigns = array()) |
|
| 147 | - { |
|
| 148 | - $engine = $this->getEngine(); |
|
| 149 | - |
|
| 150 | - $data = array(); |
|
| 151 | - if ($this->extractVars) { |
|
| 152 | - $data = $attributes; |
|
| 153 | - } else { |
|
| 154 | - $data[$this->varName] = &$attributes; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - $data[$this->slotsVarName] = &$slots; |
|
| 158 | - |
|
| 159 | - foreach ($this->assigns as $key => $getter) { |
|
| 160 | - $data[$key] = $this->getContext()->$getter(); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - foreach ($moreAssigns as $key => &$value) { |
|
| 164 | - if (isset($this->moreAssignNames[$key])) { |
|
| 165 | - $key = $this->moreAssignNames[$key]; |
|
| 166 | - } |
|
| 167 | - $data[$key] = &$value; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - return $engine->get($layer->getResourceStreamIdentifier(), $data); |
|
| 171 | - } |
|
| 19 | + /** |
|
| 20 | + * @constant string The directory inside the cache dir where templates will |
|
| 21 | + * be stored in compiled form. |
|
| 22 | + */ |
|
| 23 | + const COMPILE_DIR = 'templates'; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @constant string The subdirectory inside the compile dir where templates |
|
| 27 | + * will be stored in compiled form. |
|
| 28 | + */ |
|
| 29 | + const COMPILE_SUBDIR = 'dwoo'; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @constant string The directory inside the cache dir where cached content |
|
| 33 | + * will be stored. |
|
| 34 | + */ |
|
| 35 | + const CACHE_DIR = 'dwoo'; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @var Dwoo Dwoo template engine |
|
| 39 | + */ |
|
| 40 | + protected $dwoo = null; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @var string A string with the default template file extension, |
|
| 44 | + * including the dot |
|
| 45 | + */ |
|
| 46 | + protected $defaultExtension = '.html'; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * stores the (optional) plugin directories to add to the Dwoo_Loader. |
|
| 50 | + */ |
|
| 51 | + protected $plugin_dir = null; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Pre-serialization callback. |
|
| 55 | + * |
|
| 56 | + * Excludes the Dwoo instance to prevent excessive serialization load. |
|
| 57 | + */ |
|
| 58 | + public function __sleep() |
|
| 59 | + { |
|
| 60 | + $keys = parent::__sleep(); |
|
| 61 | + unset($keys[array_search('dwoo', $keys)]); |
|
| 62 | + |
|
| 63 | + return $keys; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Initialize this Renderer. |
|
| 68 | + * |
|
| 69 | + * @param AgaviContext The current application context |
|
| 70 | + * @param array An associative array of initialization parameters |
|
| 71 | + */ |
|
| 72 | + public function initialize(AgaviContext $context, array $parameters = array()) |
|
| 73 | + { |
|
| 74 | + parent::initialize($context, $parameters); |
|
| 75 | + |
|
| 76 | + $this->plugin_dir = $this->getParameter('plugin_dir', $this->plugin_dir); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * provides a custom compiler to the dwoo renderer with optional settings |
|
| 81 | + * you can set in the agavi output_types.xml config file. |
|
| 82 | + * |
|
| 83 | + * @return Dwoo_Compiler |
|
| 84 | + */ |
|
| 85 | + public function compilerFactory() |
|
| 86 | + { |
|
| 87 | + $compiler = Dwoo_Compiler::compilerFactory(); |
|
| 88 | + $compiler->setAutoEscape((bool) $this->getParameter('auto_escape', false)); |
|
| 89 | + |
|
| 90 | + return $compiler; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * Grab a cleaned up dwoo instance. |
|
| 95 | + * |
|
| 96 | + * @return Dwoo A Dwoo instance |
|
| 97 | + */ |
|
| 98 | + protected function getEngine() |
|
| 99 | + { |
|
| 100 | + if ($this->dwoo) { |
|
| 101 | + return $this->dwoo; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + // this triggers Agavi autoload |
|
| 105 | + if (!class_exists('Dwoo')) { |
|
| 106 | + if (file_exists(dirname(__FILE__).'/../../../dwooAutoload.php')) { |
|
| 107 | + // file was dropped with the entire dwoo package |
|
| 108 | + include dirname(__FILE__).'/../../../dwooAutoload.php'; |
|
| 109 | + } else { |
|
| 110 | + // assume the dwoo package is in the include path |
|
| 111 | + include 'dwooAutoload.php'; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + $parentMode = fileperms(AgaviConfig::get('core.cache_dir')); |
|
| 116 | + |
|
| 117 | + $compileDir = AgaviConfig::get('core.cache_dir').DIRECTORY_SEPARATOR.self::COMPILE_DIR.DIRECTORY_SEPARATOR.self::COMPILE_SUBDIR; |
|
| 118 | + AgaviToolkit::mkdir($compileDir, $parentMode, true); |
|
| 119 | + |
|
| 120 | + $cacheDir = AgaviConfig::get('core.cache_dir').DIRECTORY_SEPARATOR.self::CACHE_DIR; |
|
| 121 | + AgaviToolkit::mkdir($cacheDir, $parentMode, true); |
|
| 122 | + |
|
| 123 | + $this->dwoo = new Dwoo_Core($compileDir, $cacheDir); |
|
| 124 | + |
|
| 125 | + if (!empty($this->plugin_dir)) { |
|
| 126 | + foreach ((array) $this->plugin_dir as $dir) { |
|
| 127 | + $this->dwoo->getLoader()->addDirectory($dir); |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + $this->dwoo->setDefaultCompilerFactory('file', array($this, 'compilerFactory')); |
|
| 132 | + |
|
| 133 | + return $this->dwoo; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * Render the presentation and return the result. |
|
| 138 | + * |
|
| 139 | + * @param AgaviTemplateLayer The template layer to render |
|
| 140 | + * @param array The template variables |
|
| 141 | + * @param array The slots |
|
| 142 | + * @param array Associative array of additional assigns |
|
| 143 | + * |
|
| 144 | + * @return string A rendered result |
|
| 145 | + */ |
|
| 146 | + public function render(AgaviTemplateLayer $layer, array &$attributes = array(), array &$slots = array(), array &$moreAssigns = array()) |
|
| 147 | + { |
|
| 148 | + $engine = $this->getEngine(); |
|
| 149 | + |
|
| 150 | + $data = array(); |
|
| 151 | + if ($this->extractVars) { |
|
| 152 | + $data = $attributes; |
|
| 153 | + } else { |
|
| 154 | + $data[$this->varName] = &$attributes; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + $data[$this->slotsVarName] = &$slots; |
|
| 158 | + |
|
| 159 | + foreach ($this->assigns as $key => $getter) { |
|
| 160 | + $data[$key] = $this->getContext()->$getter(); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + foreach ($moreAssigns as $key => &$value) { |
|
| 164 | + if (isset($this->moreAssignNames[$key])) { |
|
| 165 | + $key = $this->moreAssignNames[$key]; |
|
| 166 | + } |
|
| 167 | + $data[$key] = &$value; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + return $engine->get($layer->getResourceStreamIdentifier(), $data); |
|
| 171 | + } |
|
| 172 | 172 | } |