Skip to content

Commit

Permalink
Upgraded to latest version of Smarty 2.6.9
Browse files Browse the repository at this point in the history
  • Loading branch information
thepurpleblob committed Apr 19, 2005
1 parent f55a672 commit c38950b
Show file tree
Hide file tree
Showing 49 changed files with 676 additions and 508 deletions.
6 changes: 3 additions & 3 deletions lib/smarty/Config_File.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://smarty.php.net/
* @version 2.6.2
* @copyright Copyright: 2001-2004 ispi of Lincoln, Inc.
* @version 2.6.9
* @copyright Copyright: 2001-2005 New Digital Group, Inc.
* @author Andrei Zmievski <[email protected]>
* @access public
* @package Smarty
Expand Down Expand Up @@ -240,7 +240,7 @@ function load_file($file_name, $prepend_path = true)
return false;
}

$contents = fread($fp, filesize($config_file));
$contents = ($size = filesize($config_file)) ? fread($fp, $size) : '';
fclose($fp);

$this->_config_data[$config_file] = $this->parse_contents($contents);
Expand Down
190 changes: 70 additions & 120 deletions lib/smarty/Smarty.class.php

Large diffs are not rendered by default.

387 changes: 233 additions & 154 deletions lib/smarty/Smarty_Compiler.class.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/smarty/debug.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
var title = 'Console_' + self.name;
{rdelim}
_smarty_console = window.open("",title.value,"width=680,height=600,resizable,scrollbars=yes");
_smarty_console.document.write("<HTML><TITLE>Smarty Debug Console_"+self.name+"</TITLE><BODY bgcolor=#ffffff>");
_smarty_console.document.write("<HTML><HEAD><TITLE>Smarty Debug Console_"+self.name+"</TITLE></HEAD><BODY bgcolor=#ffffff>");
_smarty_console.document.write("<table border=0 width=100%>");
_smarty_console.document.write("<tr bgcolor=#cccccc><th colspan=2>Smarty Debug Console</th></tr>");
_smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>included templates & config files (load time in seconds):</b></td></tr>");
Expand Down
31 changes: 14 additions & 17 deletions lib/smarty/plugins/block.textformat.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
/**
* Smarty {textformat}{/textformat} block plugin
*
* Type: block function<br />
* Name: textformat<br />
* Type: block function<br>
* Name: textformat<br>
* Purpose: format text a certain way with preset styles
* or custom wrap/indent settings<br />
* or custom wrap/indent settings<br>
* @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat}
* (Smarty online manual)
* @param array
Expand Down Expand Up @@ -71,33 +71,30 @@ function smarty_block_textformat($params, $content, &$smarty)
}

// split into paragraphs
$paragraphs = preg_split('![\r\n][\r\n]!',$content);
$output = '';
$_paragraphs = preg_split('![\r\n][\r\n]!',$content);
$_output = '';

foreach ($paragraphs as $paragraph) {
if ($paragraph == '') {
for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
if ($_paragraphs[$_x] == '') {
continue;
}
// convert mult. spaces & special chars to single space
$paragraph = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'),array(' ',''),$paragraph);
$_paragraphs[$_x] = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'), array(' ',''), $_paragraphs[$_x]);
// indent first line
if($indent_first > 0) {
$paragraph = str_repeat($indent_char,$indent_first) . $paragraph;
$_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x];
}
// wordwrap sentences
$paragraph = wordwrap($paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
$_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut);
// indent lines
if($indent > 0) {
$paragraph = preg_replace('!^!m',str_repeat($indent_char,$indent),$paragraph);
$_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]);
}
$output .= $paragraph . $wrap_char . $wrap_char;
}
$_output = implode($wrap_char . $wrap_char, $_paragraphs);

return $assign ? $smarty->assign($assign, $_output) : $_output;

if ($assign) {
$smarty->assign($assign,$output);
} else {
return $output;
}
}

/* vim: set expandtab: */
Expand Down
9 changes: 7 additions & 2 deletions lib/smarty/plugins/compiler.assign.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/

