mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
- added chaining to Smarty_Internal_Data so $smarty->assign('a',1)->assign('b',2); is possible now
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
===== trunk =====
|
||||
27.09.2011
|
||||
- bugfix possible warning "attempt to modify property of non-object" in {section} (issue #34)
|
||||
- added chaining to Smarty_Internal_Data so $smarty->assign('a',1)->assign('b',2); is possible now
|
||||
|
||||
26.09.2011
|
||||
- bugfix repeated calls to same subtemplate did not make use of cached template object
|
||||
|
@@ -78,7 +78,7 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
|
||||
$_paragraphs = preg_split('![\r\n]{2}!', $content);
|
||||
$_output = '';
|
||||
|
||||
for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
|
||||
for ($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
|
||||
if ($_paragraphs[$_x] == '') {
|
||||
continue;
|
||||
}
|
||||
@@ -101,8 +101,12 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
|
||||
}
|
||||
}
|
||||
$_output = implode($wrap_char . $wrap_char, $_paragraphs);
|
||||
|
||||
return $assign ? $template->assign($assign, $_output) : $_output;
|
||||
|
||||
if ($assign) {
|
||||
$template->assign($assign, $_output);
|
||||
} else {
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -49,6 +49,7 @@ class Smarty_Internal_Data {
|
||||
* @param mixed $value the value to assign
|
||||
* @param boolean $nocache if true any output of this variable will be not cached
|
||||
* @param boolean $scope the scope the variable will have (local,parent or root)
|
||||
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function assign($tpl_var, $value = null, $nocache = false)
|
||||
{
|
||||
@@ -73,6 +74,8 @@ class Smarty_Internal_Data {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,12 +84,15 @@ class Smarty_Internal_Data {
|
||||
* @param string $varname the global variable name
|
||||
* @param mixed $value the value to assign
|
||||
* @param boolean $nocache if true any output of this variable will be not cached
|
||||
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function assignGlobal($varname, $value = null, $nocache = false)
|
||||
{
|
||||
if ($varname != '') {
|
||||
Smarty::$global_tpl_vars[$varname] = new Smarty_variable($value, $nocache);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* assigns values to template variables by reference
|
||||
@@ -94,6 +100,7 @@ class Smarty_Internal_Data {
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed $ &$value the referenced value to assign
|
||||
* @param boolean $nocache if true any output of this variable will be not cached
|
||||
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function assignByRef($tpl_var, &$value, $nocache = false)
|
||||
{
|
||||
@@ -101,6 +108,8 @@ class Smarty_Internal_Data {
|
||||
$this->tpl_vars[$tpl_var] = new Smarty_variable(null, $nocache);
|
||||
$this->tpl_vars[$tpl_var]->value = &$value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,6 +119,7 @@ class Smarty_Internal_Data {
|
||||
* @param mixed $value the value to append
|
||||
* @param boolean $merge flag if array elements shall be merged
|
||||
* @param boolean $nocache if true any output of this variable will be not cached
|
||||
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function append($tpl_var, $value = null, $merge = false, $nocache = false)
|
||||
{
|
||||
@@ -159,6 +169,8 @@ class Smarty_Internal_Data {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,6 +179,7 @@ class Smarty_Internal_Data {
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to append
|
||||
* @param boolean $merge flag if array elements shall be merged
|
||||
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function appendByRef($tpl_var, &$value, $merge = false)
|
||||
{
|
||||
@@ -185,6 +198,8 @@ class Smarty_Internal_Data {
|
||||
$this->tpl_vars[$tpl_var]->value[] = &$value;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,6 +251,7 @@ class Smarty_Internal_Data {
|
||||
* clear the given assigned template variable.
|
||||
*
|
||||
* @param string|array $tpl_var the template variable(s) to clear
|
||||
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function clearAssign($tpl_var)
|
||||
{
|
||||
@@ -246,14 +262,18 @@ class Smarty_Internal_Data {
|
||||
} else {
|
||||
unset($this->tpl_vars[$tpl_var]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* clear all the assigned template variables.
|
||||
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function clearAllAssign()
|
||||
{
|
||||
$this->tpl_vars = array();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,12 +281,14 @@ class Smarty_Internal_Data {
|
||||
*
|
||||
* @param string $config_file filename
|
||||
* @param mixed $sections array of section names, single section or null
|
||||
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function configLoad($config_file, $sections = null)
|
||||
{
|
||||
// load Config class
|
||||
$config = new Smarty_Internal_Config($config_file, $this->smarty, $this);
|
||||
$config->loadConfigVars($sections);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -389,6 +411,7 @@ class Smarty_Internal_Data {
|
||||
* Deassigns a single or all config variables
|
||||
*
|
||||
* @param string $varname variable name or null
|
||||
* @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
|
||||
*/
|
||||
public function clearConfig($varname = null)
|
||||
{
|
||||
@@ -397,6 +420,7 @@ class Smarty_Internal_Data {
|
||||
} else {
|
||||
$this->config_vars = array();
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user