Permalink
Browse files

MDL-20638 importing latest smarty 2.6.26

  • Loading branch information...
1 parent 8bcf4b5 commit 5953ae1d309ec738976e2700224f5b9d04be8ccb @skodak skodak committed Nov 17, 2009
Showing with 926 additions and 514 deletions.
  1. +10 −6 lib/smarty/Config_File.class.php
  2. +57 −30 lib/smarty/Smarty.class.php
  3. +128 −67 lib/smarty/Smarty_Compiler.class.php
  4. +0 −59 lib/smarty/core/core.is_secure.php
  5. +0 −59 lib/smarty/core/core.write_compiled_include.php
  6. +0 −51 lib/smarty/core/core.write_file.php
  7. +151 −58 lib/smarty/debug.tpl
  8. +3 −2 lib/smarty/{core → internals}/core.assemble_plugin_filepath.php
  9. +2 −2 lib/smarty/{core → internals}/core.assign_smarty_interface.php
  10. +1 −1 lib/smarty/{core → internals}/core.create_dir_structure.php
  11. +4 −3 lib/smarty/{core → internals}/core.display_debug_console.php
  12. 0 lib/smarty/{core → internals}/core.get_include_path.php
  13. 0 lib/smarty/{core → internals}/core.get_microtime.php
  14. +2 −2 lib/smarty/{core → internals}/core.get_php_resource.php
  15. +59 −0 lib/smarty/internals/core.is_secure.php
  16. +1 −4 lib/smarty/{core → internals}/core.is_trusted.php
  17. 0 lib/smarty/{core → internals}/core.load_plugins.php
  18. 0 lib/smarty/{core → internals}/core.load_resource_plugin.php
  19. +4 −4 lib/smarty/{core → internals}/core.process_cached_inserts.php
  20. +6 −1 lib/smarty/{core → internals}/core.process_compiled_include.php
  21. +5 −15 lib/smarty/{core → internals}/core.read_cache_file.php
  22. +2 −2 lib/smarty/{core → internals}/core.rm_auto.php
  23. +0 −1 lib/smarty/{core → internals}/core.rmdir.php
  24. +3 −3 lib/smarty/{core → internals}/core.run_insert_handler.php
  25. +1 −1 lib/smarty/{core → internals}/core.smarty_include_php.php
  26. +32 −9 lib/smarty/{core → internals}/core.write_cache_file.php
  27. +91 −0 lib/smarty/internals/core.write_compiled_include.php
  28. +2 −3 lib/smarty/{core → internals}/core.write_compiled_resource.php
  29. +54 −0 lib/smarty/internals/core.write_file.php
  30. +1 −0 lib/smarty/plugins/block.textformat.php
  31. +2 −0 lib/smarty/plugins/compiler.assign.php
  32. +1 −0 lib/smarty/plugins/function.assign_debug_info.php
  33. +2 −0 lib/smarty/plugins/function.config_load.php
  34. +1 −0 lib/smarty/plugins/function.counter.php
  35. +1 −0 lib/smarty/plugins/function.eval.php
  36. +1 −0 lib/smarty/plugins/function.fetch.php
  37. +15 −12 lib/smarty/plugins/function.html_image.php
  38. +1 −0 lib/smarty/plugins/function.html_options.php
  39. +13 −7 lib/smarty/plugins/function.html_radios.php
  40. +31 −16 lib/smarty/plugins/function.html_select_date.php
  41. +2 −0 lib/smarty/plugins/function.html_select_time.php
  42. +50 −10 lib/smarty/plugins/function.html_table.php
  43. +3 −1 lib/smarty/plugins/function.mailto.php
  44. +4 −2 lib/smarty/plugins/function.math.php
  45. +2 −0 lib/smarty/plugins/function.popup.php
  46. +1 −0 lib/smarty/plugins/function.popup_init.php
  47. +3 −2 lib/smarty/plugins/modifier.capitalize.php
  48. +1 −0 lib/smarty/plugins/modifier.count_characters.php
  49. +1 −0 lib/smarty/plugins/modifier.count_paragraphs.php
  50. +1 −0 lib/smarty/plugins/modifier.count_sentences.php
  51. +1 −0 lib/smarty/plugins/modifier.count_words.php
  52. +21 −11 lib/smarty/plugins/modifier.date_format.php
  53. +60 −26 lib/smarty/plugins/modifier.debug_print_var.php
  54. +1 −0 lib/smarty/plugins/modifier.default.php
  55. +9 −5 lib/smarty/plugins/modifier.escape.php
  56. +1 −0 lib/smarty/plugins/modifier.indent.php
  57. +1 −0 lib/smarty/plugins/modifier.lower.php
  58. +19 −4 lib/smarty/plugins/modifier.regex_replace.php
  59. +1 −0 lib/smarty/plugins/modifier.replace.php
  60. +1 −0 lib/smarty/plugins/modifier.spacify.php
  61. +1 −0 lib/smarty/plugins/modifier.string_format.php
  62. +1 −0 lib/smarty/plugins/modifier.strip_tags.php
  63. +14 −7 lib/smarty/plugins/modifier.truncate.php
  64. +1 −0 lib/smarty/plugins/modifier.upper.php
  65. +1 −0 lib/smarty/plugins/modifier.wordwrap.php
  66. +11 −11 lib/smarty/plugins/outputfilter.trimwhitespace.php
  67. +1 −0 lib/smarty/plugins/shared.escape_special_chars.php
  68. +20 −17 lib/smarty/plugins/shared.make_timestamp.php
  69. +6 −0 lib/smarty/readme_moodle.txt
