From edf1cd368edb06a98fe0be80fb57ed3ea6476125 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Wed, 6 Jun 2018 23:02:43 +0200 Subject: [PATCH 1/8] com_finder: add search statistics --- .../sql/updates/mysql/4.0.0-2918-06-06.sql | 9 + .../updates/postgresql/4.0.0-2918-06-06.sql | 10 + .../Controller/SearchesController.php | 41 ++++ .../com_finder/Helper/FinderHelper.php | 5 + .../com_finder/Model/SearchesModel.php | 175 ++++++++++++++++++ .../com_finder/View/Searches/HtmlView.php | 157 ++++++++++++++++ .../components/com_finder/config.xml | 2 +- .../com_finder/forms/filter_searches.xml | 32 ++++ .../com_finder/sql/install.mysql.sql | 14 ++ .../com_finder/sql/install.postgresql.sql | 15 ++ .../com_finder/sql/uninstall.mysql.sql | 1 + .../com_finder/sql/uninstall.postgresql.sql | 1 + .../com_finder/tmpl/searches/default.php | 75 ++++++++ .../language/en-GB/en-GB.com_finder.ini | 8 + components/com_finder/Helper/FinderHelper.php | 79 ++++++++ .../com_finder/View/Search/HtmlView.php | 4 +- installation/sql/mysql/joomla.sql | 16 ++ installation/sql/postgresql/joomla.sql | 15 ++ 18 files changed, 656 insertions(+), 3 deletions(-) create mode 100644 administrator/components/com_admin/sql/updates/mysql/4.0.0-2918-06-06.sql create mode 100644 administrator/components/com_admin/sql/updates/postgresql/4.0.0-2918-06-06.sql create mode 100644 administrator/components/com_finder/Controller/SearchesController.php create mode 100644 administrator/components/com_finder/Model/SearchesModel.php create mode 100644 administrator/components/com_finder/View/Searches/HtmlView.php create mode 100644 administrator/components/com_finder/forms/filter_searches.xml create mode 100644 administrator/components/com_finder/tmpl/searches/default.php create mode 100644 components/com_finder/Helper/FinderHelper.php diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2918-06-06.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2918-06-06.sql new file mode 100644 index 0000000000000..b265025b2c16c --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2918-06-06.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS `#__finder_logging` ( + `searchterm` VARCHAR(255) NOT NULL DEFAULT '', + `md5sum` VARCHAR(32) NOT NULL DEFAULT '', + `query` BLOB NOT NULL, + `hits` INT(11) NOT NULL DEFAULT '1', + `results` INT(11) NOT NULL DEFAULT '0', + UNIQUE INDEX `md5sum` (`md5sum`), + INDEX `searchterm` (`searchterm`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2918-06-06.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2918-06-06.sql new file mode 100644 index 0000000000000..c0368b06a5530 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2918-06-06.sql @@ -0,0 +1,10 @@ +CREATE TABLE IF NOT EXISTS "#__finder_logging" ( + "searchterm" character varying(255) NOT NULL DEFAULT '', + "md5sum" character varying(32) NOT NULL DEFAULT '', + "query" bytes NOT NULL, + "hits" integer NOT NULL DEFAULT 1, + "results" integer NOT NULL DEFAULT 0, + CONSTRAINT "#__finder_logging_idx_md5sum" UNIQUE ("md5sum") +); +CREATE INDEX "#__finder_logging_idx_md5sum" on "#__finder_logging" ("md5sum"); +CREATE INDEX "#__finder_logging_idx_searchterm" on "#__finder_logging" ("searchterm"); diff --git a/administrator/components/com_finder/Controller/SearchesController.php b/administrator/components/com_finder/Controller/SearchesController.php new file mode 100644 index 0000000000000..734f5b5823655 --- /dev/null +++ b/administrator/components/com_finder/Controller/SearchesController.php @@ -0,0 +1,41 @@ +getModel('Searches'); + + if (!$model->reset()) + { + $this->app->enqueueMessage($model->getError(), 'error'); + } + + $this->setRedirect('index.php?option=com_finder&view=searches'); + } +} diff --git a/administrator/components/com_finder/Helper/FinderHelper.php b/administrator/components/com_finder/Helper/FinderHelper.php index b7bc2f732e271..2dcc2b40efa6f 100644 --- a/administrator/components/com_finder/Helper/FinderHelper.php +++ b/administrator/components/com_finder/Helper/FinderHelper.php @@ -53,6 +53,11 @@ public static function addSubmenu($vName) 'index.php?option=com_finder&view=filters', $vName === 'filters' ); + \JHtmlSidebar::addEntry( + \JText::_('COM_FINDER_SUBMENU_SEARCHES'), + 'index.php?option=com_finder&view=searches', + $vName === 'searches' + ); } /** diff --git a/administrator/components/com_finder/Model/SearchesModel.php b/administrator/components/com_finder/Model/SearchesModel.php new file mode 100644 index 0000000000000..ecb5cf2a5f7c2 --- /dev/null +++ b/administrator/components/com_finder/Model/SearchesModel.php @@ -0,0 +1,175 @@ +setState('show_results', $this->getUserStateFromRequest($this->context . '.show_results', 'show_results', 1, 'int')); + + // Load the parameters. + $params = ComponentHelper::getParams('com_finder'); + $this->setState('params', $params); + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get a store id based on model configuration state. + * + * This is necessary because the model is used by the component and + * different modules that might need different sets of data or different + * ordering requirements. + * + * @param string $id A prefix for the store id. + * + * @return string A store id. + * + * @since 4.0 + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('show_results'); + $id .= ':' . $this->getState('filter.search'); + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to load the list data. + * + * @return \JDatabaseQuery + * + * @since 4.0 + */ + protected function getListQuery() + { + // Create a new query object. + $db = $this->getDbo(); + $query = $db->getQuery(true); + + // Select the required fields from the table. + $query->select( + $this->getState( + 'list.select', + 'a.*' + ) + ); + $query->from($db->quoteName('#__finder_logging', 'a')); + + // Filter by search in title + if ($search = $this->getState('filter.search')) + { + $search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($search), true) . '%')); + $query->where($db->quoteName('a.searchterm') . ' LIKE ' . $search); + } + + // Add the list ordering clause. + $query->order($db->escape($this->getState('list.ordering', 'a.hits')) . ' ' . $db->escape($this->getState('list.direction', 'ASC'))); + + return $query; + } + + /** + * Override the parent getItems to inject optional data. + * + * @return mixed An array of objects on success, false on failure. + * + * @since 4.0 + */ + public function getItems() + { + $items = parent::getItems(); + + \JLoader::register('FinderIndexerQuery', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/indexer/query.php'); + \JLoader::register('FinderIndexerToken', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/indexer/token.php'); + + foreach ($items as $item) + { + $item->query = unserialize($item->query); + } + + return $items; + } + + /** + * Method to reset the search log table. + * + * @return boolean + * + * @since 4.0 + */ + public function reset() + { + $db = $this->getDbo(); + + try + { + $db->truncateTable('#__finder_logging'); + } + catch (\RuntimeException $e) + { + $this->setError($e->getMessage()); + + return false; + } + + return true; + } +} diff --git a/administrator/components/com_finder/View/Searches/HtmlView.php b/administrator/components/com_finder/View/Searches/HtmlView.php new file mode 100644 index 0000000000000..98e1d3ef849f1 --- /dev/null +++ b/administrator/components/com_finder/View/Searches/HtmlView.php @@ -0,0 +1,157 @@ +items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->filterForm = $this->get('FilterForm'); + $this->activeFilters = $this->get('ActiveFilters'); + $this->enabled = $this->state->params->get('logging_enabled'); + $this->canDo = ContentHelper::getActions('com_finder'); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new \JViewGenericdataexception(implode("\n", $errors), 500); + } + + FinderHelper::addSubmenu('searches'); + + // Check if plugin is enabled + if ($this->enabled) + { + $app->enqueueMessage(\JText::_('COM_FINDER_LOGGING_ENABLED'), 'notice'); + } + else + { + $app->enqueueMessage(\JText::_('COM_FINDER_LOGGING_DISABLED'), 'warning'); + } + + // Prepare the view. + $this->addToolbar(); + $this->sidebar = \JHtmlSidebar::render(); + + return parent::display($tpl); + } + + /** + * Add the page title and toolbar. + * + * @return void + * + * @since 1.6 + */ + protected function addToolbar() + { + $canDo = $this->canDo; + + ToolbarHelper::title(\JText::_('COM_FINDER_MANAGER_SEARCHES'), 'search'); + + if ($canDo->get('core.edit.state')) + { + ToolbarHelper::custom('searches.reset', 'refresh.png', 'refresh_f2.png', 'JSEARCH_RESET', false); + } + + ToolbarHelper::divider(); + + if ($canDo->get('core.admin') || $canDo->get('core.options')) + { + ToolbarHelper::preferences('com_finder'); + } + + ToolbarHelper::help('JHELP_COMPONENTS_FINDER_MANAGE_SEARCHES'); + + + + + + + //ToolbarHelper::title(\JText::_('COM_FINDER_MAPS_TOOLBAR_TITLE'), 'zoom-in finder'); + + + } +} diff --git a/administrator/components/com_finder/config.xml b/administrator/components/com_finder/config.xml index cb4a383edfa64..1bbf624e8d462 100644 --- a/administrator/components/com_finder/config.xml +++ b/administrator/components/com_finder/config.xml @@ -7,7 +7,7 @@ > +
+ + + + + + + + + + + + + +
diff --git a/administrator/components/com_finder/sql/install.mysql.sql b/administrator/components/com_finder/sql/install.mysql.sql index 4207fa2111075..36793122a1dc0 100644 --- a/administrator/components/com_finder/sql/install.mysql.sql +++ b/administrator/components/com_finder/sql/install.mysql.sql @@ -261,6 +261,20 @@ CREATE TABLE IF NOT EXISTS `#__finder_links_termsf` ( KEY `idx_link_term_weight` (`link_id`,`term_id`,`weight`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; +-- +-- Table structure for table `#__finder_logging` +-- + +CREATE TABLE IF NOT EXISTS `#__finder_logging` ( + `searchterm` VARCHAR(255) NOT NULL DEFAULT '', + `md5sum` VARCHAR(32) NOT NULL DEFAULT '', + `query` BLOB NOT NULL, + `hits` INT(11) NOT NULL DEFAULT '1', + `results` INT(11) NOT NULL DEFAULT '0', + UNIQUE INDEX `md5sum` (`md5sum`), + INDEX `searchterm` (`searchterm`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; + -- -- Table structure for table `#__finder_taxonomy` -- diff --git a/administrator/components/com_finder/sql/install.postgresql.sql b/administrator/components/com_finder/sql/install.postgresql.sql index 6c125dcecc439..94a7dca7adc0a 100644 --- a/administrator/components/com_finder/sql/install.postgresql.sql +++ b/administrator/components/com_finder/sql/install.postgresql.sql @@ -243,6 +243,21 @@ CREATE TABLE IF NOT EXISTS "#__finder_links_termsf" ( CREATE INDEX "#__finder_links_termsf_idx_term_weight" on "#__finder_links_termsf" ("term_id", "weight"); CREATE INDEX "#__finder_links_termsf_idx_link_term_weight" on "#__finder_links_termsf" ("link_id", "term_id", "weight"); +-- +-- Table structure for table `#__finder_logging` +-- + +CREATE TABLE IF NOT EXISTS "#__finder_logging" ( + "searchterm" character varying(255) NOT NULL DEFAULT '', + "md5sum" character varying(32) NOT NULL DEFAULT '', + "query" bytes NOT NULL, + "hits" integer NOT NULL DEFAULT 1, + "results" integer NOT NULL DEFAULT 0, + CONSTRAINT "#__finder_logging_idx_md5sum" UNIQUE ("md5sum") +); +CREATE INDEX "#__finder_logging_idx_md5sum" on "#__finder_logging" ("md5sum"); +CREATE INDEX "#__finder_logging_idx_searchterm" on "#__finder_logging" ("searchterm"); + -- -- Table: #__finder_taxonomy -- diff --git a/administrator/components/com_finder/sql/uninstall.mysql.sql b/administrator/components/com_finder/sql/uninstall.mysql.sql index 89579b982d43f..1f3f1b75a529e 100644 --- a/administrator/components/com_finder/sql/uninstall.mysql.sql +++ b/administrator/components/com_finder/sql/uninstall.mysql.sql @@ -16,6 +16,7 @@ DROP TABLE IF EXISTS `#__finder_links_termsc`; DROP TABLE IF EXISTS `#__finder_links_termsd`; DROP TABLE IF EXISTS `#__finder_links_termse`; DROP TABLE IF EXISTS `#__finder_links_termsf`; +DROP TABLE IF EXISTS `#__finder_logging`; DROP TABLE IF EXISTS `#__finder_taxonomy`; DROP TABLE IF EXISTS `#__finder_taxonomy_map`; DROP TABLE IF EXISTS `#__finder_terms`; diff --git a/administrator/components/com_finder/sql/uninstall.postgresql.sql b/administrator/components/com_finder/sql/uninstall.postgresql.sql index 76d7981529149..4ca858961d25b 100644 --- a/administrator/components/com_finder/sql/uninstall.postgresql.sql +++ b/administrator/components/com_finder/sql/uninstall.postgresql.sql @@ -16,6 +16,7 @@ DROP TABLE IF EXISTS "#__finder_links_termsc"; DROP TABLE IF EXISTS "#__finder_links_termsd"; DROP TABLE IF EXISTS "#__finder_links_termse"; DROP TABLE IF EXISTS "#__finder_links_termsf"; +DROP TABLE IF EXISTS "#__finder_logging"; DROP TABLE IF EXISTS "#__finder_taxonomy"; DROP TABLE IF EXISTS "#__finder_taxonomy_map"; DROP TABLE IF EXISTS "#__finder_terms"; diff --git a/administrator/components/com_finder/tmpl/searches/default.php b/administrator/components/com_finder/tmpl/searches/default.php new file mode 100644 index 0000000000000..85dae2f684728 --- /dev/null +++ b/administrator/components/com_finder/tmpl/searches/default.php @@ -0,0 +1,75 @@ +escape($this->state->get('list.ordering')); +$listDirn = $this->escape($this->state->get('list.direction')); +?> +
+
+
+ sidebar; ?> +
+
+
+ $this, 'options' => array('filterButton' => false))); ?> + items)) : ?> + + + + + + + + + + + + + + + + + items as $i => $item) : ?> + + + + + + + +
+ + + + + +
+ pagination->getListFooter(); ?> +
+ escape($item->searchterm); ?> + + hits; ?> + + results; ?> +
+ + + + +
+
+
+
diff --git a/administrator/language/en-GB/en-GB.com_finder.ini b/administrator/language/en-GB/en-GB.com_finder.ini index 89d5d0dba7004..cdea26349a59f 100644 --- a/administrator/language/en-GB/en-GB.com_finder.ini +++ b/administrator/language/en-GB/en-GB.com_finder.ini @@ -86,6 +86,10 @@ COM_FINDER_HEADING_MAP_COUNT="Map Count" COM_FINDER_HEADING_MAP_COUNT_ASC="Map Count ascending" COM_FINDER_HEADING_MAP_COUNT_DESC="Map Count descending" COM_FINDER_HEADING_NODES="Items" +COM_FINDER_HEADING_PHRASE="Search Phrase" +COM_FINDER_HEADING_RESULTS="Results" +COM_FINDER_HEADING_SEARCH_TERM_ASC="Search Phrase ascending" +COM_FINDER_HEADING_SEARCH_TERM_DESC="Search Phrase descending" COM_FINDER_INDEX="Index" COM_FINDER_INDEX_CONFIRM_DELETE_PROMPT="Are you sure you want to delete the selected item(s)?" COM_FINDER_INDEX_CONFIRM_PURGE_PROMPT="Are you sure you want to delete ALL items from the index? This can take a long time on large sites." @@ -127,6 +131,9 @@ COM_FINDER_INDEXER_MESSAGE_OPTIMIZE="The index tables are being optimised for th COM_FINDER_INDEXER_MESSAGE_RUNNING="Your content is being indexed. Do not close this window." COM_FINDER_ITEM_X_ONLY="%s Only" COM_FINDER_ITEMS="Content" +COM_FINDER_LOGGING_DISABLED="Gathering statistics disabled. Enable it in the Options." +COM_FINDER_LOGGING_ENABLED="Gathering statistics enabled" +COM_FINDER_MANAGER_SEARCHES="Search Term Analysis" COM_FINDER_MAPS="Maps" COM_FINDER_MAPS_CONFIRM_DELETE_PROMPT="Are you sure you want to delete the selected map(s)?" COM_FINDER_MAPS_COUNT_PUBLISHED_ITEMS="Published Indexed Content" @@ -169,4 +176,5 @@ 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_SUBMENU_SEARCHES="Statistics" COM_FINDER_XML_DESCRIPTION="Smart Search." diff --git a/components/com_finder/Helper/FinderHelper.php b/components/com_finder/Helper/FinderHelper.php new file mode 100644 index 0000000000000..4cb7990146a20 --- /dev/null +++ b/components/com_finder/Helper/FinderHelper.php @@ -0,0 +1,79 @@ +get('logging_enabled', 1); + + if (!$enable_log_searches) + { + return; + } + + // Initialise our variables + $db = \JFactory::getDbo(); + $query = $db->getQuery(true); + + // Sanitise the term for the database + $temp = unserialize(serialize($searchquery)); + $temp->input = trim(strtolower($searchquery->input)); + $entry = new \stdClass; + $entry->searchterm = $temp->input; + $entry->query = serialize($temp); + $entry->md5sum = md5($entry->query); + $entry->hits = 1; + $entry->results = $resultCount; + + // Query the table to determine if the term has been searched previously + $query->select($db->quoteName('hits')) + ->from($db->quoteName('#__finder_logging')) + ->where($db->quoteName('md5sum') . ' = ' . $db->quote($entry->md5sum)); + $db->setQuery($query); + $hits = (int) $db->loadResult(); + + // Reset the $query object + $query->clear(); + + // Update the table based on the results + if ($hits) + { + $query->update($db->quoteName('#__finder_logging')) + ->set('hits = (hits + 1)') + ->where($db->quoteName('md5sum') . ' = ' . $db->quote($entry->md5sum)); + $db->setQuery($query); + $db->execute(); + } + else + { + $db->insertObject('#__finder_logging', $entry); + } + } +} diff --git a/components/com_finder/View/Search/HtmlView.php b/components/com_finder/View/Search/HtmlView.php index c4d0b5a4c31d3..d54ec154ae1cd 100644 --- a/components/com_finder/View/Search/HtmlView.php +++ b/components/com_finder/View/Search/HtmlView.php @@ -10,7 +10,7 @@ defined('_JEXEC') or die; -use Joomla\CMS\Helper\SearchHelper; +use Joomla\Component\Finder\Site\Helper\FinderHelper; use Joomla\CMS\Pagination\Pagination; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; @@ -160,7 +160,7 @@ public function display($tpl = null) } // Log the search - SearchHelper::logSearch($this->query->input, 'com_finder'); + FinderHelper::logSearch($this->query, count($this->total)); // Push out the query data. \JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql index 6f65619e1e6fc..6894f733295ed 100644 --- a/installation/sql/mysql/joomla.sql +++ b/installation/sql/mysql/joomla.sql @@ -1049,6 +1049,22 @@ CREATE TABLE IF NOT EXISTS `#__finder_links_termsf` ( -- -------------------------------------------------------- +-- +-- Table structure for table `#__finder_logging` +-- + +CREATE TABLE IF NOT EXISTS `#__finder_logging` ( + `searchterm` VARCHAR(255) NOT NULL DEFAULT '', + `md5sum` VARCHAR(32) NOT NULL DEFAULT '', + `query` BLOB NOT NULL, + `hits` INT(11) NOT NULL DEFAULT '1', + `results` INT(11) NOT NULL DEFAULT '0', + UNIQUE INDEX `md5sum` (`md5sum`), + INDEX `searchterm` (`searchterm`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + -- -- Table structure for table `#__finder_taxonomy` -- diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql index c6369bc3b3f53..b5f02bd5e6f05 100644 --- a/installation/sql/postgresql/joomla.sql +++ b/installation/sql/postgresql/joomla.sql @@ -1019,6 +1019,21 @@ CREATE TABLE IF NOT EXISTS "#__finder_links_termsf" ( CREATE INDEX "#__finder_links_termsf_idx_term_weight" on "#__finder_links_termsf" ("term_id", "weight"); CREATE INDEX "#__finder_links_termsf_idx_link_term_weight" on "#__finder_links_termsf" ("link_id", "term_id", "weight"); +-- +-- Table structure for table `#__finder_logging` +-- + +CREATE TABLE IF NOT EXISTS "#__finder_logging" ( + "searchterm" character varying(255) NOT NULL DEFAULT '', + "md5sum" character varying(32) NOT NULL DEFAULT '', + "query" bytes NOT NULL, + "hits" integer NOT NULL DEFAULT 1, + "results" integer NOT NULL DEFAULT 0, + CONSTRAINT "#__finder_logging_idx_md5sum" UNIQUE ("md5sum") +); +CREATE INDEX "#__finder_logging_idx_md5sum" on "#__finder_logging" ("md5sum"); +CREATE INDEX "#__finder_logging_idx_searchterm" on "#__finder_logging" ("searchterm"); + -- -- Table structure for table `#__finder_taxonomy` -- From 24b6b012862f45cde583ca0059b4cb93883c1513 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Wed, 6 Jun 2018 23:51:55 +0200 Subject: [PATCH 2/8] Comments and codestyle --- .../components/com_finder/View/Searches/HtmlView.php | 9 --------- components/com_finder/Helper/FinderHelper.php | 7 ++++--- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/administrator/components/com_finder/View/Searches/HtmlView.php b/administrator/components/com_finder/View/Searches/HtmlView.php index 98e1d3ef849f1..4b578389d7541 100644 --- a/administrator/components/com_finder/View/Searches/HtmlView.php +++ b/administrator/components/com_finder/View/Searches/HtmlView.php @@ -144,14 +144,5 @@ protected function addToolbar() } ToolbarHelper::help('JHELP_COMPONENTS_FINDER_MANAGE_SEARCHES'); - - - - - - - //ToolbarHelper::title(\JText::_('COM_FINDER_MAPS_TOOLBAR_TITLE'), 'zoom-in finder'); - - } } diff --git a/components/com_finder/Helper/FinderHelper.php b/components/com_finder/Helper/FinderHelper.php index 4cb7990146a20..9851aca5796ad 100644 --- a/components/com_finder/Helper/FinderHelper.php +++ b/components/com_finder/Helper/FinderHelper.php @@ -3,8 +3,8 @@ * @package Joomla.Site * @subpackage com_finder * - * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\Component\Finder\Site\Helper; @@ -23,7 +23,8 @@ class FinderHelper /** * Method to log searches to the database * - * @param string $searchquery The search query + * @param string $searchquery The search query + * @param integer $resultCount The number of results for this search * * @return void * From ff57a95e728b7e89c36d113e7e1e0b342cd9b9e3 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Tue, 12 Jun 2018 11:51:15 +0200 Subject: [PATCH 3/8] Adding . in language string --- administrator/language/en-GB/en-GB.com_finder.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/language/en-GB/en-GB.com_finder.ini b/administrator/language/en-GB/en-GB.com_finder.ini index cdea26349a59f..c0b78e75f8c22 100644 --- a/administrator/language/en-GB/en-GB.com_finder.ini +++ b/administrator/language/en-GB/en-GB.com_finder.ini @@ -132,7 +132,7 @@ COM_FINDER_INDEXER_MESSAGE_RUNNING="Your content is being indexed. Do not close COM_FINDER_ITEM_X_ONLY="%s Only" COM_FINDER_ITEMS="Content" COM_FINDER_LOGGING_DISABLED="Gathering statistics disabled. Enable it in the Options." -COM_FINDER_LOGGING_ENABLED="Gathering statistics enabled" +COM_FINDER_LOGGING_ENABLED="Gathering statistics enabled." COM_FINDER_MANAGER_SEARCHES="Search Term Analysis" COM_FINDER_MAPS="Maps" COM_FINDER_MAPS_CONFIRM_DELETE_PROMPT="Are you sure you want to delete the selected map(s)?" From 79441d524b2765e0e2fa5f064f87dc9f6b173326 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Mon, 18 Jun 2018 22:48:31 +0200 Subject: [PATCH 4/8] Fixing logging empty searches --- components/com_finder/Helper/FinderHelper.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/components/com_finder/Helper/FinderHelper.php b/components/com_finder/Helper/FinderHelper.php index 9851aca5796ad..bfaf4107a13a2 100644 --- a/components/com_finder/Helper/FinderHelper.php +++ b/components/com_finder/Helper/FinderHelper.php @@ -23,14 +23,14 @@ class FinderHelper /** * Method to log searches to the database * - * @param string $searchquery The search query - * @param integer $resultCount The number of results for this search + * @param FinderIndexerQuery $searchquery The search query + * @param integer $resultCount The number of results for this search * * @return void * * @since __DEPLOY_VERSION__ */ - public static function logSearch($searchquery, $resultCount = 0) + public static function logSearch(FinderIndexerQuery $searchquery, $resultCount = 0) { $enable_log_searches = ComponentHelper::getParams('com_finder')->get('logging_enabled', 1); @@ -39,6 +39,11 @@ public static function logSearch($searchquery, $resultCount = 0) return; } + if (trim($searchquery->input) == '' && !$searchquery->empty) + { + return; + } + // Initialise our variables $db = \JFactory::getDbo(); $query = $db->getQuery(true); From add104e3ffab2f3dce619d8ee41589d71000f32a Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Tue, 19 Jun 2018 19:27:14 +0200 Subject: [PATCH 5/8] Typo --- components/com_finder/Helper/FinderHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/com_finder/Helper/FinderHelper.php b/components/com_finder/Helper/FinderHelper.php index bfaf4107a13a2..568f1174b18d3 100644 --- a/components/com_finder/Helper/FinderHelper.php +++ b/components/com_finder/Helper/FinderHelper.php @@ -30,7 +30,7 @@ class FinderHelper * * @since __DEPLOY_VERSION__ */ - public static function logSearch(FinderIndexerQuery $searchquery, $resultCount = 0) + public static function logSearch(\FinderIndexerQuery $searchquery, $resultCount = 0) { $enable_log_searches = ComponentHelper::getParams('com_finder')->get('logging_enabled', 1); From a25c0e5a540b5e2d88e95f3fc74191cc7ef7a305 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Wed, 20 Jun 2018 09:32:38 +0200 Subject: [PATCH 6/8] Adding different codes for label and description --- administrator/components/com_finder/forms/filter_searches.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_finder/forms/filter_searches.xml b/administrator/components/com_finder/forms/filter_searches.xml index c7117470d20c8..c3a4c1caf1418 100644 --- a/administrator/components/com_finder/forms/filter_searches.xml +++ b/administrator/components/com_finder/forms/filter_searches.xml @@ -4,8 +4,8 @@ From 82ae14ae6ea4366df9efa1db6dca2353cb37b501 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Wed, 20 Jun 2018 09:34:42 +0200 Subject: [PATCH 7/8] Adding language strings --- administrator/language/en-GB/en-GB.com_finder.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/administrator/language/en-GB/en-GB.com_finder.ini b/administrator/language/en-GB/en-GB.com_finder.ini index 6c56c062d7c99..a99f391860b71 100644 --- a/administrator/language/en-GB/en-GB.com_finder.ini +++ b/administrator/language/en-GB/en-GB.com_finder.ini @@ -163,6 +163,8 @@ COM_FINDER_QUERY_OPERATOR_AND="And" COM_FINDER_QUERY_OPERATOR_NOT="Not" COM_FINDER_QUERY_OPERATOR_OR="Or" COM_FINDER_SEARCH_FILTER_SEARCH_LABEL="Search Filters" +COM_FINDER_SEARCH_IN_PHRASE_LABEL="Filter by searched phrase" +COM_FINDER_SEARCH_IN_PHRASE_DESC="Search for the logged phrase of a search" COM_FINDER_SEARCH_LABEL="Search %s:" COM_FINDER_SEARCH_SEARCH_QUERY_LABEL="Search Content Maps" COM_FINDER_SELECT_SEARCH_FILTER="Select filter" From 9e1f71a0f3c923e182d284f8b1065a604feb44cc Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Thu, 21 Jun 2018 10:16:24 +0200 Subject: [PATCH 8/8] Fixing total count, fixing comments, fixing filename --- .../{4.0.0-2918-06-06.sql => 4.0.0-2018-06-06.sql} | 0 .../{4.0.0-2918-06-06.sql => 4.0.0-2018-06-06.sql} | 0 .../components/com_finder/Model/SearchesModel.php | 14 +++++++------- components/com_finder/View/Search/HtmlView.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) rename administrator/components/com_admin/sql/updates/mysql/{4.0.0-2918-06-06.sql => 4.0.0-2018-06-06.sql} (100%) rename administrator/components/com_admin/sql/updates/postgresql/{4.0.0-2918-06-06.sql => 4.0.0-2018-06-06.sql} (100%) diff --git a/administrator/components/com_admin/sql/updates/mysql/4.0.0-2918-06-06.sql b/administrator/components/com_admin/sql/updates/mysql/4.0.0-2018-06-06.sql similarity index 100% rename from administrator/components/com_admin/sql/updates/mysql/4.0.0-2918-06-06.sql rename to administrator/components/com_admin/sql/updates/mysql/4.0.0-2018-06-06.sql diff --git a/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2918-06-06.sql b/administrator/components/com_admin/sql/updates/postgresql/4.0.0-2018-06-06.sql similarity index 100% rename from administrator/components/com_admin/sql/updates/postgresql/4.0.0-2918-06-06.sql rename to administrator/components/com_admin/sql/updates/postgresql/4.0.0-2018-06-06.sql diff --git a/administrator/components/com_finder/Model/SearchesModel.php b/administrator/components/com_finder/Model/SearchesModel.php index ecb5cf2a5f7c2..05369341a48d2 100644 --- a/administrator/components/com_finder/Model/SearchesModel.php +++ b/administrator/components/com_finder/Model/SearchesModel.php @@ -18,7 +18,7 @@ /** * Methods supporting a list of search terms. * - * @since __DEPLOYED_VERSION__ + * @since __DEPLOY_VERSION__ */ class SearchesModel extends ListModel { @@ -29,7 +29,7 @@ class SearchesModel extends ListModel * @param MVCFactoryInterface $factory The factory. * * @see \Joomla\CMS\MVC\Model\BaseDatabaseModel - * @since 4.0 + * @since __DEPLOY_VERSION__ */ public function __construct($config = array(), MVCFactoryInterface $factory = null) { @@ -54,7 +54,7 @@ public function __construct($config = array(), MVCFactoryInterface $factory = nu * * @return void * - * @since 4.0 + * @since __DEPLOY_VERSION__ */ protected function populateState($ordering = 'a.hits', $direction = 'asc') { @@ -80,7 +80,7 @@ protected function populateState($ordering = 'a.hits', $direction = 'asc') * * @return string A store id. * - * @since 4.0 + * @since __DEPLOY_VERSION__ */ protected function getStoreId($id = '') { @@ -96,7 +96,7 @@ protected function getStoreId($id = '') * * @return \JDatabaseQuery * - * @since 4.0 + * @since __DEPLOY_VERSION__ */ protected function getListQuery() { @@ -131,7 +131,7 @@ protected function getListQuery() * * @return mixed An array of objects on success, false on failure. * - * @since 4.0 + * @since __DEPLOY_VERSION__ */ public function getItems() { @@ -153,7 +153,7 @@ public function getItems() * * @return boolean * - * @since 4.0 + * @since __DEPLOY_VERSION__ */ public function reset() { diff --git a/components/com_finder/View/Search/HtmlView.php b/components/com_finder/View/Search/HtmlView.php index 3de4492ce78a0..cb5cc1944f75e 100644 --- a/components/com_finder/View/Search/HtmlView.php +++ b/components/com_finder/View/Search/HtmlView.php @@ -160,7 +160,7 @@ public function display($tpl = null) } // Log the search - FinderHelper::logSearch($this->query, count($this->total)); + FinderHelper::logSearch($this->query, $this->total); // Push out the query data. \JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');