You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

smarty_internal_method_getstreamvariable.php 1.2KB

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