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_getconfigvars.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Smarty Method GetConfigVars
  4. *
  5. * Smarty::getConfigVars() method
  6. *
  7. * @package Smarty
  8. * @subpackage PluginsInternal
  9. * @author Uwe Tews
  10. */
  11. class Smarty_Internal_Method_GetConfigVars
  12. {
  13. /**
  14. * Valid for all objects
  15. *
  16. * @var int
  17. */
  18. public $objMap = 7;
  19. /**
  20. * Returns a single or all config variables
  21. *
  22. * @api Smarty::getConfigVars()
  23. * @link http://www.smarty.net/docs/en/api.get.config.vars.tpl
  24. *
  25. * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
  26. * @param string $varname variable name or null
  27. * @param bool $search_parents include parent templates?
  28. *
  29. * @return mixed variable value or or array of variables
  30. */
  31. public function getConfigVars(Smarty_Internal_Data $data, $varname = null, $search_parents = true)
  32. {
  33. $_ptr = $data;
  34. $var_array = array();
  35. while ($_ptr !== null) {
  36. if (isset($varname)) {
  37. if (isset($_ptr->config_vars[$varname])) {
  38. return $_ptr->config_vars[$varname];
  39. }
  40. } else {
  41. $var_array = array_merge($_ptr->config_vars, $var_array);
  42. }
  43. // not found, try at parent
  44. if ($search_parents) {
  45. $_ptr = $_ptr->parent;
  46. } else {
  47. $_ptr = null;
  48. }
  49. }
  50. if (isset($varname)) {
  51. return '';
  52. } else {
  53. return $var_array;
  54. }
  55. }
  56. }