Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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. }