[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_finder 6 * 7 * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE 9 */ 10 11 namespace Joomla\Component\Finder\Administrator\Helper; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Language\LanguageHelper as CMSLanguageHelper; 15 use Joomla\CMS\Language\Text; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('_JEXEC') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Finder language helper class. 23 * 24 * @since 2.5 25 */ 26 class LanguageHelper 27 { 28 /** 29 * Method to return a plural language code for a taxonomy branch. 30 * 31 * @param string $branchName Branch title. 32 * 33 * @return string Language key code. 34 * 35 * @since 2.5 36 */ 37 public static function branchPlural($branchName) 38 { 39 $return = preg_replace('/[^a-zA-Z0-9]+/', '_', strtoupper($branchName)); 40 41 if ($return !== '_') { 42 return 'PLG_FINDER_QUERY_FILTER_BRANCH_P_' . $return; 43 } 44 45 return $branchName; 46 } 47 48 /** 49 * Method to return a singular language code for a taxonomy branch. 50 * 51 * @param string $branchName Branch name. 52 * 53 * @return string Language key code. 54 * 55 * @since 2.5 56 */ 57 public static function branchSingular($branchName) 58 { 59 $return = preg_replace('/[^a-zA-Z0-9]+/', '_', strtoupper($branchName)); 60 $language = Factory::getApplication()->getLanguage(); 61 62 if ($language->hasKey('PLG_FINDER_QUERY_FILTER_BRANCH_S_' . $return) || JDEBUG) { 63 return 'PLG_FINDER_QUERY_FILTER_BRANCH_S_' . $return; 64 } 65 66 return $branchName; 67 } 68 69 /** 70 * Method to return the language name for a language taxonomy branch. 71 * 72 * @param string $branchName Language branch name. 73 * 74 * @return string The language title. 75 * 76 * @since 3.6.0 77 */ 78 public static function branchLanguageTitle($branchName) 79 { 80 $title = $branchName; 81 82 if ($branchName === '*') { 83 $title = Text::_('JALL_LANGUAGE'); 84 } else { 85 $languages = CMSLanguageHelper::getLanguages('lang_code'); 86 87 if (isset($languages[$branchName])) { 88 $title = $languages[$branchName]->title; 89 } 90 } 91 92 return $title; 93 } 94 95 /** 96 * Method to load Smart Search component language file. 97 * 98 * @return void 99 * 100 * @since 2.5 101 */ 102 public static function loadComponentLanguage() 103 { 104 Factory::getLanguage()->load('com_finder', JPATH_SITE); 105 } 106 107 /** 108 * Method to load Smart Search plugin language files. 109 * 110 * @return void 111 * 112 * @since 2.5 113 */ 114 public static function loadPluginLanguage() 115 { 116 static $loaded = false; 117 118 // If already loaded, don't load again. 119 if ($loaded) { 120 return; 121 } 122 123 $loaded = true; 124 125 // Get array of all the enabled Smart Search plugin names. 126 $db = Factory::getDbo(); 127 $query = $db->getQuery(true) 128 ->select(array($db->quoteName('name'), $db->quoteName('element'))) 129 ->from($db->quoteName('#__extensions')) 130 ->where($db->quoteName('type') . ' = ' . $db->quote('plugin')) 131 ->where($db->quoteName('folder') . ' = ' . $db->quote('finder')) 132 ->where($db->quoteName('enabled') . ' = 1'); 133 $db->setQuery($query); 134 $plugins = $db->loadObjectList(); 135 136 if (empty($plugins)) { 137 return; 138 } 139 140 // Load generic language strings. 141 $lang = Factory::getLanguage(); 142 $lang->load('plg_content_finder', JPATH_ADMINISTRATOR); 143 144 // Load language file for each plugin. 145 foreach ($plugins as $plugin) { 146 $lang->load($plugin->name, JPATH_ADMINISTRATOR) 147 || $lang->load($plugin->name, JPATH_PLUGINS . '/finder/' . $plugin->element); 148 } 149 } 150 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |