Skip to content

Commit

Permalink
07.10.2017
Browse files Browse the repository at this point in the history
  - bugfix modification of 9.8.2017 did fail on some recursive
    tag nesting. #389
  • Loading branch information
uwetews committed Oct 7, 2017
1 parent b0ea1cb commit f528eea
Show file tree
Hide file tree
Showing 5 changed files with 2,692 additions and 1,767 deletions.
96 changes: 96 additions & 0 deletions libs/sysplugins/smarty_internal_method_literals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php

/**
* Smarty Method GetLiterals
*
* Smarty::getLiterals() method
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*/
class Smarty_Internal_Method_Literals
{
/**
* Valid for Smarty and template object
*
* @var int
*/
public $objMap = 3;

/**
* Get literals
*
* @api Smarty::getLiterals()
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
*
* @return array list of literals
*/
public function getLiterals(Smarty_Internal_TemplateBase $obj)
{
$smarty = $obj->_getSmartyObj();
return (array)$smarty->literals;
}

/**
* Add literals
*
* @api Smarty::addLiterals()
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param array|string $literals literal or list of literals
* to add
*
* @return \Smarty|\Smarty_Internal_Template
*/
public function addLiterals(Smarty_Internal_TemplateBase $obj, $literals = null)
{
if (isset($literals)) {
$this->set($obj->_getSmartyObj(), (array)$literals);
}
return $obj;
}

/**
* Set literals
*
* @api Smarty::setLiterals()
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param array|string $literals literal or list of literals
* to set
*
* @return \Smarty|\Smarty_Internal_Template
*/
public function setLiterals(Smarty_Internal_TemplateBase $obj, $literals = null)
{
$smarty = $obj->_getSmartyObj();
$smarty->literals = array();
if (!empty($literals)) {
$this->set($smarty, (array)$literals);
}
return $obj;
}

/**
* common setter for literals for easier handling of duplicates the
* Smarty::$literals array gets filled with identical key values
*
* @param \Smarty $smarty
* @param array $literals
*
* @throws \SmartyException
*/
private function set(Smarty $smarty, $literals)
{
$literals = array_combine($literals, $literals);
$error = isset($literals[ $smarty->left_delimiter ]) ? array($smarty->left_delimiter) : array();
$error = isset($literals[ $smarty->right_delimiter ]) ? $error[] = $smarty->right_delimiter : $error;
if (!empty($error)) {
throw new SmartyException('User defined literal(s) "' . $error .
'" may not be identical with left or right delimiter');
}
$smarty->literals = array_merge((array)$smarty->literals, (array)$literals);
}
}
3 changes: 3 additions & 0 deletions libs/sysplugins/smarty_internal_templatebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
*
* @method Smarty_Internal_TemplateBase addAutoloadFilters(mixed $filters, string $type = null)
* @method Smarty_Internal_TemplateBase addDefaultModifier(mixed $modifiers)
* @method Smarty_Internal_TemplateBase addLiterals(mixed $literals)
* @method Smarty_Internal_TemplateBase createData(Smarty_Internal_Data $parent = null, string $name = null)
* @method array getAutoloadFilters(string $type = null)
* @method string getDebugTemplate()
* @method array getDefaultModifier()
* @method array getLiterals()
* @method array getTags(mixed $template = null)
* @method object getRegisteredObject(string $object_name)
* @method Smarty_Internal_TemplateBase registerCacheResource(string $name, Smarty_CacheResource $resource_handler)
Expand All @@ -36,6 +38,7 @@
* @method Smarty_Internal_TemplateBase setAutoloadFilters(mixed $filters, string $type = null)
* @method Smarty_Internal_TemplateBase setDebugTemplate(string $tpl_name)
* @method Smarty_Internal_TemplateBase setDefaultModifiers(mixed $modifiers)
* @method Smarty_Internal_TemplateBase setLiterals(mixed $literals)
* @method Smarty_Internal_TemplateBase unloadFilter(string $type, string $name)
* @method Smarty_Internal_TemplateBase unregisterCacheResource(string $name)
* @method Smarty_Internal_TemplateBase unregisterObject(string $object_name)
Expand Down
Loading

0 comments on commit f528eea

Please sign in to comment.