Beispiel #1
0
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     foreach ($this->element->children() as $option) {
         // Only add <option /> elements.
         if ($option->getName() != 'option') {
             continue;
         }
         $value = JArrayHelper::getValue($option, 'value', null, 'string');
         $selected = $value == $this->value;
         $uri = clone \JSolr\Search\Factory::getSearchRoute();
         if (!empty($value)) {
             $uri->setVar($this->name, $value);
         } else {
             $uri->delVar($this->name);
         }
         $link = '<a role="menuitem" tabindex="-1" href="' . htmlentities((string) $uri, ENT_QUOTES, 'UTF-8') . '">' . JText::alt(trim((string) $option), preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)) . '</a>';
         // Create a new option object based on the <option /> element.
         $tmp = '<li role="presentation" class="' . ($selected ? 'active' : '') . '" data-value="' . $value . '">' . $link . '</li>';
         // Add the option object to the result set.
         $options[] = $tmp;
     }
     reset($options);
     return $options;
 }
Beispiel #2
0
    /**
     * Method to get the field options.
     *
     * @return  array  The field option objects.
     *
     * @since   11.1
     */
    protected function getOptions()
    {
        // Initialize variables.
        $options = array();
        foreach ($this->element->children() as $option) {
            // Only add <option /> elements.
            if ($option->getName() != 'option') {
                continue;
            }
            $value = JArrayHelper::getValue($option, 'value', null, 'string');
            $selected = $value == $this->value;
            $uri = clone \JSolr\Search\Factory::getSearchRoute();
            if (!empty($value)) {
                $uri->setVar($this->name, $value);
            } else {
                $uri->delVar($this->name);
            }
            $link = '<a role="menuitem" tabindex="-1" href="' . (string) $uri . '">' . JText::_(trim((string) $option)) . '</a>';
            $tmp = '<li role="presentation"' . ($selected ? ' class="active" ' : '') . ' data-value="' . $value . '">' . $link . '</li>';
            // Add the option object to the result set.
            $options[] = $tmp;
        }
        if ($this->show_custom) {
            $dataValue = 'custom';
            $cssClass = '';
            if (($min = $this->_getMinInput()) && ($max = $this->_getMaxInput())) {
                $selected = true;
                $dataValue = "min:{$min},max:{$max}";
                $cssClass = 'class="active"';
            }
            $link = <<<HTML
<a
    role="menuitem"
    tabindex="-1"
    href="#custom-dates"
    id="calendar-picker">Custom...</a>
HTML;
            $tmp = <<<HTML
<li
    role="presentation"
    {$cssClass}
    data-value="{$dataValue}">{$link}</li>
HTML;
            $options[] = $tmp;
        }
        reset($options);
        return $options;
    }
Beispiel #3
0
			<?php 
    echo $this->form->getInput($field->name);
    ?>
		<?php 
}
?>
	</div>

	<?php 
echo JHTML::_('form.token');
?>
</form>

<div id="custom-dates">
	<form id="custom-dates-form" action="<?php 
echo JRoute::_(\JSolr\Search\Factory::getSearchRoute());
?>
" method="get">
		<?php 
echo JHtml::_('calendar', '', "qdr_min", "qdr_min", "%Y-%m-%d");
?>
		<?php 
echo JHtml::_('calendar', '', "qdr_max", "qdr_max", "%Y-%m-%d");
?>

		<button id="custom-dates-submit"><?php 
echo JText::_('JSUBMIT');
?>
</button>
		<a id="custom-dates-cancel" href="#"><?php 
echo JText::_('JCANCEL');
Beispiel #4
0
 /**
  * (non-PHPdoc)
  * @see JModelForm::loadFormData()
  */
 protected function loadFormData()
 {
     $query = \JSolr\Search\Factory::getSearchRoute()->getQuery(true);
     if (count($query)) {
         $query = array_merge($query, $this->parseQuery());
         $data = $query;
     }
     $context = $this->get('option') . '.' . $this->getName();
     if (version_compare(JVERSION, "3.0", "ge")) {
         $this->preprocessData($this->get('context'), $data);
     }
     return $data;
 }
Beispiel #5
0
	<ul>
	<?php 
foreach ($this->items as $keyi => $valuei) {
    ?>
		<?php 
    $field = JArrayHelper::getValue($operators, $keyi);
    ?>
		<?php 
    foreach ($valuei as $keyj => $valuej) {
        ?>
			<?php 
        $vars = array(JFactory::getApplication()->input->get('name') => Helper::getOriginalFacet($keyj), 'o' => JFactory::getApplication()->input->get('o'));
        if ($this->params->get('show_count')) {
            $facet = JText::sprintf('%s [%s]', Helper::getOriginalFacet($keyj), $valuej);
        } else {
            $facet = JText::sprintf('%s', Helper::getOriginalFacet($keyj));
        }
        ?>

			<li><?php 
        echo JHTML::_('link', JRoute::_(\JSolr\Search\Factory::getSearchRoute($vars)), $facet);
        ?>
</li>
		<?php 
    }
    ?>
	<?php 
}
?>
	</ul>
</div>
Beispiel #6
0
 public function search()
 {
     $this->setRedirect(JRoute::_(\JSolr\Search\Factory::getSearchRoute(), false));
 }
Beispiel #7
0
 /**
  * Gets the remove url for the applied hidden filter.
  *
  * @return string The filter uri for the current facet.
  */
 protected function getFilterURI()
 {
     $url = clone \JSolr\Search\Factory::getSearchRoute();
     $url->delVar($this->name);
     return (string) $url;
 }
Beispiel #8
0
 /**
  * Gets the filter uri for the current facet.
  *
  * @param string $facet The facet value to build into the filter uri.
  * @return string The filter uri for the current facet.
  */
 protected function getFilterURI($facet)
 {
     $url = clone \JSolr\Search\Factory::getSearchRoute();
     foreach ($url->getQuery(true) as $key => $value) {
         $url->setVar($key, urlencode($value));
     }
     $filters = array();
     if ($cleaned = JString::trim($this->value)) {
         $filters = explode(self::FACET_DELIMITER, $cleaned);
     }
     if ($this->isSelected($facet)) {
         if (count($filters) > 1) {
             $found = false;
             for ($i = 0; ($filter = current($filters)) && !$found; $i++) {
                 if ($filter == $facet) {
                     unset($filters[$i]);
                     $found = true;
                 } else {
                     next($filters);
                 }
             }
             $url->setVar($this->name, urlencode(implode(self::FACET_DELIMITER, $filters)));
         } else {
             $url->delVar($this->name);
         }
     } else {
         $filters[] = $facet;
         $url->setVar($this->name, urlencode(implode(self::FACET_DELIMITER, $filters)));
     }
     return (string) $url;
 }