From 240409578349843bd8467ea6a2083b564baa135d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Kaleta?= Date: Tue, 12 Jun 2018 09:58:15 +0200 Subject: [PATCH] Update PSR-2 --- composer.json | 11 +- demo/index.php | 12 +- demo/plugins/cacheresource.apc.php | 8 +- demo/plugins/cacheresource.memcache.php | 8 +- demo/plugins/cacheresource.mysql.php | 52 +- demo/plugins/cacheresource.pdo.php | 30 +- demo/plugins/cacheresource.pdo_gzip.php | 2 +- demo/plugins/resource.extendsall.php | 4 +- demo/plugins/resource.mysql.php | 8 +- demo/plugins/resource.mysqls.php | 6 +- libs/Autoloader.php | 12 +- libs/Smarty.class.php | 90 +- libs/SmartyBC.class.php | 43 +- libs/bootstrap.php | 2 +- libs/plugins/block.textformat.php | 49 +- libs/plugins/function.cycle.php | 13 +- libs/plugins/function.fetch.php | 122 +-- libs/plugins/function.html_checkboxes.php | 199 ++-- libs/plugins/function.html_image.php | 63 +- libs/plugins/function.html_options.php | 147 +-- libs/plugins/function.html_radios.php | 167 +-- libs/plugins/function.html_select_date.php | 199 ++-- libs/plugins/function.html_select_time.php | 154 +-- libs/plugins/function.html_table.php | 75 +- libs/plugins/function.mailto.php | 45 +- libs/plugins/function.math.php | 4 +- libs/plugins/modifier.capitalize.php | 44 +- libs/plugins/modifier.date_format.php | 2 +- libs/plugins/modifier.debug_print_var.php | 140 +-- libs/plugins/modifier.escape.php | 300 +++--- libs/plugins/modifier.mb_wordwrap.php | 21 +- libs/plugins/modifier.regex_replace.php | 4 +- libs/plugins/modifier.replace.php | 2 +- libs/plugins/modifier.truncate.php | 6 +- libs/plugins/modifiercompiler.cat.php | 4 +- .../modifiercompiler.count_paragraphs.php | 4 +- .../modifiercompiler.count_sentences.php | 4 +- libs/plugins/modifiercompiler.escape.php | 88 +- libs/plugins/modifiercompiler.noprint.php | 2 +- libs/plugins/modifiercompiler.unescape.php | 24 +- libs/plugins/modifiercompiler.wordwrap.php | 4 +- libs/plugins/outputfilter.trimwhitespace.php | 18 +- libs/plugins/shared.escape_special_chars.php | 4 +- .../plugins/shared.literal_compiler_param.php | 6 +- libs/plugins/shared.make_timestamp.php | 12 +- libs/plugins/shared.mb_str_replace.php | 8 +- libs/plugins/shared.mb_unicode.php | 4 +- .../variablefilter.htmlspecialchars.php | 2 +- libs/sysplugins/smarty_cacheresource.php | 5 +- .../smarty_cacheresource_custom.php | 98 +- .../smarty_cacheresource_keyvaluestore.php | 143 +-- libs/sysplugins/smarty_internal_block.php | 2 +- .../smarty_internal_cacheresource_file.php | 28 +- .../smarty_internal_compile_append.php | 4 +- .../smarty_internal_compile_assign.php | 6 +- .../smarty_internal_compile_block.php | 44 +- .../smarty_internal_compile_block_child.php | 2 +- .../smarty_internal_compile_block_parent.php | 2 +- .../smarty_internal_compile_break.php | 12 +- .../smarty_internal_compile_call.php | 4 +- .../smarty_internal_compile_capture.php | 18 +- .../smarty_internal_compile_child.php | 14 +- .../smarty_internal_compile_config_load.php | 2 +- .../smarty_internal_compile_continue.php | 8 +- .../smarty_internal_compile_debug.php | 4 +- .../smarty_internal_compile_eval.php | 4 +- .../smarty_internal_compile_extends.php | 22 +- .../smarty_internal_compile_for.php | 18 +- .../smarty_internal_compile_foreach.php | 20 +- .../smarty_internal_compile_function.php | 64 +- .../sysplugins/smarty_internal_compile_if.php | 14 +- .../smarty_internal_compile_include.php | 31 +- .../smarty_internal_compile_include_php.php | 7 +- .../smarty_internal_compile_insert.php | 20 +- .../smarty_internal_compile_ldelim.php | 4 +- .../smarty_internal_compile_make_nocache.php | 4 +- .../smarty_internal_compile_nocache.php | 4 +- .../smarty_internal_compile_parent.php | 2 +- ..._internal_compile_private_block_plugin.php | 22 +- ...nternal_compile_private_foreachsection.php | 18 +- ...ternal_compile_private_function_plugin.php | 16 +- ...arty_internal_compile_private_modifier.php | 178 ++-- ..._compile_private_object_block_function.php | 6 +- ...ternal_compile_private_object_function.php | 14 +- .../smarty_internal_compile_private_php.php | 76 +- ...ernal_compile_private_print_expression.php | 40 +- ...ernal_compile_private_registered_block.php | 6 +- ...al_compile_private_registered_function.php | 16 +- ...ernal_compile_private_special_variable.php | 146 +-- .../smarty_internal_compile_rdelim.php | 4 +- .../smarty_internal_compile_section.php | 112 +- .../smarty_internal_compile_setfilter.php | 6 +- ...ty_internal_compile_shared_inheritance.php | 12 +- .../smarty_internal_compile_while.php | 12 +- .../smarty_internal_compilebase.php | 22 +- .../smarty_internal_config_file_compiler.php | 10 +- .../smarty_internal_configfilelexer.php | 175 ++-- .../smarty_internal_configfileparser.php | 168 +-- libs/sysplugins/smarty_internal_data.php | 58 +- libs/sysplugins/smarty_internal_debug.php | 4 +- .../smarty_internal_errorhandler.php | 27 +- .../smarty_internal_extension_handler.php | 74 +- ...rty_internal_method_addautoloadfilters.php | 13 +- ...ty_internal_method_adddefaultmodifiers.php | 4 +- .../smarty_internal_method_append.php | 14 +- .../smarty_internal_method_appendbyref.php | 8 +- .../smarty_internal_method_assignbyref.php | 6 +- .../smarty_internal_method_assignglobal.php | 8 +- .../smarty_internal_method_clearallassign.php | 2 +- .../smarty_internal_method_clearallcache.php | 8 +- .../smarty_internal_method_clearassign.php | 4 +- .../smarty_internal_method_clearcache.php | 18 +- ..._internal_method_clearcompiledtemplate.php | 36 +- .../smarty_internal_method_clearconfig.php | 4 +- ...marty_internal_method_compileallconfig.php | 16 +- ...ty_internal_method_compilealltemplates.php | 48 +- .../smarty_internal_method_configload.php | 16 +- .../smarty_internal_method_createdata.php | 2 +- ...rty_internal_method_getautoloadfilters.php | 4 +- ...arty_internal_method_getconfigvariable.php | 4 +- .../smarty_internal_method_getconfigvars.php | 6 +- ...marty_internal_method_getdebugtemplate.php | 2 +- ...ty_internal_method_getdefaultmodifiers.php | 2 +- .../smarty_internal_method_getglobal.php | 6 +- ...ty_internal_method_getregisteredobject.php | 4 +- ...arty_internal_method_getstreamvariable.php | 4 +- .../smarty_internal_method_gettags.php | 2 +- ...smarty_internal_method_gettemplatevars.php | 14 +- .../smarty_internal_method_literals.php | 18 +- .../smarty_internal_method_loadfilter.php | 8 +- .../smarty_internal_method_loadplugin.php | 12 +- .../smarty_internal_method_mustcompile.php | 2 +- ..._internal_method_registercacheresource.php | 8 +- .../smarty_internal_method_registerclass.php | 6 +- ...al_method_registerdefaultconfighandler.php | 6 +- ...al_method_registerdefaultpluginhandler.php | 4 +- ..._method_registerdefaulttemplatehandler.php | 24 +- .../smarty_internal_method_registerfilter.php | 12 +- .../smarty_internal_method_registerobject.php | 29 +- .../smarty_internal_method_registerplugin.php | 17 +- ...marty_internal_method_registerresource.php | 14 +- ...rty_internal_method_setautoloadfilters.php | 13 +- ...marty_internal_method_setdebugtemplate.php | 4 +- ...ty_internal_method_setdefaultmodifiers.php | 4 +- .../smarty_internal_method_unloadfilter.php | 10 +- ...nternal_method_unregistercacheresource.php | 8 +- ...marty_internal_method_unregisterfilter.php | 8 +- ...marty_internal_method_unregisterobject.php | 4 +- ...marty_internal_method_unregisterplugin.php | 6 +- ...rty_internal_method_unregisterresource.php | 4 +- .../smarty_internal_nocache_insert.php | 10 +- .../smarty_internal_parsetree_dq.php | 16 +- .../smarty_internal_parsetree_template.php | 7 +- .../smarty_internal_resource_eval.php | 16 +- .../smarty_internal_resource_file.php | 28 +- .../smarty_internal_resource_php.php | 19 +- .../smarty_internal_resource_registered.php | 24 +- .../smarty_internal_resource_stream.php | 6 +- .../smarty_internal_resource_string.php | 16 +- .../smarty_internal_runtime_cachemodify.php | 61 +- ...rty_internal_runtime_cacheresourcefile.php | 6 +- .../smarty_internal_runtime_capture.php | 10 +- .../smarty_internal_runtime_codeframe.php | 30 +- .../smarty_internal_runtime_filterhandler.php | 6 +- .../smarty_internal_runtime_foreach.php | 8 +- ...smarty_internal_runtime_getincludepath.php | 10 +- .../smarty_internal_runtime_inheritance.php | 39 +- .../smarty_internal_runtime_make_nocache.php | 5 +- .../smarty_internal_runtime_tplfunction.php | 24 +- .../smarty_internal_runtime_updatecache.php | 47 +- .../smarty_internal_runtime_updatescope.php | 18 +- .../smarty_internal_runtime_writefile.php | 6 +- ...smarty_internal_smartytemplatecompiler.php | 23 +- libs/sysplugins/smarty_internal_template.php | 125 +-- .../smarty_internal_templatebase.php | 70 +- .../smarty_internal_templatecompilerbase.php | 330 +++--- .../smarty_internal_templatelexer.php | 198 ++-- .../smarty_internal_templateparser.php | 968 +++++++++++------- .../smarty_internal_testinstall.php | 2 +- libs/sysplugins/smarty_internal_undefined.php | 8 +- libs/sysplugins/smarty_resource.php | 47 +- libs/sysplugins/smarty_resource_custom.php | 10 +- .../sysplugins/smarty_resource_recompiled.php | 4 +- libs/sysplugins/smarty_security.php | 159 +-- libs/sysplugins/smarty_template_cached.php | 18 +- libs/sysplugins/smarty_template_compiled.php | 12 +- libs/sysplugins/smarty_template_config.php | 13 +- .../smarty_template_resource_base.php | 2 +- libs/sysplugins/smarty_template_source.php | 13 +- libs/sysplugins/smarty_undefined_variable.php | 2 +- 190 files changed, 3833 insertions(+), 3119 deletions(-) diff --git a/composer.json b/composer.json index 5064c8ce..5007517b 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,9 @@ "name": "smarty/smarty", "type": "library", "description": "Smarty - the compiling PHP template engine", - "keywords": ["templating"], + "keywords": [ + "templating" + ], "homepage": "http://www.smarty.net", "license": "LGPL-3.0", "authors": [ @@ -28,12 +30,13 @@ "php": ">=5.2" }, "autoload": { - "files": ["libs/bootstrap.php"] + "files": [ + "libs/bootstrap.php" + ] }, "extra": { "branch-alias": { "dev-master": "3.1.x-dev" } } - -} +} \ No newline at end of file diff --git a/demo/index.php b/demo/index.php index b67c217b..9db5ce03 100644 --- a/demo/index.php +++ b/demo/index.php @@ -17,11 +17,15 @@ $smarty->cache_lifetime = 120; $smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true); $smarty->assign("FirstName", array("John", "Mary", "James", "Henry")); $smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case")); -$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"), - array("M", "N", "O", "P"))); +$smarty->assign( + "Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"), + array("M", "N", "O", "P")) +); -$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), - array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234"))); +$smarty->assign( + "contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"), + array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")) +); $smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX")); $smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas")); diff --git a/demo/plugins/cacheresource.apc.php b/demo/plugins/cacheresource.apc.php index ed55ec84..dec18a29 100644 --- a/demo/plugins/cacheresource.apc.php +++ b/demo/plugins/cacheresource.apc.php @@ -22,7 +22,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore /** * Read values for a set of keys from cache * - * @param array $keys list of keys to fetch + * @param array $keys list of keys to fetch * * @return array list of values with the given keys used as indexes * @return boolean true on success, false on failure @@ -41,8 +41,8 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore /** * Save values for a set of keys to cache * - * @param array $keys list of values to save - * @param int $expire expiration time + * @param array $keys list of values to save + * @param int $expire expiration time * * @return boolean true on success, false on failure */ @@ -58,7 +58,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore /** * Remove values from cache * - * @param array $keys list of keys to delete + * @param array $keys list of keys to delete * * @return boolean true on success, false on failure */ diff --git a/demo/plugins/cacheresource.memcache.php b/demo/plugins/cacheresource.memcache.php index 945beb34..189579bb 100644 --- a/demo/plugins/cacheresource.memcache.php +++ b/demo/plugins/cacheresource.memcache.php @@ -32,7 +32,7 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore /** * Read values for a set of keys from cache * - * @param array $keys list of keys to fetch + * @param array $keys list of keys to fetch * * @return array list of values with the given keys used as indexes * @return boolean true on success, false on failure @@ -57,8 +57,8 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore /** * Save values for a set of keys to cache * - * @param array $keys list of values to save - * @param int $expire expiration time + * @param array $keys list of values to save + * @param int $expire expiration time * * @return boolean true on success, false on failure */ @@ -75,7 +75,7 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore /** * Remove values from cache * - * @param array $keys list of keys to delete + * @param array $keys list of keys to delete * * @return boolean true on success, false on failure */ diff --git a/demo/plugins/cacheresource.mysql.php b/demo/plugins/cacheresource.mysql.php index 027b9376..ff8e6f54 100644 --- a/demo/plugins/cacheresource.mysql.php +++ b/demo/plugins/cacheresource.mysql.php @@ -43,19 +43,21 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom } $this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id'); $this->fetchTimestamp = $this->db->prepare('SELECT modified FROM output_cache WHERE id = :id'); - $this->save = $this->db->prepare('REPLACE INTO output_cache (id, name, cache_id, compile_id, content) - VALUES (:id, :name, :cache_id, :compile_id, :content)'); + $this->save = $this->db->prepare( + 'REPLACE INTO output_cache (id, name, cache_id, compile_id, content) + VALUES (:id, :name, :cache_id, :compile_id, :content)' + ); } /** * fetch cached content and its modification time from data source * - * @param string $id unique cache content identifier - * @param string $name template name - * @param string $cache_id cache id - * @param string $compile_id compile id - * @param string $content cached content - * @param integer $mtime cache modification timestamp (epoch) + * @param string $id unique cache content identifier + * @param string $name template name + * @param string $cache_id cache id + * @param string $compile_id compile id + * @param string $content cached content + * @param integer $mtime cache modification timestamp (epoch) * * @return void */ @@ -78,10 +80,10 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom * * @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content. * - * @param string $id unique cache content identifier - * @param string $name template name - * @param string $cache_id cache id - * @param string $compile_id compile id + * @param string $id unique cache content identifier + * @param string $name template name + * @param string $cache_id cache id + * @param string $compile_id compile id * * @return integer|boolean timestamp (epoch) the template was modified, or false if not found */ @@ -97,19 +99,21 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom /** * Save content to cache * - * @param string $id unique cache content identifier - * @param string $name template name - * @param string $cache_id cache id - * @param string $compile_id compile id - * @param integer|null $exp_time seconds till expiration time in seconds or null - * @param string $content content to cache + * @param string $id unique cache content identifier + * @param string $name template name + * @param string $cache_id cache id + * @param string $compile_id compile id + * @param integer|null $exp_time seconds till expiration time in seconds or null + * @param string $content content to cache * * @return boolean success */ protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content) { - $this->save->execute(array('id' => $id, 'name' => $name, 'cache_id' => $cache_id, 'compile_id' => $compile_id, - 'content' => $content,)); + $this->save->execute( + array('id' => $id, 'name' => $name, 'cache_id' => $cache_id, 'compile_id' => $compile_id, + 'content' => $content,) + ); return !!$this->save->rowCount(); } @@ -117,10 +121,10 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom /** * Delete content from cache * - * @param string $name template name - * @param string $cache_id cache id - * @param string $compile_id compile id - * @param integer|null $exp_time seconds till expiration or null + * @param string $name template name + * @param string $cache_id cache id + * @param string $compile_id compile id + * @param integer|null $exp_time seconds till expiration or null * * @return integer number of deleted caches */ diff --git a/demo/plugins/cacheresource.pdo.php b/demo/plugins/cacheresource.pdo.php index 24a94c1a..5d9a132b 100644 --- a/demo/plugins/cacheresource.pdo.php +++ b/demo/plugins/cacheresource.pdo.php @@ -165,12 +165,12 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom /** * fetch cached content and its modification time from data source * - * @param string $id unique cache content identifier - * @param string $name template name - * @param string|null $cache_id cache id - * @param string|null $compile_id compile id - * @param string $content cached content - * @param integer $mtime cache modification timestamp (epoch) + * @param string $id unique cache content identifier + * @param string $name template name + * @param string|null $cache_id cache id + * @param string|null $compile_id compile id + * @param string $content cached content + * @param integer $mtime cache modification timestamp (epoch) * * @return void * @access protected @@ -197,10 +197,10 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom * {@internal implementing this method is optional. * Only implement it if modification times can be accessed faster than loading the complete cached content.}} * - * @param string $id unique cache content identifier - * @param string $name template name - * @param string|null $cache_id cache id - * @param string|null $compile_id compile id + * @param string $id unique cache content identifier + * @param string $name template name + * @param string|null $cache_id cache id + * @param string|null $compile_id compile id * * @return integer|boolean timestamp (epoch) the template was modified, or false if not found * @access protected @@ -269,10 +269,10 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom /** * Delete content from cache * - * @param string|null $name template name - * @param string|null $cache_id cache id - * @param string|null $compile_id compile id - * @param integer|null|-1 $exp_time seconds till expiration or null + * @param string|null $name template name + * @param string|null $cache_id cache id + * @param string|null $compile_id compile id + * @param integer|null|-1 $exp_time seconds till expiration or null * * @return integer number of deleted caches * @access protected @@ -324,4 +324,4 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom return (is_null($this->database)) ? "`{$this->table}`" : "`{$this->database}`.`{$this->table}`"; } } - \ No newline at end of file + diff --git a/demo/plugins/cacheresource.pdo_gzip.php b/demo/plugins/cacheresource.pdo_gzip.php index 8a9e0a5d..72427c4c 100644 --- a/demo/plugins/cacheresource.pdo_gzip.php +++ b/demo/plugins/cacheresource.pdo_gzip.php @@ -40,4 +40,4 @@ class Smarty_CacheResource_Pdo_Gzip extends Smarty_CacheResource_Pdo return gzinflate($content); } } - \ No newline at end of file + diff --git a/demo/plugins/resource.extendsall.php b/demo/plugins/resource.extendsall.php index a5ee432d..33936297 100644 --- a/demo/plugins/resource.extendsall.php +++ b/demo/plugins/resource.extendsall.php @@ -13,8 +13,8 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends /** * populate Source Object with meta data from Resource * - * @param Smarty_Template_Source $source source object - * @param Smarty_Internal_Template $_template template object + * @param Smarty_Template_Source $source source object + * @param Smarty_Internal_Template $_template template object * * @return void */ diff --git a/demo/plugins/resource.mysql.php b/demo/plugins/resource.mysql.php index 619707e7..f21ba8dc 100644 --- a/demo/plugins/resource.mysql.php +++ b/demo/plugins/resource.mysql.php @@ -43,9 +43,9 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom /** * Fetch a template and its modification time from database * - * @param string $name template name - * @param string $source template source - * @param integer $mtime template modification timestamp (epoch) + * @param string $name template name + * @param string $source template source + * @param integer $mtime template modification timestamp (epoch) * * @return void */ @@ -68,7 +68,7 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom * * @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source. * - * @param string $name template name + * @param string $name template name * * @return integer timestamp (epoch) the template was modified */ diff --git a/demo/plugins/resource.mysqls.php b/demo/plugins/resource.mysqls.php index d85aecf3..3e866830 100644 --- a/demo/plugins/resource.mysqls.php +++ b/demo/plugins/resource.mysqls.php @@ -41,9 +41,9 @@ class Smarty_Resource_Mysqls extends Smarty_Resource_Custom /** * Fetch a template and its modification time from database * - * @param string $name template name - * @param string $source template source - * @param integer $mtime template modification timestamp (epoch) + * @param string $name template name + * @param string $source template source + * @param integer $mtime template modification timestamp (epoch) * * @return void */ diff --git a/libs/Autoloader.php b/libs/Autoloader.php index 3a0da8fa..c3186750 100644 --- a/libs/Autoloader.php +++ b/libs/Autoloader.php @@ -2,14 +2,14 @@ /** * Smarty Autoloader * - * @package Smarty + * @package Smarty */ /** * Smarty Autoloader * - * @package Smarty - * @author Uwe Tews + * @package Smarty + * @author Uwe Tews * Usage: * require_once '...path/Autoloader.php'; * Smarty_Autoloader::register(); @@ -20,7 +20,7 @@ */ class Smarty_Autoloader { - /** + /** * Filepath to Smarty root * * @var string @@ -54,8 +54,8 @@ class Smarty_Autoloader if (!defined('SMARTY_SPL_AUTOLOAD')) { define('SMARTY_SPL_AUTOLOAD', 0); } - if (SMARTY_SPL_AUTOLOAD && - set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false + if (SMARTY_SPL_AUTOLOAD + && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false ) { $registeredAutoLoadFunctions = spl_autoload_functions(); if (!isset($registeredAutoLoadFunctions[ 'spl_autoload' ])) { diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 4d307547..1352d815 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -276,10 +276,10 @@ class Smarty extends Smarty_Internal_TemplateBase */ public $force_compile = false; /** - * use sub dirs for compiled/cached files? - * - * @var boolean - */ + * use sub dirs for compiled/cached files? + * + * @var boolean + */ public $use_sub_dirs = false; /** * allow ambiguous resources (that are made unique by the resource handler) @@ -618,7 +618,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Enable error handler to mute expected messages * - * @return boolean + * @return boolean * @deprecated */ public static function muteExpectedErrors() @@ -639,7 +639,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Check if a template resource exists * - * @param string $resource_name template name + * @param string $resource_name template name * * @return bool status * @throws \SmartyException @@ -654,7 +654,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Loads security class and enables security * - * @param string|Smarty_Security $security_class if a string is used, it must be class-name + * @param string|Smarty_Security $security_class if a string is used, it must be class-name * * @return Smarty current Smarty instance for chaining * @throws SmartyException when an invalid class name is provided @@ -679,9 +679,9 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Add template directory(s) * - * @param string|array $template_dir directory(s) of template sources - * @param string $key of the array element to assign the template dir to - * @param bool $isConfig true for config_dir + * @param string|array $template_dir directory(s) of template sources + * @param string $key of the array element to assign the template dir to + * @param bool $isConfig true for config_dir * * @return Smarty current Smarty instance for chaining */ @@ -747,8 +747,8 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Set template directory * - * @param string|array $template_dir directory(s) of template sources - * @param bool $isConfig true for config_dir + * @param string|array $template_dir directory(s) of template sources + * @param bool $isConfig true for config_dir * * @return \Smarty current Smarty instance for chaining */ @@ -846,7 +846,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Set plugins directory * - * @param string|array $plugins_dir directory(s) of plugins + * @param string|array $plugins_dir directory(s) of plugins * * @return Smarty current Smarty instance for chaining */ @@ -901,7 +901,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Set cache directory * - * @param string $cache_dir directory to store cached templates in + * @param string $cache_dir directory to store cached templates in * * @return Smarty current Smarty instance for chaining */ @@ -915,11 +915,11 @@ class Smarty extends Smarty_Internal_TemplateBase /** * creates a template object * - * @param string $template the resource handle of the template file - * @param mixed $cache_id cache id to be used with this template - * @param mixed $compile_id compile id to be used with this template - * @param object $parent next higher level of Smarty variables - * @param boolean $do_clone flag is Smarty object shall be cloned + * @param string $template the resource handle of the template file + * @param mixed $cache_id cache id to be used with this template + * @param mixed $compile_id compile id to be used with this template + * @param object $parent next higher level of Smarty variables + * @param boolean $do_clone flag is Smarty object shall be cloned * * @return \Smarty_Internal_Template template object * @throws \SmartyException @@ -981,8 +981,8 @@ class Smarty extends Smarty_Internal_TemplateBase * class name format: Smarty_PluginType_PluginName * plugin filename format: plugintype.pluginname.php * - * @param string $plugin_name class plugin name to load - * @param bool $check check if already loaded + * @param string $plugin_name class plugin name to load + * @param bool $check check if already loaded * * @throws SmartyException * @return string |boolean filepath of loaded file or false @@ -1005,11 +1005,11 @@ class Smarty extends Smarty_Internal_TemplateBase * @throws \SmartyException */ public function _getTemplateId($template_name, - $cache_id = null, - $compile_id = null, - $caching = null, - Smarty_Internal_Template $template = null) - { + $cache_id = null, + $compile_id = null, + $caching = null, + Smarty_Internal_Template $template = null + ) { $template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" : $template_name; $cache_id = $cache_id === null ? $this->cache_id : $cache_id; @@ -1033,10 +1033,11 @@ class Smarty extends Smarty_Internal_TemplateBase * - remove /./ and /../ * - make it absolute if required * - * @param string $path file path - * @param bool $realpath if true - convert to absolute - * false - convert to relative - * null - keep as it is but remove /./ /../ + * @param string $path file path + * @param bool $realpath if true - convert to absolute + * false - convert to relative + * null - keep as it is but + * remove /./ /../ * * @return string */ @@ -1045,9 +1046,11 @@ class Smarty extends Smarty_Internal_TemplateBase $nds = array('/' => '\\', '\\' => '/'); // normalize DIRECTORY_SEPARATOR //$path = str_replace(array($nds[DIRECTORY_SEPARATOR], DIRECTORY_SEPARATOR . '.' . DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR, $path); - preg_match('%^(?(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?(.*))$%u', - $path, - $parts); + preg_match( + '%^(?(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?(.*))$%u', + $path, + $parts + ); $path = $parts[ 'path' ]; if ($parts[ 'root' ] === '\\') { $parts[ 'root' ] = substr(getcwd(), 0, 2) . $parts[ 'root' ]; @@ -1058,8 +1061,9 @@ class Smarty extends Smarty_Internal_TemplateBase } do { $path = preg_replace( - array('#[\\\\/]{2}#', '#[\\\\/][.][\\\\/]#', '#[\\\\/]([^\\\\/.]+)[\\\\/][.][.][\\\\/]#'), - DIRECTORY_SEPARATOR, $path, -1, $count); + array('#[\\\\/]{2}#', '#[\\\\/][.][\\\\/]#', '#[\\\\/]([^\\\\/.]+)[\\\\/][.][.][\\\\/]#'), + DIRECTORY_SEPARATOR, $path, -1, $count + ); } while($count > 0); return $realpath !== false ? $parts[ 'root' ] . $path : str_ireplace(getcwd(), '.', $parts[ 'root' ] . $path); } @@ -1254,7 +1258,7 @@ class Smarty extends Smarty_Internal_TemplateBase * Calls the appropriate getter function. * Issues an E_USER_NOTICE if no valid getter is found. * - * @param string $name property name + * @param string $name property name * * @return mixed * @throws \SmartyException @@ -1265,12 +1269,14 @@ class Smarty extends Smarty_Internal_TemplateBase $method = 'get' . $this->accessMap[ $name ]; return $this->{$method}(); } else {if (isset($this->_cache[ $name ])) { - return $this->_cache[ $name ]; + return $this->_cache[ $name ]; } else {if (in_array($name, $this->obsoleteProperties)) { - return null; + return null; } else { trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); - }}} + } + } + } return null; } @@ -1290,14 +1296,15 @@ class Smarty extends Smarty_Internal_TemplateBase $method = 'set' . $this->accessMap[ $name ]; $this->{$method}($value); } else {if (in_array($name, $this->obsoleteProperties)) { - return; + return; } else { if (is_object($value) && method_exists($value, $name)) { $this->$name = $value; } else { trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); } - }} + } + } } /** @@ -1320,7 +1327,6 @@ class Smarty extends Smarty_Internal_TemplateBase * Normalize template_dir or config_dir * * @param bool $isConfig true for config_dir - * */ private function _normalizeTemplateConfig($isConfig) { diff --git a/libs/SmartyBC.class.php b/libs/SmartyBC.class.php index f2230fc9..1141e488 100644 --- a/libs/SmartyBC.class.php +++ b/libs/SmartyBC.class.php @@ -28,7 +28,7 @@ /** * @ignore */ -require_once(dirname(__FILE__) . '/Smarty.class.php'); +require_once dirname(__FILE__) . '/Smarty.class.php'; /** * Smarty Backward Compatibility Wrapper Class @@ -53,7 +53,6 @@ class SmartyBC extends Smarty /** * Initialize new SmartyBC object - * */ public function __construct() { @@ -127,12 +126,12 @@ class SmartyBC extends Smarty * @param boolean $smarty_args smarty argument format, else traditional * @param array $block_methods list of methods that are block format * - * @throws SmartyException + * @throws SmartyException * @internal param array $block_functs list of methods that are block format */ public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, - $block_methods = array()) - { + $block_methods = array() + ) { settype($allowed, 'array'); settype($smarty_args, 'boolean'); $this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods); @@ -151,8 +150,8 @@ class SmartyBC extends Smarty /** * Registers block function to be used in templates * - * @param string $block name of template block - * @param string $block_impl PHP function to register + * @param string $block name of template block + * @param string $block_impl PHP function to register * @param bool $cacheable * @param mixed $cache_attrs * @@ -326,10 +325,10 @@ class SmartyBC extends Smarty /** * clear cached content for the given template and cache id * - * @param string $tpl_file name of template file - * @param string $cache_id name of cache_id - * @param string $compile_id name of compile_id - * @param string $exp_time expiration time + * @param string $tpl_file name of template file + * @param string $cache_id name of cache_id + * @param string $compile_id name of compile_id + * @param string $exp_time expiration time * * @return boolean */ @@ -341,7 +340,7 @@ class SmartyBC extends Smarty /** * clear the entire contents of cache (all templates) * - * @param string $exp_time expire time + * @param string $exp_time expire time * * @return boolean */ @@ -353,9 +352,9 @@ class SmartyBC extends Smarty /** * test to see if valid cache exists for this template * - * @param string $tpl_file name of template file - * @param string $cache_id - * @param string $compile_id + * @param string $tpl_file name of template file + * @param string $cache_id + * @param string $compile_id * * @return bool * @throws \Exception @@ -379,9 +378,9 @@ class SmartyBC extends Smarty * or all compiled template files if one is not specified. * This function is for advanced use only, not normally needed. * - * @param string $tpl_file - * @param string $compile_id - * @param string $exp_time + * @param string $tpl_file + * @param string $compile_id + * @param string $exp_time * * @return boolean results of {@link smarty_core_rm_auto()} */ @@ -393,7 +392,7 @@ class SmartyBC extends Smarty /** * Checks whether requested template exists. * - * @param string $tpl_file + * @param string $tpl_file * * @return bool * @throws \SmartyException @@ -406,7 +405,7 @@ class SmartyBC extends Smarty /** * Returns an array containing template variables * - * @param string $name + * @param string $name * * @return array */ @@ -418,7 +417,7 @@ class SmartyBC extends Smarty /** * Returns an array containing config variables * - * @param string $name + * @param string $name * * @return array */ @@ -442,7 +441,7 @@ class SmartyBC extends Smarty /** * return a reference to a registered object * - * @param string $name + * @param string $name * * @return object */ diff --git a/libs/bootstrap.php b/libs/bootstrap.php index dad72fcb..0b183bf9 100644 --- a/libs/bootstrap.php +++ b/libs/bootstrap.php @@ -12,6 +12,6 @@ * Load and register Smarty Autoloader */ if (!class_exists('Smarty_Autoloader')) { - require dirname(__FILE__) . '/Autoloader.php'; + include dirname(__FILE__) . '/Autoloader.php'; } Smarty_Autoloader::register(true); diff --git a/libs/plugins/block.textformat.php b/libs/plugins/block.textformat.php index 310a420e..416d21ee 100644 --- a/libs/plugins/block.textformat.php +++ b/libs/plugins/block.textformat.php @@ -20,8 +20,7 @@ * - indent_char - string (" ") * - wrap_boundary - boolean (true) * - * - * @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat} + * @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat} * (Smarty online manual) * * @param array $params parameters @@ -39,8 +38,10 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te return; } if (Smarty::$_MBSTRING) { - $template->_checkPlugins(array(array('function' => 'smarty_modifier_mb_wordwrap', - 'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php'))); + $template->_checkPlugins( + array(array('function' => 'smarty_modifier_mb_wordwrap', + 'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php')) + ); } $style = null; @@ -54,25 +55,25 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te foreach ($params as $_key => $_val) { switch ($_key) { - case 'style': - case 'indent_char': - case 'wrap_char': - case 'assign': - $$_key = (string) $_val; - break; + case 'style': + case 'indent_char': + case 'wrap_char': + case 'assign': + $$_key = (string) $_val; + break; - case 'indent': - case 'indent_first': - case 'wrap': - $$_key = (int) $_val; - break; + case 'indent': + case 'indent_first': + case 'wrap': + $$_key = (int) $_val; + break; - case 'wrap_cut': - $$_key = (bool) $_val; - break; + case 'wrap_cut': + $$_key = (bool) $_val; + break; - default: - trigger_error("textformat: unknown attribute '{$_key}'"); + default: + trigger_error("textformat: unknown attribute '{$_key}'"); } } @@ -88,10 +89,12 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te } // convert mult. spaces & special chars to single space $_paragraph = - preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER, + preg_replace( + array('!\s+!' . Smarty::$_UTF8_MODIFIER, '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER), - array(' ', - ''), $_paragraph); + array(' ', + ''), $_paragraph + ); // indent first line if ($indent_first > 0) { $_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph; diff --git a/libs/plugins/function.cycle.php b/libs/plugins/function.cycle.php index b871524f..692f7033 100644 --- a/libs/plugins/function.cycle.php +++ b/libs/plugins/function.cycle.php @@ -29,14 +29,13 @@ * {cycle name=row values="one,two,three" reset=true} * {cycle name=row} * - * - * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle} + * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle} * (Smarty online manual) - * @author Monte Ohrt - * @author credit to Mark Priatel - * @author credit to Gerard - * @author credit to Jason Sweat - * @version 1.3 + * @author Monte Ohrt + * @author credit to Mark Priatel + * @author credit to Gerard + * @author credit to Jason Sweat + * @version 1.3 * * @param array $params parameters * @param Smarty_Internal_Template $template template object diff --git a/libs/plugins/function.fetch.php b/libs/plugins/function.fetch.php index 9539e1fc..dcec4146 100644 --- a/libs/plugins/function.fetch.php +++ b/libs/plugins/function.fetch.php @@ -81,73 +81,73 @@ function smarty_function_fetch($params, $template) // loop through parameters, setup headers foreach ($params as $param_key => $param_value) { switch ($param_key) { - case 'file': - case 'assign': - case 'assign_headers': - break; - case 'user': - if (!empty($param_value)) { - $user = $param_value; - } - break; - case 'pass': - if (!empty($param_value)) { - $pass = $param_value; - } - break; - case 'accept': - if (!empty($param_value)) { - $accept = $param_value; - } - break; - case 'header': - if (!empty($param_value)) { - if (!preg_match('![\w\d-]+: .+!', $param_value)) { - trigger_error("[plugin] invalid header format '{$param_value}'", E_USER_NOTICE); - - return; - } else { - $extra_headers[] = $param_value; - } - } - break; - case 'proxy_host': - if (!empty($param_value)) { - $proxy_host = $param_value; - } - break; - case 'proxy_port': - if (!preg_match('!\D!', $param_value)) { - $proxy_port = (int) $param_value; - } else { - trigger_error("[plugin] invalid value for attribute '{$param_key }'", E_USER_NOTICE); + case 'file': + case 'assign': + case 'assign_headers': + break; + case 'user': + if (!empty($param_value)) { + $user = $param_value; + } + break; + case 'pass': + if (!empty($param_value)) { + $pass = $param_value; + } + break; + case 'accept': + if (!empty($param_value)) { + $accept = $param_value; + } + break; + case 'header': + if (!empty($param_value)) { + if (!preg_match('![\w\d-]+: .+!', $param_value)) { + trigger_error("[plugin] invalid header format '{$param_value}'", E_USER_NOTICE); return; - } - break; - case 'agent': - if (!empty($param_value)) { - $agent = $param_value; - } - break; - case 'referer': - if (!empty($param_value)) { - $referer = $param_value; - } - break; - case 'timeout': - if (!preg_match('!\D!', $param_value)) { - $timeout = (int) $param_value; } else { - trigger_error("[plugin] invalid value for attribute '{$param_key}'", E_USER_NOTICE); - - return; + $extra_headers[] = $param_value; } - break; - default: - trigger_error("[plugin] unrecognized attribute '{$param_key}'", E_USER_NOTICE); + } + break; + case 'proxy_host': + if (!empty($param_value)) { + $proxy_host = $param_value; + } + break; + case 'proxy_port': + if (!preg_match('!\D!', $param_value)) { + $proxy_port = (int) $param_value; + } else { + trigger_error("[plugin] invalid value for attribute '{$param_key }'", E_USER_NOTICE); return; + } + break; + case 'agent': + if (!empty($param_value)) { + $agent = $param_value; + } + break; + case 'referer': + if (!empty($param_value)) { + $referer = $param_value; + } + break; + case 'timeout': + if (!preg_match('!\D!', $param_value)) { + $timeout = (int) $param_value; + } else { + trigger_error("[plugin] invalid value for attribute '{$param_key}'", E_USER_NOTICE); + + return; + } + break; + default: + trigger_error("[plugin] unrecognized attribute '{$param_key}'", E_USER_NOTICE); + + return; } } if (!empty($proxy_host) && !empty($proxy_port)) { diff --git a/libs/plugins/function.html_checkboxes.php b/libs/plugins/function.html_checkboxes.php index d654caba..54978ea2 100644 --- a/libs/plugins/function.html_checkboxes.php +++ b/libs/plugins/function.html_checkboxes.php @@ -29,24 +29,25 @@ * - assign (optional) - assign the output as an array to this variable * - escape (optional) - escape the content (not value), defaults to true * - * - * @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} + * @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} * (Smarty online manual) - * @author Christopher Kvarme - * @author credits to Monte Ohrt - * @version 1.0 + * @author Christopher Kvarme + * @author credits to Monte Ohrt + * @version 1.0 * * @param array $params parameters * @param Smarty_Internal_Template $template template object * * @return string - * @uses smarty_function_escape_special_chars() + * @uses smarty_function_escape_special_chars() * @throws \SmartyException */ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $template) { - $template->_checkPlugins(array(array('function' => 'smarty_function_escape_special_chars', - 'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'))); + $template->_checkPlugins( + array(array('function' => 'smarty_function_escape_special_chars', + 'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php')) + ); $name = 'checkbox'; $values = null; @@ -62,91 +63,99 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp foreach ($params as $_key => $_val) { switch ($_key) { - case 'name': - case 'separator': - $$_key = (string) $_val; - break; + case 'name': + case 'separator': + $$_key = (string) $_val; + break; - case 'escape': - case 'labels': - case 'label_ids': - $$_key = (bool) $_val; - break; + case 'escape': + case 'labels': + case 'label_ids': + $$_key = (bool) $_val; + break; - case 'options': - $$_key = (array) $_val; - break; + case 'options': + $$_key = (array) $_val; + break; - case 'values': - case 'output': - $$_key = array_values((array) $_val); - break; + case 'values': + case 'output': + $$_key = array_values((array) $_val); + break; - case 'checked': - case 'selected': - if (is_array($_val)) { - $selected = array(); - foreach ($_val as $_sel) { - if (is_object($_sel)) { - if (method_exists($_sel, '__toString')) { - $_sel = smarty_function_escape_special_chars((string) $_sel->__toString()); - } else { - trigger_error('html_checkboxes: selected attribute contains an object of class \'' . - get_class($_sel) . '\' without __toString() method', E_USER_NOTICE); - continue; - } + case 'checked': + case 'selected': + if (is_array($_val)) { + $selected = array(); + foreach ($_val as $_sel) { + if (is_object($_sel)) { + if (method_exists($_sel, '__toString')) { + $_sel = smarty_function_escape_special_chars((string) $_sel->__toString()); } else { - $_sel = smarty_function_escape_special_chars((string) $_sel); + trigger_error( + 'html_checkboxes: selected attribute contains an object of class \'' . + get_class($_sel) . '\' without __toString() method', E_USER_NOTICE + ); + continue; } - $selected[ $_sel ] = true; - } - } elseif (is_object($_val)) { - if (method_exists($_val, '__toString')) { - $selected = smarty_function_escape_special_chars((string) $_val->__toString()); } else { - trigger_error('html_checkboxes: selected attribute is an object of class \'' . get_class($_val) . - '\' without __toString() method', E_USER_NOTICE); + $_sel = smarty_function_escape_special_chars((string) $_sel); } + $selected[ $_sel ] = true; + } + } elseif (is_object($_val)) { + if (method_exists($_val, '__toString')) { + $selected = smarty_function_escape_special_chars((string) $_val->__toString()); } else { - $selected = smarty_function_escape_special_chars((string) $_val); + trigger_error( + 'html_checkboxes: selected attribute is an object of class \'' . get_class($_val) . + '\' without __toString() method', E_USER_NOTICE + ); } - break; + } else { + $selected = smarty_function_escape_special_chars((string) $_val); + } + break; - case 'checkboxes': - trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', - E_USER_WARNING); - $options = (array) $_val; - break; + case 'checkboxes': + trigger_error( + 'html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', + E_USER_WARNING + ); + $options = (array) $_val; + break; - case 'assign': - break; + case 'assign': + break; - case 'strict': - break; + case 'strict': + break; - case 'disabled': - case 'readonly': - if (!empty($params[ 'strict' ])) { - if (!is_scalar($_val)) { - trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute", - E_USER_NOTICE); - } - - if ($_val === true || $_val === $_key) { - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"'; - } - - break; + case 'disabled': + case 'readonly': + if (!empty($params[ 'strict' ])) { + if (!is_scalar($_val)) { + trigger_error( + "html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute", + E_USER_NOTICE + ); } + + if ($_val === true || $_val === $_key) { + $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"'; + } + + break; + } // omit break; to fall through! - default: - if (!is_array($_val)) { - $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; - } else { - trigger_error("html_checkboxes: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE); - } - break; + default: + if (!is_array($_val)) { + $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"'; + } else { + trigger_error("html_checkboxes: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE); + } + break; } } @@ -159,15 +168,19 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp if (isset($options)) { foreach ($options as $_key => $_val) { $_html_result[] = - smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, - $label_ids, $escape); + smarty_function_html_checkboxes_output( + $name, $_key, $_val, $selected, $extra, $separator, $labels, + $label_ids, $escape + ); } } else { foreach ($values as $_i => $_key) { $_val = isset($output[ $_i ]) ? $output[ $_i ] : ''; $_html_result[] = - smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, - $label_ids, $escape); + smarty_function_html_checkboxes_output( + $name, $_key, $_val, $selected, $extra, $separator, $labels, + $label_ids, $escape + ); } } @@ -186,21 +199,23 @@ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $temp * @param $separator * @param $labels * @param $label_ids - * @param bool $escape + * @param bool $escape * * @return string */ function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, - $label_ids, $escape = true) -{ + $label_ids, $escape = true +) { $_output = ''; if (is_object($value)) { if (method_exists($value, '__toString')) { $value = (string) $value->__toString(); } else { - trigger_error('html_options: value is an object of class \'' . get_class($value) . - '\' without __toString() method', E_USER_NOTICE); + trigger_error( + 'html_options: value is an object of class \'' . get_class($value) . + '\' without __toString() method', E_USER_NOTICE + ); return ''; } @@ -212,8 +227,10 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte if (method_exists($output, '__toString')) { $output = (string) $output->__toString(); } else { - trigger_error('html_options: output is an object of class \'' . get_class($output) . - '\' without __toString() method', E_USER_NOTICE); + trigger_error( + 'html_options: output is an object of class \'' . get_class($output) . + '\' without __toString() method', E_USER_NOTICE + ); return ''; } @@ -223,8 +240,12 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte if ($labels) { if ($label_ids) { - $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', - $name . '_' . $value)); + $_id = smarty_function_escape_special_chars( + preg_replace( + '![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', + $name . '_' . $value + ) + ); $_output .= '