Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
2809 rexy 1
<?php
2
 
3
/**
4
 * Smarty Method GetStreamVariable
5
 *
6
 * Smarty::getStreamVariable() method
7
 *
8
 * @package    Smarty
9
 * @subpackage PluginsInternal
10
 * @author     Uwe Tews
11
 */
12
class Smarty_Internal_Method_GetStreamVariable
13
{
14
    /**
15
     * Valid for all objects
16
     *
17
     * @var int
18
     */
19
    public $objMap = 7;
20
 
21
    /**
22
     * gets  a stream variable
23
     *
24
     * @api Smarty::getStreamVariable()
25
     *
26
     * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
27
     * @param string                                                  $variable the stream of the variable
28
     *
29
     * @return mixed
30
     * @throws \SmartyException
31
     */
32
    public function getStreamVariable(Smarty_Internal_Data $data, $variable)
33
    {
34
        $_result = '';
35
        $fp = fopen($variable, 'r+');
36
        if ($fp) {
37
            while (!feof($fp) && ($current_line = fgets($fp)) !== false) {
38
                $_result .= $current_line;
39
            }
40
            fclose($fp);
41
            return $_result;
42
        }
43
        $smarty = isset($data->smarty) ? $data->smarty : $data;
44
        if ($smarty->error_unassigned) {
45
            throw new SmartyException('Undefined stream variable "' . $variable . '"');
46
        } else {
47
            return null;
48
        }
49
    }
50
}