summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1fbbb90)
raw | patch | inline | side by side (parent: 1fbbb90)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 3 Mar 2008 16:32:04 +0000 (16:32 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 3 Mar 2008 16:32:04 +0000 (16:32 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@9260 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/Changelog b/Changelog
index 1b7f95afbbe26f2132f3438b2328c64d276c110a..4ba763a09e7b0a7cbcf4876337d6d3cb56d34804 100644 (file)
--- a/Changelog
+++ b/Changelog
* gosa 2.5.16
- ridbase may be undefined in domain objects
- Fixed postremove/-create/-modify parameter expansion
+ - Updated built in smarty to 2.6.19
* gosa 2.5.15
- Changed order of sys-action commandline parameters
index da3b7328b68f285517b695cf31736359b9c7d449..e3c3ca25c60688da42a34e54be6cab0c61c27de6 100644 (file)
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://smarty.php.net/
- * @version 2.6.16
+ * @version 2.6.19
* @copyright Copyright: 2001-2005 New Digital Group, Inc.
* @author Andrei Zmievski <andrei@php.net>
* @access public
* @package Smarty
*/
-/* $Id: Config_File.class.php,v 1.86 2006/11/30 17:01:28 mohrt Exp $ */
+/* $Id: Config_File.class.php 2702 2007-03-08 19:11:22Z mohrt $ */
/**
* Config file reading class
index e11a6dc7ca7d4ab09e7c64dee07edc787eabe144..5eda787bd2c9aeb9f76c1213f53c6b4cb697fe18 100644 (file)
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net>
* @package Smarty
- * @version 2.6.16
+ * @version 2.6.19
*/
-/* $Id: Smarty.class.php,v 1.526 2006/11/30 17:01:28 mohrt Exp $ */
+/* $Id: Smarty.class.php 2722 2007-06-18 14:29:00Z danilo $ */
/**
* DIR_SEP isn't used anymore, but third party apps might
*
* @var string
*/
- var $_version = '2.6.16';
+ var $_version = '2.6.19';
/**
* current template inclusion depth
* 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)]);
}
/**
{
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;
+ }
+ }
+
/**#@-*/
}
index 2b13a6d4118c2f50f63d89642a96e8746bdb14f5..52466d3188d7b613f30f87b5730844a692c8a756 100644 (file)
* @link http://smarty.php.net/
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net>
- * @version 2.6.16
+ * @version 2.6.19
* @copyright 2001-2005 New Digital Group, Inc.
* @package Smarty
*/
-/* $Id: Smarty_Compiler.class.php,v 1.386 2006/11/30 17:01:28 mohrt Exp $ */
+/* $Id: Smarty_Compiler.class.php 2736 2007-09-16 14:47:53Z mohrt $ */
/**
* Template compiling class
$ldq = preg_quote($this->left_delimiter, '~');
$rdq = preg_quote($this->right_delimiter, '~');
- /* un-hide hidden xml open tags */
- $source_content = preg_replace("~<({$ldq}(.*?){$rdq})[?]~s", '< \\1', $source_content);
-
// run template source through prefilter functions
if (count($this->_plugins['prefilter']) > 0) {
foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) {
/* loop through text blocks */
for ($curr_tb = 0, $for_max = count($text_blocks); $curr_tb < $for_max; $curr_tb++) {
/* match anything resembling php tags */
- if (preg_match_all('~(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?php[\"\']?)~is', $text_blocks[$curr_tb], $sp_match)) {
+ if (preg_match_all('~(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?\s*php\s*[\"\']?)~is', $text_blocks[$curr_tb], $sp_match)) {
/* replace tags with placeholders to prevent recursive replacements */
$sp_match[1] = array_unique($sp_match[1]);
usort($sp_match[1], '_smarty_sort_length');
}
}
}
-
+
/* Compile the template tags into PHP code. */
$compiled_tags = array();
for ($i = 0, $for_max = count($template_tags); $i < $for_max; $i++) {
}
}
$compiled_content = '';
-
+
+ $tag_guard = '%%%SMARTYOTG' . md5(uniqid(rand(), true)) . '%%%';
+
/* Interleave the compiled contents and text blocks to get the final result. */
for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) {
if ($compiled_tags[$i] == '') {
// tag result empty, remove first newline from following text block
$text_blocks[$i+1] = preg_replace('~^(\r\n|\r|\n)~', '', $text_blocks[$i+1]);
}
- $compiled_content .= $text_blocks[$i].$compiled_tags[$i];
+ // replace legit PHP tags with placeholder
+ $text_blocks[$i] = str_replace('<?', $tag_guard, $text_blocks[$i]);
+ $compiled_tags[$i] = str_replace('<?', $tag_guard, $compiled_tags[$i]);
+
+ $compiled_content .= $text_blocks[$i] . $compiled_tags[$i];
}
- $compiled_content .= $text_blocks[$i];
+ $compiled_content .= str_replace('<?', $tag_guard, $text_blocks[$i]);
+
+ // escape php tags created by interleaving
+ $compiled_content = str_replace('<?', "<?php echo '<?' ?>\n", $compiled_content);
+ $compiled_content = preg_replace("~(?<!')language\s*=\s*[\"\']?\s*php\s*[\"\']?~", "<?php echo 'language=php' ?>\n", $compiled_content);
+ // recover legit tags
+ $compiled_content = str_replace($tag_guard, '<?', $compiled_content);
+
// remove \n from the end of the file, if any
if (strlen($compiled_content) && (substr($compiled_content, -1) == "\n") ) {
$compiled_content = substr($compiled_content, 0, -1);
$compiled_content = "<?php \$this->_cache_serials['".$this->_cache_include."'] = '".$this->_cache_serial."'; ?>" . $compiled_content;
}
- // remove unnecessary close/open tags
- $compiled_content = preg_replace('~\?>\n?<\?php~', '', $compiled_content);
-
// run compiled template through postfilter functions
if (count($this->_plugins['postfilter']) > 0) {
foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) {
// traditional argument format
$args = implode(',', array_values($attrs));
if (empty($args)) {
- $args = 'null';
+ $args = '';
}
}
}
$item = $this->_dequote($attrs['item']);
if (!preg_match('~^\w+$~', $item)) {
- return $this->_syntax_error("'foreach: 'item' must be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__);
+ return $this->_syntax_error("foreach: 'item' must be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__);
}
if (isset($attrs['key'])) {
$attrs = $this->_parse_attrs($tag_args);
if ($start) {
- if (isset($attrs['name']))
- $buffer = $attrs['name'];
- else
- $buffer = "'default'";
-
- if (isset($attrs['assign']))
- $assign = $attrs['assign'];
- else
- $assign = null;
+ $buffer = isset($attrs['name']) ? $attrs['name'] : "'default'";
+ $assign = isset($attrs['assign']) ? $attrs['assign'] : null;
+ $append = isset($attrs['append']) ? $attrs['append'] : null;
+
$output = "<?php ob_start(); ?>";
- $this->_capture_stack[] = array($buffer, $assign);
+ $this->_capture_stack[] = array($buffer, $assign, $append);
} else {
- list($buffer, $assign) = array_pop($this->_capture_stack);
+ list($buffer, $assign, $append) = array_pop($this->_capture_stack);
$output = "<?php \$this->_smarty_vars['capture'][$buffer] = ob_get_contents(); ";
if (isset($assign)) {
$output .= " \$this->assign($assign, ob_get_contents());";
}
+ if (isset($append)) {
+ $output .= " \$this->append($append, ob_get_contents());";
+ }
$output .= "ob_end_clean(); ?>";
}
if ($_cacheable
|| 0<$this->_cacheable_state++) return '';
if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid('Smarty'));
- $_ret = 'if ($this->caching && !$this->_cache_including) { echo \'{nocache:'
+ $_ret = 'if ($this->caching && !$this->_cache_including): echo \'{nocache:'
. $this->_cache_serial . '#' . $this->_nocache_count
- . '}\'; };';
+ . '}\'; endif;';
return $_ret;
}
$_cacheable = !isset($this->_plugins[$type][$name]) || $this->_plugins[$type][$name][4];
if ($_cacheable
|| --$this->_cacheable_state>0) return '';
- return 'if ($this->caching && !$this->_cache_including) { echo \'{/nocache:'
+ return 'if ($this->caching && !$this->_cache_including): echo \'{/nocache:'
. $this->_cache_serial . '#' . ($this->_nocache_count++)
- . '}\'; };';
+ . '}\'; endif;';
}
diff --git a/include/smarty/internals/core.write_compiled_include.php b/include/smarty/internals/core.write_compiled_include.php
index 3a7809417d7ab0c57d626c51d99a7dcdc5eb3f1a..c14adb5f42a8e5db92914dbefcbbfdea9d29edde 100644 (file)
function smarty_core_write_compiled_include($params, &$smarty)
{
- $_tag_start = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\'; \};';
- $_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\'; \};';
+ $_tag_start = 'if \(\$this->caching && \!\$this->_cache_including\)\: echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\'; endif;';
+ $_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\)\: echo \'\{/nocache\:(\\2)#(\\3)\}\'; endif;';
preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
$params['compiled_content'], $_match_source, PREG_SET_ORDER);
-
+
// no nocache-parts found: done
if (count($_match_source)==0) return;
diff --git a/include/smarty/internals/core.write_file.php b/include/smarty/internals/core.write_file.php
index 48a3b1a7dfc3743ed1a685e333c517b4098358b5..8a3a3b39843955431036bfea1b9cfc68dc358646 100644 (file)
fwrite($fd, $params['contents']);
fclose($fd);
- if (PHP_OS == 'Windows' || !@rename($_tmp_file, $params['filename'])) {
+ if (DIRECTORY_SEPARATOR == '\\' || !@rename($_tmp_file, $params['filename'])) {
// On platforms and filesystems that cannot overwrite with rename()
// delete the file before renaming it -- because windows always suffers
// this, it is short-circuited to avoid the initial rename() attempt
diff --git a/include/smarty/plugins/compiler.assign.php b/include/smarty/plugins/compiler.assign.php
index be1729850197a6bcbd5c0b82bfaaadc59fe50043..abef377f8c45a253a95661af4b65a2a034658b36 100644 (file)
* @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com> (initial author)
- * @auther messju mohr <messju at lammfellpuschen dot de> (conversion to compiler function)
+ * @author messju mohr <messju at lammfellpuschen dot de> (conversion to compiler function)
* @param string containing var-attribute and value-attribute
* @param Smarty_Compiler
*/
diff --git a/include/smarty/plugins/function.html_select_date.php b/include/smarty/plugins/function.html_select_date.php
index ff920e435baa25e9d5593ce20f370d511c43c6c1..e5eb18307bf3922d27b2b978bd81a30920e4d57f 100644 (file)
$html_result = $month_result = $day_result = $year_result = "";
+ $field_separator_count = -1;
if ($display_months) {
+ $field_separator_count++;
$month_names = array();
$month_values = array();
if(isset($month_empty)) {
}
if ($display_days) {
+ $field_separator_count++;
$days = array();
if (isset($day_empty)) {
$days[''] = $day_empty;
}
if ($display_years) {
+ $field_separator_count++;
if (null !== $field_array){
$year_name = $field_array . '[' . $prefix . 'Year]';
} else {
break;
}
// Add the field seperator
- if($i != 2) {
+ if($i < $field_separator_count) {
$html_result .= $field_separator;
}
}
diff --git a/include/smarty/plugins/modifier.date_format.php b/include/smarty/plugins/modifier.date_format.php
index 8266e9d7183895131e541b069e4cb8ea7e1ff612..8cf7d5e14e8d5d0aa143512007b1632cc67b26d2 100644 (file)
/**
* Include the {@link shared.make_timestamp.php} plugin
*/
-require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
+require_once $smarty->_get_plugin_filepath('shared', 'make_timestamp');
/**
* Smarty date_format modifier plugin
*
* @return string|void
* @uses smarty_make_timestamp()
*/
-function smarty_modifier_date_format($string, $format="%b %e, %Y", $default_date=null)
+function smarty_modifier_date_format($string, $format = '%b %e, %Y', $default_date = '')
{
- if (substr(PHP_OS,0,3) == 'WIN') {
- $hours = strftime('%I', $string);
- $short_hours = ( $hours < 10 ) ? substr( $hours, -1) : $hours;
- $_win_from = array ('%e', '%T', '%D', '%l');
- $_win_to = array ('%#d', '%H:%M:%S', '%m/%d/%y', $short_hours);
- $format = str_replace($_win_from, $_win_to, $format);
- }
- if($string != '') {
- return strftime($format, smarty_make_timestamp($string));
- } elseif (isset($default_date) && $default_date != '') {
- return strftime($format, smarty_make_timestamp($default_date));
+ if ($string != '') {
+ $timestamp = smarty_make_timestamp($string);
+ } elseif ($default_date != '') {
+ $timestamp = smarty_make_timestamp($default_date);
} else {
return;
}
+ if (DIRECTORY_SEPARATOR == '\\') {
+ $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
+ $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
+ if (strpos($format, '%e') !== false) {
+ $_win_from[] = '%e';
+ $_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
+ }
+ if (strpos($format, '%l') !== false) {
+ $_win_from[] = '%l';
+ $_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
+ }
+ $format = str_replace($_win_from, $_win_to, $format);
+ }
+ return strftime($format, $timestamp);
}
/* vim: set expandtab: */
diff --git a/include/smarty/plugins/modifier.regex_replace.php b/include/smarty/plugins/modifier.regex_replace.php
index d4d20309d2d3b51f9723eea0229ac263fcaf4e56..d1f1545d8f095c6dab06d6362efa25f501e8fc7e 100644 (file)
*/
function smarty_modifier_regex_replace($string, $search, $replace)
{
+ if (($pos = strpos($search,"\0")) !== false)
+ $search = substr($search,0,$pos);
if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
/* remove eval-modifier from $search */
$search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
diff --git a/include/smarty/plugins/modifier.truncate.php b/include/smarty/plugins/modifier.truncate.php
index d96de5f12397bffa4769000c3ae9a09be39cb843..35c89690a1556cc6dfa943bde00f40abb43dca15 100644 (file)
return '';
if (strlen($string) > $length) {
- $length -= strlen($etc);
+ $length -= min($length, strlen($etc));
if (!$break_words && !$middle) {
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
}
if(!$middle) {
- return substr($string, 0, $length).$etc;
+ return substr($string, 0, $length) . $etc;
} else {
return substr($string, 0, $length/2) . $etc . substr($string, -$length/2);
}