/administrator/components/com_finder/helpers/language.php

https://bitbucket.org/eternaware/joomus · PHP · 107 lines · 48 code · 13 blank · 46 comment · 2 complexity · 86d66cf25f59c65a2dd6ac9d9b344676 MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joomla.Administrator
  4. * @subpackage com_finder
  5. *
  6. * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE
  8. */
  9. defined('_JEXEC') or die;
  10. /**
  11. * Finder language helper class.
  12. *
  13. * @package Joomla.Administrator
  14. * @subpackage com_finder
  15. * @since 2.5
  16. */
  17. class FinderHelperLanguage
  18. {
  19. /**
  20. * Method to return a plural language code for a taxonomy branch.
  21. *
  22. * @param string Branch title.
  23. *
  24. * @return string Language key code.
  25. */
  26. public static function branchPlural($branchName)
  27. {
  28. $return = preg_replace('/[^a-zA-Z0-9]+/', '_', strtoupper($branchName));
  29. return 'PLG_FINDER_QUERY_FILTER_BRANCH_P_'.$return;
  30. }
  31. /**
  32. * Method to return a singular language code for a taxonomy branch.
  33. *
  34. * @param string Branch name.
  35. *
  36. * @return string Language key code.
  37. */
  38. public static function branchSingular($branchName)
  39. {
  40. $return = preg_replace('/[^a-zA-Z0-9]+/', '_', strtoupper($branchName));
  41. return 'PLG_FINDER_QUERY_FILTER_BRANCH_S_'.$return;
  42. }
  43. /**
  44. * Method to load Smart Search component language file.
  45. *
  46. * @return void
  47. *
  48. * @since 2.5
  49. */
  50. public static function loadComponentLanguage()
  51. {
  52. $lang = JFactory::getLanguage();
  53. $lang->load('com_finder', JPATH_SITE);
  54. }
  55. /**
  56. * Method to load Smart Search plug-in language files.
  57. *
  58. * @return void
  59. *
  60. * @since 2.5
  61. */
  62. public static function loadPluginLanguage()
  63. {
  64. static $loaded = false;
  65. // If already loaded, don't load again.
  66. if ($loaded)
  67. {
  68. return;
  69. }
  70. $loaded = true;
  71. // Get array of all the enabled Smart Search plug-in names.
  72. $db = JFactory::getDbo();
  73. $query = $db->getQuery(true);
  74. $query->select('name');
  75. $query->from($db->quoteName('#__extensions'));
  76. $query->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
  77. $query->where($db->quoteName('folder') . ' = ' . $db->quote('finder'));
  78. $query->where($db->quoteName('enabled') . ' = 1');
  79. $db->setQuery($query);
  80. $plugins = $db->loadObjectList();
  81. if (empty($plugins))
  82. {
  83. return;
  84. }
  85. // Load generic language strings.
  86. $lang = JFactory::getLanguage();
  87. $lang->load('plg_content_finder', JPATH_ADMINISTRATOR);
  88. // Load language file for each plug-in.
  89. foreach ($plugins as $plugin)
  90. {
  91. $lang->load($plugin->name, JPATH_ADMINISTRATOR);
  92. }
  93. }
  94. }