@@ -11,116 +11,116 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Extension_Clear |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Empty cache for a specific template |
|
| 16 | - * |
|
| 17 | - * @param Smarty $smarty |
|
| 18 | - * @param string $resource_name template name |
|
| 19 | - * @param string $cache_id cache id |
|
| 20 | - * @param string $compile_id compile id |
|
| 21 | - * @param integer $exp_time expiration time (number of seconds, not timestamp) |
|
| 22 | - * |
|
| 23 | - * @return integer number of cache files deleted |
|
| 24 | - */ |
|
| 25 | - public static function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time) |
|
| 26 | - { |
|
| 27 | - $_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null; |
|
| 28 | - $_compile_id = isset($compile_id) ? preg_replace('![^\w]+!', '_', $compile_id) : null; |
|
| 29 | - $_dir_sep = $smarty->use_sub_dirs ? '/' : '^'; |
|
| 30 | - $_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0; |
|
| 31 | - $_dir = $smarty->getCacheDir(); |
|
| 32 | - if ($_dir == '/') { //We should never want to delete this! |
|
| 33 | - return 0; |
|
| 34 | - } |
|
| 35 | - $_dir_length = strlen($_dir); |
|
| 36 | - if (isset($_cache_id)) { |
|
| 37 | - $_cache_id_parts = explode('|', $_cache_id); |
|
| 38 | - $_cache_id_parts_count = count($_cache_id_parts); |
|
| 39 | - if ($smarty->use_sub_dirs) { |
|
| 40 | - foreach ($_cache_id_parts as $id_part) { |
|
| 41 | - $_dir .= $id_part . DS; |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | - if (isset($resource_name)) { |
|
| 46 | - $_save_stat = $smarty->caching; |
|
| 47 | - $smarty->caching = true; |
|
| 48 | - $tpl = new $smarty->template_class($resource_name, $smarty); |
|
| 49 | - $smarty->caching = $_save_stat; |
|
| 14 | + /** |
|
| 15 | + * Empty cache for a specific template |
|
| 16 | + * |
|
| 17 | + * @param Smarty $smarty |
|
| 18 | + * @param string $resource_name template name |
|
| 19 | + * @param string $cache_id cache id |
|
| 20 | + * @param string $compile_id compile id |
|
| 21 | + * @param integer $exp_time expiration time (number of seconds, not timestamp) |
|
| 22 | + * |
|
| 23 | + * @return integer number of cache files deleted |
|
| 24 | + */ |
|
| 25 | + public static function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time) |
|
| 26 | + { |
|
| 27 | + $_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null; |
|
| 28 | + $_compile_id = isset($compile_id) ? preg_replace('![^\w]+!', '_', $compile_id) : null; |
|
| 29 | + $_dir_sep = $smarty->use_sub_dirs ? '/' : '^'; |
|
| 30 | + $_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0; |
|
| 31 | + $_dir = $smarty->getCacheDir(); |
|
| 32 | + if ($_dir == '/') { //We should never want to delete this! |
|
| 33 | + return 0; |
|
| 34 | + } |
|
| 35 | + $_dir_length = strlen($_dir); |
|
| 36 | + if (isset($_cache_id)) { |
|
| 37 | + $_cache_id_parts = explode('|', $_cache_id); |
|
| 38 | + $_cache_id_parts_count = count($_cache_id_parts); |
|
| 39 | + if ($smarty->use_sub_dirs) { |
|
| 40 | + foreach ($_cache_id_parts as $id_part) { |
|
| 41 | + $_dir .= $id_part . DS; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | + if (isset($resource_name)) { |
|
| 46 | + $_save_stat = $smarty->caching; |
|
| 47 | + $smarty->caching = true; |
|
| 48 | + $tpl = new $smarty->template_class($resource_name, $smarty); |
|
| 49 | + $smarty->caching = $_save_stat; |
|
| 50 | 50 | |
| 51 | - // remove from template cache |
|
| 52 | - $tpl->source; // have the template registered before unset() |
|
| 51 | + // remove from template cache |
|
| 52 | + $tpl->source; // have the template registered before unset() |
|
| 53 | 53 | |
| 54 | - if ($tpl->source->exists) { |
|
| 55 | - $_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath)); |
|
| 56 | - } else { |
|
| 57 | - return 0; |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - $_count = 0; |
|
| 61 | - $_time = time(); |
|
| 62 | - if (file_exists($_dir)) { |
|
| 63 | - $_cacheDirs = new RecursiveDirectoryIterator($_dir); |
|
| 64 | - $_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST); |
|
| 65 | - foreach ($_cache as $_file) { |
|
| 66 | - if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) { |
|
| 67 | - continue; |
|
| 68 | - } |
|
| 69 | - // directory ? |
|
| 70 | - if ($_file->isDir()) { |
|
| 71 | - if (!$_cache->isDot()) { |
|
| 72 | - // delete folder if empty |
|
| 73 | - @rmdir($_file->getPathname()); |
|
| 74 | - } |
|
| 75 | - } else { |
|
| 76 | - $_parts = explode($_dir_sep, str_replace('\\', '/', substr((string) $_file, $_dir_length))); |
|
| 77 | - $_parts_count = count($_parts); |
|
| 78 | - // check name |
|
| 79 | - if (isset($resource_name)) { |
|
| 80 | - if ($_parts[ $_parts_count - 1 ] != $_resourcename_parts) { |
|
| 81 | - continue; |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - // check compile id |
|
| 85 | - if (isset($_compile_id) && (!isset($_parts[ $_parts_count - 2 - $_compile_id_offset ]) || |
|
| 86 | - $_parts[ $_parts_count - 2 - $_compile_id_offset ] != $_compile_id) |
|
| 87 | - ) { |
|
| 88 | - continue; |
|
| 89 | - } |
|
| 90 | - // check cache id |
|
| 91 | - if (isset($_cache_id)) { |
|
| 92 | - // count of cache id parts |
|
| 93 | - $_parts_count = (isset($_compile_id)) ? $_parts_count - 2 - $_compile_id_offset : |
|
| 94 | - $_parts_count - 1 - $_compile_id_offset; |
|
| 95 | - if ($_parts_count < $_cache_id_parts_count) { |
|
| 96 | - continue; |
|
| 97 | - } |
|
| 98 | - for ($i = 0; $i < $_cache_id_parts_count; $i ++) { |
|
| 99 | - if ($_parts[ $i ] != $_cache_id_parts[ $i ]) { |
|
| 100 | - continue 2; |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - // expired ? |
|
| 105 | - if (isset($exp_time)) { |
|
| 106 | - if ($exp_time < 0) { |
|
| 107 | - preg_match('#\'cache_lifetime\' =>\s*(\d*)#', file_get_contents($_file), $match); |
|
| 108 | - if ($_time < (@filemtime($_file) + $match[ 1 ])) { |
|
| 109 | - continue; |
|
| 110 | - } |
|
| 111 | - } else { |
|
| 112 | - if ($_time - @filemtime($_file) < $exp_time) { |
|
| 113 | - continue; |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - $_count += @unlink((string) $_file) ? 1 : 0; |
|
| 118 | - if (function_exists('opcache_invalidate') && strlen(ini_get("opcache.restrict_api")) < 1) { |
|
| 119 | - opcache_invalidate((string) $_file, true); |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - return $_count; |
|
| 125 | - } |
|
| 54 | + if ($tpl->source->exists) { |
|
| 55 | + $_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath)); |
|
| 56 | + } else { |
|
| 57 | + return 0; |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + $_count = 0; |
|
| 61 | + $_time = time(); |
|
| 62 | + if (file_exists($_dir)) { |
|
| 63 | + $_cacheDirs = new RecursiveDirectoryIterator($_dir); |
|
| 64 | + $_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST); |
|
| 65 | + foreach ($_cache as $_file) { |
|
| 66 | + if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) { |
|
| 67 | + continue; |
|
| 68 | + } |
|
| 69 | + // directory ? |
|
| 70 | + if ($_file->isDir()) { |
|
| 71 | + if (!$_cache->isDot()) { |
|
| 72 | + // delete folder if empty |
|
| 73 | + @rmdir($_file->getPathname()); |
|
| 74 | + } |
|
| 75 | + } else { |
|
| 76 | + $_parts = explode($_dir_sep, str_replace('\\', '/', substr((string) $_file, $_dir_length))); |
|
| 77 | + $_parts_count = count($_parts); |
|
| 78 | + // check name |
|
| 79 | + if (isset($resource_name)) { |
|
| 80 | + if ($_parts[ $_parts_count - 1 ] != $_resourcename_parts) { |
|
| 81 | + continue; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + // check compile id |
|
| 85 | + if (isset($_compile_id) && (!isset($_parts[ $_parts_count - 2 - $_compile_id_offset ]) || |
|
| 86 | + $_parts[ $_parts_count - 2 - $_compile_id_offset ] != $_compile_id) |
|
| 87 | + ) { |
|
| 88 | + continue; |
|
| 89 | + } |
|
| 90 | + // check cache id |
|
| 91 | + if (isset($_cache_id)) { |
|
| 92 | + // count of cache id parts |
|
| 93 | + $_parts_count = (isset($_compile_id)) ? $_parts_count - 2 - $_compile_id_offset : |
|
| 94 | + $_parts_count - 1 - $_compile_id_offset; |
|
| 95 | + if ($_parts_count < $_cache_id_parts_count) { |
|
| 96 | + continue; |
|
| 97 | + } |
|
| 98 | + for ($i = 0; $i < $_cache_id_parts_count; $i ++) { |
|
| 99 | + if ($_parts[ $i ] != $_cache_id_parts[ $i ]) { |
|
| 100 | + continue 2; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + // expired ? |
|
| 105 | + if (isset($exp_time)) { |
|
| 106 | + if ($exp_time < 0) { |
|
| 107 | + preg_match('#\'cache_lifetime\' =>\s*(\d*)#', file_get_contents($_file), $match); |
|
| 108 | + if ($_time < (@filemtime($_file) + $match[ 1 ])) { |
|
| 109 | + continue; |
|
| 110 | + } |
|
| 111 | + } else { |
|
| 112 | + if ($_time - @filemtime($_file) < $exp_time) { |
|
| 113 | + continue; |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + $_count += @unlink((string) $_file) ? 1 : 0; |
|
| 118 | + if (function_exists('opcache_invalidate') && strlen(ini_get("opcache.restrict_api")) < 1) { |
|
| 119 | + opcache_invalidate((string) $_file, true); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + return $_count; |
|
| 125 | + } |
|
| 126 | 126 | } |
| 127 | 127 | \ No newline at end of file |
@@ -77,26 +77,25 @@ discard block |
||
| 77 | 77 | $_parts_count = count($_parts); |
| 78 | 78 | // check name |
| 79 | 79 | if (isset($resource_name)) { |
| 80 | - if ($_parts[ $_parts_count - 1 ] != $_resourcename_parts) { |
|
| 80 | + if ($_parts[$_parts_count - 1] != $_resourcename_parts) { |
|
| 81 | 81 | continue; |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | // check compile id |
| 85 | - if (isset($_compile_id) && (!isset($_parts[ $_parts_count - 2 - $_compile_id_offset ]) || |
|
| 86 | - $_parts[ $_parts_count - 2 - $_compile_id_offset ] != $_compile_id) |
|
| 85 | + if (isset($_compile_id) && (!isset($_parts[$_parts_count - 2 - $_compile_id_offset]) || |
|
| 86 | + $_parts[$_parts_count - 2 - $_compile_id_offset] != $_compile_id) |
|
| 87 | 87 | ) { |
| 88 | 88 | continue; |
| 89 | 89 | } |
| 90 | 90 | // check cache id |
| 91 | 91 | if (isset($_cache_id)) { |
| 92 | 92 | // count of cache id parts |
| 93 | - $_parts_count = (isset($_compile_id)) ? $_parts_count - 2 - $_compile_id_offset : |
|
| 94 | - $_parts_count - 1 - $_compile_id_offset; |
|
| 93 | + $_parts_count = (isset($_compile_id)) ? $_parts_count - 2 - $_compile_id_offset : $_parts_count - 1 - $_compile_id_offset; |
|
| 95 | 94 | if ($_parts_count < $_cache_id_parts_count) { |
| 96 | 95 | continue; |
| 97 | 96 | } |
| 98 | - for ($i = 0; $i < $_cache_id_parts_count; $i ++) { |
|
| 99 | - if ($_parts[ $i ] != $_cache_id_parts[ $i ]) { |
|
| 97 | + for ($i = 0; $i < $_cache_id_parts_count; $i++) { |
|
| 98 | + if ($_parts[$i] != $_cache_id_parts[$i]) { |
|
| 100 | 99 | continue 2; |
| 101 | 100 | } |
| 102 | 101 | } |
@@ -105,7 +104,7 @@ discard block |
||
| 105 | 104 | if (isset($exp_time)) { |
| 106 | 105 | if ($exp_time < 0) { |
| 107 | 106 | preg_match('#\'cache_lifetime\' =>\s*(\d*)#', file_get_contents($_file), $match); |
| 108 | - if ($_time < (@filemtime($_file) + $match[ 1 ])) { |
|
| 107 | + if ($_time < (@filemtime($_file) + $match[1])) { |
|
| 109 | 108 | continue; |
| 110 | 109 | } |
| 111 | 110 | } else { |
@@ -12,38 +12,38 @@ |
||
| 12 | 12 | class Smarty_Internal_Undefined |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * This function is executed automatically when a compiled or cached template file is included |
|
| 17 | - * - Decode saved properties from compiled template and cache files |
|
| 18 | - * - Check if compiled or cache file is valid |
|
| 19 | - * |
|
| 20 | - * @param \Smarty_Internal_Template $tpl |
|
| 21 | - * @param array $properties special template properties |
|
| 22 | - * @param bool $cache flag if called from cache file |
|
| 23 | - * |
|
| 24 | - * @return bool flag if compiled or cache file is valid |
|
| 25 | - */ |
|
| 26 | - public function decodeProperties(Smarty_Internal_Template $tpl, $properties, $cache = false) |
|
| 27 | - { |
|
| 28 | - if ($cache) { |
|
| 29 | - $tpl->cached->valid = false; |
|
| 30 | - } else { |
|
| 31 | - $tpl->mustCompile = true; |
|
| 32 | - } |
|
| 33 | - return false; |
|
| 34 | - } |
|
| 15 | + /** |
|
| 16 | + * This function is executed automatically when a compiled or cached template file is included |
|
| 17 | + * - Decode saved properties from compiled template and cache files |
|
| 18 | + * - Check if compiled or cache file is valid |
|
| 19 | + * |
|
| 20 | + * @param \Smarty_Internal_Template $tpl |
|
| 21 | + * @param array $properties special template properties |
|
| 22 | + * @param bool $cache flag if called from cache file |
|
| 23 | + * |
|
| 24 | + * @return bool flag if compiled or cache file is valid |
|
| 25 | + */ |
|
| 26 | + public function decodeProperties(Smarty_Internal_Template $tpl, $properties, $cache = false) |
|
| 27 | + { |
|
| 28 | + if ($cache) { |
|
| 29 | + $tpl->cached->valid = false; |
|
| 30 | + } else { |
|
| 31 | + $tpl->mustCompile = true; |
|
| 32 | + } |
|
| 33 | + return false; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Call error handler for undefined method |
|
| 38 | - * |
|
| 39 | - * @param string $name unknown method-name |
|
| 40 | - * @param array $args argument array |
|
| 41 | - * |
|
| 42 | - * @return mixed |
|
| 43 | - * @throws SmartyException |
|
| 44 | - */ |
|
| 45 | - public function __call($name, $args) |
|
| 46 | - { |
|
| 47 | - throw new SmartyException(get_class($args[ 0 ]) . "->{$name}() undefined method"); |
|
| 48 | - } |
|
| 36 | + /** |
|
| 37 | + * Call error handler for undefined method |
|
| 38 | + * |
|
| 39 | + * @param string $name unknown method-name |
|
| 40 | + * @param array $args argument array |
|
| 41 | + * |
|
| 42 | + * @return mixed |
|
| 43 | + * @throws SmartyException |
|
| 44 | + */ |
|
| 45 | + public function __call($name, $args) |
|
| 46 | + { |
|
| 47 | + throw new SmartyException(get_class($args[ 0 ]) . "->{$name}() undefined method"); |
|
| 48 | + } |
|
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -44,6 +44,6 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | public function __call($name, $args) |
| 46 | 46 | { |
| 47 | - throw new SmartyException(get_class($args[ 0 ]) . "->{$name}() undefined method"); |
|
| 47 | + throw new SmartyException(get_class($args[0]) . "->{$name}() undefined method"); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | \ No newline at end of file |
@@ -16,79 +16,79 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Attribute definition: Overwrites base class. |
|
| 21 | - * |
|
| 22 | - * @var array |
|
| 23 | - * @see Smarty_Internal_CompileBase |
|
| 24 | - */ |
|
| 25 | - public $option_flags = array('nocache', 'noscope'); |
|
| 19 | + /** |
|
| 20 | + * Attribute definition: Overwrites base class. |
|
| 21 | + * |
|
| 22 | + * @var array |
|
| 23 | + * @see Smarty_Internal_CompileBase |
|
| 24 | + */ |
|
| 25 | + public $option_flags = array('nocache', 'noscope'); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | - * Valid scope names |
|
| 29 | - * |
|
| 30 | - * @var array |
|
| 31 | - */ |
|
| 32 | - public $valid_scopes = array('local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT, |
|
| 33 | - 'root' => Smarty::SCOPE_ROOT, 'global' => Smarty::SCOPE_GLOBAL, |
|
| 34 | - 'tpl_root' => Smarty::SCOPE_TPL_ROOT, 'smarty' => Smarty::SCOPE_SMARTY); |
|
| 28 | + * Valid scope names |
|
| 29 | + * |
|
| 30 | + * @var array |
|
| 31 | + */ |
|
| 32 | + public $valid_scopes = array('local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT, |
|
| 33 | + 'root' => Smarty::SCOPE_ROOT, 'global' => Smarty::SCOPE_GLOBAL, |
|
| 34 | + 'tpl_root' => Smarty::SCOPE_TPL_ROOT, 'smarty' => Smarty::SCOPE_SMARTY); |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Compiles code for the {assign} tag |
|
| 38 | - * |
|
| 39 | - * @param array $args array with attributes from parser |
|
| 40 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 41 | - * @param array $parameter array with compilation parameter |
|
| 42 | - * |
|
| 43 | - * @return string compiled code |
|
| 44 | - * @throws \SmartyCompilerException |
|
| 45 | - */ |
|
| 46 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 47 | - { |
|
| 48 | - // the following must be assigned at runtime because it will be overwritten in Smarty_Internal_Compile_Append |
|
| 49 | - $this->required_attributes = array('var', 'value'); |
|
| 50 | - $this->shorttag_order = array('var', 'value'); |
|
| 51 | - $this->optional_attributes = array('scope'); |
|
| 52 | - $this->mapCache = array(); |
|
| 53 | - $_nocache = false; |
|
| 54 | - // check and get attributes |
|
| 55 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 56 | - // nocache ? |
|
| 57 | - if ($_var = $compiler->getId($_attr[ 'var' ])) { |
|
| 58 | - $_var = "'{$_var}'"; |
|
| 59 | - } else { |
|
| 60 | - $_var = $_attr[ 'var' ]; |
|
| 61 | - } |
|
| 62 | - if ($compiler->tag_nocache || $compiler->nocache) { |
|
| 63 | - $_nocache = true; |
|
| 64 | - // create nocache var to make it know for further compiling |
|
| 65 | - $compiler->setNocacheInVariable($_attr[ 'var' ]); |
|
| 66 | - } |
|
| 67 | - // scope setup |
|
| 68 | - if ($_attr[ 'noscope' ]) { |
|
| 69 | - $_scope = - 1; |
|
| 70 | - } else { |
|
| 71 | - $_scope = $compiler->convertScope($_attr, $this->valid_scopes); |
|
| 72 | - } |
|
| 73 | - // optional parameter |
|
| 74 | - $_params = ""; |
|
| 75 | - if ($_nocache || $_scope) { |
|
| 76 | - $_params .= ' ,' . var_export($_nocache, true); |
|
| 77 | - } |
|
| 78 | - if ($_scope) { |
|
| 79 | - $_params .= ' ,' . $_scope; |
|
| 80 | - } |
|
| 81 | - if (isset($parameter[ 'smarty_internal_index' ])) { |
|
| 82 | - $output = |
|
| 83 | - "<?php \$_tmp_array = isset(\$_smarty_tpl->tpl_vars[{$_var}]) ? \$_smarty_tpl->tpl_vars[{$_var}]->value : array();\n"; |
|
| 84 | - $output .= "if (!is_array(\$_tmp_array) || \$_tmp_array instanceof ArrayAccess) {\n"; |
|
| 85 | - $output .= "settype(\$_tmp_array, 'array');\n"; |
|
| 86 | - $output .= "}\n"; |
|
| 87 | - $output .= "\$_tmp_array{$parameter['smarty_internal_index']} = {$_attr['value']};\n"; |
|
| 88 | - $output .= "\$_smarty_tpl->_assignInScope({$_var}, \$_tmp_array{$_params});\n?>"; |
|
| 89 | - } else { |
|
| 90 | - $output = "<?php \$_smarty_tpl->_assignInScope({$_var}, {$_attr['value']}{$_params});\n?>"; |
|
| 91 | - } |
|
| 92 | - return $output; |
|
| 93 | - } |
|
| 36 | + /** |
|
| 37 | + * Compiles code for the {assign} tag |
|
| 38 | + * |
|
| 39 | + * @param array $args array with attributes from parser |
|
| 40 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 41 | + * @param array $parameter array with compilation parameter |
|
| 42 | + * |
|
| 43 | + * @return string compiled code |
|
| 44 | + * @throws \SmartyCompilerException |
|
| 45 | + */ |
|
| 46 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) |
|
| 47 | + { |
|
| 48 | + // the following must be assigned at runtime because it will be overwritten in Smarty_Internal_Compile_Append |
|
| 49 | + $this->required_attributes = array('var', 'value'); |
|
| 50 | + $this->shorttag_order = array('var', 'value'); |
|
| 51 | + $this->optional_attributes = array('scope'); |
|
| 52 | + $this->mapCache = array(); |
|
| 53 | + $_nocache = false; |
|
| 54 | + // check and get attributes |
|
| 55 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 56 | + // nocache ? |
|
| 57 | + if ($_var = $compiler->getId($_attr[ 'var' ])) { |
|
| 58 | + $_var = "'{$_var}'"; |
|
| 59 | + } else { |
|
| 60 | + $_var = $_attr[ 'var' ]; |
|
| 61 | + } |
|
| 62 | + if ($compiler->tag_nocache || $compiler->nocache) { |
|
| 63 | + $_nocache = true; |
|
| 64 | + // create nocache var to make it know for further compiling |
|
| 65 | + $compiler->setNocacheInVariable($_attr[ 'var' ]); |
|
| 66 | + } |
|
| 67 | + // scope setup |
|
| 68 | + if ($_attr[ 'noscope' ]) { |
|
| 69 | + $_scope = - 1; |
|
| 70 | + } else { |
|
| 71 | + $_scope = $compiler->convertScope($_attr, $this->valid_scopes); |
|
| 72 | + } |
|
| 73 | + // optional parameter |
|
| 74 | + $_params = ""; |
|
| 75 | + if ($_nocache || $_scope) { |
|
| 76 | + $_params .= ' ,' . var_export($_nocache, true); |
|
| 77 | + } |
|
| 78 | + if ($_scope) { |
|
| 79 | + $_params .= ' ,' . $_scope; |
|
| 80 | + } |
|
| 81 | + if (isset($parameter[ 'smarty_internal_index' ])) { |
|
| 82 | + $output = |
|
| 83 | + "<?php \$_tmp_array = isset(\$_smarty_tpl->tpl_vars[{$_var}]) ? \$_smarty_tpl->tpl_vars[{$_var}]->value : array();\n"; |
|
| 84 | + $output .= "if (!is_array(\$_tmp_array) || \$_tmp_array instanceof ArrayAccess) {\n"; |
|
| 85 | + $output .= "settype(\$_tmp_array, 'array');\n"; |
|
| 86 | + $output .= "}\n"; |
|
| 87 | + $output .= "\$_tmp_array{$parameter['smarty_internal_index']} = {$_attr['value']};\n"; |
|
| 88 | + $output .= "\$_smarty_tpl->_assignInScope({$_var}, \$_tmp_array{$_params});\n?>"; |
|
| 89 | + } else { |
|
| 90 | + $output = "<?php \$_smarty_tpl->_assignInScope({$_var}, {$_attr['value']}{$_params});\n?>"; |
|
| 91 | + } |
|
| 92 | + return $output; |
|
| 93 | + } |
|
| 94 | 94 | } |
@@ -54,18 +54,18 @@ discard block |
||
| 54 | 54 | // check and get attributes |
| 55 | 55 | $_attr = $this->getAttributes($compiler, $args); |
| 56 | 56 | // nocache ? |
| 57 | - if ($_var = $compiler->getId($_attr[ 'var' ])) { |
|
| 57 | + if ($_var = $compiler->getId($_attr['var'])) { |
|
| 58 | 58 | $_var = "'{$_var}'"; |
| 59 | 59 | } else { |
| 60 | - $_var = $_attr[ 'var' ]; |
|
| 60 | + $_var = $_attr['var']; |
|
| 61 | 61 | } |
| 62 | 62 | if ($compiler->tag_nocache || $compiler->nocache) { |
| 63 | 63 | $_nocache = true; |
| 64 | 64 | // create nocache var to make it know for further compiling |
| 65 | - $compiler->setNocacheInVariable($_attr[ 'var' ]); |
|
| 65 | + $compiler->setNocacheInVariable($_attr['var']); |
|
| 66 | 66 | } |
| 67 | 67 | // scope setup |
| 68 | - if ($_attr[ 'noscope' ]) { |
|
| 68 | + if ($_attr['noscope']) { |
|
| 69 | 69 | $_scope = - 1; |
| 70 | 70 | } else { |
| 71 | 71 | $_scope = $compiler->convertScope($_attr, $this->valid_scopes); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | if ($_scope) { |
| 79 | 79 | $_params .= ' ,' . $_scope; |
| 80 | 80 | } |
| 81 | - if (isset($parameter[ 'smarty_internal_index' ])) { |
|
| 81 | + if (isset($parameter['smarty_internal_index'])) { |
|
| 82 | 82 | $output = |
| 83 | 83 | "<?php \$_tmp_array = isset(\$_smarty_tpl->tpl_vars[{$_var}]) ? \$_smarty_tpl->tpl_vars[{$_var}]->value : array();\n"; |
| 84 | 84 | $output .= "if (!is_array(\$_tmp_array) || \$_tmp_array instanceof ArrayAccess) {\n"; |
@@ -16,57 +16,57 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_Compile_Private_Block_Plugin |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Setup callback, parameter array and nocache mode |
|
| 21 | - * |
|
| 22 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 23 | - * @param array $_attr attributes |
|
| 24 | - * @param string $tag |
|
| 25 | - * @param null $function |
|
| 26 | - * |
|
| 27 | - * @return array |
|
| 28 | - */ |
|
| 29 | - public function setup(Smarty_Internal_TemplateCompilerBase $compiler, $_attr, $tag, $function) |
|
| 30 | - { |
|
| 31 | - if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ])) { |
|
| 32 | - $tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ]; |
|
| 33 | - $callback = $tag_info[ 0 ]; |
|
| 34 | - if (is_array($callback)) { |
|
| 35 | - if (is_object($callback[ 0 ])) { |
|
| 36 | - $callable = "array(\$_block_plugin{$this->nesting}, '{$callback[1]}')"; |
|
| 37 | - $callback = |
|
| 38 | - array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "->{$callback[1]}"); |
|
| 39 | - } else { |
|
| 40 | - $callable = "array(\$_block_plugin{$this->nesting}, '{$callback[1]}')"; |
|
| 41 | - $callback = |
|
| 42 | - array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "::{$callback[1]}"); |
|
| 43 | - } |
|
| 44 | - } else { |
|
| 45 | - $callable = "\$_block_plugin{$this->nesting}"; |
|
| 46 | - $callback = array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0]", ''); |
|
| 47 | - } |
|
| 48 | - } else { |
|
| 49 | - $tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ]; |
|
| 50 | - $callback = $tag_info[ 0 ]; |
|
| 51 | - if (is_array($callback)) { |
|
| 52 | - $callable = "array('{$callback[0]}', '{$callback[1]}')"; |
|
| 53 | - $callback = "{$callback[1]}::{$callback[1]}"; |
|
| 54 | - } else { |
|
| 55 | - $callable = null; |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - $compiler->tag_nocache = !$tag_info[ 1 ] | $compiler->tag_nocache; |
|
| 59 | - $_paramsArray = array(); |
|
| 60 | - foreach ($_attr as $_key => $_value) { |
|
| 61 | - if (is_int($_key)) { |
|
| 62 | - $_paramsArray[] = "$_key=>$_value"; |
|
| 63 | - } elseif ($compiler->template->caching && in_array($_key, $tag_info[ 2 ])) { |
|
| 64 | - $_value = str_replace("'", "^#^", $_value); |
|
| 65 | - $_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^"; |
|
| 66 | - } else { |
|
| 67 | - $_paramsArray[] = "'$_key'=>$_value"; |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - return array($callback, $_paramsArray, $callable); |
|
| 71 | - } |
|
| 19 | + /** |
|
| 20 | + * Setup callback, parameter array and nocache mode |
|
| 21 | + * |
|
| 22 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler |
|
| 23 | + * @param array $_attr attributes |
|
| 24 | + * @param string $tag |
|
| 25 | + * @param null $function |
|
| 26 | + * |
|
| 27 | + * @return array |
|
| 28 | + */ |
|
| 29 | + public function setup(Smarty_Internal_TemplateCompilerBase $compiler, $_attr, $tag, $function) |
|
| 30 | + { |
|
| 31 | + if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ])) { |
|
| 32 | + $tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ]; |
|
| 33 | + $callback = $tag_info[ 0 ]; |
|
| 34 | + if (is_array($callback)) { |
|
| 35 | + if (is_object($callback[ 0 ])) { |
|
| 36 | + $callable = "array(\$_block_plugin{$this->nesting}, '{$callback[1]}')"; |
|
| 37 | + $callback = |
|
| 38 | + array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "->{$callback[1]}"); |
|
| 39 | + } else { |
|
| 40 | + $callable = "array(\$_block_plugin{$this->nesting}, '{$callback[1]}')"; |
|
| 41 | + $callback = |
|
| 42 | + array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "::{$callback[1]}"); |
|
| 43 | + } |
|
| 44 | + } else { |
|
| 45 | + $callable = "\$_block_plugin{$this->nesting}"; |
|
| 46 | + $callback = array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0]", ''); |
|
| 47 | + } |
|
| 48 | + } else { |
|
| 49 | + $tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ]; |
|
| 50 | + $callback = $tag_info[ 0 ]; |
|
| 51 | + if (is_array($callback)) { |
|
| 52 | + $callable = "array('{$callback[0]}', '{$callback[1]}')"; |
|
| 53 | + $callback = "{$callback[1]}::{$callback[1]}"; |
|
| 54 | + } else { |
|
| 55 | + $callable = null; |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + $compiler->tag_nocache = !$tag_info[ 1 ] | $compiler->tag_nocache; |
|
| 59 | + $_paramsArray = array(); |
|
| 60 | + foreach ($_attr as $_key => $_value) { |
|
| 61 | + if (is_int($_key)) { |
|
| 62 | + $_paramsArray[] = "$_key=>$_value"; |
|
| 63 | + } elseif ($compiler->template->caching && in_array($_key, $tag_info[ 2 ])) { |
|
| 64 | + $_value = str_replace("'", "^#^", $_value); |
|
| 65 | + $_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^"; |
|
| 66 | + } else { |
|
| 67 | + $_paramsArray[] = "'$_key'=>$_value"; |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + return array($callback, $_paramsArray, $callable); |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | public function setup(Smarty_Internal_TemplateCompilerBase $compiler, $_attr, $tag, $function) |
| 30 | 30 | { |
| 31 | - if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ])) { |
|
| 32 | - $tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ]; |
|
| 33 | - $callback = $tag_info[ 0 ]; |
|
| 31 | + if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$tag])) { |
|
| 32 | + $tag_info = $compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$tag]; |
|
| 33 | + $callback = $tag_info[0]; |
|
| 34 | 34 | if (is_array($callback)) { |
| 35 | - if (is_object($callback[ 0 ])) { |
|
| 35 | + if (is_object($callback[0])) { |
|
| 36 | 36 | $callable = "array(\$_block_plugin{$this->nesting}, '{$callback[1]}')"; |
| 37 | 37 | $callback = |
| 38 | 38 | array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]", "->{$callback[1]}"); |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | $callback = array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0]", ''); |
| 47 | 47 | } |
| 48 | 48 | } else { |
| 49 | - $tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ]; |
|
| 50 | - $callback = $tag_info[ 0 ]; |
|
| 49 | + $tag_info = $compiler->default_handler_plugins[Smarty::PLUGIN_BLOCK][$tag]; |
|
| 50 | + $callback = $tag_info[0]; |
|
| 51 | 51 | if (is_array($callback)) { |
| 52 | 52 | $callable = "array('{$callback[0]}', '{$callback[1]}')"; |
| 53 | 53 | $callback = "{$callback[1]}::{$callback[1]}"; |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | $callable = null; |
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | - $compiler->tag_nocache = !$tag_info[ 1 ] | $compiler->tag_nocache; |
|
| 58 | + $compiler->tag_nocache = !$tag_info[1] | $compiler->tag_nocache; |
|
| 59 | 59 | $_paramsArray = array(); |
| 60 | 60 | foreach ($_attr as $_key => $_value) { |
| 61 | 61 | if (is_int($_key)) { |
| 62 | 62 | $_paramsArray[] = "$_key=>$_value"; |
| 63 | - } elseif ($compiler->template->caching && in_array($_key, $tag_info[ 2 ])) { |
|
| 63 | + } elseif ($compiler->template->caching && in_array($_key, $tag_info[2])) { |
|
| 64 | 64 | $_value = str_replace("'", "^#^", $_value); |
| 65 | 65 | $_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^"; |
| 66 | 66 | } else { |
@@ -16,72 +16,72 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Attribute definition: Overwrites base class. |
|
| 21 | - * |
|
| 22 | - * @var array |
|
| 23 | - * @see Smarty_Internal_CompileBase |
|
| 24 | - */ |
|
| 25 | - public $required_attributes = array('name'); |
|
| 19 | + /** |
|
| 20 | + * Attribute definition: Overwrites base class. |
|
| 21 | + * |
|
| 22 | + * @var array |
|
| 23 | + * @see Smarty_Internal_CompileBase |
|
| 24 | + */ |
|
| 25 | + public $required_attributes = array('name'); |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Attribute definition: Overwrites base class. |
|
| 29 | - * |
|
| 30 | - * @var array |
|
| 31 | - * @see Smarty_Internal_CompileBase |
|
| 32 | - */ |
|
| 33 | - public $shorttag_order = array('name'); |
|
| 27 | + /** |
|
| 28 | + * Attribute definition: Overwrites base class. |
|
| 29 | + * |
|
| 30 | + * @var array |
|
| 31 | + * @see Smarty_Internal_CompileBase |
|
| 32 | + */ |
|
| 33 | + public $shorttag_order = array('name'); |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Attribute definition: Overwrites base class. |
|
| 37 | - * |
|
| 38 | - * @var array |
|
| 39 | - * @see Smarty_Internal_CompileBase |
|
| 40 | - */ |
|
| 41 | - public $optional_attributes = array('_any'); |
|
| 35 | + /** |
|
| 36 | + * Attribute definition: Overwrites base class. |
|
| 37 | + * |
|
| 38 | + * @var array |
|
| 39 | + * @see Smarty_Internal_CompileBase |
|
| 40 | + */ |
|
| 41 | + public $optional_attributes = array('_any'); |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Compiles the calls of user defined tags defined by {function} |
|
| 45 | - * |
|
| 46 | - * @param array $args array with attributes from parser |
|
| 47 | - * @param object $compiler compiler object |
|
| 48 | - * |
|
| 49 | - * @return string compiled code |
|
| 50 | - */ |
|
| 51 | - public function compile($args, $compiler) |
|
| 52 | - { |
|
| 53 | - // check and get attributes |
|
| 54 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 55 | - // save possible attributes |
|
| 56 | - if (isset($_attr[ 'assign' ])) { |
|
| 57 | - // output will be stored in a smarty variable instead of being displayed |
|
| 58 | - $_assign = $_attr[ 'assign' ]; |
|
| 59 | - } |
|
| 60 | - $_name = $_attr[ 'name' ]; |
|
| 61 | - unset($_attr[ 'name' ], $_attr[ 'assign' ], $_attr[ 'nocache' ]); |
|
| 62 | - // set flag (compiled code of {function} must be included in cache file |
|
| 63 | - if (!$compiler->template->caching || $compiler->nocache || $compiler->tag_nocache) { |
|
| 64 | - $_nocache = 'true'; |
|
| 65 | - } else { |
|
| 66 | - $_nocache = 'false'; |
|
| 67 | - } |
|
| 68 | - $_paramsArray = array(); |
|
| 69 | - foreach ($_attr as $_key => $_value) { |
|
| 70 | - if (is_int($_key)) { |
|
| 71 | - $_paramsArray[] = "$_key=>$_value"; |
|
| 72 | - } else { |
|
| 73 | - $_paramsArray[] = "'$_key'=>$_value"; |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - $_params = 'array(' . implode(",", $_paramsArray) . ')'; |
|
| 77 | - // was there an assign attribute |
|
| 78 | - if (isset($_assign)) { |
|
| 79 | - $_output = |
|
| 80 | - "<?php ob_start();\n\$_smarty_tpl->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n"; |
|
| 81 | - } else { |
|
| 82 | - $_output = |
|
| 83 | - "<?php \$_smarty_tpl->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n"; |
|
| 84 | - } |
|
| 85 | - return $_output; |
|
| 86 | - } |
|
| 43 | + /** |
|
| 44 | + * Compiles the calls of user defined tags defined by {function} |
|
| 45 | + * |
|
| 46 | + * @param array $args array with attributes from parser |
|
| 47 | + * @param object $compiler compiler object |
|
| 48 | + * |
|
| 49 | + * @return string compiled code |
|
| 50 | + */ |
|
| 51 | + public function compile($args, $compiler) |
|
| 52 | + { |
|
| 53 | + // check and get attributes |
|
| 54 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 55 | + // save possible attributes |
|
| 56 | + if (isset($_attr[ 'assign' ])) { |
|
| 57 | + // output will be stored in a smarty variable instead of being displayed |
|
| 58 | + $_assign = $_attr[ 'assign' ]; |
|
| 59 | + } |
|
| 60 | + $_name = $_attr[ 'name' ]; |
|
| 61 | + unset($_attr[ 'name' ], $_attr[ 'assign' ], $_attr[ 'nocache' ]); |
|
| 62 | + // set flag (compiled code of {function} must be included in cache file |
|
| 63 | + if (!$compiler->template->caching || $compiler->nocache || $compiler->tag_nocache) { |
|
| 64 | + $_nocache = 'true'; |
|
| 65 | + } else { |
|
| 66 | + $_nocache = 'false'; |
|
| 67 | + } |
|
| 68 | + $_paramsArray = array(); |
|
| 69 | + foreach ($_attr as $_key => $_value) { |
|
| 70 | + if (is_int($_key)) { |
|
| 71 | + $_paramsArray[] = "$_key=>$_value"; |
|
| 72 | + } else { |
|
| 73 | + $_paramsArray[] = "'$_key'=>$_value"; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + $_params = 'array(' . implode(",", $_paramsArray) . ')'; |
|
| 77 | + // was there an assign attribute |
|
| 78 | + if (isset($_assign)) { |
|
| 79 | + $_output = |
|
| 80 | + "<?php ob_start();\n\$_smarty_tpl->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n"; |
|
| 81 | + } else { |
|
| 82 | + $_output = |
|
| 83 | + "<?php \$_smarty_tpl->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n"; |
|
| 84 | + } |
|
| 85 | + return $_output; |
|
| 86 | + } |
|
| 87 | 87 | } |
@@ -53,12 +53,12 @@ |
||
| 53 | 53 | // check and get attributes |
| 54 | 54 | $_attr = $this->getAttributes($compiler, $args); |
| 55 | 55 | // save possible attributes |
| 56 | - if (isset($_attr[ 'assign' ])) { |
|
| 56 | + if (isset($_attr['assign'])) { |
|
| 57 | 57 | // output will be stored in a smarty variable instead of being displayed |
| 58 | - $_assign = $_attr[ 'assign' ]; |
|
| 58 | + $_assign = $_attr['assign']; |
|
| 59 | 59 | } |
| 60 | - $_name = $_attr[ 'name' ]; |
|
| 61 | - unset($_attr[ 'name' ], $_attr[ 'assign' ], $_attr[ 'nocache' ]); |
|
| 60 | + $_name = $_attr['name']; |
|
| 61 | + unset($_attr['name'], $_attr['assign'], $_attr['nocache']); |
|
| 62 | 62 | // set flag (compiled code of {function} must be included in cache file |
| 63 | 63 | if (!$compiler->template->caching || $compiler->nocache || $compiler->tag_nocache) { |
| 64 | 64 | $_nocache = 'true'; |
@@ -11,30 +11,30 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_RegisterCacheResource |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Valid for Smarty and template object |
|
| 16 | - * |
|
| 17 | - * @var int |
|
| 18 | - */ |
|
| 19 | - public $objMap = 3; |
|
| 14 | + /** |
|
| 15 | + * Valid for Smarty and template object |
|
| 16 | + * |
|
| 17 | + * @var int |
|
| 18 | + */ |
|
| 19 | + public $objMap = 3; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Registers a resource to fetch a template |
|
| 23 | - * |
|
| 24 | - * @api Smarty::registerCacheResource() |
|
| 25 | - * @link http://www.smarty.net/docs/en/api.register.cacheresource.tpl |
|
| 26 | - * |
|
| 27 | - * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 28 | - * @param string $name name of resource type |
|
| 29 | - * @param \Smarty_CacheResource $resource_handler |
|
| 30 | - * |
|
| 31 | - * @return \Smarty|\Smarty_Internal_Template |
|
| 32 | - */ |
|
| 33 | - public function registerCacheResource(Smarty_Internal_TemplateBase $obj, $name, |
|
| 34 | - Smarty_CacheResource $resource_handler) |
|
| 35 | - { |
|
| 36 | - $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 37 | - $smarty->registered_cache_resources[ $name ] = $resource_handler; |
|
| 38 | - return $obj; |
|
| 39 | - } |
|
| 21 | + /** |
|
| 22 | + * Registers a resource to fetch a template |
|
| 23 | + * |
|
| 24 | + * @api Smarty::registerCacheResource() |
|
| 25 | + * @link http://www.smarty.net/docs/en/api.register.cacheresource.tpl |
|
| 26 | + * |
|
| 27 | + * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 28 | + * @param string $name name of resource type |
|
| 29 | + * @param \Smarty_CacheResource $resource_handler |
|
| 30 | + * |
|
| 31 | + * @return \Smarty|\Smarty_Internal_Template |
|
| 32 | + */ |
|
| 33 | + public function registerCacheResource(Smarty_Internal_TemplateBase $obj, $name, |
|
| 34 | + Smarty_CacheResource $resource_handler) |
|
| 35 | + { |
|
| 36 | + $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 37 | + $smarty->registered_cache_resources[ $name ] = $resource_handler; |
|
| 38 | + return $obj; |
|
| 39 | + } |
|
| 40 | 40 | } |
| 41 | 41 | \ No newline at end of file |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | Smarty_CacheResource $resource_handler) |
| 35 | 35 | { |
| 36 | 36 | $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
| 37 | - $smarty->registered_cache_resources[ $name ] = $resource_handler; |
|
| 37 | + $smarty->registered_cache_resources[$name] = $resource_handler; |
|
| 38 | 38 | return $obj; |
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | \ No newline at end of file |
@@ -11,25 +11,25 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_GetDebugTemplate |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Valid for Smarty and template object |
|
| 16 | - * |
|
| 17 | - * @var int |
|
| 18 | - */ |
|
| 19 | - public $objMap = 3; |
|
| 14 | + /** |
|
| 15 | + * Valid for Smarty and template object |
|
| 16 | + * |
|
| 17 | + * @var int |
|
| 18 | + */ |
|
| 19 | + public $objMap = 3; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * return name of debugging template |
|
| 23 | - * |
|
| 24 | - * @api Smarty::getDebugTemplate() |
|
| 25 | - * |
|
| 26 | - * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 27 | - * |
|
| 28 | - * @return string |
|
| 29 | - */ |
|
| 30 | - public function getDebugTemplate(Smarty_Internal_TemplateBase $obj) |
|
| 31 | - { |
|
| 32 | - $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 33 | - return $smarty->debug_tpl; |
|
| 34 | - } |
|
| 21 | + /** |
|
| 22 | + * return name of debugging template |
|
| 23 | + * |
|
| 24 | + * @api Smarty::getDebugTemplate() |
|
| 25 | + * |
|
| 26 | + * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj |
|
| 27 | + * |
|
| 28 | + * @return string |
|
| 29 | + */ |
|
| 30 | + public function getDebugTemplate(Smarty_Internal_TemplateBase $obj) |
|
| 31 | + { |
|
| 32 | + $smarty = isset($obj->smarty) ? $obj->smarty : $obj; |
|
| 33 | + return $smarty->debug_tpl; |
|
| 34 | + } |
|
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -11,34 +11,34 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class Smarty_Internal_Method_ClearCache |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Valid for Smarty object |
|
| 16 | - * |
|
| 17 | - * @var int |
|
| 18 | - */ |
|
| 19 | - public $objMap = 1; |
|
| 14 | + /** |
|
| 15 | + * Valid for Smarty object |
|
| 16 | + * |
|
| 17 | + * @var int |
|
| 18 | + */ |
|
| 19 | + public $objMap = 1; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Empty cache for a specific template |
|
| 23 | - * |
|
| 24 | - * @api Smarty::clearCache() |
|
| 25 | - * @link http://www.smarty.net/docs/en/api.clear.cache.tpl |
|
| 26 | - * |
|
| 27 | - * @param \Smarty $smarty |
|
| 28 | - * @param string $template_name template name |
|
| 29 | - * @param string $cache_id cache id |
|
| 30 | - * @param string $compile_id compile id |
|
| 31 | - * @param integer $exp_time expiration time |
|
| 32 | - * @param string $type resource type |
|
| 33 | - * |
|
| 34 | - * @return integer number of cache files deleted |
|
| 35 | - */ |
|
| 36 | - public function clearCache(Smarty $smarty, $template_name, $cache_id = null, $compile_id = null, $exp_time = null, |
|
| 37 | - $type = null) |
|
| 38 | - { |
|
| 39 | - $smarty->_clearTemplateCache(); |
|
| 40 | - // load cache resource and call clear |
|
| 41 | - $_cache_resource = Smarty_CacheResource::load($smarty, $type); |
|
| 42 | - return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time); |
|
| 43 | - } |
|
| 21 | + /** |
|
| 22 | + * Empty cache for a specific template |
|
| 23 | + * |
|
| 24 | + * @api Smarty::clearCache() |
|
| 25 | + * @link http://www.smarty.net/docs/en/api.clear.cache.tpl |
|
| 26 | + * |
|
| 27 | + * @param \Smarty $smarty |
|
| 28 | + * @param string $template_name template name |
|
| 29 | + * @param string $cache_id cache id |
|
| 30 | + * @param string $compile_id compile id |
|
| 31 | + * @param integer $exp_time expiration time |
|
| 32 | + * @param string $type resource type |
|
| 33 | + * |
|
| 34 | + * @return integer number of cache files deleted |
|
| 35 | + */ |
|
| 36 | + public function clearCache(Smarty $smarty, $template_name, $cache_id = null, $compile_id = null, $exp_time = null, |
|
| 37 | + $type = null) |
|
| 38 | + { |
|
| 39 | + $smarty->_clearTemplateCache(); |
|
| 40 | + // load cache resource and call clear |
|
| 41 | + $_cache_resource = Smarty_CacheResource::load($smarty, $type); |
|
| 42 | + return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time); |
|
| 43 | + } |
|
| 44 | 44 | } |
| 45 | 45 | \ No newline at end of file |
@@ -16,33 +16,33 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Array of names of valid option flags |
|
| 21 | - * |
|
| 22 | - * @var array |
|
| 23 | - */ |
|
| 24 | - public $option_flags = array(); |
|
| 19 | + /** |
|
| 20 | + * Array of names of valid option flags |
|
| 21 | + * |
|
| 22 | + * @var array |
|
| 23 | + */ |
|
| 24 | + public $option_flags = array(); |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Compiles code for the {nocache} tag |
|
| 28 | - * This tag does not generate compiled output. It only sets a compiler flag. |
|
| 29 | - * |
|
| 30 | - * @param array $args array with attributes from parser |
|
| 31 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 32 | - * |
|
| 33 | - * @return bool |
|
| 34 | - */ |
|
| 35 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 36 | - { |
|
| 37 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 38 | - $this->openTag($compiler, 'nocache', array($compiler->nocache)); |
|
| 39 | - // enter nocache mode |
|
| 40 | - $compiler->nocache = true; |
|
| 41 | - // this tag does not return compiled code |
|
| 42 | - $compiler->has_code = false; |
|
| 26 | + /** |
|
| 27 | + * Compiles code for the {nocache} tag |
|
| 28 | + * This tag does not generate compiled output. It only sets a compiler flag. |
|
| 29 | + * |
|
| 30 | + * @param array $args array with attributes from parser |
|
| 31 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 32 | + * |
|
| 33 | + * @return bool |
|
| 34 | + */ |
|
| 35 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 36 | + { |
|
| 37 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 38 | + $this->openTag($compiler, 'nocache', array($compiler->nocache)); |
|
| 39 | + // enter nocache mode |
|
| 40 | + $compiler->nocache = true; |
|
| 41 | + // this tag does not return compiled code |
|
| 42 | + $compiler->has_code = false; |
|
| 43 | 43 | |
| 44 | - return true; |
|
| 45 | - } |
|
| 44 | + return true; |
|
| 45 | + } |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -53,23 +53,23 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase |
| 55 | 55 | { |
| 56 | - /** |
|
| 57 | - * Compiles code for the {/nocache} tag |
|
| 58 | - * This tag does not generate compiled output. It only sets a compiler flag. |
|
| 59 | - * |
|
| 60 | - * @param array $args array with attributes from parser |
|
| 61 | - * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 62 | - * |
|
| 63 | - * @return bool |
|
| 64 | - */ |
|
| 65 | - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 66 | - { |
|
| 67 | - $_attr = $this->getAttributes($compiler, $args); |
|
| 68 | - // leave nocache mode |
|
| 69 | - list($compiler->nocache) = $this->closeTag($compiler, array('nocache')); |
|
| 70 | - // this tag does not return compiled code |
|
| 71 | - $compiler->has_code = false; |
|
| 56 | + /** |
|
| 57 | + * Compiles code for the {/nocache} tag |
|
| 58 | + * This tag does not generate compiled output. It only sets a compiler flag. |
|
| 59 | + * |
|
| 60 | + * @param array $args array with attributes from parser |
|
| 61 | + * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
| 62 | + * |
|
| 63 | + * @return bool |
|
| 64 | + */ |
|
| 65 | + public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler) |
|
| 66 | + { |
|
| 67 | + $_attr = $this->getAttributes($compiler, $args); |
|
| 68 | + // leave nocache mode |
|
| 69 | + list($compiler->nocache) = $this->closeTag($compiler, array('nocache')); |
|
| 70 | + // this tag does not return compiled code |
|
| 71 | + $compiler->has_code = false; |
|
| 72 | 72 | |
| 73 | - return true; |
|
| 74 | - } |
|
| 73 | + return true; |
|
| 74 | + } |
|
| 75 | 75 | } |