/**
* Smarty {assign} compiler function plugin
*
* Type: compiler function<br />
* Name: assign<br />
* Type: compiler function<br>
* Name: assign<br>
* Purpose: assign a value to a template variable
* @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign}
* (Smarty online manual)
Expand Down
8 changes: 4 additions & 4 deletions lib/smarty/plugins/function.assign_debug_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
/**
* Smarty {assign_debug_info} function plugin
*
* Type: function<br />
* Name: assign_debug_info<br />
* Purpose: assign debug info to the template<br />
* Type: function<br>
* Name: assign_debug_info<br>
* Purpose: assign debug info to the template<br>
* @param array unused in this plugin, this plugin uses {@link Smarty::$_config},
* {@link Smarty::$_tpl_vars} and {@link Smarty::$_smarty_debug_info}
* @param Smarty
Expand All @@ -24,7 +24,7 @@ function smarty_function_assign_debug_info($params, &$smarty)
ksort($config_vars);
$smarty->assign("_debug_config_keys", array_keys($config_vars));
$smarty->assign("_debug_config_vals", array_values($config_vars));
}
}

$included_templates = $smarty->_smarty_debug_info;

Expand Down
36 changes: 25 additions & 11 deletions lib/smarty/plugins/function.config_load.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
/**
* Smarty {config_load} function plugin
*
* Type: function<br />
* Name: config_load<br />
* Type: function<br>
* Name: config_load<br>
* Purpose: load config file vars
* @link http://smarty.php.net/manual/en/language.function.config.load.php {config_load}
* (Smarty online manual)
Expand All @@ -26,7 +26,7 @@ function smarty_function_config_load($params, &$smarty)
{
if ($smarty->debugging) {
$_params = array();
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
$_debug_start_time = smarty_core_get_microtime($_params, $smarty);
}

Expand All @@ -53,18 +53,29 @@ function smarty_function_config_load($params, &$smarty)
}
}

$_params = array('resource_name' => $_file, 'resource_base_path' => $smarty->config_dir);
$_params = array('resource_name' => $_file,
'resource_base_path' => $smarty->config_dir,
'get_source' => false);
$smarty->_parse_resource_name($_params);
$_file_path = $_params['resource_type'] . ':' . $_params['resource_name'];
if (isset($_section))
$_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section);
else
$_compile_file = $smarty->_get_compile_path($_file_path);

if($smarty->force_compile
|| !file_exists($_compile_file)
|| ($smarty->compile_check
&& !$smarty->_is_compiled($_file_path, $_compile_file))) {
if($smarty->force_compile || !file_exists($_compile_file)) {
$_compile = true;
} elseif ($smarty->compile_check) {
$_params = array('resource_name' => $_file,
'resource_base_path' => $smarty->config_dir,
'get_source' => false);
$_compile = $smarty->_fetch_resource_info($_params) &&
$_params['resource_timestamp'] > filemtime($_compile_file);
} else {
$_compile = false;
}

if($_compile) {
// compile config file
if(!is_object($smarty->_conf_obj)) {
require_once SMARTY_DIR . $smarty->config_class . '.class.php';
Expand All @@ -74,7 +85,10 @@ function smarty_function_config_load($params, &$smarty)
$smarty->_conf_obj->read_hidden = $smarty->config_read_hidden;
$smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines;
}
$_params = array('resource_name' => $_file, 'resource_base_path' => $smarty->config_dir);

$_params = array('resource_name' => $_file,
'resource_base_path' => $smarty->config_dir,
$_params['get_source'] = true);
if (!$smarty->_fetch_resource_info($_params)) {
return;
}
Expand All @@ -87,7 +101,7 @@ function smarty_function_config_load($params, &$smarty)
$_output = '<?php $_config_vars = unserialize(\'' . strtr(serialize($_config_vars),array('\''=>'\\\'', '\\'=>'\\\\')) . '\'); ?>';
}
$_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => $_params['resource_timestamp']));
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php');
require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
smarty_core_write_compiled_resource($_params, $smarty);
} else {
include($_compile_file);
Expand All @@ -112,7 +126,7 @@ function smarty_function_config_load($params, &$smarty)

if ($smarty->debugging) {
$_params = array();
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
$smarty->_smarty_debug_info[] = array('type' => 'config',
'filename' => $_file.' ['.$_section.'] '.$_scope,
'depth' => $smarty->_inclusion_depth,
Expand Down
4 changes: 2 additions & 2 deletions lib/smarty/plugins/function.counter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
/**
* Smarty {counter} function plugin
*
* Type: function<br />
* Name: counter<br />
* Type: function<br>
* Name: counter<br>
* Purpose: print out a counter value
* @link http://smarty.php.net/manual/en/language.function.counter.php {counter}
* (Smarty online manual)
Expand Down
18 changes: 9 additions & 9 deletions lib/smarty/plugins/function.cycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
/**
* Smarty {cycle} function plugin
*
* Type: function<br />
* Name: cycle<br />
* Date: May 3, 2002<br />
* Purpose: cycle through given values<br />
* Type: function<br>
* Name: cycle<br>
* Date: May 3, 2002<br>
* Purpose: cycle through given values<br>
* Input:
* - name = name of cycle (optional)
* - values = comma separated list of values to cycle,
Expand All @@ -23,16 +23,16 @@
* - delimiter = the value delimiter, default is ","
* - assign = boolean, assigns to template var instead of
* printed.
*
* Examples:<br />
*
* Examples:<br>
* <pre>
* {cycle values="#eeeeee,#d0d0d0d"}
* {cycle name=row values="one,two,three" reset=true}
* {cycle name=row}
* </pre>
* @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle}
* (Smarty online manual)
* @author Monte Ohrt <monte@ispi.net>
* @author Monte Ohrt <monte at ohrt dot com>
* @author credit to Mark Priatel <[email protected]>
* @author credit to Gerard <[email protected]>
* @author credit to Jason Sweat <[email protected]>
Expand Down Expand Up @@ -66,7 +66,7 @@ function smarty_function_cycle($params, &$smarty)
$cycle_vars[$name]['delimiter'] = (isset($params['delimiter'])) ? $params['delimiter'] : ',';

if(is_array($cycle_vars[$name]['values'])) {
$cycle_array = $cycle_vars[$name]['values'];
$cycle_array = $cycle_vars[$name]['values'];
} else {
$cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']);
}
Expand All @@ -88,7 +88,7 @@ function smarty_function_cycle($params, &$smarty)

if($advance) {
if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
$cycle_vars[$name]['index'] = 0;
$cycle_vars[$name]['index'] = 0;
} else {
$cycle_vars[$name]['index']++;
}
Expand Down
14 changes: 7 additions & 7 deletions lib/smarty/plugins/function.debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@
/**
* Smarty {debug} function plugin
*
* Type: function<br />
* Name: debug<br />
* Date: July 1, 2002<br />
* Type: function<br>
* Name: debug<br>
* Date: July 1, 2002<br>
* Purpose: popup debug window
* @link http://smarty.php.net/manual/en/language.function.debug.php {debug}
* (Smarty online manual)
* @author Monte Ohrt <monte@ispi.net>
* @author Monte Ohrt <monte at ohrt dot com>
* @version 1.0
* @param array
* @param Smarty
* @return string output from {@link Smarty::_generate_debug_output()}
*/
function smarty_function_debug($params, &$smarty)
{
if($params['output']) {
$smarty->assign('_smarty_debug_output',$params['output']);
if (isset($params['output'])) {
$smarty->assign('_smarty_debug_output', $params['output']);
}
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php');
require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
return smarty_core_display_debug_console(null, $smarty);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/smarty/plugins/function.eval.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
/**
* Smarty {eval} function plugin
*
* Type: function<br />
* Name: eval<br />
* Purpose: evaluate a template variable as a template<br />
* Type: function<br>
* Name: eval<br>
* Purpose: evaluate a template variable as a template<br>
* @link http://smarty.php.net/manual/en/language.function.eval.php {eval}
* (Smarty online manual)
* @param array
Expand Down
15 changes: 9 additions & 6 deletions lib/smarty/plugins/function.fetch.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
/**
* Smarty {fetch} plugin
*
* Type: function<br />
* Name: fetch<br />
* Type: function<br>
* Name: fetch<br>
* Purpose: fetch file, web or ftp data and display results
* @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch}
* (Smarty online manual)
Expand All @@ -26,9 +26,10 @@ function smarty_function_fetch($params, &$smarty)
return;
}

$content = '';
if ($smarty->security && !preg_match('!^(http|ftp)://!i', $params['file'])) {
$_params = array('resource_type' => 'file', 'resource_name' => $params['file']);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_secure.php');
require_once(SMARTY_CORE_DIR . 'core.is_secure.php');
if(!smarty_core_is_secure($_params, $smarty)) {
$smarty->_trigger_fatal_error('[plugin] (secure mode) fetch \'' . $params['file'] . '\' is not allowed');
return;
Expand Down Expand Up @@ -63,8 +64,11 @@ function smarty_function_fetch($params, &$smarty)
} else {
$port = $uri_parts['port'];
}
if(empty($uri_parts['user'])) {
$user = '';
if(!empty($uri_parts['user'])) {
$user = $uri_parts['user'];
}
if(!empty($uri_parts['pass'])) {
$pass = $uri_parts['pass'];
}
// loop through parameters, setup headers
foreach($params as $param_key => $param_value) {
Expand Down Expand Up @@ -171,7 +175,6 @@ function smarty_function_fetch($params, &$smarty)
fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n");
}

$content = '';
fputs($fp, "\r\n");
while(!feof($fp)) {
$content .= fgets($fp,4096);
Expand Down
Loading

0 comments on commit c38950b

Please sign in to comment.