config_functions.lib.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Common config manipulation functions
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. /**
  9. * Returns sanitized language string, taking into account our special codes
  10. * for formatting. Takes variable number of arguments.
  11. * Based on PMA_sanitize from sanitize.lib.php.
  12. *
  13. * @param string $lang_key key in $GLOBALS WITHOUT 'strSetup' prefix
  14. * @param mixed $args,... arguments for sprintf
  15. *
  16. * @return string
  17. */
  18. function PMA_lang($lang_key, $args = null)
  19. {
  20. $message = isset($GLOBALS["strConfig$lang_key"])
  21. ? $GLOBALS["strConfig$lang_key"] : $lang_key;
  22. $message = PMA_sanitize($message);
  23. if (func_num_args() == 1) {
  24. return $message;
  25. } else {
  26. $args = func_get_args();
  27. array_shift($args);
  28. return vsprintf($message, $args);
  29. }
  30. }
  31. /**
  32. * Returns translated field name/description or comment
  33. *
  34. * @param string $canonical_path
  35. * @param string $type 'name', 'desc' or 'cmt'
  36. * @param mixed $default
  37. *
  38. * @return string
  39. */
  40. function PMA_lang_name($canonical_path, $type = 'name', $default = 'key')
  41. {
  42. $lang_key = str_replace(
  43. array('Servers/1/', '/'),
  44. array('Servers/', '_'),
  45. $canonical_path
  46. ) . '_' . $type;
  47. return isset($GLOBALS["strConfig$lang_key"])
  48. ? ($type == 'desc' ? PMA_lang($lang_key) : $GLOBALS["strConfig$lang_key"])
  49. : ($default == 'key' ? $lang_key : $default);
  50. }
  51. ?>