You've already forked joomla_test
first commit
This commit is contained in:
8
administrator/components/com_search/access.xml
Normal file
8
administrator/components/com_search/access.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<access component="com_search">
|
||||
<section name="component">
|
||||
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
|
||||
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
|
||||
<action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" />
|
||||
</section>
|
||||
</access>
|
72
administrator/components/com_search/config.xml
Normal file
72
administrator/components/com_search/config.xml
Normal file
@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<config>
|
||||
<fieldset name="component">
|
||||
<field
|
||||
name="enabled"
|
||||
type="radio"
|
||||
class="btn-group"
|
||||
default="0"
|
||||
label="COM_SEARCH_CONFIG_GATHER_SEARCH_STATISTICS_LABEL"
|
||||
description="COM_SEARCH_CONFIG_GATHER_SEARCH_STATISTICS_DESC">
|
||||
<option
|
||||
value="0">JNO</option>
|
||||
<option
|
||||
value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field name="search_areas"
|
||||
type="radio"
|
||||
class="btn-group"
|
||||
default="1"
|
||||
description="COM_SEARCH_FIELD_SEARCH_AREAS_DESC"
|
||||
label="COM_SEARCH_FIELD_SEARCH_AREAS_LABEL"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="show_date"
|
||||
type="radio"
|
||||
class="btn-group"
|
||||
default="1"
|
||||
label="COM_SEARCH_CONFIG_FIELD_CREATED_DATE_LABEL"
|
||||
description="COM_SEARCH_CONFIG_FIELD_CREATED_DATE_DESC">
|
||||
<option
|
||||
value="0">JHIDE</option>
|
||||
<option
|
||||
value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field
|
||||
name="opensearch_name"
|
||||
type="text"
|
||||
label="COM_SEARCH_CONFIG_FIELD_OPENSEARCH_NAME_LABEL"
|
||||
description="COM_SEARCH_CONFIG_FIELD_OPENSEARCH_NAME_DESC"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="opensearch_description"
|
||||
type="textarea"
|
||||
label="COM_SEARCH_CONFIG_FIELD_OPENSEARCH_DESCRIPTON_LABEL"
|
||||
description="COM_SEARCH_CONFIG_FIELD_OPENSEARCH_DESCRIPTON_DESC"
|
||||
cols="30" rows="2"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
name="permissions"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
description="JCONFIG_PERMISSIONS_DESC"
|
||||
>
|
||||
|
||||
<field
|
||||
name="rules"
|
||||
type="rules"
|
||||
label="JCONFIG_PERMISSIONS_LABEL"
|
||||
filter="rules"
|
||||
validate="rules"
|
||||
component="com_search"
|
||||
section="component" />
|
||||
</fieldset>
|
||||
</config>
|
45
administrator/components/com_search/controller.php
Normal file
45
administrator/components/com_search/controller.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_search
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Search master display controller.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_search
|
||||
* @since 1.6
|
||||
*/
|
||||
class SearchController extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
* @var string The default view.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $default_view = 'searches';
|
||||
|
||||
/**
|
||||
* Method to display a view.
|
||||
*
|
||||
* @param boolean If true, the view output will be cached
|
||||
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
|
||||
*
|
||||
* @return JController This object to support chaining.
|
||||
* @since 1.5
|
||||
*/
|
||||
public function display($cachable = false, $urlparams = false)
|
||||
{
|
||||
require_once JPATH_COMPONENT.'/helpers/search.php';
|
||||
|
||||
// Load the submenu.
|
||||
SearchHelper::addSubmenu($this->input->get('view', 'searches'));
|
||||
|
||||
parent::display();
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
40
administrator/components/com_search/controllers/searches.php
Normal file
40
administrator/components/com_search/controllers/searches.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_search
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Methods supporting a list of search terms.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_search
|
||||
* @since 1.6
|
||||
*/
|
||||
class SearchControllerSearches extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
* Method to reset the seach log table.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
// Check for request forgeries.
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
$model = $this->getModel('Searches');
|
||||
|
||||
if (!$model->reset())
|
||||
{
|
||||
JError::raiseWarning(500, $model->getError());
|
||||
}
|
||||
|
||||
$this->setRedirect('index.php?option=com_search&view=searches');
|
||||
}
|
||||
}
|
1
administrator/components/com_search/helpers/index.html
Normal file
1
administrator/components/com_search/helpers/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
294
administrator/components/com_search/helpers/search.php
Normal file
294
administrator/components/com_search/helpers/search.php
Normal file
@ -0,0 +1,294 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_search
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Search component helper.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_search
|
||||
* @since 1.5
|
||||
*/
|
||||
class SearchHelper
|
||||
{
|
||||
/**
|
||||
* Configure the Linkbar.
|
||||
*
|
||||
* @param string The name of the active view.
|
||||
* @since 1.6
|
||||
*/
|
||||
public static function addSubmenu($vName)
|
||||
{
|
||||
// Not required.
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of the actions that can be performed.
|
||||
*
|
||||
* @return JObject
|
||||
*/
|
||||
public static function getActions()
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$result = new JObject;
|
||||
$assetName = 'com_search';
|
||||
|
||||
$actions = JAccess::getActions($assetName);
|
||||
|
||||
foreach ($actions as $action)
|
||||
{
|
||||
$result->set($action->name, $user->authorise($action->name, $assetName));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function santiseSearchWord(&$searchword, $searchphrase)
|
||||
{
|
||||
$ignored = false;
|
||||
|
||||
$lang = JFactory::getLanguage();
|
||||
$tag = $lang->getTag();
|
||||
$search_ignore = $lang->getIgnoredSearchWords();
|
||||
|
||||
// Deprecated in 1.6 use $lang->getIgnoredSearchWords instead
|
||||
$ignoreFile = $lang->getLanguagePath() . '/' . $tag . '/' . $tag . '.ignore.php';
|
||||
|
||||
if (file_exists($ignoreFile))
|
||||
{
|
||||
include $ignoreFile;
|
||||
}
|
||||
|
||||
// Check for words to ignore
|
||||
$aterms = explode(' ', JString::strtolower($searchword));
|
||||
|
||||
// First case is single ignored word
|
||||
if (count($aterms) == 1 && in_array(JString::strtolower($searchword), $search_ignore))
|
||||
{
|
||||
$ignored = true;
|
||||
}
|
||||
|
||||
// Filter out search terms that are too small
|
||||
$lower_limit = $lang->getLowerLimitSearchWord();
|
||||
|
||||
foreach ($aterms as $aterm)
|
||||
{
|
||||
if (JString::strlen($aterm) < $lower_limit)
|
||||
{
|
||||
$search_ignore[] = $aterm;
|
||||
}
|
||||
}
|
||||
|
||||
// Next is to remove ignored words from type 'all' or 'any' (not exact) searches with multiple words
|
||||
if (count($aterms) > 1 && $searchphrase != 'exact')
|
||||
{
|
||||
$pruned = array_diff($aterms, $search_ignore);
|
||||
$searchword = implode(' ', $pruned);
|
||||
}
|
||||
|
||||
return $ignored;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function limitSearchWord(&$searchword)
|
||||
{
|
||||
$restriction = false;
|
||||
|
||||
$lang = JFactory::getLanguage();
|
||||
|
||||
// Limit searchword to a maximum of characters
|
||||
$upper_limit = $lang->getUpperLimitSearchWord();
|
||||
|
||||
if (JString::strlen($searchword) > $upper_limit)
|
||||
{
|
||||
$searchword = JString::substr($searchword, 0, $upper_limit - 1);
|
||||
$restriction = true;
|
||||
}
|
||||
|
||||
// Searchword must contain a minimum of characters
|
||||
if ($searchword && JString::strlen($searchword) < $lang->getLowerLimitSearchWord())
|
||||
{
|
||||
$searchword = '';
|
||||
$restriction = true;
|
||||
}
|
||||
|
||||
return $restriction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs a search term
|
||||
*
|
||||
* @param string $search_term The term being searched
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.5
|
||||
* @deprecated 4.0 Use JSearchHelper::logSearch() instead
|
||||
*/
|
||||
public static function logSearch($search_term)
|
||||
{
|
||||
JLog::add(__METHOD__ . '() is deprecated, use JSearchHelper::logSearch() instead.', JLog::WARNING, 'deprecated');
|
||||
|
||||
JSearchHelper::logSearch($search_term, 'com_search');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares results from search for display
|
||||
*
|
||||
* @param string $text The source string
|
||||
* @param string $searchword The searchword to select around
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function prepareSearchContent($text, $searchword)
|
||||
{
|
||||
// Strips tags won't remove the actual jscript
|
||||
$text = preg_replace("'<script[^>]*>.*?</script>'si", "", $text);
|
||||
$text = preg_replace('/{.+?}/', '', $text);
|
||||
|
||||
// $text = preg_replace('/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is','\2', $text);
|
||||
|
||||
// Replace line breaking tags with whitespace
|
||||
$text = preg_replace("'<(br[^/>]*?/|hr[^/>]*?/|/(div|h[1-6]|li|p|td))>'si", ' ', $text);
|
||||
|
||||
return self::_smartSubstr(strip_tags($text), $searchword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks an object for search terms (after stripping fields of HTML)
|
||||
*
|
||||
* @param object $object The object to check
|
||||
* @param string $searchTerm Search words to check for
|
||||
* @param array $fields List of object variables to check against
|
||||
*
|
||||
* @return boolean True if searchTerm is in object, false otherwise
|
||||
*/
|
||||
public static function checkNoHtml($object, $searchTerm, $fields)
|
||||
{
|
||||
$searchRegex = array(
|
||||
'#<script[^>]*>.*?</script>#si',
|
||||
'#<style[^>]*>.*?</style>#si',
|
||||
'#<!.*?(--|]])>#si',
|
||||
'#<[^>]*>#i'
|
||||
);
|
||||
$terms = explode(' ', $searchTerm);
|
||||
|
||||
if (empty($fields))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
if (!isset($object->$field))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$text = self::remove_accents($object->$field);
|
||||
|
||||
foreach ($searchRegex as $regex)
|
||||
{
|
||||
$text = preg_replace($regex, '', $text);
|
||||
}
|
||||
|
||||
foreach ($terms as $term)
|
||||
{
|
||||
$term = self::remove_accents($term);
|
||||
|
||||
if (JString::stristr($text, $term) !== false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transliterates given text to ASCII//TRANSLIT.
|
||||
* Simulates glibc transliteration style even if libiconv is used by PHP
|
||||
*
|
||||
* @param string $str String to remove accents from
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 3.2
|
||||
*/
|
||||
public static function remove_accents($str)
|
||||
{
|
||||
setlocale(LC_ALL, "en_GB.UTF-8");
|
||||
$str = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", $str);
|
||||
//TODO: remove other prefixes as well?
|
||||
return preg_replace("/[\"'^]([a-z])/ui", '\1', $str);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns substring of characters around a searchword
|
||||
*
|
||||
* @param string $text The source string
|
||||
* @param integer $searchword Number of chars to return
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function _smartSubstr($text, $searchword)
|
||||
{
|
||||
$lang = JFactory::getLanguage();
|
||||
$length = $lang->getSearchDisplayedCharactersNumber();
|
||||
$ltext = self::remove_accents($text);
|
||||
$textlen = JString::strlen($ltext);
|
||||
$lsearchword = JString::strtolower(self::remove_accents($searchword));
|
||||
$wordfound = false;
|
||||
$pos = 0;
|
||||
|
||||
while ($wordfound === false && $pos < $textlen)
|
||||
{
|
||||
if (($wordpos = @JString::strpos($ltext, ' ', $pos + $length)) !== false)
|
||||
{
|
||||
$chunk_size = $wordpos - $pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
$chunk_size = $length;
|
||||
}
|
||||
|
||||
$chunk = JString::substr($ltext, $pos, $chunk_size);
|
||||
$wordfound = JString::strpos(JString::strtolower($chunk), $lsearchword);
|
||||
|
||||
if ($wordfound === false)
|
||||
{
|
||||
$pos += $chunk_size + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($wordfound !== false)
|
||||
{
|
||||
return (($pos > 0) ? '... ' : '') . JString::substr($text, $pos, $chunk_size) . ' ...';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (($wordpos = @JString::strpos($text, ' ', $length)) !== false)
|
||||
{
|
||||
return JString::substr($text, 0, $wordpos) . ' ...';
|
||||
}
|
||||
else
|
||||
{
|
||||
return JString::substr($text, 0, $length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
41
administrator/components/com_search/helpers/site.php
Normal file
41
administrator/components/com_search/helpers/site.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_search
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Mock JSite class used to fool the frontend search plugins because they route the results.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_search
|
||||
* @since 1.5
|
||||
*/
|
||||
class JSite extends JObject
|
||||
{
|
||||
/**
|
||||
* False method to fool the frontend search plugins
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function getMenu()
|
||||
{
|
||||
$result = new JSite;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* False method to fool the frontend search plugins
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
1
administrator/components/com_search/index.html
Normal file
1
administrator/components/com_search/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1
administrator/components/com_search/models/index.html
Normal file
1
administrator/components/com_search/models/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
195
administrator/components/com_search/models/searches.php
Normal file
195
administrator/components/com_search/models/searches.php
Normal file
@ -0,0 +1,195 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_search
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Methods supporting a list of search terms.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_search
|
||||
* @since 1.6
|
||||
*/
|
||||
class SearchModelSearches extends JModelList
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array An optional associative array of configuration settings.
|
||||
* @see JController
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct($config = array())
|
||||
{
|
||||
if (empty($config['filter_fields']))
|
||||
{
|
||||
$config['filter_fields'] = array(
|
||||
'search_term', 'a.search_term',
|
||||
'hits', 'a.hits',
|
||||
);
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @param string $ordering An optional ordering field.
|
||||
* @param string $direction An optional direction (asc|desc).
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
// Load the filter state.
|
||||
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
|
||||
$this->setState('filter.search', $search);
|
||||
|
||||
$showResults = $this->getUserStateFromRequest($this->context . '.filter.results', 'filter_results', null, 'int');
|
||||
$this->setState('filter.results', $showResults);
|
||||
|
||||
// Load the parameters.
|
||||
$params = JComponentHelper::getParams('com_search');
|
||||
$this->setState('params', $params);
|
||||
|
||||
// List state information.
|
||||
parent::populateState('a.hits', 'asc');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 1.6
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Compile the store id.
|
||||
$id .= ':' . $this->getState('filter.search');
|
||||
$id .= ':' . $this->getState('filter.results');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an SQL query to load the list data.
|
||||
*
|
||||
* @return JDatabaseQuery
|
||||
* @since 1.6
|
||||
*/
|
||||
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('#__core_log_searches') . ' AS a');
|
||||
|
||||
// Filter by access level.
|
||||
if ($access = $this->getState('filter.access'))
|
||||
{
|
||||
$query->where('a.access = ' . (int) $access);
|
||||
}
|
||||
|
||||
// Filter by search in title
|
||||
$search = $this->getState('filter.search');
|
||||
if (!empty($search))
|
||||
{
|
||||
$search = $db->quote('%' . $db->escape($search, true) . '%');
|
||||
$query->where('a.search_term LIKE ' . $search);
|
||||
}
|
||||
|
||||
// Add the list ordering clause.
|
||||
$query->order($db->escape($this->getState('list.ordering', 'a.hits')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
|
||||
|
||||
//echo nl2br(str_replace('#__','jos_',$query));
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the parnet getItems to inject optional data.
|
||||
*
|
||||
* @return mixed An array of objects on success, false on failure.
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
$items = parent::getItems();
|
||||
|
||||
// Determine if number of results for search item should be calculated
|
||||
// by default it is `off` as it is highly query intensive
|
||||
if ($this->getState('filter.results'))
|
||||
{
|
||||
JPluginHelper::importPlugin('search');
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
if (!class_exists('JSite'))
|
||||
{
|
||||
// This fools the routers in the search plugins into thinking it's in the frontend
|
||||
JLoader::register('JSite', JPATH_COMPONENT . '/helpers/site.php');
|
||||
}
|
||||
|
||||
foreach ($items as &$item)
|
||||
{
|
||||
$results = $app->triggerEvent('onContentSearch', array($item->search_term));
|
||||
$item->returns = 0;
|
||||
foreach ($results as $result)
|
||||
{
|
||||
$item->returns += count($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to reset the seach log table.
|
||||
*
|
||||
* @return boolean
|
||||
* @since 1.6
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$db = $this->getDbo();
|
||||
$db->setQuery(
|
||||
'DELETE FROM #__core_log_searches'
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
$db->execute();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
$this->setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
19
administrator/components/com_search/search.php
Normal file
19
administrator/components/com_search/search.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_search
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
if (!JFactory::getUser()->authorise('core.manage', 'com_search'))
|
||||
{
|
||||
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
|
||||
}
|
||||
|
||||
$controller = JControllerLegacy::getInstance('Search');
|
||||
$controller->execute(JFactory::getApplication()->input->get('task'));
|
||||
$controller->redirect();
|
43
administrator/components/com_search/search.xml
Normal file
43
administrator/components/com_search/search.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" version="3.1" method="upgrade">
|
||||
<name>com_search</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>April 2006</creationDate>
|
||||
<copyright>(C) 2005 - 2013 Open Source Matters. All rights reserved.
|
||||
</copyright>
|
||||
<license>GNU General Public License version 2 or later; see
|
||||
LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.0.0</version>
|
||||
<description>COM_SEARCH_XML_DESCRIPTION</description>
|
||||
|
||||
<files folder="site">
|
||||
<filename>controller.php</filename>
|
||||
<filename>index.html</filename>
|
||||
<filename>router.php</filename>
|
||||
<filename>search.php</filename>
|
||||
<folder>models</folder>
|
||||
<folder>views</folder>
|
||||
</files>
|
||||
<languages folder="site">
|
||||
<language tag="en-GB">language/en-GB.com_search.ini</language>
|
||||
</languages>
|
||||
<administration>
|
||||
<menu link="option=com_search" img="class:search">Search</menu>
|
||||
<files folder="admin">
|
||||
<filename>config.xml</filename>
|
||||
<filename>controller.php</filename>
|
||||
<filename>index.html</filename>
|
||||
<filename>search.php</filename>
|
||||
<folder>controllers</folder>
|
||||
<folder>helpers</folder>
|
||||
<folder>models</folder>
|
||||
<folder>views</folder>
|
||||
</files>
|
||||
<languages folder="admin">
|
||||
<language tag="en-GB">language/en-GB.com_search.ini</language>
|
||||
<language tag="en-GB">language/en-GB.com_search.sys.ini</language>
|
||||
</languages>
|
||||
</administration>
|
||||
</extension>
|
1
administrator/components/com_search/views/index.html
Normal file
1
administrator/components/com_search/views/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_search
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Include the component HTML helpers.
|
||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
||||
|
||||
JHtml::_('bootstrap.tooltip');
|
||||
JHtml::_('behavior.multiselect');
|
||||
JHtml::_('formbehavior.chosen', 'select');
|
||||
|
||||
$listOrder = $this->escape($this->state->get('list.ordering'));
|
||||
$listDirn = $this->escape($this->state->get('list.direction'));
|
||||
$canDo = SearchHelper::getActions();
|
||||
?>
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_search&view=searches'); ?>" method="post" name="adminForm" id="adminForm">
|
||||
<div id="filter-bar" class="btn-toolbar">
|
||||
<div class="filter-search btn-group pull-left">
|
||||
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_SEARCH_SEARCH_IN_PHRASE'); ?>" />
|
||||
</div>
|
||||
<div class="filter-search btn-group pull-left">
|
||||
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
|
||||
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
|
||||
</div>
|
||||
<div class="btn-group pull-right hidden-phone">
|
||||
<label for="limit" class="element-invisible"><?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC');?></label>
|
||||
<?php echo $this->pagination->getLimitBox(); ?>
|
||||
</div>
|
||||
<div class="filter-select btn-group pull-left">
|
||||
<span class="adminlist-searchstatus">
|
||||
<?php if ($this->state->get('filter.results')) : ?>
|
||||
<a class="btn" href="<?php echo JRoute::_('index.php?option=com_search&filter_results=0');?>">
|
||||
<i class="icon-zoom-out"></i> <?php echo JText::_('COM_SEARCH_HIDE_SEARCH_RESULTS'); ?></a>
|
||||
<?php else : ?>
|
||||
<a class="btn" href="<?php echo JRoute::_('index.php?option=com_search&filter_results=1');?>">
|
||||
<i class="icon-zoom-in"></i> <?php echo JText::_('COM_SEARCH_SHOW_SEARCH_RESULTS'); ?></a>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"> </div>
|
||||
<?php if ($this->enabled) : ?>
|
||||
<div class="alert alert-info">
|
||||
<a class="close" data-dismiss="alert">×</a>
|
||||
<?php echo JText::_('COM_SEARCH_LOGGING_ENABLED'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="alert alert-error">
|
||||
<a class="close" data-dismiss="alert">×</a>
|
||||
<?php echo JText::_('COM_SEARCH_LOGGING_DISABLED'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="title">
|
||||
<?php echo JHtml::_('grid.sort', 'COM_SEARCH_HEADING_PHRASE', 'a.search_term', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th width="15%" class="center">
|
||||
<?php echo JHtml::_('grid.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
|
||||
</th>
|
||||
<th width="15%" class="center">
|
||||
<?php echo JText::_('COM_SEARCH_HEADING_RESULTS'); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<?php echo $this->pagination->getListFooter(); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<?php foreach ($this->items as $i => $item) : ?>
|
||||
<tr class="row<?php echo $i % 2; ?>">
|
||||
<td>
|
||||
<?php echo $this->escape($item->search_term); ?>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php echo (int) $item->hits; ?>
|
||||
</td>
|
||||
<td class="center">
|
||||
<?php if ($this->state->get('filter.results')) : ?>
|
||||
<?php echo (int) $item->returns; ?>
|
||||
<?php else: ?>
|
||||
<?php echo JText::_('COM_SEARCH_NO_RESULTS'); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div>
|
||||
<input type="hidden" name="task" value="" />
|
||||
<input type="hidden" name="boxchecked" value="0" />
|
||||
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
|
||||
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
|
||||
<?php echo JHtml::_('form.token'); ?>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_search
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* View class for a list of search terms.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_search
|
||||
* @since 1.5
|
||||
*/
|
||||
class SearchViewSearches extends JViewLegacy
|
||||
{
|
||||
protected $enabled;
|
||||
|
||||
protected $items;
|
||||
|
||||
protected $pagination;
|
||||
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Display the view
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->items = $this->get('Items');
|
||||
$this->pagination = $this->get('Pagination');
|
||||
$this->state = $this->get('State');
|
||||
$this->enabled = $this->state->params->get('enabled');
|
||||
|
||||
// Check for errors.
|
||||
if (count($errors = $this->get('Errors')))
|
||||
{
|
||||
JError::raiseError(500, implode("\n", $errors));
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->addToolbar();
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the page title and toolbar.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function addToolbar()
|
||||
{
|
||||
$canDo = SearchHelper::getActions();
|
||||
|
||||
JToolbarHelper::title(JText::_('COM_SEARCH_MANAGER_SEARCHES'), 'search.png');
|
||||
|
||||
if ($canDo->get('core.edit.state'))
|
||||
{
|
||||
JToolbarHelper::custom('searches.reset', 'refresh.png', 'refresh_f2.png', 'JSEARCH_RESET', false);
|
||||
}
|
||||
JToolbarHelper::divider();
|
||||
if ($canDo->get('core.admin'))
|
||||
{
|
||||
JToolbarHelper::preferences('com_search');
|
||||
}
|
||||
JToolbarHelper::divider();
|
||||
JToolbarHelper::help('JHELP_COMPONENTS_SEARCH');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user