Skip to content

Commit

Permalink
Merge pull request #306 from infograf768/case_insensitive_search
Browse files Browse the repository at this point in the history
Allowing case insensitive search in translations view
  • Loading branch information
infograf768 committed Apr 23, 2016
2 parents 1962c30 + 85f1412 commit fdaf562
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 33 deletions.
11 changes: 0 additions & 11 deletions component/admin/models/forms/translations.xml
@@ -1,16 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="search">
<fieldset name="search">
<field
id="expr"
name="expr"
type="search"
label="JSEARCH_FILTER"
placeholder="JSEARCH_FILTER"
description="JSEARCH_FILTER" />
</fieldset>
</fields>
<fields name="select">
<fieldset name="select">
<field
Expand Down
41 changes: 29 additions & 12 deletions component/admin/models/translations.php
Expand Up @@ -72,18 +72,25 @@ protected function populateState($ordering = null, $direction = null)
{
$data = array();
$data['select'] = $app->getUserState('com_localise.select');
$data['search'] = $app->getUserState('com_localise.translations.search');
}
else
{
$app->setUserState('com_localise.select', $data['select']);
$app->setUserState('com_localise.translations.search', isset($data['search']) ? $data['search'] : '');
}

$this->setState(
'filter.search',
isset($data['search']['expr']) ? $data['search']['expr'] : ''
);
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string');
$search = JFilterInput::getInstance()->clean($search, 'TRIM');
$search = strtolower($search);

if ($search)
{
$app->setUserState('filter.search', strtolower($search));
}
else
{
$app->setUserState('filter.search', '');
}

$this->setState(
'filter.storage',
isset($data['select']['storage']) ? $data['select']['storage'] : ''
Expand Down Expand Up @@ -158,7 +165,7 @@ public function getForm()
}

// Check the session for previously entered form data.
$data = $app->getUserState('com_localise.translations.search', array());
$data = $app->getUserState('com_localise.translations.filter.search', array());

