mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
- move getStreamVariable() into extension
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
- optimize security isTrustedResourceDir()
|
||||
- move auto load filter methods into extension
|
||||
- move $smarty->getTemplateVars() into extension
|
||||
- move getStreamVariable() into extension
|
||||
|
||||
27.06.2015
|
||||
- bugfix resolve naming conflict between custom Smarty delimiter '<%' and PHP ASP tags https://github.com/smarty-php/smarty/issues/64
|
||||
|
@@ -325,21 +325,6 @@ class Smarty_Internal_Data
|
||||
*/
|
||||
public function getStreamVariable($variable)
|
||||
{
|
||||
$_result = '';
|
||||
$fp = fopen($variable, 'r+');
|
||||
if ($fp) {
|
||||
while (!feof($fp) && ($current_line = fgets($fp)) !== false) {
|
||||
$_result .= $current_line;
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
return $_result;
|
||||
}
|
||||
$smarty = isset($this->smarty) ? $this->smarty : $this;
|
||||
if ($smarty->error_unassigned) {
|
||||
throw new SmartyException('Undefined stream variable "' . $variable . '"');
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return Smarty_Internal_Extension_GetStreamVar::getStreamVariable($this, $variable);
|
||||
}
|
||||
}
|
||||
|
42
libs/sysplugins/smarty_internal_extension_getstreamvar.php
Normal file
42
libs/sysplugins/smarty_internal_extension_getstreamvar.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Extension GetStreamVar
|
||||
*
|
||||
* getStreamVariable() method
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Extension_GetStreamVar
|
||||
{
|
||||
/**
|
||||
* gets a stream variable
|
||||
*
|
||||
* @param $obj
|
||||
* @param string $variable the stream of the variable
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public static function getStreamVariable($obj, $variable)
|
||||
{
|
||||
$_result = '';
|
||||
$fp = fopen($variable, 'r+');
|
||||
if ($fp) {
|
||||
while (!feof($fp) && ($current_line = fgets($fp)) !== false) {
|
||||
$_result .= $current_line;
|
||||
}
|
||||
fclose($fp);
|
||||
|
||||
return $_result;
|
||||
}
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
if ($smarty->error_unassigned) {
|
||||
throw new SmartyException('Undefined stream variable "' . $variable . '"');
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user