core.assign_smarty_interface.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Smarty plugin
  4. * @package Smarty
  5. * @subpackage plugins
  6. */
  7. /**
  8. * Smarty assign_smarty_interface core plugin
  9. *
  10. * Type: core<br>
  11. * Name: assign_smarty_interface<br>
  12. * Purpose: assign the $smarty interface variable
  13. * @param array Format: null
  14. * @param Smarty
  15. */
  16. function smarty_core_assign_smarty_interface($params, &$smarty)
  17. {
  18. if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) {
  19. return;
  20. }
  21. $_globals_map = array('g' => 'HTTP_GET_VARS',
  22. 'p' => 'HTTP_POST_VARS',
  23. 'c' => 'HTTP_COOKIE_VARS',
  24. 's' => 'HTTP_SERVER_VARS',
  25. 'e' => 'HTTP_ENV_VARS');
  26. $_smarty_vars_request = array();
  27. foreach (preg_split('!!', strtolower($smarty->request_vars_order)) as $_c) {
  28. if (isset($_globals_map[$_c])) {
  29. $_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]);
  30. }
  31. }
  32. $_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']);
  33. $smarty->_smarty_vars['request'] = $_smarty_vars_request;
  34. }
  35. /* vim: set expandtab: */
  36. ?>