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_getglobal.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Smarty Method GetGlobal
  4. *
  5. * Smarty::getGlobal() method
  6. *
  7. * @package Smarty
  8. * @subpackage PluginsInternal
  9. * @author Uwe Tews
  10. */
  11. class Smarty_Internal_Method_GetGlobal
  12. {
  13. /**
  14. * Valid for all objects
  15. *
  16. * @var int
  17. */
  18. public $objMap = 7;
  19. /**
  20. * Returns a single or all global variables
  21. *
  22. * @api Smarty::getGlobal()
  23. *
  24. * @param \Smarty_Internal_Data $data
  25. * @param string $varName variable name or null
  26. *
  27. * @return string|array variable value or or array of variables
  28. */
  29. public function getGlobal(Smarty_Internal_Data $data, $varName = null)
  30. {
  31. if (isset($varName)) {
  32. if (isset(Smarty::$global_tpl_vars[ $varName ])) {
  33. return Smarty::$global_tpl_vars[ $varName ]->value;
  34. } else {
  35. return '';
  36. }
  37. } else {
  38. $_result = array();
  39. foreach (Smarty::$global_tpl_vars AS $key => $var) {
  40. $_result[ $key ] = $var->value;
  41. }
  42. return $_result;
  43. }
  44. }
  45. }