diff --git a/library/Smarty/INHERITANCE_RELEASE_NOTES.txt b/library/Smarty/INHERITANCE_RELEASE_NOTES.txt deleted file mode 100644 index a7d285f0a..000000000 --- a/library/Smarty/INHERITANCE_RELEASE_NOTES.txt +++ /dev/null @@ -1,35 +0,0 @@ -In Smarty 3.1 template inheritance is a compile time process. All the extending of {block} tags -is done at compile time and the parent and child templates are compiled in a single compiled template. -{include} subtemplate could also {block} tags. Such subtemplate could not compiled by it's own because -it could be used in other context where the {block} extended with a different result. For that reasion -the compiled code of {include} subtemplates gets also merged in compiled inheritance template. - -Merging the code into a single compile template has some drawbacks. -1. You could not use variable file names in {include} Smarty would use the {include} of compilation time. -2. You could not use individual compile_id in {include} -3. Seperate caching of subtemplate was not possible -4. Any change of the template directory structure between calls was not necessarily seen. - -Starting with 3.1.15 some of the above conditions got checked and resulted in an exception. It turned out -that a couple of users did use some of above and now got exceptions. - -To resolve this starting with 3.1.16 there is a new configuration parameter $inheritance_merge_compiled_includes. -For most backward compatibility its default setting is true. -With this setting all {include} subtemplate will be merge into the compiled inheritance template, but the above cases -could be rejected by exception. - - -If $smarty->inheritance_merge_compiled_includes = false; {include} subtemplate will not be merged. -You must now manually merge all {include} subtemplate which do contain {block} tags. This is done by setting the "inline" option. -{include file='foo.bar' inline} - -1. In case of a variable file name like {include file=$foo inline} you must use the variable in a compile_id $smarty->compile_id = $foo; -2. If you use individual compile_id in {include file='foo.tpl' compile_id=$bar inline} it must be used in the - global compile_id as well $smarty->compile_id = $bar; -3. If call templates with different template_dir configurations and a parent could same named child template from different folders - you must make the folder name part of the compile_id. - - -In the upcomming major release Smarty 3.2 inheritance will no longer be a compile time process. -All restrictions will be then removed. - diff --git a/library/Smarty/NEW_FEATURES.txt b/library/Smarty/NEW_FEATURES.txt deleted file mode 100644 index b2c18c99b..000000000 --- a/library/Smarty/NEW_FEATURES.txt +++ /dev/null @@ -1,86 +0,0 @@ - - -This file contains a brief description of new features which have been added to Smarty 3.1 - -Smarty 3.1.22 - - Namespace support within templates - ================================== - Within templates you can now use namespace specifications on: - - Constants like foo\bar\FOO - - Class names like foo\bar\Baz::FOO, foo\bar\Baz::$foo, foo\bar\Baz::foo() - - PHP function names like foo\bar\baz() - - Security - ======== - - disable special $smarty variable - - The Smarty_Security class has the new property $disabled_special_smarty_vars. - It's an array which can be loaded with the $smarty special variable names like - 'template_object', 'template', 'current_dir' and others which will be disabled. - Note: That this security check is performed at compile time. - - - limit template nesting - - Property $max_template_nesting of Smarty_Security does set the maximum template nesting level. - The main template is level 1. The nesting level is checked at run time. When the maximum will be exceeded - an Exception will be thrown. The default setting is 0 which does disable this check. - - - trusted static methods - - The Smarty_Security class has the new property $trusted_static_methods to restrict access to static methods. - It's an nested array of trusted class and method names. - Format: - array ( - 'class_1' => array('method_1', 'method_2'), // allowed methods - 'class_2' => array(), // all methods of class allowed - ) - To disable access for all methods of all classes set $trusted_static_methods = null; - The default value is an empty array() which does enables all methods of all classes, but for backward compatibility - the setting of $static_classes will be checked. - Note: That this security check is performed at compile time. - - - trusted static properties - - The Smarty_Security class has the new property $trusted_static_properties to restrict access to static properties. - It's an nested array of trusted class and property names. - Format: - array ( - 'class_1' => array('prop_1', 'prop_2'), // allowed properties listed - 'class_2' => array(), // all properties of class allowed - } - To disable access for all properties of all classes set $trusted_static_properties = null; - The default value is an empty array() which does enables all properties of all classes, but for backward compatibility - the setting of $static_classes will be checked. - Note: That this security check is performed at compile time. - - - trusted constants . - The Smarty_Security class has the new property $trusted_constants to restrict access to constants. - It's an array of trusted constant names. - Format: - array ( - 'SMARTY_DIR' , // allowed constant - } - If the array is empty (default) the usage of constants can be controlled with the - Smarty_Security::$allow_constants property (default true) - - - - Compiled Templates - ================== - Smarty does now automatically detects a change of the $merge_compiled_includes and $escape_html - property and creates different compiled templates files depending on the setting. - - Same applies to config files and the $config_overwrite, $config_booleanize and - $config_read_hidden properties. - - Debugging - ========= - The layout of the debug window has been changed for better readability - - New class constants - Smarty::DEBUG_OFF - Smarty::DEBUG_ON - Smarty::DEBUG_INDIVIDUAL - have been introduced for setting the $debugging property. - - Smarty::DEBUG_INDIVIDUAL will create for each display() and fetch() call an individual gebug window. - - . - \ No newline at end of file diff --git a/library/Smarty/README.md b/library/Smarty/README.md deleted file mode 100644 index f5f93fa95..000000000 --- a/library/Smarty/README.md +++ /dev/null @@ -1,52 +0,0 @@ -#Smarty 3 template engine -##Distribution repository - -*Read the NEW_FEATURES file for recent extensions to Smarty 3.1 functionality* - -Smarty versions 3.1.11 or later are now on github and can be installed with Composer. - - -The "smarty/smarty" package will start at libs/.... subfolder. - -To get the latest stable version of Smarty 3.1 use - - "require": { - "smarty/smarty": "~3.1" - } - -in your composer.json file. - - To get the trunk version use - - "require": { - "smarty/smarty": "~3.1@dev" - } - -For a specific version use something like - - "require": { - "smarty/smarty": "3.1.19" - } - -PHPUnit test can be installed by corresponding composer entries like - - "require": { - "smarty/smarty-phpunit": "3.1.19" - } - -Similar applies for the lexer/parser generator - - "require": { - "smarty/smarty-lexer": "3.1.19" - } - -Or you could use - - "require": { - "smarty/smarty-dev": "3.1.19" - } - -Which is a wrapper to install all 3 packages - - -Composer can also be used for Smarty2 versions 2.6.24 to 2.6.28 diff --git a/library/Smarty/SMARTY_2_BC_NOTES.txt b/library/Smarty/SMARTY_2_BC_NOTES.txt deleted file mode 100644 index 79a2cb1b6..000000000 --- a/library/Smarty/SMARTY_2_BC_NOTES.txt +++ /dev/null @@ -1,109 +0,0 @@ -= Known incompatibilities with Smarty 2 = - -== Syntax == - -Smarty 3 API has a new syntax. Much of the Smarty 2 syntax is supported -by a wrapper but deprecated. See the README that comes with Smarty 3 for more -information. - -The {$array|@mod} syntax has always been a bit confusing, where an "@" is required -to apply a modifier to an array instead of the individual elements. Normally you -always want the modifier to apply to the variable regardless of its type. In Smarty 3, -{$array|mod} and {$array|@mod} behave identical. It is safe to drop the "@" and the -modifier will still apply to the array. If you really want the modifier to apply to -each array element, you must loop the array in-template, or use a custom modifier that -supports array iteration. Most smarty functions already escape values where necessary -such as {html_options} - -== PHP Version == -Smarty 3 is PHP 5 only. It will not work with PHP 4. - -== {php} Tag == -The {php} tag is disabled by default. The use of {php} tags is -deprecated. It can be enabled with $smarty->allow_php_tag=true. - -But if you scatter PHP code which belongs together into several -{php} tags it may not work any longer. - -== Delimiters and whitespace == -Delimiters surrounded by whitespace are no longer treated as Smarty tags. -Therefore, { foo } will not compile as a tag, you must use {foo}. This change -Makes Javascript/CSS easier to work with, eliminating the need for {literal}. -This can be disabled by setting $smarty->auto_literal = false; - -== Unquoted Strings == -Smarty 2 was a bit more forgiving (and ambiguous) when it comes to unquoted strings -in parameters. Smarty3 is more restrictive. You can still pass strings without quotes -so long as they contain no special characters. (anything outside of A-Za-z0-9_) - -For example filename strings must be quoted - - -== Extending the Smarty class == -Smarty 3 makes use of the __construct method for initialization. If you are extending -the Smarty class, its constructor is not called implicitly if the your child class defines -its own constructor. In order to run Smarty's constructor, a call to parent::__construct() -within your child constructor is required. - - - -== Autoloader == -Smarty 3 does register its own autoloader with spl_autoload_register. If your code has -an existing __autoload function then this function must be explicitly registered on -the __autoload stack. See http://us3.php.net/manual/en/function.spl-autoload-register.php -for further details. - -== Plugin Filenames == -Smarty 3 optionally supports the PHP spl_autoloader. The autoloader requires filenames -to be lower case. Because of this, Smarty plugin file names must also be lowercase. -In Smarty 2, mixed case file names did work. - -== Scope of Special Smarty Variables == -In Smarty 2 the special Smarty variables $smarty.section... and $smarty.foreach... -had global scope. If you had loops with the same name in subtemplates you could accidentally -overwrite values of parent template. - -In Smarty 3 these special Smarty variable have only local scope in the template which -is defining the loop. If you need their value in a subtemplate you have to pass them -as parameter. - - -== SMARTY_RESOURCE_CHAR_SET == -Smarty 3 sets the constant SMARTY_RESOURCE_CHAR_SET to utf-8 as default template charset. -This is now used also on modifiers like escape as default charset. If your templates use -other charsets make sure that you define the constant accordingly. Otherwise you may not -get any output. - -== newline at {if} tags == -A \n was added to the compiled code of the {if},{else},{elseif},{/if} tags to get output of newlines as expected by the template source. -If one of the {if} tags is at the line end you will now get a newline in the HTML output. - -== trigger_error() == -The API function trigger_error() has been removed because it did just map to PHP trigger_error. -However it's still included in the Smarty2 API wrapper. - -== Smarty constants == -The constants -SMARTY_PHP_PASSTHRU -SMARTY_PHP_QUOTE -SMARTY_PHP_REMOVE -SMARTY_PHP_ALLOW -have been replaced with class constants -Smarty::PHP_PASSTHRU -Smarty::PHP_QUOTE -Smarty::PHP_REMOVE -Smarty::PHP_ALLOW - diff --git a/library/Smarty/SMARTY_3.0_BC_NOTES.txt b/library/Smarty/SMARTY_3.0_BC_NOTES.txt deleted file mode 100644 index fd8b540c2..000000000 --- a/library/Smarty/SMARTY_3.0_BC_NOTES.txt +++ /dev/null @@ -1,24 +0,0 @@ -== Smarty2 backward compatibility == -All Smarty2 specific API functions and deprecated functionallity has been moved -to the SmartyBC class. - -== {php} Tag == -The {php} tag is no longer available in the standard Smarty calls. -The use of {php} tags is deprecated and only available in the SmartyBC class. - -== {include_php} Tag == -The {include_php} tag is no longer available in the standard Smarty calls. -The use of {include_php} tags is deprecated and only available in the SmartyBC class. - -== php template resource == -The support of the php template resource is removed. - -== $cache_dir, $compile_dir, $config_dir, $template_dir access == -The mentioned properties can't be accessed directly any longer. You must use -corresponding getter/setters like addConfigDir(), setConfigDir(), getConfigDir() - -== obsolete Smarty class properties == -The following no longer used properties are removed: -$allow_php_tag -$allow_php_template -$deprecation_notices \ No newline at end of file diff --git a/library/Smarty/SMARTY_3.1_NOTES.txt b/library/Smarty/SMARTY_3.1_NOTES.txt deleted file mode 100644 index 57709f0d7..000000000 --- a/library/Smarty/SMARTY_3.1_NOTES.txt +++ /dev/null @@ -1,306 +0,0 @@ -Smarty 3.1 Notes -================ - -Smarty 3.1 is a departure from 2.0 compatibility. Most notably, all -backward compatibility has been moved to a separate class file named -SmartyBC.class.php. If you require compatibility with 2.0, you will -need to use this class. - -Some differences from 3.0 are also present. 3.1 begins the journey of -requiring setters/getters for property access. So far this is only -implemented on the five directory properties: template_dir, -plugins_dir, configs_dir, compile_dir and cache_dir. These properties -are now protected, it is required to use the setters/getters instead. -That said, direct property access will still work, however slightly -slower since they will now fall through __set() and __get() and in -turn passed through the setter/getter methods. 3.2 will exhibit a full -list of setter/getter methods for all (currently) public properties, -so code-completion in your IDE will work as expected. - -There is absolutely no PHP allowed in templates any more. All -deprecated features of Smarty 2.0 are gone. Again, use the SmartyBC -class if you need any backward compatibility. - -Internal Changes - - Full UTF-8 Compatibility - -The plugins shipped with Smarty 3.1 have been rewritten to fully -support UTF-8 strings if Multibyte String is available. Without -MBString UTF-8 cannot be handled properly. For those rare cases where -templates themselves have to juggle encodings, the new modifiers -to_charset and from_charset may come in handy. - - Plugin API and Performance - -All Plugins (modifiers, functions, blocks, resources, -default_template_handlers, etc) are now receiving the -Smarty_Internal_Template instance, where they were supplied with the -Smarty instance in Smarty 3.0. *. As The Smarty_Internal_Template -mimics the behavior of Smarty, this API simplification should not -require any changes to custom plugins. - -The plugins shipped with Smarty 3.1 have been rewritten for better -performance. Most notably {html_select_date} and {html_select_time} -have been improved vastly. Performance aside, plugins have also been -reviewed and generalized in their API. {html_select_date} and -{html_select_time} now share almost all available options. - -The escape modifier now knows the $double_encode option, which will -prevent entities from being encoded again. - -The capitalize modifier now know the $lc_rest option, which makes sure -all letters following a captial letter are lower-cased. - -The count_sentences modifier now accepts (.?!) as -legitimate endings of a sentence - previously only (.) was -accepted - -The new unescape modifier is there to reverse the effects of the -escape modifier. This applies to the escape formats html, htmlall and -entity. - - default_template_handler_func - -The invocation of $smarty->$default_template_handler_func had to be -altered. Instead of a Smarty_Internal_Template, the fifth argument is -now provided with the Smarty instance. New footprint: - - -/** - * Default Template Handler - * - * called when Smarty's file: resource is unable to load a requested file - * - * @param string $type resource type (e.g. "file", "string", "eval", "resource") - * @param string $name resource name (e.g. "foo/bar.tpl") - * @param string &$content template's content - * @param integer &$modified template's modification time - * @param Smarty $smarty Smarty instance - * @return string|boolean path to file or boolean true if $content and $modified - * have been filled, boolean false if no default template - * could be loaded - */ -function default_template_handler_func($type, $name, &$content, &$modified, Smarty $smarty) { - if (false) { - // return corrected filepath - return "/tmp/some/foobar.tpl"; - } elseif (false) { - // return a template directly - $content = "the template source"; - $modified = time(); - return true; - } else { - // tell smarty that we failed - return false; - } -} - - Stuff done to the compiler - -Many performance improvements have happened internally. One notable -improvement is that all compiled templates are now handled as PHP -functions. This speeds up repeated templates tremendously, as each one -calls an (in-memory) PHP function instead of performing another file -include/scan. - -New Features - - Template syntax - - {block}..{/block} - -The {block} tag has a new hide option flag. It does suppress the block -content if no corresponding child block exists. -EXAMPLE: -parent.tpl -{block name=body hide} child content "{$smarty.block.child}" was -inserted {block} -In the above example the whole block will be suppressed if no child -block "body" is existing. - - {setfilter}..{/setfilter} - -The new {setfilter} block tag allows the definition of filters which -run on variable output. -SYNTAX: -{setfilter filter1|filter2|filter3....} -Smarty3 will lookup up matching filters in the following search order: -1. varibale filter plugin in plugins_dir. -2. a valid modifier. A modifier specification will also accept -additional parameter like filter2:'foo' -3. a PHP function -{/setfilter} will turn previous filter setting off again. -{setfilter} tags can be nested. -EXAMPLE: -{setfilter filter1} - {$foo} - {setfilter filter2} - {$bar} - {/setfilter} - {$buh} -{/setfilter} -{$blar} -In the above example filter1 will run on the output of $foo, filter2 -on $bar, filter1 again on $buh and no filter on $blar. -NOTES: -- {$foo nofilter} will suppress the filters -- These filters will run in addition to filters defined by -registerFilter('variable',...), autoLoadFilter('variable',...) and -defined default modifier. -- {setfilter} will effect only the current template, not included -subtemplates. - - Resource API - -Smarty 3.1 features a new approach to resource management. The -Smarty_Resource API allows simple, yet powerful integration of custom -resources for templates and configuration files. It offers simple -functions for loading data from a custom resource (e.g. database) as -well as define new template types adhering to the special -non-compiling (e,g, plain php) and non-compile-caching (e.g. eval: -resource type) resources. - -See demo/plugins/resource.mysql.php for an example custom database -resource. - -Note that old-fashioned registration of callbacks for resource -management has been deprecated but is still possible with SmartyBC. - - CacheResource API - -In line with the Resource API, the CacheResource API offers a more -comfortable handling of output-cache data. With the -Smarty_CacheResource_Custom accessing databases is made simple. With -the introduction of Smarty_CacheResource_KeyValueStore the -implementation of resources like memcache or APC became a no-brainer; -simple hash-based storage systems are now supporting hierarchical -output-caches. - -See demo/plugins/cacheresource.mysql.php for an example custom -database CacheResource. -See demo/plugins/cacheresource.memcache.php for an example custom -memcache CacheResource using the KeyValueStore helper. - -Note that old-fashioned registration of $cache_handler is not possible -anymore. As the functionality had not been ported to Smarty 3.0.x -properly, it has been dropped from 3.1 completely. - -Locking facilities have been implemented to avoid concurrent cache -generation. Enable cache locking by setting -$smarty->cache_locking = true; - - Relative Paths in Templates (File-Resource) - -As of Smarty 3.1 {include file="../foo.tpl"} and {include -file="./foo.tpl"} will resolve relative to the template they're in. -Relative paths are available with {include file="..."} and -{extends file="..."}. As $smarty->fetch('../foo.tpl') and -$smarty->fetch('./foo.tpl') cannot be relative to a template, an -exception is thrown. - - Addressing a specific $template_dir - -Smarty 3.1 introduces the $template_dir index notation. -$smarty->fetch('[foo]bar.tpl') and {include file="[foo]bar.tpl"} -require the template bar.tpl to be loaded from $template_dir['foo']; -Smarty::setTemplateDir() and Smarty::addTemplateDir() offer ways to -define indexes along with the actual directories. - - Mixing Resources in extends-Resource - -Taking the php extends: template resource one step further, it is now -possible to mix resources within an extends: call like -$smarty->fetch("extends:file:foo.tpl|db:bar.tpl"); - -To make eval: and string: resources available to the inheritance -chain, eval:base64:TPL_STRING and eval:urlencode:TPL_STRING have been -introduced. Supplying the base64 or urlencode flags will trigger -decoding the TPL_STRING in with either base64_decode() or urldecode(). - - extends-Resource in template inheritance - -Template based inheritance may now inherit from php's extends: -resource like {extends file="extends:foo.tpl|db:bar.tpl"}. - - New Smarty property escape_html - -$smarty->escape_html = true will autoescape all template variable -output by calling htmlspecialchars({$output}, ENT_QUOTES, -SMARTY_RESOURCE_CHAR_SET). -NOTE: -This is a compile time option. If you change the setting you must make -sure that the templates get recompiled. - - New option at Smarty property compile_check - -The automatic recompilation of modified templates can now be -controlled by the following settings: -$smarty->compile_check = COMPILECHECK_OFF (false) - template files -will not be checked -$smarty->compile_check = COMPILECHECK_ON (true) - template files will -always be checked -$smarty->compile_check = COMPILECHECK_CACHEMISS - template files will -be checked if caching is enabled and there is no existing cache file -or it has expired - - Automatic recompilation on Smarty version change - -Templates will now be automatically recompiled on Smarty version -changes to avoide incompatibillities in the compiled code. Compiled -template checked against the current setting of the SMARTY_VERSION -constant. - - default_config_handler_func() - -Analogous to the default_template_handler_func() -default_config_handler_func() has been introduced. - - default_plugin_handler_func() - -An optional default_plugin_handler_func() can be defined which gets called -by the compiler on tags which can't be resolved internally or by plugins. -The default_plugin_handler() can map tags to plugins on the fly. - -New getters/setters - -The following setters/getters will be part of the official -documentation, and will be strongly recommended. Direct property -access will still work for the foreseeable future... it will be -transparently routed through the setters/getters, and consequently a -bit slower. - -array|string getTemplateDir( [string $index] ) -replaces $smarty->template_dir; and $smarty->template_dir[$index]; -Smarty setTemplateDir( array|string $path ) -replaces $smarty->template_dir = "foo"; and $smarty->template_dir = -array("foo", "bar"); -Smarty addTemplateDir( array|string $path, [string $index]) -replaces $smarty->template_dir[] = "bar"; and -$smarty->template_dir[$index] = "bar"; - -array|string getConfigDir( [string $index] ) -replaces $smarty->config_dir; and $smarty->config_dir[$index]; -Smarty setConfigDir( array|string $path ) -replaces $smarty->config_dir = "foo"; and $smarty->config_dir = -array("foo", "bar"); -Smarty addConfigDir( array|string $path, [string $index]) -replaces $smarty->config_dir[] = "bar"; and -$smarty->config_dir[$index] = "bar"; - -array getPluginsDir() -replaces $smarty->plugins_dir; -Smarty setPluginsDir( array|string $path ) -replaces $smarty->plugins_dir = "foo"; -Smarty addPluginsDir( array|string $path ) -replaces $smarty->plugins_dir[] = "bar"; - -string getCompileDir() -replaces $smarty->compile_dir; -Smarty setCompileDir( string $path ) -replaces $smarty->compile_dir = "foo"; - -string getCacheDir() -replaces $smarty->cache_dir; -Smarty setCacheDir( string $path ) -replaces $smarty->cache_dir; diff --git a/library/Smarty/demo/configs/test.conf b/library/Smarty/demo/configs/test.conf deleted file mode 100644 index 5eac748ec..000000000 --- a/library/Smarty/demo/configs/test.conf +++ /dev/null @@ -1,5 +0,0 @@ -title = Welcome to Smarty! -cutoff_size = 40 - -[setup] -bold = true diff --git a/library/Smarty/demo/index.php b/library/Smarty/demo/index.php deleted file mode 100644 index 33f3035c5..000000000 --- a/library/Smarty/demo/index.php +++ /dev/null @@ -1,30 +0,0 @@ -force_compile = true; -$smarty->debugging = true; -$smarty->caching = true; -$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("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")); -$smarty->assign("option_selected", "NE"); - -$smarty->display('index.tpl'); diff --git a/library/Smarty/demo/plugins/cacheresource.apc.php b/library/Smarty/demo/plugins/cacheresource.apc.php deleted file mode 100644 index d7336f2bf..000000000 --- a/library/Smarty/demo/plugins/cacheresource.apc.php +++ /dev/null @@ -1,83 +0,0 @@ - $v) { - $_res[$k] = $v; - } - - return $_res; - } - - /** - * Save values for a set of keys to cache - * - * @param array $keys list of values to save - * @param int $expire expiration time - * - * @return boolean true on success, false on failure - */ - protected function write(array $keys, $expire = null) - { - foreach ($keys as $k => $v) { - apc_store($k, $v, $expire); - } - - return true; - } - - /** - * Remove values from cache - * - * @param array $keys list of keys to delete - * - * @return boolean true on success, false on failure - */ - protected function delete(array $keys) - { - foreach ($keys as $k) { - apc_delete($k); - } - - return true; - } - - /** - * Remove *all* values from cache - * - * @return boolean true on success, false on failure - */ - protected function purge() - { - return apc_clear_cache('user'); - } -} diff --git a/library/Smarty/demo/plugins/cacheresource.memcache.php b/library/Smarty/demo/plugins/cacheresource.memcache.php deleted file mode 100644 index e265365fb..000000000 --- a/library/Smarty/demo/plugins/cacheresource.memcache.php +++ /dev/null @@ -1,97 +0,0 @@ -memcache = new Memcache(); - $this->memcache->addServer('127.0.0.1', 11211); - } - - /** - * Read values for a set of keys from cache - * - * @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 - */ - protected function read(array $keys) - { - $_keys = $lookup = array(); - foreach ($keys as $k) { - $_k = sha1($k); - $_keys[] = $_k; - $lookup[$_k] = $k; - } - $_res = array(); - $res = $this->memcache->get($_keys); - foreach ($res as $k => $v) { - $_res[$lookup[$k]] = $v; - } - - return $_res; - } - - /** - * Save values for a set of keys to cache - * - * @param array $keys list of values to save - * @param int $expire expiration time - * - * @return boolean true on success, false on failure - */ - protected function write(array $keys, $expire = null) - { - foreach ($keys as $k => $v) { - $k = sha1($k); - $this->memcache->set($k, $v, 0, $expire); - } - - return true; - } - - /** - * Remove values from cache - * - * @param array $keys list of keys to delete - * - * @return boolean true on success, false on failure - */ - protected function delete(array $keys) - { - foreach ($keys as $k) { - $k = sha1($k); - $this->memcache->delete($k); - } - - return true; - } - - /** - * Remove *all* values from cache - * - * @return boolean true on success, false on failure - */ - protected function purge() - { - $this->memcache->flush(); - } -} diff --git a/library/Smarty/demo/plugins/cacheresource.mysql.php b/library/Smarty/demo/plugins/cacheresource.mysql.php deleted file mode 100644 index d8d00ab26..000000000 --- a/library/Smarty/demo/plugins/cacheresource.mysql.php +++ /dev/null @@ -1,162 +0,0 @@ -CREATE TABLE IF NOT EXISTS `output_cache` ( - * `id` CHAR(40) NOT NULL COMMENT 'sha1 hash', - * `name` VARCHAR(250) NOT NULL, - * `cache_id` VARCHAR(250) NULL DEFAULT NULL, - * `compile_id` VARCHAR(250) NULL DEFAULT NULL, - * `modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - * `content` LONGTEXT NOT NULL, - * PRIMARY KEY (`id`), - * INDEX(`name`), - * INDEX(`cache_id`), - * INDEX(`compile_id`), - * INDEX(`modified`) - * ) ENGINE = InnoDB; - * - * @package CacheResource-examples - * @author Rodney Rehm - */ -class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom -{ - // PDO instance - protected $db; - protected $fetch; - protected $fetchTimestamp; - protected $save; - - public function __construct() - { - try { - $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); - } - catch (PDOException $e) { - throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); - } - $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)'); - } - - /** - * 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) - * - * @return void - */ - protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime) - { - $this->fetch->execute(array('id' => $id)); - $row = $this->fetch->fetch(); - $this->fetch->closeCursor(); - if ($row) { - $content = $row['content']; - $mtime = strtotime($row['modified']); - } else { - $content = null; - $mtime = null; - } - } - - /** - * Fetch cached content's modification timestamp from data source - * - * @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 - * - * @return integer|boolean timestamp (epoch) the template was modified, or false if not found - */ - protected function fetchTimestamp($id, $name, $cache_id, $compile_id) - { - $this->fetchTimestamp->execute(array('id' => $id)); - $mtime = strtotime($this->fetchTimestamp->fetchColumn()); - $this->fetchTimestamp->closeCursor(); - - return $mtime; - } - - /** - * 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 - * - * @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, - )); - - return !!$this->save->rowCount(); - } - - /** - * 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 - * - * @return integer number of deleted caches - */ - protected function delete($name, $cache_id, $compile_id, $exp_time) - { - // delete the whole cache - if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) { - // returning the number of deleted caches would require a second query to count them - $query = $this->db->query('TRUNCATE TABLE output_cache'); - - return - 1; - } - // build the filter - $where = array(); - // equal test name - if ($name !== null) { - $where[] = 'name = ' . $this->db->quote($name); - } - // equal test compile_id - if ($compile_id !== null) { - $where[] = 'compile_id = ' . $this->db->quote($compile_id); - } - // range test expiration time - if ($exp_time !== null) { - $where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)'; - } - // equal test cache_id and match sub-groups - if ($cache_id !== null) { - $where[] = '(cache_id = ' . $this->db->quote($cache_id) - . ' OR cache_id LIKE ' . $this->db->quote($cache_id . '|%') . ')'; - } - // run delete query - $query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where)); - - return $query->rowCount(); - } -} diff --git a/library/Smarty/demo/plugins/cacheresource.pdo.php b/library/Smarty/demo/plugins/cacheresource.pdo.php deleted file mode 100644 index 569193aa4..000000000 --- a/library/Smarty/demo/plugins/cacheresource.pdo.php +++ /dev/null @@ -1,322 +0,0 @@ -setCachingType('pdo'); - * $smarty->loadPlugin('Smarty_CacheResource_Pdo'); - * $smarty->registerCacheResource('pdo', new Smarty_CacheResource_Pdo($cnx, 'smarty_cache')); - * - * @author Beno!t POLASZEK - 2014 - */ -class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom -{ - - protected $fetchStatements = Array('default' => 'SELECT %2$s - FROM %1$s - WHERE 1 - AND id = :id - AND cache_id IS NULL - AND compile_id IS NULL', - - 'withCacheId' => 'SELECT %2$s - FROM %1$s - WHERE 1 - AND id = :id - AND cache_id = :cache_id - AND compile_id IS NULL', - - 'withCompileId' => 'SELECT %2$s - FROM %1$s - WHERE 1 - AND id = :id - AND compile_id = :compile_id - AND cache_id IS NULL', - - 'withCacheIdAndCompileId' => 'SELECT %2$s - FROM %1$s - WHERE 1 - AND id = :id - AND cache_id = :cache_id - AND compile_id = :compile_id'); - protected $insertStatement = 'INSERT INTO %s - - SET id = :id, - name = :name, - cache_id = :cache_id, - compile_id = :compile_id, - modified = CURRENT_TIMESTAMP, - expire = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL :expire SECOND), - content = :content - - ON DUPLICATE KEY UPDATE - name = :name, - cache_id = :cache_id, - compile_id = :compile_id, - modified = CURRENT_TIMESTAMP, - expire = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL :expire SECOND), - content = :content'; - - protected $deleteStatement = 'DELETE FROM %1$s WHERE %2$s'; - protected $truncateStatement = 'TRUNCATE TABLE %s'; - - protected $fetchColumns = 'modified, content'; - protected $fetchTimestampColumns = 'modified'; - - protected $pdo, $table, $database; - - /* - * Constructor - * - * @param PDO $pdo PDO : active connection - * @param string $table : table (or view) name - * @param string $database : optionnal - if table is located in another db - */ - public function __construct(PDO $pdo, $table, $database = null) - { - - if (is_null($table)) { - throw new SmartyException("Table name for caching can't be null"); - } - - $this->pdo = $pdo; - $this->table = $table; - $this->database = $database; - - $this->fillStatementsWithTableName(); - } - - /* - * Fills the table name into the statements. - * - * @return Current Instance - * @access protected - */ - protected function fillStatementsWithTableName() - { - - foreach ($this->fetchStatements AS &$statement) { - $statement = sprintf($statement, $this->getTableName(), '%s'); - } - - $this->insertStatement = sprintf($this->insertStatement, $this->getTableName()); - $this->deleteStatement = sprintf($this->deleteStatement, $this->getTableName(), '%s'); - $this->truncateStatement = sprintf($this->truncateStatement, $this->getTableName()); - - return $this; - } - - /* - * Gets the fetch statement, depending on what you specify - * - * @param string $columns : the column(s) name(s) you want to retrieve from the database - * @param string $id unique cache content identifier - * @param string|null $cache_id cache id - * @param string|null $compile_id compile id - * @access protected - */ - protected function getFetchStatement($columns, $id, $cache_id = null, $compile_id = null) - { - - if (!is_null($cache_id) && !is_null($compile_id)) { - $query = $this->fetchStatements['withCacheIdAndCompileId'] AND $args = Array('id' => $id, 'cache_id' => $cache_id, 'compile_id' => $compile_id); - } elseif (is_null($cache_id) && !is_null($compile_id)) { - $query = $this->fetchStatements['withCompileId'] AND $args = Array('id' => $id, 'compile_id' => $compile_id); - } elseif (!is_null($cache_id) && is_null($compile_id)) { - $query = $this->fetchStatements['withCacheId'] AND $args = Array('id' => $id, 'cache_id' => $cache_id); - } else { - $query = $this->fetchStatements['default'] AND $args = Array('id' => $id); - } - - $query = sprintf($query, $columns); - - $stmt = $this->pdo->prepare($query); - - foreach ($args AS $key => $value) { - $stmt->bindValue($key, $value); - } - - return $stmt; - } - - /** - * 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) - * - * @return void - * @access protected - */ - protected function fetch($id, $name, $cache_id = null, $compile_id = null, &$content, &$mtime) - { - - $stmt = $this->getFetchStatement($this->fetchColumns, $id, $cache_id, $compile_id); - $stmt ->execute(); - $row = $stmt->fetch(); - $stmt ->closeCursor(); - - if ($row) { - $content = $this->outputContent($row['content']); - $mtime = strtotime($row['modified']); - } else { - $content = null; - $mtime = null; - } - } - - /** - * Fetch cached content's modification timestamp from data source - * {@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 - * - * @return integer|boolean timestamp (epoch) the template was modified, or false if not found - * @access protected - */ - // protected function fetchTimestamp($id, $name, $cache_id = null, $compile_id = null) { - // $stmt = $this->getFetchStatement($this->fetchTimestampColumns, $id, $cache_id, $compile_id); - // $stmt -> execute(); - // $mtime = strtotime($stmt->fetchColumn()); - // $stmt -> closeCursor(); - // return $mtime; - // } - - /** - * Save content to cache - * - * @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 integer|null $exp_time seconds till expiration time in seconds or null - * @param string $content content to cache - * - * @return boolean success - * @access protected - */ - protected function save($id, $name, $cache_id = null, $compile_id = null, $exp_time, $content) - { - - $stmt = $this->pdo->prepare($this->insertStatement); - - $stmt ->bindValue('id', $id); - $stmt ->bindValue('name', $name); - $stmt ->bindValue('cache_id', $cache_id, (is_null($cache_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR); - $stmt ->bindValue('compile_id', $compile_id, (is_null($compile_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR); - $stmt ->bindValue('expire', (int) $exp_time, PDO::PARAM_INT); - $stmt ->bindValue('content', $this->inputContent($content)); - $stmt ->execute(); - - return !!$stmt->rowCount(); - } - - /* - * Encodes the content before saving to database - * - * @param string $content - * @return string $content - * @access protected - */ - protected function inputContent($content) - { - return $content; - } - - /* - * Decodes the content before saving to database - * - * @param string $content - * @return string $content - * @access protected - */ - protected function outputContent($content) - { - return $content; - } - - /** - * 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 - * - * @return integer number of deleted caches - * @access protected - */ - protected function delete($name = null, $cache_id = null, $compile_id = null, $exp_time = null) - { - - // delete the whole cache - if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) { - // returning the number of deleted caches would require a second query to count them - $this->pdo->query($this->truncateStatement); - return - 1; - } - // build the filter - $where = array(); - // equal test name - if ($name !== null) { - $where[] = 'name = ' . $this->pdo->quote($name); - } - // equal test cache_id and match sub-groups - if ($cache_id !== null) { - $where[] = '(cache_id = ' . $this->pdo->quote($cache_id) - . ' OR cache_id LIKE ' . $this->pdo->quote($cache_id . '|%') . ')'; - } - // equal test compile_id - if ($compile_id !== null) { - $where[] = 'compile_id = ' . $this->pdo->quote($compile_id); - } - // for clearing expired caches - if ($exp_time === Smarty::CLEAR_EXPIRED) { - $where[] = 'expire < CURRENT_TIMESTAMP'; - } // range test expiration time - elseif ($exp_time !== null) { - $where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)'; - } - // run delete query - $query = $this->pdo->query(sprintf($this->deleteStatement, join(' AND ', $where))); - return $query->rowCount(); - } - - /** - * Gets the formatted table name - * - * @return string - * @access protected - */ - protected function getTableName() - { - return (is_null($this->database)) ? "`{$this->table}`" : "`{$this->database}`.`{$this->table}`"; - } -} - \ No newline at end of file diff --git a/library/Smarty/demo/plugins/cacheresource.pdo_gzip.php b/library/Smarty/demo/plugins/cacheresource.pdo_gzip.php deleted file mode 100644 index 8a9e0a5dd..000000000 --- a/library/Smarty/demo/plugins/cacheresource.pdo_gzip.php +++ /dev/null @@ -1,43 +0,0 @@ -setCachingType('pdo_gzip'); - * $smarty->loadPlugin('Smarty_CacheResource_Pdo_Gzip'); - * $smarty->registerCacheResource('pdo_gzip', new Smarty_CacheResource_Pdo_Gzip($cnx, 'smarty_cache')); - * - * @require Smarty_CacheResource_Pdo class - * @author Beno!t POLASZEK - 2014 - */ -require_once 'cacheresource.pdo.php'; - -class Smarty_CacheResource_Pdo_Gzip extends Smarty_CacheResource_Pdo -{ - - /* - * Encodes the content before saving to database - * - * @param string $content - * @return string $content - * @access protected - */ - protected function inputContent($content) - { - return gzdeflate($content); - } - - /* - * Decodes the content before saving to database - * - * @param string $content - * @return string $content - * @access protected - */ - protected function outputContent($content) - { - return gzinflate($content); - } -} - \ No newline at end of file diff --git a/library/Smarty/demo/plugins/resource.extendsall.php b/library/Smarty/demo/plugins/resource.extendsall.php deleted file mode 100644 index 500b3c862..000000000 --- a/library/Smarty/demo/plugins/resource.extendsall.php +++ /dev/null @@ -1,60 +0,0 @@ -smarty->getTemplateDir() as $key => $directory) { - try { - $s = Smarty_Resource::source(null, $source->smarty, '[' . $key . ']' . $source->name); - if (!$s->exists) { - continue; - } - $sources[$s->uid] = $s; - $uid .= $s->filepath; - } - catch (SmartyException $e) { - } - } - - if (!$sources) { - $source->exists = false; - $source->template = $_template; - - return; - } - - $sources = array_reverse($sources, true); - reset($sources); - $s = current($sources); - - $source->components = $sources; - $source->filepath = $s->filepath; - $source->uid = sha1($uid); - $source->exists = $exists; - if ($_template && $_template->smarty->compile_check) { - $source->timestamp = $s->timestamp; - } - // need the template at getContent() - $source->template = $_template; - } -} diff --git a/library/Smarty/demo/plugins/resource.mysql.php b/library/Smarty/demo/plugins/resource.mysql.php deleted file mode 100644 index dfc9606b4..000000000 --- a/library/Smarty/demo/plugins/resource.mysql.php +++ /dev/null @@ -1,81 +0,0 @@ -CREATE TABLE IF NOT EXISTS `templates` ( - * `name` varchar(100) NOT NULL, - * `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - * `source` text, - * PRIMARY KEY (`name`) - * ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - * Demo data: - *
INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');- * - * @package Resource-examples - * @author Rodney Rehm - */ -class Smarty_Resource_Mysql extends Smarty_Resource_Custom -{ - // PDO instance - protected $db; - // prepared fetch() statement - protected $fetch; - // prepared fetchTimestamp() statement - protected $mtime; - - public function __construct() - { - try { - $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); - } - catch (PDOException $e) { - throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); - } - $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); - $this->mtime = $this->db->prepare('SELECT modified FROM templates WHERE name = :name'); - } - - /** - * 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) - * - * @return void - */ - protected function fetch($name, &$source, &$mtime) - { - $this->fetch->execute(array('name' => $name)); - $row = $this->fetch->fetch(); - $this->fetch->closeCursor(); - if ($row) { - $source = $row['source']; - $mtime = strtotime($row['modified']); - } else { - $source = null; - $mtime = null; - } - } - - /** - * Fetch a template's modification time from database - * - * @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 - * - * @return integer timestamp (epoch) the template was modified - */ - protected function fetchTimestamp($name) - { - $this->mtime->execute(array('name' => $name)); - $mtime = $this->mtime->fetchColumn(); - $this->mtime->closeCursor(); - - return strtotime($mtime); - } -} diff --git a/library/Smarty/demo/plugins/resource.mysqls.php b/library/Smarty/demo/plugins/resource.mysqls.php deleted file mode 100644 index f694ddf11..000000000 --- a/library/Smarty/demo/plugins/resource.mysqls.php +++ /dev/null @@ -1,62 +0,0 @@ -CREATE TABLE IF NOT EXISTS `templates` ( - * `name` varchar(100) NOT NULL, - * `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - * `source` text, - * PRIMARY KEY (`name`) - * ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - * Demo data: - *
INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');- * - * @package Resource-examples - * @author Rodney Rehm - */ -class Smarty_Resource_Mysqls extends Smarty_Resource_Custom -{ - // PDO instance - protected $db; - // prepared fetch() statement - protected $fetch; - - public function __construct() - { - try { - $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); - } - catch (PDOException $e) { - throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); - } - $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); - } - - /** - * 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) - * - * @return void - */ - protected function fetch($name, &$source, &$mtime) - { - $this->fetch->execute(array('name' => $name)); - $row = $this->fetch->fetch(); - $this->fetch->closeCursor(); - if ($row) { - $source = $row['source']; - $mtime = strtotime($row['modified']); - } else { - $source = null; - $mtime = null; - } - } -} diff --git a/library/Smarty/demo/templates/footer.tpl b/library/Smarty/demo/templates/footer.tpl deleted file mode 100644 index e04310fdd..000000000 --- a/library/Smarty/demo/templates/footer.tpl +++ /dev/null @@ -1,2 +0,0 @@ -