Skip to content

Commit

Permalink
com_finder view review
Browse files Browse the repository at this point in the history
  • Loading branch information
zero-24 committed Jul 24, 2017
1 parent 247480f commit c34ffe0
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 57 deletions.
41 changes: 19 additions & 22 deletions components/com_finder/views/search/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,24 @@
?>

<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 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; ?>
<?php // Load the search results layout if we are performing a search. ?>
<?php if ($this->query->search === true) : ?>
<div id="search-results">
<?php echo $this->loadTemplate('results'); ?>
</div>
<?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>
25 changes: 12 additions & 13 deletions components/com_finder/views/search/tmpl/default_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,30 +63,29 @@

<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_query')) : ?>
<button name="Search" type="submit" class="btn btn-primary"><span class="icon-search icon-white"></span> <?php echo JText::_('JSEARCH_FILTER_SUBMIT'); ?></button>
<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>
<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" aria-hidden="true"></span> <?php echo JText::_('COM_FINDER_ADVANCED_SEARCH_TOGGLE'); ?></a>
<a href="#advancedSearch" data-toggle="collapse" class="btn">
<span class="icon-list" aria-hidden="true"></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<?php if ($this->params->get('expand_advanced', 0)) echo ' in'; ?>">
<hr />
Expand Down
7 changes: 4 additions & 3 deletions components/com_finder/views/search/tmpl/default_result.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// Calculate number of characters to display around the result
$term_length = StringHelper::strlen($this->query->input);
$desc_length = $this->params->get('description_length', 255);
$pad_length = $term_length < $desc_length ? (int) floor(($desc_length - $term_length) / 2) : 0;
$pad_length = $term_length < $desc_length ? (int) floor(($desc_length - $term_length) / 2) : 0;

// Find the position of the search term
$pos = $term_length ? StringHelper::strpos(StringHelper::strtolower($this->result->description), StringHelper::strtolower($this->query->input)) : false;
Expand All @@ -46,12 +46,13 @@
{
$route .= '&highlight=' . base64_encode(json_encode($this->query->highlight));
}

?>

<li>
<h4 class="result-title <?php echo $mime; ?>">
<a href="<?php echo JRoute::_($route); ?>"><?php echo $this->result->title; ?></a>
<a href="<?php echo JRoute::_($route); ?>">
<?php echo $this->result->title; ?>
</a>
</h4>
<?php if ($show_description && $description !== '') : ?>
<p class="result-text<?php echo $this->pageclass_sfx; ?>">
Expand Down
27 changes: 8 additions & 19 deletions components/com_finder/views/search/tmpl/default_results.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
defined('_JEXEC') or die;

?>

<?php // Display the suggested search if it is different from the current search. ?>
<?php if (($this->suggested && $this->params->get('show_suggested_query', 1)) || ($this->explained && $this->params->get('show_explained_query', 1))) : ?>
<div id="search-query-explained">
Expand All @@ -18,64 +19,52 @@
<?php // Replace the base query string with the suggested query string. ?>
<?php $uri = JUri::getInstance($this->query->toUri()); ?>
<?php $uri->setVar('q', $this->suggested); ?>

<?php // Compile the suggested query link. ?>
<?php $linkUrl = JRoute::_($uri->toString(array('path', 'query'))); ?>
<?php $link = '<a href="' . $linkUrl . '">' . $this->escape($this->suggested) . '</a>'; ?>

<?php echo JText::sprintf('COM_FINDER_SEARCH_SIMILAR', $link); ?>

<?php // Display the explained search query. ?>
<?php elseif ($this->explained && $this->params->get('show_explained_query', 1)) : ?>
<?php // Display the explained search query. ?>
<?php echo $this->explained; ?>
<?php endif; ?>
</div>
<?php endif; ?>

<?php // Display the 'no results' message and exit the template. ?>
<?php if ($this->total == 0) : ?>
<div id="search-result-empty">
<h2><?php echo JText::_('COM_FINDER_SEARCH_NO_RESULTS_HEADING'); ?></h2>
<?php $multilang = JFactory::getApplication()->getLanguageFilter() ? '_MULTILANG' : ''; ?>
<p><?php echo JText::sprintf('COM_FINDER_SEARCH_NO_RESULTS_BODY' . $multilang, $this->escape($this->query->input)); ?></p>
</div>

<?php // Exit this template. ?>
<?php return; ?>
<?php endif; ?>

<?php // Activate the highlighter if enabled. ?>
<?php if (!empty($this->query->highlight) && $this->params->get('highlight_terms', 1)) : ?>
<?php JHtml::_('behavior.highlighter', $this->query->highlight); ?>
<?php endif; ?>

<?php // Display a list of results ?>
<br id="highlighter-start" />
<ul class="search-results<?php echo $this->pageclass_sfx; ?> list-striped">
<?php $this->baseUrl = JUri::getInstance()->toString(array('scheme', 'host', 'port')); ?>

<?php foreach ($this->results as $result) : ?>
<?php $this->result = &$result; ?>
<?php $layout = $this->getLayoutFile($this->result->layout); ?>
<?php echo $this->loadTemplate($layout); ?>
<?php endforeach; ?>
</ul>
<br id="highlighter-end" />

<?php // Display the pagination ?>
<div class="search-pagination">
<div class="pagination">
<?php echo $this->pagination->getPagesLinks(); ?>
</div>
<div class="search-pages-counter">
<?php
// 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->get('pages.current');
$limit = (int) ($limit > $total ? $total : $limit);

echo JText::sprintf('COM_FINDER_SEARCH_RESULTS_OF', $start, $limit, $total);
?>
<?php // Prepare the pagination string. Results X - Y of Z ?>
<?php $start = (int) $this->pagination->get('limitstart') + 1; ?>
<?php $total = (int) $this->pagination->get('total'); ?>
<?php $limit = (int) $this->pagination->get('limit') * $this->pagination->get('pages.current'); ?>
<?php $limit = (int) ($limit > $total ? $total : $limit); ?>
<?php echo JText::sprintf('COM_FINDER_SEARCH_RESULTS_OF', $start, $limit, $total); ?>
</div>
</div>

0 comments on commit c34ffe0

Please sign in to comment.