Files

51 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2015-06-28 05:00:27 +02:00
<?php
/**
* Smarty Method GetStreamVariable
2015-06-28 05:00:27 +02:00
*
* Smarty::getStreamVariable() method
2015-06-28 05:00:27 +02:00
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*/
class Smarty_Internal_Method_GetStreamVariable
2015-06-28 05:00:27 +02:00
{
/**
* Valid for all objects
*
* @var int
*/
public $objMap = 7;
2015-06-28 05:00:27 +02:00
/**
* gets a stream variable
*
* @api Smarty::getStreamVariable()
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
2018-06-12 09:58:15 +02:00
* @param string $variable the stream of the variable
2015-06-28 05:00:27 +02:00
*
* @return mixed
* @throws \SmartyException
*/
public function getStreamVariable(Smarty_Internal_Data $data, $variable)
2015-06-28 05:00:27 +02:00
{
$_result = '';
$fp = fopen($variable, 'r+');
if ($fp) {
while (!feof($fp) && ($current_line = fgets($fp)) !== false) {
$_result .= $current_line;
}
fclose($fp);
return $_result;
}
$smarty = isset($data->smarty) ? $data->smarty : $data;
2015-06-28 05:00:27 +02:00
if ($smarty->error_unassigned) {
throw new SmartyException('Undefined stream variable "' . $variable . '"');
} else {
return null;
}
}
2018-06-12 09:58:15 +02:00
}