PageRenderTime 54ms CodeModel.GetById 32ms app.highlight 3ms RepoModel.GetById 17ms app.codeStats 0ms

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