29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-08-26 04:59:48 +00:00

#$ [#27565] Move Smart Search content type-specific language strings

into their respective plug-ins. Thanks Chris.
This commit is contained in:
Chris Davenport 2012-01-10 10:29:14 +01:00 committed by Jean-Marie Simonet
parent bb29bf5277
commit ad8af3419f
20 changed files with 211 additions and 74 deletions

View File

@ -9,6 +9,8 @@
defined('_JEXEC') or die;
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/language.php');
/**
* HTML behavior class for Finder.
*
@ -27,10 +29,10 @@ abstract class JHtmlFinder
*/
public static function typeslist()
{
$lang = &JFactory::getLanguage();
$lang = JFactory::getLanguage();
// Load the finder types.
$db = &JFactory::getDBO();
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('DISTINCT t.title AS text, t.id AS value');
$query->from($db->quoteName('#__finder_types') . ' AS t');
@ -50,8 +52,8 @@ abstract class JHtmlFinder
foreach ($rows as $row)
{
$key = $lang->hasKey('COM_FINDER_TYPE_P_' . strtoupper(str_replace(' ', '_', $row->text)))
? 'COM_FINDER_TYPE_P_' . strtoupper(str_replace(' ', '_', $row->text)) : $row->text;
$key = $lang->hasKey(FinderHelperLanguage::branchPlural($row->text))
? FinderHelperLanguage::branchPlural($row->text) : $row->text;
$string = JText::sprintf('COM_FINDER_ITEM_X_ONLY', JText::_($key));
$options[] = JHtml::_('select.option', $row->value, $string);
}
@ -68,10 +70,10 @@ abstract class JHtmlFinder
*/
public static function mapslist()
{
$lang = &JFactory::getLanguage();
$lang = JFactory::getLanguage();
// Load the finder types.
$db = &JFactory::getDBO();
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('title AS text, id AS value');
$query->from($db->quoteName('#__finder_taxonomy'));
@ -92,8 +94,8 @@ abstract class JHtmlFinder
foreach ($rows as $row)
{
$key = $lang->hasKey('COM_FINDER_TYPE_P_' . strtoupper($row->text))
? 'COM_FINDER_TYPE_P_' . strtoupper(str_replace(' ', '_', $row->text)) : $row->text;
$key = $lang->hasKey(FinderHelperLanguage::branchPlural($row->text))
? FinderHelperLanguage::branchPlural($row->text) : $row->text;
$string = JText::sprintf('COM_FINDER_ITEM_X_ONLY', JText::_($key));
$options[] = JHtml::_('select.option', $row->value, $string);
}

View File

@ -13,6 +13,7 @@ defined('_JEXEC') or die;
JLoader::register('FinderIndexerHelper', dirname(__FILE__) . '/helper.php');
JLoader::register('FinderIndexerTaxonomy', dirname(__FILE__) . '/taxonomy.php');
JLoader::register('FinderHelperRoute', JPATH_SITE . '/components/com_finder/helpers/route.php');
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/language.php');
/**
* Query class for the Finder indexer package.
@ -772,7 +773,7 @@ class FinderIndexerQuery
foreach (FinderIndexerTaxonomy::getBranchTitles() as $branch)
{
// Add the pattern.
$patterns[$branch] = JString::strtolower(JText::_('COM_FINDER_QUERY_FILTER_BRANCH_' . $branch));
$patterns[$branch] = JString::strtolower(JText::_(FinderHelperLanguage::branchSingular($branch)));
}
// Container for search terms and phrases.

View File

@ -0,0 +1,105 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('_JEXEC') or die;
/**
* Finder language helper class.
*
* @package Joomla.Administrator
* @subpackage com_finder
* @since 2.5
*/
class FinderHelperLanguage
{
/**
* Method to return a plural language code for a taxonomy branch.
*
* @param string Branch title.
*
* @return string Language key code.
*/
public static function branchPlural($branchName)
{
$return = preg_replace('/[^a-zA-Z0-9]+/', '_', strtoupper($branchName));
return 'PLG_FINDER_QUERY_FILTER_BRANCH_P_'.$return;
}
/**
* Method to return a singular language code for a taxonomy branch.
*
* @param string Branch name.
*
* @return string Language key code.
*/
public static function branchSingular($branchName)
{
$return = preg_replace('/[^a-zA-Z0-9]+/', '_', strtoupper($branchName));
return 'PLG_FINDER_QUERY_FILTER_BRANCH_S_'.$return;
}
/**
* Method to load Smart Search component language file.
*
* @return void
*
* @since 2.5
*/
public static function loadComponentLanguage()
{
$lang = JFactory::getLanguage();
$lang->load('com_finder', JPATH_SITE);
}
/**
* Method to load Smart Search plug-in language files.
*
* @return void
*
* @since 2.5
*/
public static function loadPluginLanguage()
{
static $loaded = false;
// If already loaded, don't load again.
if ($loaded) {
return;
}
$loaded = true;
// Get array of all the enabled Smart Search plug-in names.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('name');
$query->from($db->quoteName('#__extensions'));
$query->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
$query->where($db->quoteName('folder') . ' = ' . $db->quote('finder'));
$query->where($db->quoteName('enabled') . ' = 1');
$db->setQuery($query);
$plugins = $db->loadObjectList();
if (empty($plugins)) {
return;
}
// Load generic language strings.
$lang = JFactory::getLanguage();
$lang->load('plg_content_finder', JPATH_ADMINISTRATOR);
// Load language file for each plug-in.
foreach ($plugins as $plugin) {
$lang->load($plugin->name, JPATH_ADMINISTRATOR);
}
}
}

View File

@ -126,8 +126,9 @@ Joomla.submitbutton = function(pressbutton) {
</td>
<td class="center nowrap">
<?php
$key = $lang->hasKey('COM_FINDER_TYPE_S_' . strtoupper(str_replace(' ', '_', $item->t_title))) ? 'COM_FINDER_TYPE_S_' . strtoupper(str_replace(' ', '_', $item->t_title)) : $item->t_title;
echo JText::_($key); ?>
$key = FinderHelperLanguage::branchSingular($item->t_title);
echo $lang->hasKey($key) ? JText::_($key) : $item->t_title;
?>
</td>
<td class="nowrap">
<?php

View File

@ -11,6 +11,8 @@ defined('_JEXEC') or die;
jimport('joomla.application.component.view');
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/language.php');
/**
* Index view class for Finder.
*
@ -31,6 +33,9 @@ class FinderViewIndex extends JView
*/
public function display($tpl = null)
{
// Load plug-in language files.
FinderHelperLanguage::loadPluginLanguage();
// Initialise variables
$this->items = $this->get('Items');
$this->total = $this->get('Total');

View File

@ -88,7 +88,7 @@ Joomla.submitbutton = function(pressbutton) {
</td>
<td>
<?php
$key = 'COM_FINDER_TYPE_S_' . strtoupper(str_replace(' ', '_', $item->title));
$key = FinderHelperLanguage::branchSingular($item->title);
$title = $lang->hasKey($key) ? JText::_($key) : $item->title;
?>
<?php if ($this->state->get('filter.branch') == 1 && $item->num_children) : ?>

View File

@ -11,6 +11,8 @@ defined('_JEXEC') or die;
jimport('joomla.application.component.view');
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/language.php');
/**
* Groups view class for Finder.
*
@ -31,6 +33,9 @@ class FinderViewMaps extends JView
*/
public function display($tpl = null)
{
// Load plug-in language files.
FinderHelperLanguage::loadPluginLanguage();
// Load the view data.
$this->items = $this->get('Items');
$this->total = $this->get('Total');

View File

@ -160,42 +160,6 @@ COM_FINDER_STATISTICS_TITLE="Smart Search Statistics"
COM_FINDER_SUBMENU_FILTERS="Search Filters"
COM_FINDER_SUBMENU_INDEX="Indexed Content"
COM_FINDER_SUBMENU_MAPS="Content Maps"
COM_FINDER_TYPE_P_ARTICLE="Articles"
COM_FINDER_TYPE_P_AUTHOR="Authors"
COM_FINDER_TYPE_P_CATALOG_ITEM="Catalog Item"
COM_FINDER_TYPE_P_CATEGORY="Categories"
COM_FINDER_TYPE_P_CONTACT="Contacts"
COM_FINDER_TYPE_P_COUNTRY="Country"
COM_FINDER_TYPE_P_EVENT="Events"
COM_FINDER_TYPE_P_ISSUE="Issues"
COM_FINDER_TYPE_P_LABEL="Labels"
COM_FINDER_TYPE_P_LANGUAGE="Language"
COM_FINDER_TYPE_P_NEWS_FEED="News Feeds"
COM_FINDER_TYPE_P_PDF="PDFs"
COM_FINDER_TYPE_P_PUBLICATION="Publications"
COM_FINDER_TYPE_P_REGION="Region"
COM_FINDER_TYPE_P_SECTION="Sections"
COM_FINDER_TYPE_P_TYPE="Types"
COM_FINDER_TYPE_P_VENUE="Venues"
COM_FINDER_TYPE_P_WEB_LINK="Web Links"
COM_FINDER_TYPE_S_ARTICLE="Article"
COM_FINDER_TYPE_S_AUTHOR="Author"
COM_FINDER_TYPE_S_CATALOG_ITEM="Catalog Item"
COM_FINDER_TYPE_S_CATEGORY="Category"
COM_FINDER_TYPE_S_CONTACT="Contact"
COM_FINDER_TYPE_S_COUNTRY="Country"
COM_FINDER_TYPE_S_EVENT="Event"
COM_FINDER_TYPE_S_ISSUE="Issue"
COM_FINDER_TYPE_S_LABEL="Label"
COM_FINDER_TYPE_S_LANGUAGE="Language"
COM_FINDER_TYPE_S_NEWS_FEED="News Feed"
COM_FINDER_TYPE_S_PDF="PDF"
COM_FINDER_TYPE_S_PUBLICATION="Publication"
COM_FINDER_TYPE_S_REGION="Region"
COM_FINDER_TYPE_S_SECTION="Section"
COM_FINDER_TYPE_S_TYPE="Type"
COM_FINDER_TYPE_S_VENUE="Venue"
COM_FINDER_TYPE_S_WEB_LINK="Web Link"
COM_FINDER_UPDATER_MESSAGE_COMPLETE="Smart Search is up to date."
COM_FINDER_UPDATER_MESSAGE_OPTIMIZE="Smart Search is optimizing."
COM_FINDER_UPDATER_MESSAGE_PROCESS="Smart Search is updating."

View File

@ -5,3 +5,13 @@
PLG_CONTENT_FINDER="Content - Smart Search"
PLG_CONTENT_FINDER_XML_DESCRIPTION="Enables Indexing for Smart Search"
PLG_FINDER_QUERY_FILTER_BRANCH_P__="All"
PLG_FINDER_QUERY_FILTER_BRANCH_S_TYPE="Type"
PLG_FINDER_QUERY_FILTER_BRANCH_S_LANGUAGE="Language"
PLG_FINDER_QUERY_FILTER_BRANCH_S_CATEGORY="Category"
PLG_FINDER_QUERY_FILTER_BRANCH_P_TYPE="Types"
PLG_FINDER_QUERY_FILTER_BRANCH_P_LANGUAGE="Languages"
PLG_FINDER_QUERY_FILTER_BRANCH_P_CATEGORY="Categories"

View File

@ -5,3 +5,11 @@
PLG_FINDER_CONTACTS="Smart Search - Contacts"
PLG_FINDER_CONTACTS_XML_DESCRIPTION="This plugin indexes Joomla! Contacts."
PLG_FINDER_QUERY_FILTER_BRANCH_S_CONTACT="Contact"
PLG_FINDER_QUERY_FILTER_BRANCH_S_REGION="Region"
PLG_FINDER_QUERY_FILTER_BRANCH_S_COUNTRY="Country"
PLG_FINDER_QUERY_FILTER_BRANCH_P_CONTACT="Contacts"
PLG_FINDER_QUERY_FILTER_BRANCH_P_REGION="Regions"
PLG_FINDER_QUERY_FILTER_BRANCH_P_COUNTRY="Countries"

View File

@ -5,3 +5,9 @@
PLG_FINDER_CONTENT="Smart Search - Content"
PLG_FINDER_CONTENT_XML_DESCRIPTION="This plugin indexes Joomla! Articles."
PLG_FINDER_QUERY_FILTER_BRANCH_S_ARTICLE="Article"
PLG_FINDER_QUERY_FILTER_BRANCH_S_AUTHOR="Author"
PLG_FINDER_QUERY_FILTER_BRANCH_P_ARTICLE="Articles"
PLG_FINDER_QUERY_FILTER_BRANCH_P_AUTHOR="Authors"

View File

@ -5,3 +5,6 @@
PLG_FINDER_NEWSFEEDS="Smart Search - Newsfeeds"
PLG_FINDER_NEWSFEEDS_XML_DESCRIPTION="This plugin indexes Joomla! Newsfeeds."
PLG_FINDER_QUERY_FILTER_BRANCH_S_NEWS_FEED="News feed"
PLG_FINDER_QUERY_FILTER_BRANCH_P_NEWS_FEED="News feeds"

View File

@ -5,3 +5,6 @@
PLG_FINDER_WEBLINKS="Smart Search - Weblinks"
PLG_FINDER_WEBLINKS_XML_DESCRIPTION="This plugin indexes Joomla! Weblinks."
PLG_FINDER_QUERY_FILTER_BRANCH_S_WEB_LINK="Web link"
PLG_FINDER_QUERY_FILTER_BRANCH_P_WEB_LINK="Web links"

View File

@ -124,8 +124,9 @@ Joomla.submitbutton = function(pressbutton) {
</td>
<td class="center nowrap">
<?php
$key = $lang->hasKey('COM_FINDER_TYPE_S_' . strtoupper(str_replace(' ', '_', $item->t_title))) ? 'COM_FINDER_TYPE_S_' . strtoupper(str_replace(' ', '_', $item->t_title)) : $item->t_title;
echo JText::_($key); ?>
$key = FinderHelperLanguage::branchSingular($item->t_title);
echo $lang->hasKey($key) ? JText::_($key) : $item->t_title;
?>
</td>
<td class="nowrap">
<?php

View File

@ -101,8 +101,8 @@ Joomla.submitbutton = function(pressbutton) {
</th>
<td>
<?php
$key = 'COM_FINDER_TYPE_S_' . strtoupper(str_replace(' ', '_', $item->title));
$title = $lang->hasKey($key) ? JText::_($key) : $item->title;
$key = FinderHelperLanguage::branchSingular($item->title);
echo $lang->hasKey($key) ? JText::_($key) : $item->title;
?>
<?php if ($this->state->get('filter.branch') == 1 && $item->num_children) : ?>
<a href="#" onclick="document.id('filter_branch').value='<?php echo (int) $item->id;?>';document.adminForm.submit();" title="<?php echo JText::_('COM_FINDER_MAPS_BRANCH_LINK'); ?>">

View File

@ -11,6 +11,8 @@ defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/language.php');
/**
* Finder Component Controller.
*
@ -38,11 +40,14 @@ class FinderController extends JController
$cachable = true;
$user = JFactory::getUser();
// Load plug-in language files.
FinderHelperLanguage::loadPluginLanguage();
// Set the default view name and format from the Request.
$viewName = $input->get('view', 'search', 'word');
$input->set('view', $viewName);
if ($user->get('id') || ($_SERVER['REQUEST_METHOD'] == 'POST' && $vName = 'search'))
if ($user->get('id') || ($_SERVER['REQUEST_METHOD'] == 'POST' && $viewName = 'search'))
{
$cachable = false;
}

View File

@ -9,6 +9,8 @@
defined('_JEXEC') or die;
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/language.php');
/**
* Filter HTML Behaviors for Finder.
*
@ -114,6 +116,9 @@ abstract class JHtmlFilter
JHtml::script('com_finder/sliderfilter.js', false, true);
}
// Load plug-in language files.
FinderHelperLanguage::loadPluginLanguage();
// Start the widget.
$html .= '<div id="finder-filter-container">';
$html .= '<dl id="branch-selectors">';
@ -130,7 +135,7 @@ abstract class JHtmlFilter
$html .= '<dd>';
$html .= '<label for="tax-' . $bk . '">';
$html .= '<input type="checkbox" class="toggler" id="tax-' . $bk . '"/>';
$html .= JText::sprintf('COM_FINDER_FILTER_BRANCH_LABEL', JText::_('COM_FINDER_TYPE_P_'.$bv->title));
$html .= JText::sprintf('COM_FINDER_FILTER_BRANCH_LABEL', JText::_(FinderHelperLanguage::branchSingular($bv->title)));
$html .= '</label>';
$html .= '</dd>';
}
@ -159,13 +164,22 @@ abstract class JHtmlFilter
{
return null;
}
// Translate node titles if possible.
$lang = JFactory::getLanguage();
foreach ($nodes as $nk => $nv) {
$key = FinderHelperLanguage::branchPlural($nv->title);
if ($lang->hasKey($key)) {
$nodes[$nk]->title = JText::_($key);
}
}
// Start the group.
$html .= '<dl class="checklist" rel="tax-' . $bk . '">';
$html .= '<dt>';
$html .= '<label for="tax-' . JFilterOutput::stringUrlSafe($bv->title) . '">';
$html .= '<input type="checkbox" class="branch-selector filter-branch' . $classSuffix . '" id="tax-' . JFilterOutput::stringUrlSafe($bv->title) . '" />';
$html .= JText::sprintf('COM_FINDER_FILTER_BRANCH_LABEL', JText::_('COM_FINDER_TYPE_P_'.$bv->title));
$html .= JText::sprintf('COM_FINDER_FILTER_BRANCH_LABEL', JText::_(FinderHelperLanguage::branchSingular($bv->title)));
$html .= '</label>';
$html .= '</dt>';
@ -211,6 +225,7 @@ abstract class JHtmlFilter
$db = JFactory::getDBO();
$sql = $db->getQuery(true);
$user = JFactory::getUser();
$app = JFactory::getApplication();
$groups = implode(',', $user->getAuthorisedViewLevels());
$html = '';
$in = '';
@ -317,6 +332,11 @@ abstract class JHtmlFilter
// Iterate through the branches and build the branch groups.
foreach ($branches as $bk => $bv)
{
// If the multi-lang plug-in is enabled then drop the language branch.
if ($bv->title == 'Language' && $app->isSite() && $app->getLanguageFilter()) {
continue;
}
// Build the query to get the child nodes for this branch.
$sql->clear();
$sql->select('t.*');
@ -348,15 +368,15 @@ abstract class JHtmlFilter
continue;
}
// Translate branch nodes if possible.
$language = JFactory::getLanguage();
foreach($nodes as $node_id => $node) {
$node_key = 'COM_FINDER_FILTER_BRANCH_' . preg_replace('/[^a-zA-Z0-9]+/', '_', $bv->title) . '_NODE_' . preg_replace('/[^a-zA-Z0-9]+/', '_', $node->title);
if ($language->hasKey($node_key)) {
$nodes[$node_id]->title = JText::_($node_key);
// Translate node titles if possible.
$lang = JFactory::getLanguage();
foreach ($nodes as $node_id => $node) {
$key = FinderHelperLanguage::branchPlural($node->title);
if ($lang->hasKey($key)) {
$nodes[$node_id]->title = JText::_($key);
}
}
// Add the Search All option to the branch.
array_unshift($nodes, array('id' => null, 'title' => JText::_('COM_FINDER_FILTER_SELECT_ALL_LABEL')));
@ -375,7 +395,7 @@ abstract class JHtmlFilter
$html .= '<li class="filter-branch' . $classSuffix . '">';
$html .= '<label for="tax-' . JFilterOutput::stringUrlSafe($bv->title) . '">';
$html .= JText::sprintf('COM_FINDER_FILTER_BRANCH_LABEL', JText::_('COM_FINDER_QUERY_FILTER_BRANCH_'.$bv->title));
$html .= JText::sprintf('COM_FINDER_FILTER_BRANCH_LABEL', JText::_(FinderHelperLanguage::branchSingular($bv->title)));
$html .= '</label>';
$html .= JHtml::_('select.genericlist', $nodes, 't[]', 'class="inputbox"', 'id', 'title', $active, 'tax-' . JFilterOutput::stringUrlSafe($bv->title));
$html .= '</li>';

View File

@ -29,6 +29,7 @@ $ -> Language fix or change
10-Jan-2012 Jean-Marie Simonet
$ Updating installation ini files az-AZ, bg-BG, ckb-IQ, da-DK, de-DE, es-ES, et-EE, fi-FI, hu-HU, it-IT, ja-JP, km-KH, mk-MK, nl-NL, sr-SR, sr-YU, sv-SE, ta-IN
#$ [#27565] Move Smart Search content type-specific language strings into their respective plug-ins. Thanks Chris.
10-Jan-2012 Mark Dexter
# [#27634] PHP Strict error for SQLServer (merge with 11.4 platform)

View File

@ -19,15 +19,6 @@ COM_FINDER_FILTER_SELECT_ALL_LABEL="Search All"
COM_FINDER_FILTER_WHEN_AFTER="After"
COM_FINDER_FILTER_WHEN_BEFORE="Before"
COM_FINDER_QUERY_END_DATE="ending date <span class="_QQ_"when"_QQ_">%s</span> <span class="_QQ_"date"_QQ_">%s</span>"
COM_FINDER_QUERY_FILTER_BRANCH_AUTHOR="author"
COM_FINDER_QUERY_FILTER_BRANCH_CATEGORY="category"
COM_FINDER_QUERY_FILTER_BRANCH_COUNTRY="country"
COM_FINDER_QUERY_FILTER_BRANCH_EVENT="event"
COM_FINDER_QUERY_FILTER_BRANCH_ISSUE="issue"
COM_FINDER_QUERY_FILTER_BRANCH_LABEL="label"
COM_FINDER_QUERY_FILTER_BRANCH_LANGUAGE="language"
COM_FINDER_QUERY_FILTER_BRANCH_REGION="region"
COM_FINDER_QUERY_FILTER_BRANCH_TYPE="type"
COM_FINDER_QUERY_OPERATOR_AND="and"
COM_FINDER_QUERY_OPERATOR_OR="or"
COM_FINDER_QUERY_OPERATOR_NOT="not"
@ -44,4 +35,3 @@ COM_FINDER_SEARCH_NO_RESULTS_HEADING="No Results Found"
COM_FINDER_SEARCH_RESULTS_OF="Results <strong>%s</strong> - <strong>%s</strong> of <strong>%s</strong>"
COM_FINDER_SEARCH_SIMILAR="Did you mean: %s?"
COM_FINDER_SEARCH_TERMS="Search Terms:"
COM_FINDER_FILTER_BRANCH_LANGUAGE_NODE__="All"

View File

@ -11,6 +11,7 @@ defined('_JEXEC') or die;
// Register dependent classes.
JLoader::register('FinderHelperRoute', JPATH_SITE . '/components/com_finder/helpers/route.php');
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/language.php');
// Include the helper.
require_once dirname(__FILE__) . '/helper.php';
@ -38,4 +39,10 @@ $params->def('field_size', 20);
// Get the route.
$route = FinderHelperRoute::getSearchRoute($params->get('f', null));
// Load component language file.
FinderHelperLanguage::loadComponentLanguage();
// Load plug-in language files.
FinderHelperLanguage::loadPluginLanguage();
require JModuleHelper::getLayoutPath('mod_finder', $params->get('layout', 'default'));