From 85f141241724be877d2203a212df86ef228636d0 Mon Sep 17 00:00:00 2001 From: Jean-Marie Simonet Date: Sat, 23 Apr 2016 17:08:45 +0200 Subject: [PATCH] Allowing case insensitive search in translations view --- component/admin/models/forms/translations.xml | 11 ----- component/admin/models/translations.php | 41 +++++++++++++------ .../views/translations/tmpl/default_head.php | 26 +++++++----- 3 files changed, 45 insertions(+), 33 deletions(-) diff --git a/component/admin/models/forms/translations.xml b/component/admin/models/forms/translations.xml index 23a4aac2..60d7fbfe 100644 --- a/component/admin/models/forms/translations.xml +++ b/component/admin/models/forms/translations.xml @@ -1,16 +1,5 @@
- -
- -
-
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'] : '' @@ -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)) @@ -176,6 +183,8 @@ 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'); @@ -183,7 +192,7 @@ private function scanLocalTranslationsFolders() 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) @@ -243,6 +252,8 @@ private function scanLocalTranslationsFolders() */ private function scanGlobalTranslationsFolders() { + $app = JFactory::getApplication(); + $filter_storage = $this->getState('filter.storage'); $reftag = $this->getState('translations.reference'); @@ -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)) @@ -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'); @@ -692,6 +705,8 @@ private function scanReference() */ private function scanOverride() { + $app = JFactory::getApplication(); + // Scan overrides ini files $reftag = $this->getState('translations.reference'); $filter_client = $this->getState('filter.client'); @@ -699,7 +714,7 @@ private function scanOverride() $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') @@ -756,6 +771,8 @@ private function scanOverride() */ private function getTranslations() { + $app = JFactory::getApplication(); + if (!isset($this->translations)) { $filter_client = $this->getState('filter.client'); @@ -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); diff --git a/component/admin/views/translations/tmpl/default_head.php b/component/admin/views/translations/tmpl/default_head.php index 6880d742..070002bb 100644 --- a/component/admin/views/translations/tmpl/default_head.php +++ b/component/admin/views/translations/tmpl/default_head.php @@ -12,13 +12,19 @@ $listOrder = $this->escape($this->state->get('list.ordering')); $listDirn = $this->escape($this->state->get('list.direction')); ?> - - # - - - - - - - - +items)) : ?> +
+ +
+ + + # + + + + + + + + +