@@ -17,160 +17,160 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Smarty_Internal_Resource_File extends Smarty_Resource |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * build template filepath by traversing the template_dir array |
|
| 22 | - * |
|
| 23 | - * @param Smarty_Template_Source $source source object |
|
| 24 | - * @param Smarty_Internal_Template $_template template object |
|
| 25 | - * |
|
| 26 | - * @return string fully qualified filepath |
|
| 27 | - * @throws SmartyException |
|
| 28 | - */ |
|
| 29 | - protected function buildFilepath(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) |
|
| 30 | - { |
|
| 31 | - $file = $source->name; |
|
| 32 | - // absolute file ? |
|
| 33 | - if ($file[ 0 ] == '/' || $file[ 1 ] == ':') { |
|
| 34 | - $file = $source->smarty->_realpath($file, true); |
|
| 35 | - return is_file($file) ? $file : false; |
|
| 36 | - } |
|
| 37 | - // go relative to a given template? |
|
| 38 | - if ($file[ 0 ] == '.' && $_template && isset($_template->parent) && $_template->parent->_objType == 2 && |
|
| 39 | - preg_match('#^[.]{1,2}[\\\/]#', $file) |
|
| 40 | - ) { |
|
| 41 | - if ($_template->parent->source->type != 'file' && $_template->parent->source->type != 'extends' && |
|
| 42 | - !isset($_template->parent->_cache[ 'allow_relative_path' ]) |
|
| 43 | - ) { |
|
| 44 | - throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'"); |
|
| 45 | - } |
|
| 46 | - // normalize path |
|
| 47 | - $path = $source->smarty->_realpath(dirname($_template->parent->source->filepath) . DS . $file); |
|
| 48 | - // files relative to a template only get one shot |
|
| 49 | - return is_file($path) ? $path : false; |
|
| 50 | - } |
|
| 51 | - // normalize DS |
|
| 52 | - if (strpos($file, DS == '/' ? '\\' : '/') !== false) { |
|
| 53 | - $file = str_replace(DS == '/' ? '\\' : '/', DS, $file); |
|
| 54 | - } |
|
| 20 | + /** |
|
| 21 | + * build template filepath by traversing the template_dir array |
|
| 22 | + * |
|
| 23 | + * @param Smarty_Template_Source $source source object |
|
| 24 | + * @param Smarty_Internal_Template $_template template object |
|
| 25 | + * |
|
| 26 | + * @return string fully qualified filepath |
|
| 27 | + * @throws SmartyException |
|
| 28 | + */ |
|
| 29 | + protected function buildFilepath(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) |
|
| 30 | + { |
|
| 31 | + $file = $source->name; |
|
| 32 | + // absolute file ? |
|
| 33 | + if ($file[ 0 ] == '/' || $file[ 1 ] == ':') { |
|
| 34 | + $file = $source->smarty->_realpath($file, true); |
|
| 35 | + return is_file($file) ? $file : false; |
|
| 36 | + } |
|
| 37 | + // go relative to a given template? |
|
| 38 | + if ($file[ 0 ] == '.' && $_template && isset($_template->parent) && $_template->parent->_objType == 2 && |
|
| 39 | + preg_match('#^[.]{1,2}[\\\/]#', $file) |
|
| 40 | + ) { |
|
| 41 | + if ($_template->parent->source->type != 'file' && $_template->parent->source->type != 'extends' && |
|
| 42 | + !isset($_template->parent->_cache[ 'allow_relative_path' ]) |
|
| 43 | + ) { |
|
| 44 | + throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'"); |
|
| 45 | + } |
|
| 46 | + // normalize path |
|
| 47 | + $path = $source->smarty->_realpath(dirname($_template->parent->source->filepath) . DS . $file); |
|
| 48 | + // files relative to a template only get one shot |
|
| 49 | + return is_file($path) ? $path : false; |
|
| 50 | + } |
|
| 51 | + // normalize DS |
|
| 52 | + if (strpos($file, DS == '/' ? '\\' : '/') !== false) { |
|
| 53 | + $file = str_replace(DS == '/' ? '\\' : '/', DS, $file); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - $_directories = $source->smarty->getTemplateDir(null, $source->isConfig); |
|
| 57 | - // template_dir index? |
|
| 58 | - if ($file[ 0 ] == '[' && preg_match('#^\[([^\]]+)\](.+)$#', $file, $fileMatch)) { |
|
| 59 | - $file = $fileMatch[ 2 ]; |
|
| 60 | - $_indices = explode(',', $fileMatch[ 1 ]); |
|
| 61 | - $_index_dirs = array(); |
|
| 62 | - foreach ($_indices as $index) { |
|
| 63 | - $index = trim($index); |
|
| 64 | - // try string indexes |
|
| 65 | - if (isset($_directories[ $index ])) { |
|
| 66 | - $_index_dirs[] = $_directories[ $index ]; |
|
| 67 | - } elseif (is_numeric($index)) { |
|
| 68 | - // try numeric index |
|
| 69 | - $index = (int) $index; |
|
| 70 | - if (isset($_directories[ $index ])) { |
|
| 71 | - $_index_dirs[] = $_directories[ $index ]; |
|
| 72 | - } else { |
|
| 73 | - // try at location index |
|
| 74 | - $keys = array_keys($_directories); |
|
| 75 | - if (isset($_directories[ $keys[ $index ] ])) { |
|
| 76 | - $_index_dirs[] = $_directories[ $keys[ $index ] ]; |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - if (empty($_index_dirs)) { |
|
| 82 | - // index not found |
|
| 83 | - return false; |
|
| 84 | - } else { |
|
| 85 | - $_directories = $_index_dirs; |
|
| 86 | - } |
|
| 87 | - } |
|
| 56 | + $_directories = $source->smarty->getTemplateDir(null, $source->isConfig); |
|
| 57 | + // template_dir index? |
|
| 58 | + if ($file[ 0 ] == '[' && preg_match('#^\[([^\]]+)\](.+)$#', $file, $fileMatch)) { |
|
| 59 | + $file = $fileMatch[ 2 ]; |
|
| 60 | + $_indices = explode(',', $fileMatch[ 1 ]); |
|
| 61 | + $_index_dirs = array(); |
|
| 62 | + foreach ($_indices as $index) { |
|
| 63 | + $index = trim($index); |
|
| 64 | + // try string indexes |
|
| 65 | + if (isset($_directories[ $index ])) { |
|
| 66 | + $_index_dirs[] = $_directories[ $index ]; |
|
| 67 | + } elseif (is_numeric($index)) { |
|
| 68 | + // try numeric index |
|
| 69 | + $index = (int) $index; |
|
| 70 | + if (isset($_directories[ $index ])) { |
|
| 71 | + $_index_dirs[] = $_directories[ $index ]; |
|
| 72 | + } else { |
|
| 73 | + // try at location index |
|
| 74 | + $keys = array_keys($_directories); |
|
| 75 | + if (isset($_directories[ $keys[ $index ] ])) { |
|
| 76 | + $_index_dirs[] = $_directories[ $keys[ $index ] ]; |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + if (empty($_index_dirs)) { |
|
| 82 | + // index not found |
|
| 83 | + return false; |
|
| 84 | + } else { |
|
| 85 | + $_directories = $_index_dirs; |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - // relative file name? |
|
| 90 | - foreach ($_directories as $_directory) { |
|
| 91 | - $path = $_directory . $file; |
|
| 92 | - if (is_file($path)) { |
|
| 93 | - return (strpos($path, '.' . DS) !== false) ? $source->smarty->_realpath($path) : $path; |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - if (!isset($_index_dirs)) { |
|
| 97 | - // Could be relative to cwd |
|
| 98 | - $path = $source->smarty->_realpath($file, true); |
|
| 99 | - if (is_file($path)) { |
|
| 100 | - return $path; |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - // Use include path ? |
|
| 104 | - if ($source->smarty->use_include_path) { |
|
| 105 | - return $source->smarty->ext->_getIncludePath->getIncludePath($_directories, $file, $source->smarty); |
|
| 106 | - } |
|
| 107 | - return false; |
|
| 108 | - } |
|
| 89 | + // relative file name? |
|
| 90 | + foreach ($_directories as $_directory) { |
|
| 91 | + $path = $_directory . $file; |
|
| 92 | + if (is_file($path)) { |
|
| 93 | + return (strpos($path, '.' . DS) !== false) ? $source->smarty->_realpath($path) : $path; |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + if (!isset($_index_dirs)) { |
|
| 97 | + // Could be relative to cwd |
|
| 98 | + $path = $source->smarty->_realpath($file, true); |
|
| 99 | + if (is_file($path)) { |
|
| 100 | + return $path; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + // Use include path ? |
|
| 104 | + if ($source->smarty->use_include_path) { |
|
| 105 | + return $source->smarty->ext->_getIncludePath->getIncludePath($_directories, $file, $source->smarty); |
|
| 106 | + } |
|
| 107 | + return false; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * populate Source Object with meta data from Resource |
|
| 112 | - * |
|
| 113 | - * @param Smarty_Template_Source $source source object |
|
| 114 | - * @param Smarty_Internal_Template $_template template object |
|
| 115 | - */ |
|
| 116 | - public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) |
|
| 117 | - { |
|
| 118 | - $source->filepath = $this->buildFilepath($source, $_template); |
|
| 110 | + /** |
|
| 111 | + * populate Source Object with meta data from Resource |
|
| 112 | + * |
|
| 113 | + * @param Smarty_Template_Source $source source object |
|
| 114 | + * @param Smarty_Internal_Template $_template template object |
|
| 115 | + */ |
|
| 116 | + public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) |
|
| 117 | + { |
|
| 118 | + $source->filepath = $this->buildFilepath($source, $_template); |
|
| 119 | 119 | |
| 120 | - if ($source->filepath !== false) { |
|
| 121 | - if (isset($source->smarty->security_policy) && is_object($source->smarty->security_policy)) { |
|
| 122 | - $source->smarty->security_policy->isTrustedResourceDir($source->filepath, $source->isConfig); |
|
| 123 | - } |
|
| 124 | - $source->exists = true; |
|
| 125 | - $source->uid = sha1($source->filepath . ($source->isConfig ? $source->smarty->_joined_config_dir : |
|
| 126 | - $source->smarty->_joined_template_dir)); |
|
| 127 | - $source->timestamp = filemtime($source->filepath); |
|
| 128 | - } else { |
|
| 129 | - $source->timestamp = $source->exists = false; |
|
| 130 | - } |
|
| 131 | - } |
|
| 120 | + if ($source->filepath !== false) { |
|
| 121 | + if (isset($source->smarty->security_policy) && is_object($source->smarty->security_policy)) { |
|
| 122 | + $source->smarty->security_policy->isTrustedResourceDir($source->filepath, $source->isConfig); |
|
| 123 | + } |
|
| 124 | + $source->exists = true; |
|
| 125 | + $source->uid = sha1($source->filepath . ($source->isConfig ? $source->smarty->_joined_config_dir : |
|
| 126 | + $source->smarty->_joined_template_dir)); |
|
| 127 | + $source->timestamp = filemtime($source->filepath); |
|
| 128 | + } else { |
|
| 129 | + $source->timestamp = $source->exists = false; |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * populate Source Object with timestamp and exists from Resource |
|
| 135 | - * |
|
| 136 | - * @param Smarty_Template_Source $source source object |
|
| 137 | - */ |
|
| 138 | - public function populateTimestamp(Smarty_Template_Source $source) |
|
| 139 | - { |
|
| 140 | - if (!$source->exists) { |
|
| 141 | - $source->timestamp = $source->exists = is_file($source->filepath); |
|
| 142 | - } |
|
| 143 | - if ($source->exists) { |
|
| 144 | - $source->timestamp = filemtime($source->filepath); |
|
| 145 | - } |
|
| 146 | - } |
|
| 133 | + /** |
|
| 134 | + * populate Source Object with timestamp and exists from Resource |
|
| 135 | + * |
|
| 136 | + * @param Smarty_Template_Source $source source object |
|
| 137 | + */ |
|
| 138 | + public function populateTimestamp(Smarty_Template_Source $source) |
|
| 139 | + { |
|
| 140 | + if (!$source->exists) { |
|
| 141 | + $source->timestamp = $source->exists = is_file($source->filepath); |
|
| 142 | + } |
|
| 143 | + if ($source->exists) { |
|
| 144 | + $source->timestamp = filemtime($source->filepath); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Load template's source from file into current template object |
|
| 150 | - * |
|
| 151 | - * @param Smarty_Template_Source $source source object |
|
| 152 | - * |
|
| 153 | - * @return string template source |
|
| 154 | - * @throws SmartyException if source cannot be loaded |
|
| 155 | - */ |
|
| 156 | - public function getContent(Smarty_Template_Source $source) |
|
| 157 | - { |
|
| 158 | - if ($source->exists) { |
|
| 159 | - return file_get_contents($source->filepath); |
|
| 160 | - } |
|
| 161 | - throw new SmartyException('Unable to read ' . ($source->isConfig ? 'config' : 'template') . |
|
| 162 | - " {$source->type} '{$source->name}'"); |
|
| 163 | - } |
|
| 148 | + /** |
|
| 149 | + * Load template's source from file into current template object |
|
| 150 | + * |
|
| 151 | + * @param Smarty_Template_Source $source source object |
|
| 152 | + * |
|
| 153 | + * @return string template source |
|
| 154 | + * @throws SmartyException if source cannot be loaded |
|
| 155 | + */ |
|
| 156 | + public function getContent(Smarty_Template_Source $source) |
|
| 157 | + { |
|
| 158 | + if ($source->exists) { |
|
| 159 | + return file_get_contents($source->filepath); |
|
| 160 | + } |
|
| 161 | + throw new SmartyException('Unable to read ' . ($source->isConfig ? 'config' : 'template') . |
|
| 162 | + " {$source->type} '{$source->name}'"); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - /** |
|
| 166 | - * Determine basename for compiled filename |
|
| 167 | - * |
|
| 168 | - * @param Smarty_Template_Source $source source object |
|
| 169 | - * |
|
| 170 | - * @return string resource's basename |
|
| 171 | - */ |
|
| 172 | - public function getBasename(Smarty_Template_Source $source) |
|
| 173 | - { |
|
| 174 | - return basename($source->filepath); |
|
| 175 | - } |
|
| 165 | + /** |
|
| 166 | + * Determine basename for compiled filename |
|
| 167 | + * |
|
| 168 | + * @param Smarty_Template_Source $source source object |
|
| 169 | + * |
|
| 170 | + * @return string resource's basename |
|
| 171 | + */ |
|
| 172 | + public function getBasename(Smarty_Template_Source $source) |
|
| 173 | + { |
|
| 174 | + return basename($source->filepath); |
|
| 175 | + } |
|
| 176 | 176 | } |
@@ -30,16 +30,16 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $file = $source->name; |
| 32 | 32 | // absolute file ? |
| 33 | - if ($file[ 0 ] == '/' || $file[ 1 ] == ':') { |
|
| 33 | + if ($file[0] == '/' || $file[1] == ':') { |
|
| 34 | 34 | $file = $source->smarty->_realpath($file, true); |
| 35 | 35 | return is_file($file) ? $file : false; |
| 36 | 36 | } |
| 37 | 37 | // go relative to a given template? |
| 38 | - if ($file[ 0 ] == '.' && $_template && isset($_template->parent) && $_template->parent->_objType == 2 && |
|
| 38 | + if ($file[0] == '.' && $_template && isset($_template->parent) && $_template->parent->_objType == 2 && |
|
| 39 | 39 | preg_match('#^[.]{1,2}[\\\/]#', $file) |
| 40 | 40 | ) { |
| 41 | 41 | if ($_template->parent->source->type != 'file' && $_template->parent->source->type != 'extends' && |
| 42 | - !isset($_template->parent->_cache[ 'allow_relative_path' ]) |
|
| 42 | + !isset($_template->parent->_cache['allow_relative_path']) |
|
| 43 | 43 | ) { |
| 44 | 44 | throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'"); |
| 45 | 45 | } |
@@ -55,25 +55,25 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $_directories = $source->smarty->getTemplateDir(null, $source->isConfig); |
| 57 | 57 | // template_dir index? |
| 58 | - if ($file[ 0 ] == '[' && preg_match('#^\[([^\]]+)\](.+)$#', $file, $fileMatch)) { |
|
| 59 | - $file = $fileMatch[ 2 ]; |
|
| 60 | - $_indices = explode(',', $fileMatch[ 1 ]); |
|
| 58 | + if ($file[0] == '[' && preg_match('#^\[([^\]]+)\](.+)$#', $file, $fileMatch)) { |
|
| 59 | + $file = $fileMatch[2]; |
|
| 60 | + $_indices = explode(',', $fileMatch[1]); |
|
| 61 | 61 | $_index_dirs = array(); |
| 62 | 62 | foreach ($_indices as $index) { |
| 63 | 63 | $index = trim($index); |
| 64 | 64 | // try string indexes |
| 65 | - if (isset($_directories[ $index ])) { |
|
| 66 | - $_index_dirs[] = $_directories[ $index ]; |
|
| 65 | + if (isset($_directories[$index])) { |
|
| 66 | + $_index_dirs[] = $_directories[$index]; |
|
| 67 | 67 | } elseif (is_numeric($index)) { |
| 68 | 68 | // try numeric index |
| 69 | 69 | $index = (int) $index; |
| 70 | - if (isset($_directories[ $index ])) { |
|
| 71 | - $_index_dirs[] = $_directories[ $index ]; |
|
| 70 | + if (isset($_directories[$index])) { |
|
| 71 | + $_index_dirs[] = $_directories[$index]; |
|
| 72 | 72 | } else { |
| 73 | 73 | // try at location index |
| 74 | 74 | $keys = array_keys($_directories); |
| 75 | - if (isset($_directories[ $keys[ $index ] ])) { |
|
| 76 | - $_index_dirs[] = $_directories[ $keys[ $index ] ]; |
|
| 75 | + if (isset($_directories[$keys[$index]])) { |
|
| 76 | + $_index_dirs[] = $_directories[$keys[$index]]; |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -122,8 +122,7 @@ discard block |
||
| 122 | 122 | $source->smarty->security_policy->isTrustedResourceDir($source->filepath, $source->isConfig); |
| 123 | 123 | } |
| 124 | 124 | $source->exists = true; |
| 125 | - $source->uid = sha1($source->filepath . ($source->isConfig ? $source->smarty->_joined_config_dir : |
|
| 126 | - $source->smarty->_joined_template_dir)); |
|
| 125 | + $source->uid = sha1($source->filepath . ($source->isConfig ? $source->smarty->_joined_config_dir : $source->smarty->_joined_template_dir)); |
|
| 127 | 126 | $source->timestamp = filemtime($source->filepath); |
| 128 | 127 | } else { |
| 129 | 128 | $source->timestamp = $source->exists = false; |
@@ -12,22 +12,22 @@ |
||
| 12 | 12 | class Smarty_Internal_Method_CompileAllConfig extends Smarty_Internal_Method_CompileAllTemplates |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Compile all config files |
|
| 17 | - * |
|
| 18 | - * @api Smarty::compileAllConfig() |
|
| 19 | - * |
|
| 20 | - * @param \Smarty $smarty passed smarty object |
|
| 21 | - * @param string $extension file extension |
|
| 22 | - * @param bool $force_compile force all to recompile |
|
| 23 | - * @param int $time_limit |
|
| 24 | - * @param int $max_errors |
|
| 25 | - * |
|
| 26 | - * @return int number of template files recompiled |
|
| 27 | - */ |
|
| 28 | - public function compileAllConfig(Smarty $smarty, $extension = '.conf', $force_compile = false, $time_limit = 0, |
|
| 29 | - $max_errors = null) |
|
| 30 | - { |
|
| 31 | - return $this->compileAll($smarty, $extension, $force_compile, $time_limit, $max_errors, true); |
|
| 32 | - } |
|
| 15 | + /** |
|
| 16 | + * Compile all config files |
|
| 17 | + * |
|
| 18 | + * @api Smarty::compileAllConfig() |
|
| 19 | + * |
|
| 20 | + * @param \Smarty $smarty passed smarty object |
|
| 21 | + * @param string $extension file extension |
|
| 22 | + * @param bool $force_compile force all to recompile |
|
| 23 | + * @param int $time_limit |
|
| 24 | + * @param int $max_errors |
|
| 25 | + * |
|
| 26 | + * @return int number of template files recompiled |
|
| 27 | + */ |
|
| 28 | + public function compileAllConfig(Smarty $smarty, $extension = '.conf', $force_compile = false, $time_limit = 0, |
|
| 29 | + $max_errors = null) |
|
| 30 | + { |
|
| 31 | + return $this->compileAll($smarty, $extension, $force_compile, $time_limit, $max_errors, true); |
|
| 32 | + } |
|
| 33 | 33 | } |
| 34 | 34 | \ No newline at end of file |
@@ -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 |