You've already forked joomla_test
first commit
This commit is contained in:
59
components/com_finder/controller.php
Normal file
59
components/com_finder/controller.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/language.php');
|
||||
|
||||
/**
|
||||
* Finder Component Controller.
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class FinderController extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
* Method to display a view.
|
||||
*
|
||||
* @param boolean $cachable If true, the view output will be cached. [optional]
|
||||
* @param array $urlparams An array of safe url parameters and their variable types,
|
||||
* for valid values see {@link JFilterInput::clean()}. [optional]
|
||||
*
|
||||
* @return JControllerLegacy This object is to support chaining.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function display($cachable = false, $urlparams = array())
|
||||
{
|
||||
$input = JFactory::getApplication()->input;
|
||||
$cachable = true;
|
||||
|
||||
// Load plug-in language files.
|
||||
FinderHelperLanguage::loadPluginLanguage();
|
||||
|
||||
// Set the default view name and format from the Request.
|
||||
$viewName = $input->get('view', 'search', 'word');
|
||||
$input->set('view', $viewName);
|
||||
|
||||
// Don't cache view for search queries
|
||||
if ($input->get('q') || $input->get('f') || $input->get('t'))
|
||||
{
|
||||
$cachable = false;
|
||||
}
|
||||
|
||||
$safeurlparams = array(
|
||||
'f' => 'INT',
|
||||
'lang' => 'CMD'
|
||||
);
|
||||
|
||||
return parent::display($cachable, $safeurlparams);
|
||||
}
|
||||
}
|
1
components/com_finder/controllers/index.html
Normal file
1
components/com_finder/controllers/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
56
components/com_finder/controllers/suggestions.json.php
Normal file
56
components/com_finder/controllers/suggestions.json.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Suggestions JSON controller for Finder.
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class FinderControllerSuggestions extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
* Method to find search query suggestions.
|
||||
*
|
||||
* @param boolean $cachable If true, the view output will be cached
|
||||
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function display($cachable = false, $urlparams = false)
|
||||
{
|
||||
$return = array();
|
||||
|
||||
$params = JComponentHelper::getParams('com_finder');
|
||||
if ($params->get('show_autosuggest', 1))
|
||||
{
|
||||
// Get the suggestions.
|
||||
$model = $this->getModel('Suggestions', 'FinderModel');
|
||||
$return = $model->getItems();
|
||||
}
|
||||
|
||||
// Check the data.
|
||||
if (empty($return))
|
||||
{
|
||||
$return = array();
|
||||
}
|
||||
|
||||
// Use the correct json mime-type
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Send the response.
|
||||
echo json_encode($return);
|
||||
JFactory::getApplication()->close();
|
||||
}
|
||||
}
|
16
components/com_finder/finder.php
Normal file
16
components/com_finder/finder.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once JPATH_COMPONENT . '/helpers/route.php';
|
||||
|
||||
$controller = JControllerLegacy::getInstance('Finder');
|
||||
$controller->execute(JFactory::getApplication()->input->get('task'));
|
||||
$controller->redirect();
|
506
components/com_finder/helpers/html/filter.php
Normal file
506
components/com_finder/helpers/html/filter.php
Normal file
@ -0,0 +1,506 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JLoader::register('FinderHelperLanguage', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/language.php');
|
||||
|
||||
/**
|
||||
* Filter HTML Behaviors for Finder.
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
abstract class JHtmlFilter
|
||||
{
|
||||
/**
|
||||
* Method to generate filters using the slider widget and decorated
|
||||
* with the FinderFilter JavaScript behaviors.
|
||||
*
|
||||
* @param array $options An array of configuration options. [optional]
|
||||
*
|
||||
* @return mixed A rendered HTML widget on success, null otherwise.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public static function slider($options = array())
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$user = JFactory::getUser();
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$html = '';
|
||||
$filter = null;
|
||||
|
||||
// Get the configuration options.
|
||||
$filterId = array_key_exists('filter_id', $options) ? $options['filter_id'] : null;
|
||||
$activeNodes = array_key_exists('selected_nodes', $options) ? $options['selected_nodes'] : array();
|
||||
$classSuffix = array_key_exists('class_suffix', $options) ? $options['class_suffix'] : '';
|
||||
$loadMedia = array_key_exists('load_media', $options) ? $options['load_media'] : true;
|
||||
|
||||
// Load the predefined filter if specified.
|
||||
if (!empty($filterId))
|
||||
{
|
||||
$query->select('f.data, f.params')
|
||||
->from($db->quoteName('#__finder_filters') . ' AS f')
|
||||
->where('f.filter_id = ' . (int) $filterId);
|
||||
|
||||
// Load the filter data.
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$filter = $db->loadObject();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Initialize the filter parameters.
|
||||
if ($filter)
|
||||
{
|
||||
$registry = new JRegistry;
|
||||
$registry->loadString($filter->params);
|
||||
$filter->params = $registry;
|
||||
}
|
||||
}
|
||||
|
||||
// Build the query to get the branch data and the number of child nodes.
|
||||
$query->clear()
|
||||
->select('t.*, count(c.id) AS children')
|
||||
->from($db->quoteName('#__finder_taxonomy') . ' AS t')
|
||||
->join('INNER', $db->quoteName('#__finder_taxonomy') . ' AS c ON c.parent_id = t.id')
|
||||
->where('t.parent_id = 1')
|
||||
->where('t.state = 1')
|
||||
->where('t.access IN (' . $groups . ')')
|
||||
->where('c.state = 1')
|
||||
->where('c.access IN (' . $groups . ')')
|
||||
->group('t.id, t.parent_id, t.state, t.access, t.ordering, t.title, c.parent_id')
|
||||
->order('t.ordering, t.title');
|
||||
|
||||
// Limit the branch children to a predefined filter.
|
||||
if ($filter)
|
||||
{
|
||||
$query->where('c.id IN(' . $filter->data . ')');
|
||||
}
|
||||
|
||||
// Load the branches.
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$branches = $db->loadObjectList('id');
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check that we have at least one branch.
|
||||
if (count($branches) === 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Load the CSS/JS resources.
|
||||
if ($loadMedia)
|
||||
{
|
||||
JHtml::_('stylesheet', 'com_finder/sliderfilter.css', false, true, false);
|
||||
JHtml::_('script', 'com_finder/sliderfilter.js', false, true);
|
||||
}
|
||||
|
||||
// Load plug-in language files.
|
||||
FinderHelperLanguage::loadPluginLanguage();
|
||||
|
||||
// Start the widget.
|
||||
$html .= '<div id="finder-filter-container">';
|
||||
$html .= '<dl id="branch-selectors">';
|
||||
$html .= '<dt>';
|
||||
$html .= '<label for="tax-select-all" class="checkbox">';
|
||||
$html .= '<input type="checkbox" id="tax-select-all" />';
|
||||
$html .= JText::_('COM_FINDER_FILTER_SELECT_ALL_LABEL');
|
||||
$html .= '</label>';
|
||||
$html .= '</dt>';
|
||||
$html .= '<div class="control-group">';
|
||||
|
||||
// Iterate through the branches to build the branch selector.
|
||||
foreach ($branches as $bk => $bv)
|
||||
{
|
||||
// If the multi-lang plug-in is enabled then drop the language branch.
|
||||
if ($bv->title == 'Language' && JLanguageMultilang::isEnabled())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$html .= '<label for="tax-' . $bk . '" class="checkbox">';
|
||||
$html .= '<input type="checkbox" class="toggler" id="tax-' . $bk . '"/>';
|
||||
$html .= JText::sprintf('COM_FINDER_FILTER_BRANCH_LABEL', JText::_(FinderHelperLanguage::branchSingular($bv->title)));
|
||||
$html .= '</label>';
|
||||
}
|
||||
|
||||
$html .= '</div>';
|
||||
$html .= '</dl>';
|
||||
$html .= '<div id="finder-filter-container">';
|
||||
|
||||
// Iterate through the branches and build the branch groups.
|
||||
foreach ($branches as $bk => $bv)
|
||||
{
|
||||
// If the multi-lang plug-in is enabled then drop the language branch.
|
||||
if ($bv->title == 'Language' && JLanguageMultilang::isEnabled())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Build the query to get the child nodes for this branch.
|
||||
$query->clear()
|
||||
->select('t.*')
|
||||
->from($db->quoteName('#__finder_taxonomy') . ' AS t')
|
||||
->where('t.parent_id = ' . (int) $bk)
|
||||
->where('t.state = 1')
|
||||
->where('t.access IN (' . $groups . ')')
|
||||
->order('t.ordering, t.title');
|
||||
|
||||
// Load the branches.
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$nodes = $db->loadObjectList('id');
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Translate node titles if possible.
|
||||
$lang = JFactory::getLanguage();
|
||||
foreach ($nodes as $nk => $nv)
|
||||
{
|
||||
$key = FinderHelperLanguage::branchPlural($nv->title);
|
||||
if ($lang->hasKey($key))
|
||||
{
|
||||
$nodes[$nk]->title = JText::_($key);
|
||||
}
|
||||
}
|
||||
|
||||
// Start the group.
|
||||
$html .= '<dl class="checklist" rel="tax-' . $bk . '">';
|
||||
$html .= '<dt>';
|
||||
$html .= '<label for="tax-' . JFilterOutput::stringUrlSafe($bv->title) . '" class="checkbox">';
|
||||
$html .= '<input type="checkbox" class="branch-selector filter-branch' . $classSuffix . '" id="tax-'
|
||||
. JFilterOutput::stringUrlSafe($bv->title) . '" />';
|
||||
$html .= JText::sprintf('COM_FINDER_FILTER_BRANCH_LABEL', JText::_(FinderHelperLanguage::branchSingular($bv->title)));
|
||||
$html .= '</label>';
|
||||
$html .= '</dt>';
|
||||
$html .= '<div class="control-group">';
|
||||
|
||||
// Populate the group with nodes.
|
||||
foreach ($nodes as $nk => $nv)
|
||||
{
|
||||
// Determine if the node should be checked.
|
||||
$checked = in_array($nk, $activeNodes) ? ' checked="checked"' : '';
|
||||
|
||||
// Build a node.
|
||||
$html .= '<label for="tax-' . $nk . '" class="checkbox">';
|
||||
$html .= '<input class="selector filter-node' . $classSuffix . '" type="checkbox" value="' . $nk . '" name="t[]" id="tax-'
|
||||
. $nk . '"' . $checked . ' />';
|
||||
$html .= $nv->title;
|
||||
$html .= '</label>';
|
||||
}
|
||||
|
||||
// Close the group.
|
||||
$html .= '</div>';
|
||||
$html .= '</dl>';
|
||||
}
|
||||
|
||||
// Close the widget.
|
||||
$html .= '<div class="clr"></div>';
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to generate filters using select box drop down controls.
|
||||
*
|
||||
* @param FinderIndexerQuery $idxQuery A FinderIndexerQuery object.
|
||||
* @param array $options An array of options.
|
||||
*
|
||||
* @return mixed A rendered HTML widget on success, null otherwise.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public static function select($idxQuery, $options)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$filter = null;
|
||||
|
||||
// Get the configuration options.
|
||||
$classSuffix = $options->get('class_suffix', null);
|
||||
$loadMedia = $options->get('load_media', true);
|
||||
$showDates = $options->get('show_date_filters', false);
|
||||
|
||||
// Try to load the results from cache.
|
||||
$cache = JFactory::getCache('com_finder', '');
|
||||
$cacheId = 'filter_select_' . serialize(array($idxQuery->filter, $options, $groups, JFactory::getLanguage()->getTag()));
|
||||
|
||||
// Check the cached results.
|
||||
if (!($branches = $cache->get($cacheId)))
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Load the predefined filter if specified.
|
||||
if (!empty($idxQuery->filter))
|
||||
{
|
||||
$query->select('f.data, ' . $db->quoteName('f.params'))
|
||||
->from($db->quoteName('#__finder_filters') . ' AS f')
|
||||
->where('f.filter_id = ' . (int) $idxQuery->filter);
|
||||
|
||||
// Load the filter data.
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$filter = $db->loadObject();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Initialize the filter parameters.
|
||||
if ($filter)
|
||||
{
|
||||
$registry = new JRegistry;
|
||||
$registry->loadString($filter->params);
|
||||
$filter->params = $registry;
|
||||
}
|
||||
}
|
||||
|
||||
// Build the query to get the branch data and the number of child nodes.
|
||||
$query->clear()
|
||||
->select('t.*, count(c.id) AS children')
|
||||
->from($db->quoteName('#__finder_taxonomy') . ' AS t')
|
||||
->join('INNER', $db->quoteName('#__finder_taxonomy') . ' AS c ON c.parent_id = t.id')
|
||||
->where('t.parent_id = 1')
|
||||
->where('t.state = 1')
|
||||
->where('t.access IN (' . $groups . ')')
|
||||
->where('c.state = 1')
|
||||
->where('c.access IN (' . $groups . ')')
|
||||
->group($db->quoteName('t.id'))
|
||||
->order('t.ordering, t.title');
|
||||
|
||||
// Limit the branch children to a predefined filter.
|
||||
if (!empty($filter->data))
|
||||
{
|
||||
$query->where('c.id IN(' . $filter->data . ')');
|
||||
}
|
||||
|
||||
// Load the branches.
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$branches = $db->loadObjectList('id');
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check that we have at least one branch.
|
||||
if (count($branches) === 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Iterate through the branches and build the branch groups.
|
||||
foreach ($branches as $bk => $bv)
|
||||
{
|
||||
// If the multi-lang plug-in is enabled then drop the language branch.
|
||||
if ($bv->title == 'Language' && JLanguageMultilang::isEnabled())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Build the query to get the child nodes for this branch.
|
||||
$query->clear()
|
||||
->select('t.*')
|
||||
->from($db->quoteName('#__finder_taxonomy') . ' AS t')
|
||||
->where('t.parent_id = ' . (int) $bk)
|
||||
->where('t.state = 1')
|
||||
->where('t.access IN (' . $groups . ')')
|
||||
->order('t.ordering, t.title');
|
||||
|
||||
// Limit the nodes to a predefined filter.
|
||||
if (!empty($filter->data))
|
||||
{
|
||||
$query->where('t.id IN(' . $filter->data . ')');
|
||||
}
|
||||
|
||||
// Load the branches.
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$branches[$bk]->nodes = $db->loadObjectList('id');
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Translate branch nodes if possible.
|
||||
$language = JFactory::getLanguage();
|
||||
foreach ($branches[$bk]->nodes as $node_id => $node)
|
||||
{
|
||||
$key = FinderHelperLanguage::branchPlural($node->title);
|
||||
if ($language->hasKey($key))
|
||||
{
|
||||
$branches[$bk]->nodes[$node_id]->title = JText::_($key);
|
||||
}
|
||||
}
|
||||
|
||||
// Add the Search All option to the branch.
|
||||
array_unshift($branches[$bk]->nodes, array('id' => null, 'title' => JText::_('COM_FINDER_FILTER_SELECT_ALL_LABEL')));
|
||||
}
|
||||
|
||||
// Store the data in cache.
|
||||
$cache->store($branches, $cacheId);
|
||||
}
|
||||
|
||||
$html = '';
|
||||
|
||||
// Add the dates if enabled.
|
||||
if ($showDates)
|
||||
{
|
||||
$html .= JHtml::_('filter.dates', $idxQuery, $options);
|
||||
}
|
||||
|
||||
$html .= '<div id="finder-filter-select-list" class="form-horizontal">';
|
||||
|
||||
// Iterate through all branches and build code.
|
||||
foreach ($branches as $bk => $bv)
|
||||
{
|
||||
// If the multi-lang plug-in is enabled then drop the language branch.
|
||||
if ($bv->title == 'Language' && JLanguageMultilang::isEnabled())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$active = null;
|
||||
|
||||
// Check if the branch is in the filter.
|
||||
if (array_key_exists($bv->title, $idxQuery->filters))
|
||||
{
|
||||
// Get the request filters.
|
||||
$temp = JFactory::getApplication()->input->request->get('t', array(), 'array');
|
||||
|
||||
// Search for active nodes in the branch and get the active node.
|
||||
$active = array_intersect($temp, $idxQuery->filters[$bv->title]);
|
||||
$active = count($active) === 1 ? array_shift($active) : null;
|
||||
}
|
||||
|
||||
$html .= '<div class="filter-branch' . $classSuffix . ' control-group">';
|
||||
$html .= '<label for="tax-' . JFilterOutput::stringUrlSafe($bv->title) . '" class="control-label">';
|
||||
$html .= JText::sprintf('COM_FINDER_FILTER_BRANCH_LABEL', JText::_(FinderHelperLanguage::branchSingular($bv->title)));
|
||||
$html .= '</label>';
|
||||
$html .= '<div class="controls">';
|
||||
$html .= JHtml::_(
|
||||
'select.genericlist', $branches[$bk]->nodes, 't[]', 'class="inputbox"', 'id', 'title', $active,
|
||||
'tax-' . JFilterOutput::stringUrlSafe($bv->title)
|
||||
);
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
}
|
||||
|
||||
// Close the widget.
|
||||
$html .= '</div>';
|
||||
|
||||
// Load the CSS/JS resources.
|
||||
if ($loadMedia)
|
||||
{
|
||||
JHtml::stylesheet('com_finder/sliderfilter.css', false, true, false);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to generate fields for filtering dates
|
||||
*
|
||||
* @param FinderIndexerQuery $idxQuery A FinderIndexerQuery object.
|
||||
* @param array $options An array of options.
|
||||
*
|
||||
* @return mixed A rendered HTML widget on success, null otherwise.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public static function dates($idxQuery, $options)
|
||||
{
|
||||
$html = '';
|
||||
|
||||
// Get the configuration options.
|
||||
$classSuffix = $options->get('class_suffix', null);
|
||||
$loadMedia = $options->get('load_media', true);
|
||||
$showDates = $options->get('show_date_filters', false);
|
||||
|
||||
if (!empty($showDates))
|
||||
{
|
||||
// Build the date operators options.
|
||||
$operators = array();
|
||||
$operators[] = JHtml::_('select.option', 'before', JText::_('COM_FINDER_FILTER_DATE_BEFORE'));
|
||||
$operators[] = JHtml::_('select.option', 'exact', JText::_('COM_FINDER_FILTER_DATE_EXACTLY'));
|
||||
$operators[] = JHtml::_('select.option', 'after', JText::_('COM_FINDER_FILTER_DATE_AFTER'));
|
||||
|
||||
// Load the CSS/JS resources.
|
||||
if ($loadMedia)
|
||||
{
|
||||
JHtml::stylesheet('com_finder/dates.css', false, true, false);
|
||||
}
|
||||
|
||||
// Open the widget.
|
||||
$html .= '<ul id="finder-filter-select-dates">';
|
||||
|
||||
// Start date filter.
|
||||
$html .= '<li class="filter-date' . $classSuffix . '">';
|
||||
$html .= '<label for="filter_date1">';
|
||||
$html .= JText::_('COM_FINDER_FILTER_DATE1');
|
||||
$html .= '</label>';
|
||||
$html .= '<br />';
|
||||
$html .= JHtml::_(
|
||||
'select.genericlist', $operators, 'w1', 'class="inputbox filter-date-operator"', 'value', 'text', $idxQuery->when1, 'finder-filter-w1'
|
||||
);
|
||||
$html .= JHtml::calendar($idxQuery->date1, 'd1', 'filter_date1', '%Y-%m-%d', 'title="' . JText::_('COM_FINDER_FILTER_DATE1_DESC') . '"');
|
||||
$html .= '</li>';
|
||||
|
||||
// End date filter.
|
||||
$html .= '<li class="filter-date' . $classSuffix . '">';
|
||||
$html .= '<label for="filter_date2">';
|
||||
$html .= JText::_('COM_FINDER_FILTER_DATE2');
|
||||
$html .= '</label>';
|
||||
$html .= '<br />';
|
||||
$html .= JHtml::_(
|
||||
'select.genericlist', $operators, 'w2', 'class="inputbox filter-date-operator"', 'value', 'text', $idxQuery->when2, 'finder-filter-w2'
|
||||
);
|
||||
$html .= JHtml::calendar($idxQuery->date2, 'd2', 'filter_date2', '%Y-%m-%d', 'title="' . JText::_('COM_FINDER_FILTER_DATE2_DESC') . '"');
|
||||
$html .= '</li>';
|
||||
|
||||
// Close the widget.
|
||||
$html .= '</ul>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
1
components/com_finder/helpers/html/index.html
Normal file
1
components/com_finder/helpers/html/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
164
components/com_finder/helpers/html/query.php
Normal file
164
components/com_finder/helpers/html/query.php
Normal file
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Query HTML behavior class for Finder.
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
abstract class JHtmlQuery
|
||||
{
|
||||
/**
|
||||
* Method to get the explained (human-readable) search query.
|
||||
*
|
||||
* @param FinderIndexerQuery $query A FinderIndexerQuery object to explain.
|
||||
*
|
||||
* @return mixed String if there is data to explain, null otherwise.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public static function explained(FinderIndexerQuery $query)
|
||||
{
|
||||
$parts = array();
|
||||
|
||||
// Process the required tokens.
|
||||
foreach ($query->included as $token)
|
||||
{
|
||||
if ($token->required && (!isset($token->derived) || $token->derived == false))
|
||||
{
|
||||
$parts[] = '<span class="query-required">' . JText::sprintf('COM_FINDER_QUERY_TOKEN_REQUIRED', $token->term) . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
// Process the optional tokens.
|
||||
foreach ($query->included as $token)
|
||||
{
|
||||
if (!$token->required && (!isset($token->derived) || $token->derived == false))
|
||||
{
|
||||
$parts[] = '<span class="query-optional">' . JText::sprintf('COM_FINDER_QUERY_TOKEN_OPTIONAL', $token->term) . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
// Process the excluded tokens.
|
||||
foreach ($query->excluded as $token)
|
||||
{
|
||||
if (!isset($token->derived) || $token->derived == false)
|
||||
{
|
||||
$parts[] = '<span class="query-excluded">' . JText::sprintf('COM_FINDER_QUERY_TOKEN_EXCLUDED', $token->term) . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
// Process the start date.
|
||||
if ($query->date1)
|
||||
{
|
||||
$date = JFactory::getDate($query->date1)->format(JText::_('DATE_FORMAT_LC'));
|
||||
$parts[] = '<span class="query-start-date">' . JText::sprintf('COM_FINDER_QUERY_START_DATE', $query->when1, $date) . '</span>';
|
||||
}
|
||||
|
||||
// Process the end date.
|
||||
if ($query->date2)
|
||||
{
|
||||
$date = JFactory::getDate($query->date2)->format(JText::_('DATE_FORMAT_LC'));
|
||||
$parts[] = '<span class="query-end-date">' . JText::sprintf('COM_FINDER_QUERY_END_DATE', $query->when2, $date) . '</span>';
|
||||
}
|
||||
|
||||
// Process the taxonomy filters.
|
||||
if (!empty($query->filters))
|
||||
{
|
||||
// Get the filters in the request.
|
||||
$t = JFactory::getApplication()->input->request->get('t', array(), 'array');
|
||||
|
||||
// Process the taxonomy branches.
|
||||
foreach ($query->filters as $branch => $nodes)
|
||||
{
|
||||
// Process the taxonomy nodes.
|
||||
$lang = JFactory::getLanguage();
|
||||
foreach ($nodes as $title => $id)
|
||||
{
|
||||
// Translate the title for Types
|
||||
$key = FinderHelperLanguage::branchPlural($title);
|
||||
if ($lang->hasKey($key))
|
||||
{
|
||||
$title = JText::_($key);
|
||||
}
|
||||
|
||||
// Don't include the node if it is not in the request.
|
||||
if (!in_array($id, $t))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add the node to the explanation.
|
||||
$parts[] = '<span class="query-taxonomy">'
|
||||
. JText::sprintf('COM_FINDER_QUERY_TAXONOMY_NODE', $title, JText::_(FinderHelperLanguage::branchSingular($branch)))
|
||||
. '</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build the interpreted query.
|
||||
return count($parts) ? JText::sprintf('COM_FINDER_QUERY_TOKEN_INTERPRETED', implode(JText::_('COM_FINDER_QUERY_TOKEN_GLUE'), $parts)) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the suggested search query.
|
||||
*
|
||||
* @param FinderIndexerQuery $query A FinderIndexerQuery object.
|
||||
*
|
||||
* @return mixed String if there is a suggestion, false otherwise.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public static function suggested(FinderIndexerQuery $query)
|
||||
{
|
||||
$suggested = false;
|
||||
|
||||
// Check if the query input is empty.
|
||||
if (empty($query->input))
|
||||
{
|
||||
return $suggested;
|
||||
}
|
||||
|
||||
// Check if there were any ignored or included keywords.
|
||||
if (count($query->ignored) || count($query->included))
|
||||
{
|
||||
$suggested = $query->input;
|
||||
|
||||
// Replace the ignored keyword suggestions.
|
||||
foreach (array_reverse($query->ignored) as $token)
|
||||
{
|
||||
if (isset($token->suggestion))
|
||||
{
|
||||
$suggested = str_replace($token->term, $token->suggestion, $suggested);
|
||||
}
|
||||
}
|
||||
|
||||
// Replace the included keyword suggestions.
|
||||
foreach (array_reverse($query->included) as $token)
|
||||
{
|
||||
if (isset($token->suggestion))
|
||||
{
|
||||
$suggested = str_replace($token->term, $token->suggestion, $suggested);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we made any changes.
|
||||
if ($suggested == $query->input)
|
||||
{
|
||||
$suggested = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $suggested;
|
||||
}
|
||||
}
|
1
components/com_finder/helpers/index.html
Normal file
1
components/com_finder/helpers/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
161
components/com_finder/helpers/route.php
Normal file
161
components/com_finder/helpers/route.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Finder route helper class.
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class FinderHelperRoute
|
||||
{
|
||||
/**
|
||||
* Method to get the route for a search page.
|
||||
*
|
||||
* @param integer $f The search filter id. [optional]
|
||||
* @param string $q The search query string. [optional]
|
||||
*
|
||||
* @return string The search route.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public static function getSearchRoute($f = null, $q = null)
|
||||
{
|
||||
// Get the menu item id.
|
||||
$query = array('view' => 'search', 'q' => $q, 'f' => $f);
|
||||
$item = self::getItemid($query);
|
||||
|
||||
// Get the base route.
|
||||
$uri = clone(JUri::getInstance('index.php?option=com_finder&view=search'));
|
||||
|
||||
// Add the pre-defined search filter if present.
|
||||
if ($f !== null)
|
||||
{
|
||||
$uri->setVar('f', $f);
|
||||
}
|
||||
|
||||
// Add the search query string if present.
|
||||
if ($q !== null)
|
||||
{
|
||||
$uri->setVar('q', $q);
|
||||
}
|
||||
|
||||
// Add the menu item id if present.
|
||||
if ($item !== null)
|
||||
{
|
||||
$uri->setVar('Itemid', $item);
|
||||
}
|
||||
|
||||
return $uri->toString(array('path', 'query'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the route for an advanced search page.
|
||||
*
|
||||
* @param integer $f The search filter id. [optional]
|
||||
* @param string $q The search query string. [optional]
|
||||
*
|
||||
* @return string The advanced search route.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public static function getAdvancedRoute($f = null, $q = null)
|
||||
{
|
||||
// Get the menu item id.
|
||||
$query = array('view' => 'advanced', 'q' => $q, 'f' => $f);
|
||||
$item = self::getItemid($query);
|
||||
|
||||
// Get the base route.
|
||||
$uri = clone(JUri::getInstance('index.php?option=com_finder&view=advanced'));
|
||||
|
||||
// Add the pre-defined search filter if present.
|
||||
if ($q !== null)
|
||||
{
|
||||
$uri->setVar('f', $f);
|
||||
}
|
||||
|
||||
// Add the search query string if present.
|
||||
if ($q !== null)
|
||||
{
|
||||
$uri->setVar('q', $q);
|
||||
}
|
||||
|
||||
// Add the menu item id if present.
|
||||
if ($item !== null)
|
||||
{
|
||||
$uri->setVar('Itemid', $item);
|
||||
}
|
||||
|
||||
return $uri->toString(array('path', 'query'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the most appropriate menu item for the route based on the
|
||||
* supplied query needles.
|
||||
*
|
||||
* @param array $query An array of URL parameters.
|
||||
*
|
||||
* @return mixed An integer on success, null otherwise.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public static function getItemid($query)
|
||||
{
|
||||
static $items, $active;
|
||||
|
||||
// Get the menu items for com_finder.
|
||||
if (!$items || !$active)
|
||||
{
|
||||
$app = JFactory::getApplication('site');
|
||||
$com = JComponentHelper::getComponent('com_finder');
|
||||
$menu = $app->getMenu();
|
||||
$active = $menu->getActive();
|
||||
$items = $menu->getItems('component_id', $com->id);
|
||||
$items = is_array($items) ? $items : array();
|
||||
}
|
||||
|
||||
// Try to match the active view and filter.
|
||||
if ($active && @$active->query['view'] == @$query['view'] && @$active->query['f'] == @$query['f'])
|
||||
{
|
||||
return $active->id;
|
||||
}
|
||||
|
||||
// Try to match the view, query, and filter.
|
||||
foreach ($items as $item)
|
||||
{
|
||||
if (@$item->query['view'] == @$query['view'] && @$item->query['q'] == @$query['q'] && @$item->query['f'] == @$query['f'])
|
||||
{
|
||||
return $item->id;
|
||||
}
|
||||
}
|
||||
|
||||
// Try to match the view and filter.
|
||||
foreach ($items as $item)
|
||||
{
|
||||
if (@$item->query['view'] == @$query['view'] && @$item->query['f'] == @$query['f'])
|
||||
{
|
||||
return $item->id;
|
||||
}
|
||||
}
|
||||
|
||||
// Try to match the view.
|
||||
foreach ($items as $item)
|
||||
{
|
||||
if (@$item->query['view'] == @$query['view'])
|
||||
{
|
||||
return $item->id;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
1
components/com_finder/index.html
Normal file
1
components/com_finder/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1
components/com_finder/models/index.html
Normal file
1
components/com_finder/models/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1235
components/com_finder/models/search.php
Normal file
1235
components/com_finder/models/search.php
Normal file
File diff suppressed because it is too large
Load Diff
140
components/com_finder/models/suggestions.php
Normal file
140
components/com_finder/models/suggestions.php
Normal file
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
define('FINDER_PATH_INDEXER', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer');
|
||||
JLoader::register('FinderIndexerHelper', FINDER_PATH_INDEXER . '/helper.php');
|
||||
|
||||
/**
|
||||
* Suggestions model class for the Finder package.
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class FinderModelSuggestions extends JModelList
|
||||
{
|
||||
/**
|
||||
* Context string for the model type.
|
||||
*
|
||||
* @var string
|
||||
* @since 2.5
|
||||
*/
|
||||
protected $context = 'com_finder.suggestions';
|
||||
|
||||
/**
|
||||
* Method to get an array of data items.
|
||||
*
|
||||
* @return array An array of data items.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
// Get the items.
|
||||
$items = parent::getItems();
|
||||
|
||||
// Convert them to a simple array.
|
||||
foreach ($items as $k => $v)
|
||||
{
|
||||
$items[$k] = $v->term;
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to build a database query to load the list data.
|
||||
*
|
||||
* @return JDatabaseQuery A database query
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
// Create a new query object.
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select required fields
|
||||
$query->select('t.term')
|
||||
->from($db->quoteName('#__finder_terms') . ' AS t')
|
||||
->where('t.term LIKE ' . $db->quote($db->escape($this->getState('input'), true) . '%'))
|
||||
->where('t.common = 0')
|
||||
->where('t.language IN (' . $db->quote($db->escape($this->getState('language'), true)) . ', ' . $db->quote('*') . ')')
|
||||
->order('t.links DESC')
|
||||
->order('t.weight DESC');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a store id based on model the 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 An identifier string to generate the store id. [optional]
|
||||
*
|
||||
* @return string A store id.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function getStoreId($id = '')
|
||||
{
|
||||
// Add the search query state.
|
||||
$id .= ':' . $this->getState('input');
|
||||
$id .= ':' . $this->getState('language');
|
||||
|
||||
// Add the list state.
|
||||
$id .= ':' . $this->getState('list.start');
|
||||
$id .= ':' . $this->getState('list.limit');
|
||||
|
||||
return parent::getStoreId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state. 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 2.5
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
// Get the configuration options.
|
||||
$app = JFactory::getApplication();
|
||||
$input = $app->input;
|
||||
$params = JComponentHelper::getParams('com_finder');
|
||||
$user = JFactory::getUser();
|
||||
|
||||
// Get the query input.
|
||||
$this->setState('input', $input->request->get('q', '', 'string'));
|
||||
|
||||
// Set the query language
|
||||
$lang = FinderIndexerHelper::getDefaultLanguage();
|
||||
$lang = FinderIndexerHelper::getPrimaryLanguage($lang);
|
||||
$this->setState('language', $lang);
|
||||
|
||||
// Load the list state.
|
||||
$this->setState('list.start', 0);
|
||||
$this->setState('list.limit', 10);
|
||||
|
||||
// Load the parameters.
|
||||
$this->setState('params', $params);
|
||||
|
||||
// Load the user state.
|
||||
$this->setState('user.id', (int) $user->get('id'));
|
||||
}
|
||||
}
|
110
components/com_finder/router.php
Normal file
110
components/com_finder/router.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Method to build a SEF route.
|
||||
*
|
||||
* @param array &$query An array of route variables.
|
||||
*
|
||||
* @return array An array of route segments.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
function FinderBuildRoute(&$query)
|
||||
{
|
||||
static $menu;
|
||||
$segments = array();
|
||||
|
||||
// Load the menu if necessary.
|
||||
if (!$menu)
|
||||
{
|
||||
$menu = JFactory::getApplication('site')->getMenu();
|
||||
}
|
||||
|
||||
/*
|
||||
* First, handle menu item routes first. When the menu system builds a
|
||||
* route, it only provides the option and the menu item id. We don't have
|
||||
* to do anything to these routes.
|
||||
*/
|
||||
if (count($query) === 2 && isset($query['Itemid']) && isset($query['option']))
|
||||
{
|
||||
return $segments;
|
||||
}
|
||||
|
||||
/*
|
||||
* Next, handle a route with a supplied menu item id. All system generated
|
||||
* routes should fall into this group. We can assume that the menu item id
|
||||
* is the best possible match for the query but we need to go through and
|
||||
* see which variables we can eliminate from the route query string because
|
||||
* they are present in the menu item route already.
|
||||
*/
|
||||
if (!empty($query['Itemid']))
|
||||
{
|
||||
// Get the menu item.
|
||||
$item = $menu->getItem($query['Itemid']);
|
||||
|
||||
// Check if the view matches.
|
||||
if ($item && @$item->query['view'] === @$query['view'])
|
||||
{
|
||||
unset($query['view']);
|
||||
}
|
||||
|
||||
// Check if the search query filter matches.
|
||||
if ($item && @$item->query['f'] === @$query['f'])
|
||||
{
|
||||
unset($query['f']);
|
||||
}
|
||||
|
||||
// Check if the search query string matches.
|
||||
if ($item && @$item->query['q'] === @$query['q'])
|
||||
{
|
||||
unset($query['q']);
|
||||
}
|
||||
|
||||
return $segments;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lastly, handle a route with no menu item id. Fortunately, we only need
|
||||
* to deal with the view as the other route variables are supposed to stay
|
||||
* in the query string.
|
||||
*/
|
||||
if (isset($query['view']))
|
||||
{
|
||||
// Add the view to the segments.
|
||||
$segments[] = $query['view'];
|
||||
unset($query['view']);
|
||||
}
|
||||
|
||||
return $segments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to parse a SEF route.
|
||||
*
|
||||
* @param array $segments An array of route segments.
|
||||
*
|
||||
* @return array An array of route variables.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
function FinderParseRoute($segments)
|
||||
{
|
||||
$vars = array();
|
||||
|
||||
// Check if the view segment is set and it equals search or advanced.
|
||||
if (@$segments[0] === 'search' || @$segments[0] === 'advanced')
|
||||
{
|
||||
$vars['view'] = $segments[0];
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
1
components/com_finder/views/index.html
Normal file
1
components/com_finder/views/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1
components/com_finder/views/search/index.html
Normal file
1
components/com_finder/views/search/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
6
components/com_finder/views/search/metadata.xml
Normal file
6
components/com_finder/views/search/metadata.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
<view title="COM_FINDER_MENU_SEARCH_VIEW_TITLE">
|
||||
<message><![CDATA[COM_FINDER_MENU_SEARCH_VIEW_TEXT]]></message>
|
||||
</view>
|
||||
</metadata>
|
41
components/com_finder/views/search/tmpl/default.php
Normal file
41
components/com_finder/views/search/tmpl/default.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
JHtml::_('behavior.framework');
|
||||
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
|
||||
JHtml::stylesheet('com_finder/finder.css', false, true, false);
|
||||
?>
|
||||
|
||||
<div class="finder<?php echo $this->pageclass_sfx; ?>">
|
||||
<?php if ($this->params->get('show_page_heading')) : ?>
|
||||
<h1>
|
||||
<?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 if ($this->params->get('show_search_form', 1)) : ?>
|
||||
<div id="search-form">
|
||||
<?php echo $this->loadTemplate('form'); ?>
|
||||
</div>
|
||||
<?php endif;
|
||||
|
||||
// Load the search results layout if we are performing a search.
|
||||
if ($this->query->search === true):
|
||||
?>
|
||||
<div id="search-results">
|
||||
<?php echo $this->loadTemplate('results'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
181
components/com_finder/views/search/tmpl/default.xml
Normal file
181
components/com_finder/views/search/tmpl/default.xml
Normal file
@ -0,0 +1,181 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
<layout title="COM_FINDER_MENU_SEARCH_VIEW_DEFAULT_TITLE">
|
||||
<help
|
||||
key = "JHELP_MENUS_MENU_ITEM_FINDER_SEARCH"
|
||||
/>
|
||||
<message>
|
||||
<![CDATA[COM_FINDER_MENU_SEARCH_VIEW_DEFAULT_TEXT]]>
|
||||
</message>
|
||||
</layout>
|
||||
|
||||
<fields name="request" addfieldpath="/administrator/components/com_finder/models/fields">
|
||||
<fieldset name="request">
|
||||
<field name="q"
|
||||
type="text"
|
||||
label="COM_FINDER_SEARCH_SEARCH_QUERY_LABEL"
|
||||
description="COM_FINDER_SEARCH_SEARCH_QUERY_DESC"
|
||||
size="30"
|
||||
/>
|
||||
<field name="f"
|
||||
type="searchfilter"
|
||||
default=""
|
||||
label="COM_FINDER_SEARCH_FILTER_SEARCH_LABEL"
|
||||
description="COM_FINDER_SEARCH_FILTER_SEARCH_DESC"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<fields name="params" addfieldpath="/administrator/components/com_finder/models/fields">
|
||||
<fieldset name="basic">
|
||||
<field name="show_date_filters"
|
||||
type="list"
|
||||
default=""
|
||||
validate="options"
|
||||
label="COM_FINDER_CONFIG_SHOW_DATE_FILTERS_LABEL"
|
||||
description="COM_FINDER_CONFIG_SHOW_DATE_FILTERS_DESC">
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
</field>
|
||||
<field name="show_advanced"
|
||||
type="list"
|
||||
default=""
|
||||
validate="options"
|
||||
label="COM_FINDER_CONFIG_SHOW_ADVANCED_LABEL"
|
||||
description="COM_FINDER_CONFIG_SHOW_ADVANCED_DESC">
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
</field>
|
||||
<field name="expand_advanced"
|
||||
type="list"
|
||||
default=""
|
||||
validate="options"
|
||||
label="COM_FINDER_CONFIG_EXPAND_ADVANCED_LABEL"
|
||||
description="COM_FINDER_CONFIG_EXPAND_ADVANCED_DESC">
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
</field>
|
||||
<field type="spacer" />
|
||||
<field name="show_description"
|
||||
type="list"
|
||||
default=""
|
||||
validate="options"
|
||||
label="COM_FINDER_CONFIG_SHOW_DESCRIPTION_LABEL"
|
||||
description="COM_FINDER_CONFIG_SHOW_DESCRIPTION_DESC">
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
</field>
|
||||
<field name="description_length"
|
||||
type="text"
|
||||
default="255"
|
||||
filter="integer"
|
||||
label="COM_FINDER_CONFIG_DESCRIPTION_LENGTH_LABEL"
|
||||
description="COM_FINDER_CONFIG_DESCRIPTION_LENGTH_DESC"
|
||||
size="5"
|
||||
/>
|
||||
<field name="show_url"
|
||||
type="list"
|
||||
default=""
|
||||
validate="options"
|
||||
label="COM_FINDER_CONFIG_SHOW_URL_LABEL"
|
||||
description="COM_FINDER_CONFIG_SHOW_URL_DESC">
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
</field>
|
||||
<field type="spacer" />
|
||||
</fieldset>
|
||||
<fieldset name="advanced">
|
||||
<field name="show_pagination_limit" type="list"
|
||||
label="JGLOBAL_DISPLAY_SELECT_LABEL"
|
||||
validate="options"
|
||||
description="JGLOBAL_DISPLAY_SELECT_DESC">
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
<field name="show_pagination" type="list"
|
||||
description="JGLOBAL_PAGINATION_DESC"
|
||||
validate="options"
|
||||
label="JGLOBAL_PAGINATION_LABEL" >
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="2">JGLOBAL_AUTO</option>
|
||||
</field>
|
||||
<field name="show_pagination_results" type="list"
|
||||
label="JGLOBAL_PAGINATION_RESULTS_LABEL"
|
||||
validate="options"
|
||||
description="JGLOBAL_PAGINATION_RESULTS_DESC" >
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
<field name="allow_empty_query"
|
||||
type="radio"
|
||||
class="btn-group"
|
||||
default="0"
|
||||
validate="options"
|
||||
label="COM_FINDER_ALLOW_EMPTY_QUERY_LABEL"
|
||||
description="COM_FINDER_ALLOW_EMPTY_QUERY_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
<field name="sort_order"
|
||||
type="list"
|
||||
default=""
|
||||
validate="options"
|
||||
label="COM_FINDER_CONFIG_SORT_ORDER_LABEL"
|
||||
description="COM_FINDER_CONFIG_SORT_ORDER_DESC">
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="relevance">COM_FINDER_CONFIG_SORT_OPTION_RELEVANCE</option>
|
||||
<option value="date">COM_FINDER_CONFIG_SORT_OPTION_START_DATE</option>
|
||||
<option value="price">COM_FINDER_CONFIG_SORT_OPTION_LIST_PRICE</option>
|
||||
</field>
|
||||
<field name="sort_direction"
|
||||
type="list"
|
||||
default=""
|
||||
validate="options"
|
||||
label="COM_FINDER_CONFIG_SORT_DIRECTION_LABEL"
|
||||
description="COM_FINDER_CONFIG_SORT_DIRECTION_DESC">
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="desc">COM_FINDER_CONFIG_SORT_OPTION_DESCENDING</option>
|
||||
<option value="asc">COM_FINDER_CONFIG_SORT_OPTION_ASCENDING</option>
|
||||
</field>
|
||||
<field type="spacer" />
|
||||
<field name="show_feed"
|
||||
type="radio"
|
||||
class="btn-group"
|
||||
default="0"
|
||||
validate="options"
|
||||
label="COM_FINDER_CONFIG_SHOW_FEED_LABEL"
|
||||
description="COM_FINDER_CONFIG_SHOW_FEED_DESC">
|
||||
<option value="1">JSHOW</option>
|
||||
<option value="0">JHIDE</option>
|
||||
</field>
|
||||
<field name="show_feed_text"
|
||||
type="radio"
|
||||
class="btn-group"
|
||||
default="0"
|
||||
validate="options"
|
||||
label="COM_FINDER_CONFIG_SHOW_FEED_TEXT_LABEL"
|
||||
description="COM_FINDER_CONFIG_SHOW_FEED_TEXT_DESC">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="integration">
|
||||
<field name="show_feed_link" type="list"
|
||||
description="JGLOBAL_SHOW_FEED_LINK_DESC"
|
||||
validate="options"
|
||||
label="JGLOBAL_SHOW_FEED_LINK_LABEL" >
|
||||
<option value="">JGLOBAL_USE_GLOBAL</option>
|
||||
<option value="0">JHIDE</option>
|
||||
<option value="1">JSHOW</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</metadata>
|
111
components/com_finder/views/search/tmpl/default_form.php
Normal file
111
components/com_finder/views/search/tmpl/default_form.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
window.addEvent('domready', function() {
|
||||
<?php if ($this->params->get('show_advanced', 1)) : ?>
|
||||
/*
|
||||
* This segment of code adds the slide effect to the advanced search box.
|
||||
*/
|
||||
if (document.id('advanced-search') != null)
|
||||
{
|
||||
var searchSlider = new Fx.Slide('advanced-search');
|
||||
|
||||
<?php if (!$this->params->get('expand_advanced', 0)) : ?>
|
||||
searchSlider.hide();
|
||||
<?php endif; ?>
|
||||
|
||||
document.id('advanced-search-toggle').addEvent('click', function(e)
|
||||
{
|
||||
e = new Event(e);
|
||||
e.stop();
|
||||
searchSlider.toggle();
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* This segment of code disables select boxes that have no value when the
|
||||
* form is submitted so that the URL doesn't get blown up with null values.
|
||||
*/
|
||||
if (document.id('finder-search') != null)
|
||||
{
|
||||
document.id('finder-search').addEvent('submit', function(e){
|
||||
e = new Event(e);
|
||||
e.stop();
|
||||
|
||||
if (document.id('advanced-search') != null)
|
||||
{
|
||||
// Disable select boxes with no value selected.
|
||||
document.id('advanced-search').getElements('select').each(function(s){
|
||||
if (!s.getProperty('value'))
|
||||
{
|
||||
s.setProperty('disabled', 'disabled');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.id('finder-search').submit();
|
||||
});
|
||||
}
|
||||
<?php endif; ?>
|
||||
/*
|
||||
* This segment of code sets up the autocompleter.
|
||||
*/
|
||||
<?php if ($this->params->get('show_autosuggest', 1)) : ?>
|
||||
<?php JHtml::_('script', 'com_finder/autocompleter.js', false, true); ?>
|
||||
var url = '<?php echo JRoute::_('index.php?option=com_finder&task=suggestions.display&format=json&tmpl=component', false); ?>';
|
||||
var completer = new Autocompleter.Request.JSON(document.id('q'), url, {'postVar': 'q'});
|
||||
<?php endif; ?>
|
||||
});
|
||||
</script>
|
||||
|
||||
<form id="finder-search" action="<?php echo JRoute::_($this->query->toURI()); ?>" method="get" class="form-inline">
|
||||
<?php echo $this->getFields(); ?>
|
||||
|
||||
<?php
|
||||
/*
|
||||
* DISABLED UNTIL WEIRD VALUES CAN BE TRACKED DOWN.
|
||||
*/
|
||||
if (false && $this->state->get('list.ordering') !== 'relevance_dsc') : ?>
|
||||
<input type="hidden" name="o" value="<?php echo $this->escape($this->state->get('list.ordering')); ?>" />
|
||||
<?php endif; ?>
|
||||
|
||||
<fieldset class="word">
|
||||
<label for="q">
|
||||
<?php echo JText::_('COM_FINDER_SEARCH_TERMS'); ?>
|
||||
</label>
|
||||
<input type="text" name="q" id="q" size="30" value="<?php echo $this->escape($this->query->input); ?>" class="inputbox" />
|
||||
<?php if ($this->escape($this->query->input) != '' || $this->params->get('allow_empty_search')):?>
|
||||
<button name="Search" type="submit" class="btn btn-primary"><span class="icon-search icon-white"></span> <?php echo JText::_('JSEARCH_FILTER_SUBMIT');?></button>
|
||||
<?php else: ?>
|
||||
<button name="Search" type="submit" class="btn btn-primary disabled"><span class="icon-search icon-white"></span> <?php echo JText::_('JSEARCH_FILTER_SUBMIT');?></button>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->params->get('show_advanced', 1)) : ?>
|
||||
<a href="#advancedSearch" data-toggle="collapse" class="btn"><span class="icon-list"></span> <?php echo JText::_('COM_FINDER_ADVANCED_SEARCH_TOGGLE'); ?></a>
|
||||
<?php endif; ?>
|
||||
</fieldset>
|
||||
|
||||
<?php if ($this->params->get('show_advanced', 1)) : ?>
|
||||
<div id="advancedSearch" class="collapse">
|
||||
<hr />
|
||||
<?php if ($this->params->get('show_advanced_tips', 1)) : ?>
|
||||
<div class="advanced-search-tip">
|
||||
<?php echo JText::_('COM_FINDER_ADVANCED_TIPS'); ?>
|
||||
</div>
|
||||
<hr />
|
||||
<?php endif; ?>
|
||||
<div id="finder-filter-window">
|
||||
<?php echo JHtml::_('filter.select', $this->query, $this->params); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</form>
|
37
components/com_finder/views/search/tmpl/default_result.php
Normal file
37
components/com_finder/views/search/tmpl/default_result.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Get the mime type class.
|
||||
$mime = !empty($this->result->mime) ? 'mime-' . $this->result->mime : null;
|
||||
|
||||
// Get the base url.
|
||||
$base = JUri::getInstance()->toString(array('scheme', 'host', 'port'));
|
||||
|
||||
// Get the route with highlighting information.
|
||||
if (!empty($this->query->highlight) && empty($this->result->mime) && $this->params->get('highlight_terms', 1) && JPluginHelper::isEnabled('system', 'highlight'))
|
||||
{
|
||||
$route = $this->result->route . '&highlight=' . base64_encode(json_encode($this->query->highlight));
|
||||
} else {
|
||||
$route = $this->result->route;
|
||||
}
|
||||
?>
|
||||
|
||||
<li>
|
||||
<h4 class="result-title <?php echo $mime; ?>"><a href="<?php echo JRoute::_($route); ?>"><?php echo $this->result->title; ?></a></h4>
|
||||
<?php if ($this->params->get('show_description', 1)) : ?>
|
||||
<p class="result-text<?php echo $this->pageclass_sfx; ?>">
|
||||
<?php echo JHtml::_('string.truncate', $this->result->description, $this->params->get('description_length', 255)); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->params->get('show_url', 1)) : ?>
|
||||
<div class="small result-url<?php echo $this->pageclass_sfx; ?>"><?php echo $base . JRoute::_($this->result->route); ?></div>
|
||||
<?php endif; ?>
|
||||
</li>
|
92
components/com_finder/views/search/tmpl/default_results.php
Normal file
92
components/com_finder/views/search/tmpl/default_results.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Activate the highlighter if enabled.
|
||||
if (!empty($this->query->highlight) && $this->params->get('highlight_terms', 1))
|
||||
{
|
||||
JHtml::_('behavior.highlighter', $this->query->highlight);
|
||||
}
|
||||
|
||||
// Get the application object.
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
// Display the suggested search if it is different from the current search.
|
||||
if (($this->suggested && $this->params->get('show_suggested_query', 1)) || ($this->explained && $this->params->get('show_explained_query', 1))):
|
||||
?>
|
||||
<div id="search-query-explained">
|
||||
<?php
|
||||
// Display the suggested search query.
|
||||
if ($this->suggested && $this->params->get('show_suggested_query', 1))
|
||||
{
|
||||
// Replace the base query string with the suggested query string.
|
||||
$uri = JUri::getInstance($this->query->toURI());
|
||||
$uri->setVar('q', $this->suggested);
|
||||
|
||||
// Compile the suggested query link.
|
||||
$link = '<a href="' . JRoute::_($uri->toString(array('path', 'query'))) . '">'
|
||||
. $this->escape($this->suggested)
|
||||
. '</a>';
|
||||
|
||||
echo JText::sprintf('COM_FINDER_SEARCH_SIMILAR', $link);
|
||||
}
|
||||
// Display the explained search query.
|
||||
elseif ($this->explained && $this->params->get('show_explained_query', 1))
|
||||
{
|
||||
echo $this->explained;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
if ($this->total == 0):
|
||||
?>
|
||||
<div id="search-result-empty">
|
||||
<h2><?php echo JText::_('COM_FINDER_SEARCH_NO_RESULTS_HEADING'); ?></h2>
|
||||
<?php if ($app->getLanguageFilter()) : ?>
|
||||
<p><?php echo JText::sprintf('COM_FINDER_SEARCH_NO_RESULTS_BODY_MULTILANG', $this->escape($this->query->input)); ?></p>
|
||||
<?php else : ?>
|
||||
<p><?php echo JText::sprintf('COM_FINDER_SEARCH_NO_RESULTS_BODY', $this->escape($this->query->input)); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
else:
|
||||
// Prepare the pagination string. Results X - Y of Z
|
||||
$start = (int) $this->pagination->get('limitstart') + 1;
|
||||
$total = (int) $this->pagination->get('total');
|
||||
$limit = (int) $this->pagination->get('limit') * $this->pagination->pagesTotal;
|
||||
$limit = (int) ($limit > $total ? $total : $limit);
|
||||
$pages = JText::sprintf('COM_FINDER_SEARCH_RESULTS_OF', $start, $limit, $total);
|
||||
?>
|
||||
<br id="highlighter-start" />
|
||||
<ul class="search-results<?php echo $this->pageclass_sfx; ?> list-striped">
|
||||
<?php
|
||||
for ($i = 0, $n = count($this->results); $i < $n; $i++):
|
||||
$this->result = &$this->results[$i];
|
||||
$layout = $this->getLayoutFile($this->result->layout);
|
||||
?>
|
||||
<?php echo $this->loadTemplate($layout); ?>
|
||||
<?php
|
||||
endfor;
|
||||
?>
|
||||
</ul>
|
||||
<br id="highlighter-end" />
|
||||
|
||||
<div class="search-pagination">
|
||||
<div class="pagination">
|
||||
<?php echo $this->pagination->getPagesLinks(); ?>
|
||||
</div>
|
||||
<div class="search-pages-counter">
|
||||
<?php echo $pages; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
1
components/com_finder/views/search/tmpl/index.html
Normal file
1
components/com_finder/views/search/tmpl/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
105
components/com_finder/views/search/view.feed.php
Normal file
105
components/com_finder/views/search/view.feed.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Search feed view class for the Finder package.
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class FinderViewSearch extends JViewLegacy
|
||||
{
|
||||
/**
|
||||
* Method to display the view.
|
||||
*
|
||||
* @param string $tpl A template file to load. [optional]
|
||||
*
|
||||
* @return mixed JError object on failure, void on success.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
// Get the application
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
// Adjust the list limit to the feed limit.
|
||||
$app->input->set('limit', $app->getCfg('feed_limit'));
|
||||
|
||||
// Get view data.
|
||||
$state = $this->get('State');
|
||||
$params = $state->get('params');
|
||||
$query = $this->get('Query');
|
||||
$results = $this->get('Results');
|
||||
|
||||
// Push out the query data.
|
||||
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
|
||||
$explained = JHtml::_('query.explained', $query);
|
||||
|
||||
// Set the document title.
|
||||
$title = $params->get('page_title', '');
|
||||
|
||||
if (empty($title))
|
||||
{
|
||||
$title = $app->getCfg('sitename');
|
||||
}
|
||||
elseif ($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);
|
||||
|
||||
// Configure the document description.
|
||||
if (!empty($explained))
|
||||
{
|
||||
$this->document->setDescription(html_entity_decode(strip_tags($explained), ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
|
||||
// Set the document link.
|
||||
$this->document->link = JRoute::_($query->toURI());
|
||||
|
||||
// If we don't have any results, we are done.
|
||||
if (empty($results))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert the results to feed entries.
|
||||
foreach ($results as $result)
|
||||
{
|
||||
// Convert the result to a feed entry.
|
||||
$item = new JFeedItem;
|
||||
$item->title = $result->title;
|
||||
$item->link = JRoute::_($result->route);
|
||||
$item->description = $result->description;
|
||||
$item->date = (int) $result->start_date ? JHtml::date($result->start_date, 'l d F Y') : $result->indexdate;
|
||||
|
||||
// Get the taxonomy data.
|
||||
$taxonomy = $result->getTaxonomy();
|
||||
|
||||
// Add the category to the feed if available.
|
||||
if (isset($taxonomy['Category']))
|
||||
{
|
||||
$node = array_pop($taxonomy['Category']);
|
||||
$item->category = $node->title;
|
||||
}
|
||||
|
||||
// Loads item info into RSS array
|
||||
$this->document->addItem($item);
|
||||
}
|
||||
}
|
||||
}
|
256
components/com_finder/views/search/view.html.php
Normal file
256
components/com_finder/views/search/view.html.php
Normal file
@ -0,0 +1,256 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Search HTML view class for the Finder package.
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class FinderViewSearch extends JViewLegacy
|
||||
{
|
||||
protected $query;
|
||||
|
||||
protected $params;
|
||||
|
||||
protected $state;
|
||||
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Method to display the view.
|
||||
*
|
||||
* @param string $tpl A template file to load. [optional]
|
||||
*
|
||||
* @return mixed JError object on failure, void on success.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$params = $app->getParams();
|
||||
|
||||
// Get view data.
|
||||
$state = $this->get('State');
|
||||
$query = $this->get('Query');
|
||||
JDEBUG ? $GLOBALS['_PROFILER']->mark('afterFinderQuery') : null;
|
||||
$results = $this->get('Results');
|
||||
JDEBUG ? $GLOBALS['_PROFILER']->mark('afterFinderResults') : null;
|
||||
$total = $this->get('Total');
|
||||
JDEBUG ? $GLOBALS['_PROFILER']->mark('afterFinderTotal') : null;
|
||||
$pagination = $this->get('Pagination');
|
||||
JDEBUG ? $GLOBALS['_PROFILER']->mark('afterFinderPagination') : null;
|
||||
|
||||
// Check for errors.
|
||||
if (count($errors = $this->get('Errors')))
|
||||
{
|
||||
JError::raiseError(500, implode("\n", $errors));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Configure the pathway.
|
||||
if (!empty($query->input))
|
||||
{
|
||||
$app->getPathWay()->addItem($this->escape($query->input));
|
||||
}
|
||||
|
||||
// Push out the view data.
|
||||
$this->state = &$state;
|
||||
$this->params = &$params;
|
||||
$this->query = &$query;
|
||||
$this->results = &$results;
|
||||
$this->total = &$total;
|
||||
$this->pagination = &$pagination;
|
||||
|
||||
// Check for a double quote in the query string.
|
||||
if (strpos($this->query->input, '"'))
|
||||
{
|
||||
// Get the application router.
|
||||
$router =& $app->getRouter();
|
||||
|
||||
// Fix the q variable in the URL.
|
||||
if ($router->getVar('q') !== $this->query->input)
|
||||
{
|
||||
$router->setVar('q', $this->query->input);
|
||||
}
|
||||
}
|
||||
|
||||
// Log the search
|
||||
JSearchHelper::logSearch($this->query->input, 'com_finder');
|
||||
|
||||
// Push out the query data.
|
||||
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
|
||||
$this->suggested = JHtml::_('query.suggested', $query);
|
||||
$this->explained = JHtml::_('query.explained', $query);
|
||||
|
||||
// Escape strings for HTML output
|
||||
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
|
||||
|
||||
// Check for layout override only if this is not the active menu item
|
||||
// If it is the active menu item, then the view and category id will match
|
||||
$active = $app->getMenu()->getActive();
|
||||
if (isset($active->query['layout']))
|
||||
{
|
||||
// We need to set the layout in case this is an alternative menu item (with an alternative layout)
|
||||
$this->setLayout($active->query['layout']);
|
||||
}
|
||||
|
||||
$this->prepareDocument($query);
|
||||
|
||||
JDEBUG ? $GLOBALS['_PROFILER']->mark('beforeFinderLayout') : null;
|
||||
|
||||
parent::display($tpl);
|
||||
|
||||
JDEBUG ? $GLOBALS['_PROFILER']->mark('afterFinderLayout') : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get hidden input fields for a get form so that control variables
|
||||
* are not lost upon form submission
|
||||
*
|
||||
* @return string A string of hidden input form fields
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function getFields()
|
||||
{
|
||||
$fields = null;
|
||||
|
||||
// Get the URI.
|
||||
$uri = JUri::getInstance(JRoute::_($this->query->toURI()));
|
||||
$uri->delVar('q');
|
||||
$uri->delVar('o');
|
||||
$uri->delVar('t');
|
||||
$uri->delVar('d1');
|
||||
$uri->delVar('d2');
|
||||
$uri->delVar('w1');
|
||||
$uri->delVar('w2');
|
||||
$elements = $uri->getQuery(true);
|
||||
|
||||
// Create hidden input elements for each part of the URI.
|
||||
foreach ($elements as $n => $v)
|
||||
{
|
||||
if (is_scalar($v))
|
||||
{
|
||||
$fields .= '<input type="hidden" name="' . $n . '" value="' . $v . '" />';
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the layout file for a search result object.
|
||||
*
|
||||
* @param string $layout The layout file to check. [optional]
|
||||
*
|
||||
* @return string The layout file to use.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function getLayoutFile($layout = null)
|
||||
{
|
||||
// Create and sanitize the file name.
|
||||
$file = $this->_layout . '_' . preg_replace('/[^A-Z0-9_\.-]/i', '', $layout);
|
||||
|
||||
// Check if the file exists.
|
||||
jimport('joomla.filesystem.path');
|
||||
$filetofind = $this->_createFileName('template', array('name' => $file));
|
||||
$exists = JPath::find($this->_path['template'], $filetofind);
|
||||
|
||||
return ($exists ? $layout : 'result');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the document
|
||||
*
|
||||
* @param FinderIndexerQuery $query The search query
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function prepareDocument($query)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$menus = $app->getMenu();
|
||||
$title = null;
|
||||
|
||||
// Because the application sets a default page title,
|
||||
// we need to get it from the menu item itself
|
||||
$menu = $menus->getActive();
|
||||
|
||||
if ($menu)
|
||||
{
|
||||
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->params->def('page_heading', JText::_('COM_FINDER_DEFAULT_PAGE_TITLE'));
|
||||
}
|
||||
|
||||
$title = $this->params->get('page_title', '');
|
||||
|
||||
if (empty($title))
|
||||
{
|
||||
$title = $app->getCfg('sitename');
|
||||
}
|
||||
elseif ($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 ($layout = $this->params->get('article_layout'))
|
||||
{
|
||||
$this->setLayout($layout);
|
||||
}
|
||||
|
||||
// Configure the document meta-description.
|
||||
if (!empty($this->explained))
|
||||
{
|
||||
$explained = $this->escape(html_entity_decode(strip_tags($this->explained), ENT_QUOTES, 'UTF-8'));
|
||||
$this->document->setDescription($explained);
|
||||
}
|
||||
|
||||
// Configure the document meta-keywords.
|
||||
if (!empty($query->highlight))
|
||||
{
|
||||
$this->document->setMetadata('keywords', implode(', ', $query->highlight));
|
||||
}
|
||||
|
||||
if ($this->params->get('robots'))
|
||||
{
|
||||
$this->document->setMetadata('robots', $this->params->get('robots'));
|
||||
}
|
||||
|
||||
// Add feed link to the document head.
|
||||
if ($this->params->get('show_feed_link', 1) == 1)
|
||||
{
|
||||
// Add the RSS link.
|
||||
$props = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
|
||||
$route = JRoute::_($this->query->toURI() . '&format=feed&type=rss');
|
||||
$this->document->addHeadLink($route, 'alternate', 'rel', $props);
|
||||
|
||||
// Add the ATOM link.
|
||||
$props = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
|
||||
$route = JRoute::_($this->query->toURI() . '&format=feed&type=atom');
|
||||
$this->document->addHeadLink($route, 'alternate', 'rel', $props);
|
||||
}
|
||||
}
|
||||
}
|
54
components/com_finder/views/search/view.opensearch.php
Normal file
54
components/com_finder/views/search/view.opensearch.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* OpenSearch View class for Finder
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage com_finder
|
||||
* @since 2.5
|
||||
*/
|
||||
class FinderViewSearch extends JViewLegacy
|
||||
{
|
||||
/**
|
||||
* Method to display the view.
|
||||
*
|
||||
* @param string $tpl A template file to load. [optional]
|
||||
*
|
||||
* @return mixed JError object on failure, void on success.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$doc = JFactory::getDocument();
|
||||
$app = JFactory::getApplication();
|
||||
|
||||
$params = JComponentHelper::getParams('com_finder');
|
||||
$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_finder&q={searchTerms}';
|
||||
|
||||
// Find the menu item for the search
|
||||
$menu = $app->getMenu();
|
||||
$items = $menu->getItems('link', 'index.php?option=com_finder&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