You've already forked joomla_test
first commit
This commit is contained in:
91
components/com_search/controller.php
Normal file
91
components/com_search/controller.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @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 Controller
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_search
|
||||
* @since 1.5
|
||||
*/
|
||||
class SearchController extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$this->input->set('view', 'search'); // force it to be the search view
|
||||
|
||||
return parent::display($cachable, $urlparams);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
// slashes cause errors, <> get stripped anyway later on. # causes problems.
|
||||
$badchars = array('#', '>', '<', '\\');
|
||||
$searchword = trim(str_replace($badchars, '', $this->input->getString('searchword', null, 'post')));
|
||||
// if searchword enclosed in double quotes, strip quotes and do exact match
|
||||
if (substr($searchword, 0, 1) == '"' && substr($searchword, -1) == '"')
|
||||
{
|
||||
$post['searchword'] = substr($searchword, 1, -1);
|
||||
$this->input->set('searchphrase', 'exact');
|
||||
}
|
||||
else
|
||||
{
|
||||
$post['searchword'] = $searchword;
|
||||
}
|
||||
$post['ordering'] = $this->input->getWord('ordering', null, 'post');
|
||||
$post['searchphrase'] = $this->input->getWord('searchphrase', 'all', 'post');
|
||||
$post['limit'] = $this->input->getUInt('limit', null, 'post');
|
||||
|
||||
if ($post['limit'] === null)
|
||||
{
|
||||
unset($post['limit']);
|
||||
}
|
||||
|
||||
$areas = $this->input->post->get('areas', null, 'array');
|
||||
if ($areas)
|
||||
{
|
||||
foreach ($areas as $area)
|
||||
{
|
||||
$post['areas'][] = JFilterInput::getInstance()->clean($area, 'cmd');
|
||||
}
|
||||
}
|
||||
|
||||
// set Itemid id for links from menu
|
||||
$app = JFactory::getApplication();
|
||||
$menu = $app->getMenu();
|
||||
$items = $menu->getItems('link', 'index.php?option=com_search&view=search');
|
||||
|
||||
if (isset($items[0]))
|
||||
{
|
||||
$post['Itemid'] = $items[0]->id;
|
||||
} elseif ($this->input->getInt('Itemid') > 0) { //use Itemid from requesting page only if there is no existing menu
|
||||
$post['Itemid'] = $this->input->getInt('Itemid');
|
||||
}
|
||||
|
||||
unset($post['task']);
|
||||
unset($post['submit']);
|
||||
|
||||
$uri = JUri::getInstance();
|
||||
$uri->setQuery($post);
|
||||
$uri->setVar('option', 'com_search');
|
||||
|
||||
$this->setRedirect(JRoute::_('index.php'.$uri->toString(array('query', 'fragment')), false));
|
||||
}
|
||||
}
|
1
components/com_search/index.html
Normal file
1
components/com_search/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1
components/com_search/models/index.html
Normal file
1
components/com_search/models/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
218
components/com_search/models/search.php
Normal file
218
components/com_search/models/search.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @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 Search Model
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_search
|
||||
* @since 1.5
|
||||
*/
|
||||
class SearchModelSearch extends JModelLegacy
|
||||
{
|
||||
/**
|
||||
* Search data array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_data = null;
|
||||
|
||||
/**
|
||||
* Search total
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $_total = null;
|
||||
|
||||
/**
|
||||
* Search areas
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $_areas = null;
|
||||
|
||||
/**
|
||||
* Pagination object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $_pagination = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
//Get configuration
|
||||
$app = JFactory::getApplication();
|
||||
$config = JFactory::getConfig();
|
||||
|
||||
// Get the pagination request variables
|
||||
$this->setState('limit', $app->getUserStateFromRequest('com_search.limit', 'limit', $config->get('list_limit'), 'uint'));
|
||||
$this->setState('limitstart', $app->input->get('limitstart', 0, 'uint'));
|
||||
|
||||
// Set the search parameters
|
||||
$keyword = urldecode($app->input->getString('searchword'));
|
||||
$match = $app->input->get('searchphrase', 'all', 'word');
|
||||
$ordering = $app->input->get('ordering', 'newest', 'word');
|
||||
$this->setSearch($keyword, $match, $ordering);
|
||||
|
||||
//Set the search areas
|
||||
$areas = $app->input->get('areas', null, 'array');
|
||||
$this->setAreas($areas);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the search parameters
|
||||
*
|
||||
* @access public
|
||||
* @param string search string
|
||||
* @param string mathcing option, exact|any|all
|
||||
* @param string ordering option, newest|oldest|popular|alpha|category
|
||||
*/
|
||||
public function setSearch($keyword, $match = 'all', $ordering = 'newest')
|
||||
{
|
||||
if (isset($keyword))
|
||||
{
|
||||
$this->setState('origkeyword', $keyword);
|
||||
if ($match !== 'exact')
|
||||
{
|
||||
$keyword = preg_replace('#\xE3\x80\x80#s', ' ', $keyword);
|
||||
}
|
||||
$this->setState('keyword', $keyword);
|
||||
}
|
||||
|
||||
if (isset($match))
|
||||
{
|
||||
$this->setState('match', $match);
|
||||
}
|
||||
|
||||
if (isset($ordering))
|
||||
{
|
||||
$this->setState('ordering', $ordering);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set the search areas
|
||||
*
|
||||
* @access public
|
||||
* @param array Active areas
|
||||
* @param array Search areas
|
||||
*/
|
||||
public function setAreas($active = array(), $search = array())
|
||||
{
|
||||
$this->_areas['active'] = $active;
|
||||
$this->_areas['search'] = $search;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get weblink item data for the category
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
// Lets load the content if it doesn't already exist
|
||||
if (empty($this->_data))
|
||||
{
|
||||
$areas = $this->getAreas();
|
||||
|
||||
JPluginHelper::importPlugin('search');
|
||||
$dispatcher = JEventDispatcher::getInstance();
|
||||
$results = $dispatcher->trigger('onContentSearch', array(
|
||||
$this->getState('keyword'),
|
||||
$this->getState('match'),
|
||||
$this->getState('ordering'),
|
||||
$areas['active'])
|
||||
);
|
||||
|
||||
$rows = array();
|
||||
foreach ($results as $result)
|
||||
{
|
||||
$rows = array_merge((array) $rows, (array) $result);
|
||||
}
|
||||
|
||||
$this->_total = count($rows);
|
||||
if ($this->getState('limit') > 0)
|
||||
{
|
||||
$this->_data = array_splice($rows, $this->getState('limitstart'), $this->getState('limit'));
|
||||
} else {
|
||||
$this->_data = $rows;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the total number of weblink items for the category
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
public function getTotal()
|
||||
{
|
||||
return $this->_total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a pagination object of the weblink items for the category
|
||||
*
|
||||
* @access public
|
||||
* @return integer
|
||||
*/
|
||||
public function getPagination()
|
||||
{
|
||||
// Lets load the content if it doesn't already exist
|
||||
if (empty($this->_pagination))
|
||||
{
|
||||
$this->_pagination = new JPagination($this->getTotal(), $this->getState('limitstart'), $this->getState('limit'));
|
||||
}
|
||||
|
||||
return $this->_pagination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the search areas
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public function getAreas()
|
||||
{
|
||||
// Load the Category data
|
||||
if (empty($this->_areas['search']))
|
||||
{
|
||||
$areas = array();
|
||||
|
||||
JPluginHelper::importPlugin('search');
|
||||
$dispatcher = JEventDispatcher::getInstance();
|
||||
$searchareas = $dispatcher->trigger('onContentSearchAreas');
|
||||
|
||||
foreach ($searchareas as $area)
|
||||
{
|
||||
if (is_array($area))
|
||||
{
|
||||
$areas = array_merge($areas, $area);
|
||||
}
|
||||
}
|
||||
|
||||
$this->_areas['search'] = $areas;
|
||||
}
|
||||
|
||||
return $this->_areas;
|
||||
}
|
||||
}
|
40
components/com_search/router.php
Normal file
40
components/com_search/router.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* @param array
|
||||
* @return array
|
||||
*/
|
||||
function SearchBuildRoute(&$query)
|
||||
{
|
||||
$segments = array();
|
||||
|
||||
if (isset($query['view']))
|
||||
{
|
||||
unset($query['view']);
|
||||
}
|
||||
return $segments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array
|
||||
* @return array
|
||||
*/
|
||||
function SearchParseRoute($segments)
|
||||
{
|
||||
$vars = array();
|
||||
|
||||
$searchword = array_shift($segments);
|
||||
$vars['searchword'] = $searchword;
|
||||
$vars['view'] = 'search';
|
||||
|
||||
return $vars;
|
||||
}
|
14
components/com_search/search.php
Normal file
14
components/com_search/search.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @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;
|
||||
|
||||
$controller = JControllerLegacy::getInstance('Search');
|
||||
$controller->execute(JFactory::getApplication()->input->get('task'));
|
||||
$controller->redirect();
|
1
components/com_search/views/index.html
Normal file
1
components/com_search/views/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1
components/com_search/views/search/index.html
Normal file
1
components/com_search/views/search/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
6
components/com_search/views/search/metadata.xml
Normal file
6
components/com_search/views/search/metadata.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
<view title="Search">
|
||||
<message><![CDATA[TYPESEARCHDESC]]></message>
|
||||
</view>
|
||||
</metadata>
|
30
components/com_search/views/search/tmpl/default.php
Normal file
30
components/com_search/views/search/tmpl/default.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @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;
|
||||
?>
|
||||
|
||||
<div class="search<?php echo $this->pageclass_sfx; ?>">
|
||||
<?php if ($this->params->get('show_page_heading', 1)) : ?>
|
||||
<h1 class="page-title">
|
||||
<?php if ($this->escape($this->params->get('page_heading'))) :?>
|
||||
<?php echo $this->escape($this->params->get('page_heading')); ?>
|
||||
<?php else : ?>
|
||||
<?php echo $this->escape($this->params->get('page_title')); ?>
|
||||
<?php endif; ?>
|
||||
</h1>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo $this->loadTemplate('form'); ?>
|
||||
<?php if ($this->error == null && count($this->results) > 0) :
|
||||
echo $this->loadTemplate('results');
|
||||
else :
|
||||
echo $this->loadTemplate('error');
|
||||
endif; ?>
|
||||
</div>
|
77
components/com_search/views/search/tmpl/default.xml
Normal file
77
components/com_search/views/search/tmpl/default.xml
Normal file
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
<layout title="COM_SEARCH_SEARCH_VIEW_DEFAULT_TITLE" option="COM_SEARCH_SEARCH_VIEW_DEFAULT_OPTION">
|
||||
<help
|
||||
key = "JHELP_MENUS_MENU_ITEM_SEARCH_RESULTS"
|
||||
/>
|
||||
<message>
|
||||
<![CDATA[COM_SEARCH_SEARCH_VIEW_DEFAULT_DESC]]>
|
||||
</message>
|
||||
</layout>
|
||||
|
||||
<!-- Add fields to the request variables for the layout. -->
|
||||
<fields name="request">
|
||||
<fieldset name="request" label="COM_SEARCH_FIELDSET_OPTIONAL_LABEL">
|
||||
|
||||
<field name="searchword" type="text"
|
||||
description="COM_SEARCH_FIELD_DESC"
|
||||
label="COM_SEARCH_FIELD_LABEL"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<!-- Add fields to the parameters object for the layout. -->
|
||||
<fields name="params">
|
||||
|
||||
<!-- Basic options. -->
|
||||
<fieldset name="basic" label="COM_MENUS_BASIC_FIELDSET_LABEL">
|
||||
|
||||
<field name="search_areas" type="list"
|
||||
|
||||
description="COM_SEARCH_FIELD_SEARCH_AREAS_DESC"
|
||||
label="COM_SEARCH_FIELD_SEARCH_AREAS_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
|
||||
<field name="show_date" type="list"
|
||||
|
||||
description="COM_SEARCH_CONFIG_FIELD_CREATED_DATE_DESC"
|
||||
label="COM_SEARCH_CONFIG_FIELD_CREATED_DATE_LABEL"
|
||||
>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
|
||||
<field name="spacer1" type="spacer" class="text"
|
||||
label="COM_SEARCH_SAVED_SEARCH_OPTIONS"
|
||||
/>
|
||||
|
||||
<!-- Add fields to define saved search. -->
|
||||
|
||||
<field name="searchphrase" type="list"
|
||||
default="0"
|
||||
description="COM_SEARCH_FOR_DESC"
|
||||
label="COM_SEARCH_FOR_LABEL"
|
||||
>
|
||||
<option value="0">COM_SEARCH_ALL_WORDS</option>
|
||||
<option value="1">COM_SEARCH_ANY_WORDS</option>
|
||||
<option value="2">COM_SEARCH_EXACT_PHRASE</option>
|
||||
</field>
|
||||
<field name="ordering" type="list"
|
||||
default="0"
|
||||
description="COM_SEARCH_ORDERING_DESC"
|
||||
label="COM_SEARCH_ORDERING_LABEL"
|
||||
>
|
||||
<option value="newest">COM_SEARCH_NEWEST_FIRST</option>
|
||||
<option value="oldest">COM_SEARCH_OLDEST_FIRST</option>
|
||||
<option value="popular">COM_SEARCH_MOST_POPULAR</option>
|
||||
<option value="alpha">COM_SEARCH_ALPHABETICAL</option>
|
||||
<option value="category">JCATEGORY</option>
|
||||
</field>
|
||||
|
||||
</fieldset>
|
||||
</fields>
|
||||
</metadata>
|
17
components/com_search/views/search/tmpl/default_error.php
Normal file
17
components/com_search/views/search/tmpl/default_error.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @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;
|
||||
?>
|
||||
|
||||
<?php if ($this->error) : ?>
|
||||
<div class="error">
|
||||
<?php echo $this->escape($this->error); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
78
components/com_search/views/search/tmpl/default_form.php
Normal file
78
components/com_search/views/search/tmpl/default_form.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @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;
|
||||
|
||||
JHtml::_('bootstrap.tooltip');
|
||||
|
||||
$lang = JFactory::getLanguage();
|
||||
$upper_limit = $lang->getUpperLimitSearchWord();
|
||||
?>
|
||||
<form id="searchForm" action="<?php echo JRoute::_('index.php?option=com_search');?>" method="post">
|
||||
|
||||
<div class="btn-toolbar">
|
||||
<div class="btn-group pull-left">
|
||||
<input type="text" name="searchword" placeholder="<?php echo JText::_('COM_SEARCH_SEARCH_KEYWORD'); ?>" id="search-searchword" size="30" maxlength="<?php echo $upper_limit; ?>" value="<?php echo $this->escape($this->origkeyword); ?>" class="inputbox" />
|
||||
</div>
|
||||
<div class="btn-group pull-left">
|
||||
<button name="Search" onclick="this.form.submit()" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('COM_SEARCH_SEARCH');?>"><span class="icon-search"></span></button>
|
||||
</div>
|
||||
<input type="hidden" name="task" value="search" />
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
|
||||
<div class="searchintro<?php echo $this->params->get('pageclass_sfx'); ?>">
|
||||
<?php if (!empty($this->searchword)):?>
|
||||
<p><?php echo JText::plural('COM_SEARCH_SEARCH_KEYWORD_N_RESULTS', '<span class="badge badge-info">'. $this->total. '</span>');?></p>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
|
||||
<fieldset class="phrases">
|
||||
<legend><?php echo JText::_('COM_SEARCH_FOR');?>
|
||||
</legend>
|
||||
<div class="phrases-box">
|
||||
<?php echo $this->lists['searchphrase']; ?>
|
||||
</div>
|
||||
<div class="ordering-box">
|
||||
<label for="ordering" class="ordering">
|
||||
<?php echo JText::_('COM_SEARCH_ORDERING');?>
|
||||
</label>
|
||||
<?php echo $this->lists['ordering'];?>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<?php if ($this->params->get('search_areas', 1)) : ?>
|
||||
<fieldset class="only">
|
||||
<legend><?php echo JText::_('COM_SEARCH_SEARCH_ONLY');?></legend>
|
||||
<?php foreach ($this->searchareas['search'] as $val => $txt) :
|
||||
$checked = is_array($this->searchareas['active']) && in_array($val, $this->searchareas['active']) ? 'checked="checked"' : '';
|
||||
?>
|
||||
<label for="area-<?php echo $val;?>" class="checkbox">
|
||||
<input type="checkbox" name="areas[]" value="<?php echo $val;?>" id="area-<?php echo $val;?>" <?php echo $checked;?> >
|
||||
<?php echo JText::_($txt); ?>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</fieldset>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->total > 0) : ?>
|
||||
|
||||
<div class="form-limit">
|
||||
<label for="limit">
|
||||
<?php echo JText::_('JGLOBAL_DISPLAY_NUM'); ?>
|
||||
</label>
|
||||
<?php echo $this->pagination->getLimitBox(); ?>
|
||||
</div>
|
||||
<p class="counter">
|
||||
<?php echo $this->pagination->getPagesCounter(); ?>
|
||||
</p>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</form>
|
45
components/com_search/views/search/tmpl/default_results.php
Normal file
45
components/com_search/views/search/tmpl/default_results.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @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;
|
||||
?>
|
||||
|
||||
<dl class="search-results<?php echo $this->pageclass_sfx; ?>">
|
||||
<?php foreach ($this->results as $result) : ?>
|
||||
<dt class="result-title">
|
||||
<?php echo $this->pagination->limitstart + $result->count.'. ';?>
|
||||
<?php if ($result->href) :?>
|
||||
<a href="<?php echo JRoute::_($result->href); ?>"<?php if ($result->browsernav == 1) :?> target="_blank"<?php endif;?>>
|
||||
<?php echo $this->escape($result->title);?>
|
||||
</a>
|
||||
<?php else:?>
|
||||
<?php echo $this->escape($result->title);?>
|
||||
<?php endif; ?>
|
||||
</dt>
|
||||
<?php if ($result->section) : ?>
|
||||
<dd class="result-category">
|
||||
<span class="small<?php echo $this->pageclass_sfx; ?>">
|
||||
(<?php echo $this->escape($result->section); ?>)
|
||||
</span>
|
||||
</dd>
|
||||
<?php endif; ?>
|
||||
<dd class="result-text">
|
||||
<?php echo $result->text; ?>
|
||||
</dd>
|
||||
<?php if ($this->params->get('show_date')) : ?>
|
||||
<dd class="result-created<?php echo $this->pageclass_sfx; ?>">
|
||||
<?php echo JText::sprintf('JGLOBAL_CREATED_DATE_ON', $result->created); ?>
|
||||
</dd>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</dl>
|
||||
|
||||
<div class="pagination">
|
||||
<?php echo $this->pagination->getPagesLinks(); ?>
|
||||
</div>
|
1
components/com_search/views/search/tmpl/index.html
Normal file
1
components/com_search/views/search/tmpl/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
225
components/com_search/views/search/view.html.php
Normal file
225
components/com_search/views/search/view.html.php
Normal file
@ -0,0 +1,225 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* HTML View class for the search component
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_search
|
||||
* @since 1.0
|
||||
*/
|
||||
class SearchViewSearch extends JViewLegacy
|
||||
{
|
||||
/**
|
||||
* Execute and display a template script.
|
||||
*
|
||||
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
||||
*
|
||||
* @return mixed A string if successful, otherwise a Error object.
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/search.php';
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$uri = JUri::getInstance();
|
||||
|
||||
$error = null;
|
||||
$rows = null;
|
||||
$results = null;
|
||||
$total = 0;
|
||||
|
||||
// Get some data from the model
|
||||
$areas = $this->get('areas');
|
||||
$state = $this->get('state');
|
||||
$searchword = $state->get('keyword');
|
||||
$params = $app->getParams();
|
||||
|
||||
$menus = $app->getMenu();
|
||||
$menu = $menus->getActive();
|
||||
|
||||
// Because the application sets a default page title, we need to get it right from the menu item itself
|
||||
if (is_object($menu))
|
||||
{
|
||||
$menu_params = new JRegistry;
|
||||
$menu_params->loadString($menu->params);
|
||||
|
||||
if (!$menu_params->get('page_title'))
|
||||
{
|
||||
$params->set('page_title', JText::_('COM_SEARCH_SEARCH'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$params->set('page_title', JText::_('COM_SEARCH_SEARCH'));
|
||||
}
|
||||
|
||||
$title = $params->get('page_title');
|
||||
|
||||
if ($app->getCfg('sitename_pagetitles', 0) == 1)
|
||||
{
|
||||
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
|
||||
}
|
||||
elseif ($app->getCfg('sitename_pagetitles', 0) == 2)
|
||||
{
|
||||
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
|
||||
}
|
||||
|
||||
$this->document->setTitle($title);
|
||||
|
||||
if ($params->get('menu-meta_description'))
|
||||
{
|
||||
$this->document->setDescription($params->get('menu-meta_description'));
|
||||
}
|
||||
|
||||
if ($params->get('menu-meta_keywords'))
|
||||
{
|
||||
$this->document->setMetadata('keywords', $params->get('menu-meta_keywords'));
|
||||
}
|
||||
|
||||
if ($params->get('robots'))
|
||||
{
|
||||
$this->document->setMetadata('robots', $params->get('robots'));
|
||||
}
|
||||
|
||||
// Built select lists
|
||||
$orders = array();
|
||||
$orders[] = JHtml::_('select.option', 'newest', JText::_('COM_SEARCH_NEWEST_FIRST'));
|
||||
$orders[] = JHtml::_('select.option', 'oldest', JText::_('COM_SEARCH_OLDEST_FIRST'));
|
||||
$orders[] = JHtml::_('select.option', 'popular', JText::_('COM_SEARCH_MOST_POPULAR'));
|
||||
$orders[] = JHtml::_('select.option', 'alpha', JText::_('COM_SEARCH_ALPHABETICAL'));
|
||||
$orders[] = JHtml::_('select.option', 'category', JText::_('JCATEGORY'));
|
||||
|
||||
$lists = array();
|
||||
$lists['ordering'] = JHtml::_('select.genericlist', $orders, 'ordering', 'class="inputbox"', 'value', 'text', $state->get('ordering'));
|
||||
|
||||
$searchphrases = array();
|
||||
$searchphrases[] = JHtml::_('select.option', 'all', JText::_('COM_SEARCH_ALL_WORDS'));
|
||||
$searchphrases[] = JHtml::_('select.option', 'any', JText::_('COM_SEARCH_ANY_WORDS'));
|
||||
$searchphrases[] = JHtml::_('select.option', 'exact', JText::_('COM_SEARCH_EXACT_PHRASE'));
|
||||
$lists['searchphrase'] = JHtml::_('select.radiolist', $searchphrases, 'searchphrase', '', 'value', 'text', $state->get('match'));
|
||||
|
||||
// Log the search
|
||||
JSearchHelper::logSearch($searchword, 'com_search');
|
||||
|
||||
// Limit searchword
|
||||
$lang = JFactory::getLanguage();
|
||||
$upper_limit = $lang->getUpperLimitSearchWord();
|
||||
$lower_limit = $lang->getLowerLimitSearchWord();
|
||||
|
||||
if (SearchHelper::limitSearchWord($searchword))
|
||||
{
|
||||
$error = JText::sprintf('COM_SEARCH_ERROR_SEARCH_MESSAGE', $lower_limit, $upper_limit);
|
||||
}
|
||||
|
||||
// Sanitise searchword
|
||||
if (SearchHelper::santiseSearchWord($searchword, $state->get('match')))
|
||||
{
|
||||
$error = JText::_('COM_SEARCH_ERROR_IGNOREKEYWORD');
|
||||
}
|
||||
|
||||
if (!$searchword && !empty($this->input) && count($this->input->post))
|
||||
{
|
||||
// $error = JText::_('COM_SEARCH_ERROR_ENTERKEYWORD');
|
||||
}
|
||||
|
||||
// Put the filtered results back into the model
|
||||
// for next release, the checks should be done in the model perhaps...
|
||||
$state->set('keyword', $searchword);
|
||||
|
||||
if ($error == null)
|
||||
{
|
||||
$results = $this->get('data');
|
||||
$total = $this->get('total');
|
||||
$pagination = $this->get('pagination');
|
||||
|
||||
require_once JPATH_SITE . '/components/com_content/helpers/route.php';
|
||||
|
||||
for ($i = 0, $count = count($results); $i < $count; $i++)
|
||||
{
|
||||
$row = & $results[$i]->text;
|
||||
|
||||
if ($state->get('match') == 'exact')
|
||||
{
|
||||
$searchwords = array($searchword);
|
||||
$needle = $searchword;
|
||||
}
|
||||
else
|
||||
{
|
||||
$searchworda = preg_replace('#\xE3\x80\x80#s', ' ', $searchword);
|
||||
$searchwords = preg_split("/\s+/u", $searchworda);
|
||||
$needle = $searchwords[0];
|
||||
}
|
||||
|
||||
$row = SearchHelper::prepareSearchContent($row, $needle);
|
||||
$searchwords = array_values(array_unique($searchwords));
|
||||
$srow = strtolower(SearchHelper::remove_accents($row));
|
||||
$hl1 = '<span class="highlight">';
|
||||
$hl2 = '</span>';
|
||||
$cnt = 0;
|
||||
|
||||
foreach ($searchwords as $hlword)
|
||||
{
|
||||
if (($pos = mb_strpos($srow, strtolower(SearchHelper::remove_accents($hlword)))) !== false)
|
||||
{
|
||||
$pos += $cnt++ * mb_strlen($hl1 . $hl2);
|
||||
|
||||
// iconv transliterates '€' to 'EUR'
|
||||
// TODO: add other expanding translations?
|
||||
$eur_compensation = $pos > 0 ? substr_count($row, "\xE2\x82\xAC", 0, $pos) * 2 : 0;
|
||||
$pos -= $eur_compensation;
|
||||
$row = mb_substr($row, 0, $pos) . $hl1 . mb_substr($row, $pos, mb_strlen($hlword)) . $hl2 . mb_substr($row, $pos + mb_strlen($hlword));
|
||||
}
|
||||
}
|
||||
|
||||
$result = & $results[$i];
|
||||
|
||||
if ($result->created)
|
||||
{
|
||||
$created = JHtml::_('date', $result->created, JText::_('DATE_FORMAT_LC3'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$created = '';
|
||||
}
|
||||
|
||||
$result->text = JHtml::_('content.prepare', $result->text, '', 'com_search.search');
|
||||
$result->created = $created;
|
||||
$result->count = $i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for layout override
|
||||
$active = JFactory::getApplication()->getMenu()->getActive();
|
||||
|
||||
if (isset($active->query['layout']))
|
||||
{
|
||||
$this->setLayout($active->query['layout']);
|
||||
}
|
||||
|
||||
// Escape strings for HTML output
|
||||
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
|
||||
$this->pagination = &$pagination;
|
||||
$this->results = &$results;
|
||||
$this->lists = &$lists;
|
||||
$this->params = &$params;
|
||||
$this->ordering = $state->get('ordering');
|
||||
$this->searchword = $searchword;
|
||||
$this->origkeyword = $state->get('origkeyword');
|
||||
$this->searchphrase = $state->get('match');
|
||||
$this->searchareas = $areas;
|
||||
$this->total = $total;
|
||||
$this->error = $error;
|
||||
$this->action = $uri;
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
}
|
45
components/com_search/views/search/view.opensearch.php
Normal file
45
components/com_search/views/search/view.opensearch.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* OpenSearch View class for the Search component
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage Search
|
||||
* @since 1.7
|
||||
*/
|
||||
class SearchViewSearch extends JViewLegacy
|
||||
{
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$doc = JFactory::getDocument();
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
$params = JComponentHelper::getParams('com_search');
|
||||
$doc->setShortName($params->get('opensearch_name', $app->getCfg('sitename')));
|
||||
$doc->setDescription($params->get('opensearch_description', $app->getCfg('MetaDesc')));
|
||||
|
||||
// Add the URL for the search
|
||||
$searchUri = JUri::base().'index.php?option=com_search&searchword={searchTerms}';
|
||||
|
||||
// Find the menu item for the search
|
||||
$menu = $app->getMenu();
|
||||
$items = $menu->getItems('link', 'index.php?option=com_search&view=search');
|
||||
if (isset($items[0]))
|
||||
{
|
||||
$searchUri .= '&Itemid='.$items[0]->id;
|
||||
}
|
||||
|
||||
$htmlSearch = new JOpenSearchUrl;
|
||||
$htmlSearch->template = JRoute::_($searchUri);
|
||||
$doc->addUrl($htmlSearch);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user