@@ -17,8 +17,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * @link http://smarty.php.net/
- * @version 2.6.9
+ * For questions, help, comments, discussion, etc., please join the
+ * Smarty mailing list. Send a blank e-mail to
+ * smarty-discussion-subscribe@googlegroups.com
+ *
+ * @link http://www.smarty.net/
+ * @version 2.6.26
* @copyright Copyright: 2001-2005 New Digital Group, Inc.
* @author Andrei Zmievski <andrei@php.net>
* @access public
@@ -105,7 +109,7 @@ function set_path($config_path)
* @param string $var_name (optional) variable to get info for
* @return string|array a value or array of values
*/
- function &get($file_name, $section_name = NULL, $var_name = NULL)
+ function get($file_name, $section_name = NULL, $var_name = NULL)
{
if (empty($file_name)) {
$this->_trigger_error_msg('Empty config file name');
@@ -285,9 +289,9 @@ function parse_contents($contents)
$line = $lines[$i];
if (empty($line)) continue;
- if ( $line{0} == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) {
+ if ( substr($line, 0, 1) == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) {
/* section found */
- if ($match[1]{0} == '.') {
+ if (substr($match[1], 0, 1) == '.') {
/* hidden section */
if ($this->read_hidden) {
$section_name = substr($match[1], 1);
@@ -347,7 +351,7 @@ function parse_contents($contents)
*/
function _set_config_var(&$container, $var_name, $var_value, $booleanize)
{
- if ($var_name{0} == '.') {
+ if (substr($var_name, 0, 1) == '.') {
if (!$this->read_hidden)
return;
else
@@ -20,14 +20,14 @@
*
* For questions, help, comments, discussion, etc., please join the
* Smarty mailing list. Send a blank e-mail to
- * smarty-general-subscribe@lists.php.net
+ * smarty-discussion-subscribe@googlegroups.com
*
- * @link http://smarty.php.net/
+ * @link http://www.smarty.net/
* @copyright 2001-2005 New Digital Group, Inc.
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net>
* @package Smarty
- * @version 2.6.9
+ * @version 2.6.26
*/
/* $Id$ */
@@ -50,7 +50,7 @@
}
if (!defined('SMARTY_CORE_DIR')) {
- define('SMARTY_CORE_DIR', SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR);
+ define('SMARTY_CORE_DIR', SMARTY_DIR . 'internals' . DIRECTORY_SEPARATOR);
}
define('SMARTY_PHP_PASSTHRU', 0);
@@ -107,7 +107,7 @@ class Smarty
/**
* When set, smarty does uses this value as error_reporting-level.
*
- * @var boolean
+ * @var integer
*/
var $error_reporting = null;
@@ -236,7 +236,8 @@ class Smarty
'INCLUDE_ANY' => false,
'PHP_TAGS' => false,
'MODIFIER_FUNCS' => array('count'),
- 'ALLOW_CONSTANTS' => false
+ 'ALLOW_CONSTANTS' => false,
+ 'ALLOW_SUPER_GLOBALS' => true
);
/**
@@ -464,7 +465,7 @@ class Smarty
*
* @var string
*/
- var $_version = '2.6.9';
+ var $_version = '2.6.26';
/**
* current template inclusion depth
@@ -838,69 +839,66 @@ function unregister_resource($type)
* Registers a prefilter function to apply
* to a template before compiling
*
- * @param string $function name of PHP function to register
+ * @param callback $function
*/
function register_prefilter($function)
{
- $_name = (is_array($function)) ? $function[1] : $function;
- $this->_plugins['prefilter'][$_name]
+ $this->_plugins['prefilter'][$this->_get_filter_name($function)]
= array($function, null, null, false);
}
/**
* Unregisters a prefilter function
*
- * @param string $function name of PHP function
+ * @param callback $function
*/
function unregister_prefilter($function)
{
- unset($this->_plugins['prefilter'][$function]);
+ unset($this->_plugins['prefilter'][$this->_get_filter_name($function)]);
}
/**
* Registers a postfilter function to apply
* to a compiled template after compilation
*
- * @param string $function name of PHP function to register
+ * @param callback $function
*/
function register_postfilter($function)
{
- $_name = (is_array($function)) ? $function[1] : $function;
- $this->_plugins['postfilter'][$_name]
+ $this->_plugins['postfilter'][$this->_get_filter_name($function)]
= array($function, null, null, false);
}
/**
* Unregisters a postfilter function
*
- * @param string $function name of PHP function
+ * @param callback $function
*/
function unregister_postfilter($function)
{
- unset($this->_plugins['postfilter'][$function]);
+ unset($this->_plugins['postfilter'][$this->_get_filter_name($function)]);
}
/**
* Registers an output filter function to apply
* to a template output
*
- * @param string $function name of PHP function
+ * @param callback $function
*/
function register_outputfilter($function)
{
- $_name = (is_array($function)) ? $function[1] : $function;
- $this->_plugins['outputfilter'][$_name]
+ $this->_plugins['outputfilter'][$this->_get_filter_name($function)]
= array($function, null, null, false);
}
/**
* Unregisters an outputfilter function
*
- * @param string $function name of PHP function
+ * @param callback $function
*/
function unregister_outputfilter($function)
{
- unset($this->_plugins['outputfilter'][$function]);
+ unset($this->_plugins['outputfilter'][$this->_get_filter_name($function)]);
}
/**
@@ -1055,9 +1053,12 @@ function &get_template_vars($name=null)
{
if(!isset($name)) {
return $this->_tpl_vars;
- }
- if(isset($this->_tpl_vars[$name])) {
+ } elseif(isset($this->_tpl_vars[$name])) {
return $this->_tpl_vars[$name];
+ } else {
+ // var non-existant, return valid reference
+ $_tmp = null;
+ return $_tmp;
}
}
@@ -1074,6 +1075,10 @@ function &get_config_vars($name=null)
return $this->_config[0]['vars'];
} else if(isset($this->_config[0]['vars'][$name])) {
return $this->_config[0]['vars'][$name];
+ } else {
+ // var non-existant, return valid reference
+ $_tmp = null;
+ return $_tmp;
}
}
@@ -1544,7 +1549,7 @@ function _fetch_resource_info(&$params)
$params['source_content'] = $this->_read_file($_resource_name);
}
$params['resource_timestamp'] = filemtime($_resource_name);
- $_return = is_file($_resource_name);
+ $_return = is_file($_resource_name) && is_readable($_resource_name);
break;
default:
@@ -1691,8 +1696,8 @@ function _run_mod_handler()
*/
function _dequote($string)
{
- if (($string{0} == "'" || $string{0} == '"') &&
- $string{strlen($string)-1} == $string{0})
+ if ((substr($string, 0, 1) == "'" || substr($string, 0, 1) == '"') &&
+ substr($string, -1) == substr($string, 0, 1))
return substr($string, 1, -1);
else
return $string;
@@ -1707,8 +1712,11 @@ function _dequote($string)
*/
function _read_file($filename)
{
- if ( file_exists($filename) && ($fd = @fopen($filename, 'rb')) ) {
- $contents = ($size = filesize($filename)) ? fread($fd, $size) : '';
+ if ( file_exists($filename) && is_readable($filename) && ($fd = @fopen($filename, 'rb')) ) {
+ $contents = '';
+ while (!feof($fd)) {
+ $contents .= fread($fd, 8192);
+ }
fclose($fd);
return $contents;
} else {
@@ -1889,7 +1897,7 @@ function &_smarty_cache_attrs($cache_serial, $count) {
if ($this->_cache_including) {
/* return next set of cache_attrs */
- $_return =& current($_cache_attrs);
+ $_return = current($_cache_attrs);
next($_cache_attrs);
return $_return;
@@ -1925,6 +1933,25 @@ function _eval($code, $params=null)
{
return eval($code);
}
+
+ /**
+ * Extracts the filter name from the given callback
+ *
+ * @param callback $function
+ * @return string
+ */
+ function _get_filter_name($function)
+ {
+ if (is_array($function)) {
+ $_class_name = (is_object($function[0]) ?
+ get_class($function[0]) : $function[0]);
+ return $_class_name . '_' . $function[1];
+ }
+ else {
+ return $function;
+ }
+ }
+
/**#@-*/
}
Oops, something went wrong.

0 comments on commit 5953ae1

Please sign in to comment.