mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 18:04:26 +02:00
Dropped deprecated constants, an API method and an API argument type
This commit is contained in:
@@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Dropped deprecated API calls that where only accessible through SmartyBC
|
||||
- Dropped support for {php} and {include_php} tags and embedded PHP in templates. Embedded PHP will now be passed through as is.
|
||||
- Removed all PHP_VERSION_ID and compare_version checks and conditional code blocks that are now no longer required
|
||||
- Dropped deprecated SMARTY_RESOURCE_CHAR_SET and SMARTY_RESOURCE_DATE_FORMAT constants
|
||||
- Dropped deprecated Smarty::muteExpectedErrors and Smarty::unmuteExpectedErrors API methods
|
||||
- Dropped deprecated $smarty->getVariable() method. Use $smarty->getTemplateVars() instead.
|
||||
- $smarty->registerResource() no longer accepts an array of callback functions
|
||||
|
||||
## [3.1.38] - 2021-01-08
|
||||
|
||||
|
@@ -60,19 +60,6 @@ if (!defined('SMARTY_MBSTRING')) {
|
||||
*/
|
||||
define('SMARTY_MBSTRING', function_exists('mb_get_info'));
|
||||
}
|
||||
if (!defined('SMARTY_RESOURCE_CHAR_SET')) {
|
||||
// UTF-8 can only be done properly when mbstring is available!
|
||||
/**
|
||||
* @deprecated in favor of Smarty::$_CHARSET
|
||||
*/
|
||||
define('SMARTY_RESOURCE_CHAR_SET', SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1');
|
||||
}
|
||||
if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) {
|
||||
/**
|
||||
* @deprecated in favor of Smarty::$_DATE_FORMAT
|
||||
*/
|
||||
define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y');
|
||||
}
|
||||
/**
|
||||
* Load Smarty_Autoloader
|
||||
*/
|
||||
@@ -173,13 +160,13 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* The character set to adhere to (e.g. "UTF-8")
|
||||
*/
|
||||
public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
|
||||
public static $_CHARSET = SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1';
|
||||
|
||||
/**
|
||||
* The date format to be used internally
|
||||
* (accepts date() and strftime())
|
||||
*/
|
||||
public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
|
||||
public static $_DATE_FORMAT = '%b %e, %Y';
|
||||
|
||||
/**
|
||||
* Flag denoting if PCRE should run in UTF-8 mode
|
||||
@@ -675,27 +662,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable error handler to mute expected messages
|
||||
*
|
||||
* @return boolean
|
||||
* @deprecated
|
||||
*/
|
||||
public static function muteExpectedErrors()
|
||||
{
|
||||
return Smarty_Internal_ErrorHandler::muteExpectedErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable error handler muting expected messages
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public static function unmuteExpectedErrors()
|
||||
{
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a template resource exists
|
||||
*
|
||||
@@ -1374,11 +1340,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
private function _normalizeDir($dirName, $dir)
|
||||
{
|
||||
$this->{$dirName} = $this->_realpath(rtrim($dir, "/\\") . DIRECTORY_SEPARATOR, true);
|
||||
if (class_exists('Smarty_Internal_ErrorHandler', false)) {
|
||||
if (!isset(Smarty_Internal_ErrorHandler::$mutedDirectories[ $this->{$dirName} ])) {
|
||||
Smarty_Internal_ErrorHandler::$mutedDirectories[ $this->{$dirName} ] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -195,26 +195,6 @@ abstract class Smarty_Internal_Data
|
||||
return $this->ext->getTemplateVars->getTemplateVars($this, $varName, $_ptr, $searchParents);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the object of a Smarty variable
|
||||
*
|
||||
* @param string $variable the name of the Smarty variable
|
||||
* @param Smarty_Internal_Data $_ptr optional pointer to data object
|
||||
* @param boolean $searchParents search also in parent data
|
||||
* @param bool $error_enable
|
||||
*
|
||||
* @return Smarty_Variable|Smarty_Undefined_Variable the object of the variable
|
||||
* @deprecated since 3.1.28 please use Smarty_Internal_Data::getTemplateVars() instead.
|
||||
*/
|
||||
public function getVariable(
|
||||
$variable = null,
|
||||
Smarty_Internal_Data $_ptr = null,
|
||||
$searchParents = true,
|
||||
$error_enable = true
|
||||
) {
|
||||
return $this->ext->getTemplateVars->_getVariable($this, $variable, $_ptr, $searchParents, $error_enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow the parent chain an merge template and config variables
|
||||
*
|
||||
|
@@ -26,21 +26,14 @@ class Smarty_Internal_Method_RegisterResource
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||
* @param string $name name of resource type
|
||||
* @param Smarty_Resource|array $resource_handler or instance of
|
||||
* Smarty_Resource,
|
||||
* or array of
|
||||
* callbacks to
|
||||
* handle
|
||||
* resource
|
||||
* (deprecated)
|
||||
* @param Smarty_Resource $resource_handler instance of Smarty_Resource
|
||||
*
|
||||
* @return \Smarty|\Smarty_Internal_Template
|
||||
*/
|
||||
public function registerResource(Smarty_Internal_TemplateBase $obj, $name, $resource_handler)
|
||||
public function registerResource(Smarty_Internal_TemplateBase $obj, $name, Smarty_Resource $resource_handler)
|
||||
{
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
$smarty->registered_resources[ $name ] =
|
||||
$resource_handler instanceof Smarty_Resource ? $resource_handler : array($resource_handler, false);
|
||||
$smarty->registered_resources[ $name ] = $resource_handler;
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
|
@@ -1,101 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Resource Registered
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage TemplateResources
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Resource Registered
|
||||
* Implements the registered resource for Smarty template
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage TemplateResources
|
||||
* @deprecated
|
||||
*/
|
||||
class Smarty_Internal_Resource_Registered extends Smarty_Resource
|
||||
{
|
||||
/**
|
||||
* populate Source Object with meta data from Resource
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
|
||||
{
|
||||
$source->filepath = $source->type . ':' . $source->name;
|
||||
$source->uid = sha1($source->filepath . $source->smarty->_joined_template_dir);
|
||||
$source->timestamp = $this->getTemplateTimestamp($source);
|
||||
$source->exists = !!$source->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* populate Source Object with timestamp and exists from Resource
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function populateTimestamp(Smarty_Template_Source $source)
|
||||
{
|
||||
$source->timestamp = $this->getTemplateTimestamp($source);
|
||||
$source->exists = !!$source->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get timestamp (epoch) the template source was modified
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
*
|
||||
* @return integer|boolean timestamp (epoch) the template was modified, false if resources has no timestamp
|
||||
*/
|
||||
public function getTemplateTimestamp(Smarty_Template_Source $source)
|
||||
{
|
||||
// return timestamp
|
||||
$time_stamp = false;
|
||||
call_user_func_array(
|
||||
$source->smarty->registered_resources[ $source->type ][ 0 ][ 1 ],
|
||||
array($source->name, &$time_stamp, $source->smarty)
|
||||
);
|
||||
return is_numeric($time_stamp) ? (int)$time_stamp : $time_stamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load template's source by invoking the registered callback into current template object
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
*
|
||||
* @return string template source
|
||||
* @throws SmartyException if source cannot be loaded
|
||||
*/
|
||||
public function getContent(Smarty_Template_Source $source)
|
||||
{
|
||||
// return template string
|
||||
$content = null;
|
||||
$t = call_user_func_array(
|
||||
$source->smarty->registered_resources[ $source->type ][ 0 ][ 0 ],
|
||||
array($source->name, &$content, $source->smarty)
|
||||
);
|
||||
if (is_bool($t) && !$t) {
|
||||
throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine basename for compiled filename
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
*
|
||||
* @return string resource's basename
|
||||
*/
|
||||
public function getBasename(Smarty_Template_Source $source)
|
||||
{
|
||||
return basename($source->name);
|
||||
}
|
||||
}
|
@@ -386,7 +386,6 @@ class Smarty_Internal_TestInstall
|
||||
'smarty_internal_config_file_compiler.php' => true,
|
||||
'smarty_internal_data.php' => true,
|
||||
'smarty_internal_debug.php' => true,
|
||||
'smarty_internal_errorhandler.php' => true,
|
||||
'smarty_internal_extension_handler.php' => true,
|
||||
'smarty_internal_method_addautoloadfilters.php' => true,
|
||||
'smarty_internal_method_adddefaultmodifiers.php' => true,
|
||||
@@ -448,7 +447,6 @@ class Smarty_Internal_TestInstall
|
||||
'smarty_internal_resource_extends.php' => true,
|
||||
'smarty_internal_resource_file.php' => true,
|
||||
'smarty_internal_resource_php.php' => true,
|
||||
'smarty_internal_resource_registered.php' => true,
|
||||
'smarty_internal_resource_stream.php' => true,
|
||||
'smarty_internal_resource_string.php' => true,
|
||||
'smarty_internal_runtime_cachemodify.php' => true,
|
||||
|
@@ -72,9 +72,7 @@ abstract class Smarty_Resource
|
||||
}
|
||||
// try registered resource
|
||||
if (isset($smarty->registered_resources[ $type ])) {
|
||||
return $smarty->_cache[ 'resource_handlers' ][ $type ] =
|
||||
$smarty->registered_resources[ $type ] instanceof Smarty_Resource ?
|
||||
$smarty->registered_resources[ $type ] : new Smarty_Internal_Resource_Registered();
|
||||
return $smarty->_cache[ 'resource_handlers' ][ $type ] = $smarty->registered_resources[ $type ];
|
||||
}
|
||||
// try sysplugins dir
|
||||
if (isset(self::$sysplugins[ $type ])) {
|
||||
|
Reference in New Issue
Block a user