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_assignglobal.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Smarty Method AssignGlobal
  4. *
  5. * Smarty::assignGlobal() method
  6. *
  7. * @package Smarty
  8. * @subpackage PluginsInternal
  9. * @author Uwe Tews
  10. */
  11. class Smarty_Internal_Method_AssignGlobal
  12. {
  13. /**
  14. * Valid for all objects
  15. *
  16. * @var int
  17. */
  18. public $objMap = 7;
  19. /**
  20. * assigns a global Smarty variable
  21. *
  22. * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
  23. * @param string $varName the global variable name
  24. * @param mixed $value the value to assign
  25. * @param boolean $nocache if true any output of this variable will be not cached
  26. *
  27. * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
  28. */
  29. public function assignGlobal(Smarty_Internal_Data $data, $varName, $value = null, $nocache = false)
  30. {
  31. if ($varName != '') {
  32. Smarty::$global_tpl_vars[$varName] = new Smarty_Variable($value, $nocache);
  33. $ptr = $data;
  34. while ($ptr->_objType == 2) {
  35. $ptr->tpl_vars[$varName] = clone Smarty::$global_tpl_vars[$varName];
  36. $ptr = $ptr->parent;
  37. }
  38. }
  39. return $data;
  40. }
  41. }