// Bind the form data if present.
if (!empty($data))
Expand All @@ -176,14 +183,16 @@ public function getForm()
*/
private function scanLocalTranslationsFolders()
{
$app = JFactory::getApplication();

$filter_storage = $this->getState('filter.storage');
$filter_origin = $this->getState('filter.origin') ? $this->getState('filter.origin') : '.';
$reftag = $this->getState('translations.reference');

if ($filter_storage != 'global')
{
$filter_tag = $this->getState('filter.tag') ? ("^($reftag|" . $this->getState('filter.tag') . ")$") : '.';
$filter_search = $this->getState('filter.search') ? $this->getState('filter.search') : '.';
$filter_search = $app->getUserState('filter.search') ? $app->getUserState('filter.search') : '.';
$scans = LocaliseHelper::getScans($this->getState('filter.client'), $this->getState('filter.type'));

foreach ($scans as $scan)
Expand Down Expand Up @@ -243,6 +252,8 @@ private function scanLocalTranslationsFolders()
*/
private function scanGlobalTranslationsFolders()
{
$app = JFactory::getApplication();

$filter_storage = $this->getState('filter.storage');
$reftag = $this->getState('translations.reference');

Expand All @@ -252,7 +263,7 @@ private function scanGlobalTranslationsFolders()
$filter_client = $this->getState('filter.client');
$filter_tag = $this->getState('filter.tag') ? ("^($reftag|" . $this->getState('filter.tag') . ")$") : '.';
$filter_type = $this->getState('filter.type') ? $this->getState('filter.type') : '.';
$filter_search = $this->getState('filter.search') ? $this->getState('filter.search') : '.';
$filter_search = $app->getUserState('filter.search') ? $app->getUserState('filter.search') : '.';
$filter_origin = $this->getState('filter.origin') ? $this->getState('filter.origin') : '.';

if (empty($filter_client))
Expand Down Expand Up @@ -380,9 +391,11 @@ private function scanGlobalTranslationsFolders()
*/
private function scanReference()
{
$app = JFactory::getApplication();

$reftag = $this->getState('translations.reference');
$filter_tag = $this->getState('filter.tag') ? ("^($reftag|" . $this->getState('filter.tag') . ")$") : '.';
$filter_search = $this->getState('filter.search') ? $this->getState('filter.search') : '.';
$filter_search = $app->getUserState('filter.search') ? $app->getUserState('filter.search') : '.';
$filter_storage = $this->getState('filter.storage');
$filter_origin = $this->getState('filter.origin');
$filter_client = $this->getState('filter.client');
Expand Down Expand Up @@ -692,14 +705,16 @@ private function scanReference()
*/
private function scanOverride()
{
$app = JFactory::getApplication();

// Scan overrides ini files
$reftag = $this->getState('translations.reference');
$filter_client = $this->getState('filter.client');
$filter_tag = $this->getState('filter.tag') ? ("^($reftag|" . $this->getState('filter.tag') . ")$") : '.';
$filter_storage = $this->getState('filter.storage');
$filter_type = $this->getState('filter.type');
$filter_origin = $this->getState('filter.origin') ? $this->getState('filter.origin') : '.';
$filter_search = $this->getState('filter.search') ? $this->getState('filter.search') : '.';
$filter_search = $app->getUserState('filter.search') ? $app->getUserState('filter.search') : '.';

if ((empty($filter_client) || $filter_client != 'installation')
&& (empty($filter_storage) || $filter_storage == 'global')
Expand Down Expand Up @@ -756,6 +771,8 @@ private function scanOverride()
*/
private function getTranslations()
{
$app = JFactory::getApplication();

if (!isset($this->translations))
{
$filter_client = $this->getState('filter.client');
Expand Down Expand Up @@ -787,7 +804,7 @@ private function getTranslations()
. ($this->getState('filter.storage') ? $this->getState('filter.storage') . '-' : '')
. ($this->getState('filter.tag') ? ("^(" . $this->getState('translations.reference') . "|" . $this->getState('filter.tag') . ")$") . '-' : '')
. ($this->getState('filter.type') ? $this->getState('filter.type') . '-' : '')
. ($this->getState('filter.search') ? $this->getState('filter.search') . '-' : '')
. ($app->getUserState('filter.search') ? $app->getUserState('filter.search') . '-' : '')
. ($this->getState('filter.origin') ? $this->getState('filter.origin') . '-' : '');

$key = substr($key, 0, strlen($key) - 1);
Expand Down
26 changes: 16 additions & 10 deletions component/admin/views/translations/tmpl/default_head.php
Expand Up @@ -12,13 +12,19 @@
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
?>
<tr>
<th width="20" class="center hidden-phone">#</th>
<th width="100" class="center hidden-phone"><?php echo JText::_('COM_LOCALISE_HEADING_TRANSLATIONS_INFORMATION'); ?></th>
<th width="50" class="center"><?php echo JText::_('COM_LOCALISE_TOOLBAR_PACKAGES_LANGUAGE'); ?></th>
<th width="100" class="center hidden-phone"><?php echo JText::_('COM_LOCALISE_HEADING_LANGUAGES_CLIENT'); ?></th>
<th width="250" class="title"><?php echo JHtml::_('searchtools.sort', 'COM_LOCALISE_HEADING_LANGUAGES_FILES', 'filename', $listDirn, $listOrder); ?></th>
<th width="120" class="center"><?php echo JHtml::_('searchtools.sort', 'COM_LOCALISE_HEADING_TRANSLATIONS_TRANSLATED', 'completed', $listDirn, $listOrder); ?></th>
<th width="120" class="center"><?php echo JHtml::_('searchtools.sort', 'COM_LOCALISE_HEADING_TRANSLATIONS_PHRASES', 'translated', $listDirn, $listOrder); ?></th>
<th width="100" class="hidden-phone"><?php echo JText::_('COM_LOCALISE_HEADING_TRANSLATIONS_AUTHOR'); ?></th>
</tr>
<?php if (empty($this->items)) : ?>
<div class="alert alert-no-items">
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
</div>
<?php else : ?>
<tr>
<th width="20" class="center hidden-phone">#</th>
<th width="100" class="center hidden-phone"><?php echo JText::_('COM_LOCALISE_HEADING_TRANSLATIONS_INFORMATION'); ?></th>
<th width="50" class="center"><?php echo JText::_('COM_LOCALISE_TOOLBAR_PACKAGES_LANGUAGE'); ?></th>
<th width="100" class="center hidden-phone"><?php echo JText::_('COM_LOCALISE_HEADING_LANGUAGES_CLIENT'); ?></th>
<th width="250" class="title"><?php echo JHtml::_('searchtools.sort', 'COM_LOCALISE_HEADING_LANGUAGES_FILES', 'filename', $listDirn, $listOrder); ?></th>
<th width="120" class="center"><?php echo JHtml::_('searchtools.sort', 'COM_LOCALISE_HEADING_TRANSLATIONS_TRANSLATED', 'completed', $listDirn, $listOrder); ?></th>
<th width="120" class="center"><?php echo JHtml::_('searchtools.sort', 'COM_LOCALISE_HEADING_TRANSLATIONS_PHRASES', 'translated', $listDirn, $listOrder); ?></th>
<th width="100" class="hidden-phone"><?php echo JText::_('COM_LOCALISE_HEADING_TRANSLATIONS_AUTHOR'); ?></th>
</tr>
<?php endif; ?>

0 comments on commit fdaf562

Please sign in to comment.