/**
  * checks if the entered searchstring is the default value
  *
  * @param string $searchString
  * @return string Returns the searchstring or an empty string
  */
 public function checkAgainstDefaultValue($searchString)
 {
     $searchStringToLower = strtolower(trim($searchString));
     $defaultValueToLower = strtolower($this->pObj->pi_getLL('searchbox_default_value'));
     if ($searchStringToLower === $defaultValueToLower) {
         $searchString = '';
     }
     return $searchString;
 }
 /**
  * Finds the selected filter options for a given filter.
  * Checks
  * - piVars one-dimensional filter
  * - piVars multi-dimensional filter
  * - backend preselected filter options
  *
  * returns the filter options uids as values of an array or zero if no option has been selected.
  *
  * @param array $filter
  * @return integer
  * @author Christian Bülter <*****@*****.**>
  * @since 09.09.14
  */
 public function getSelectedFilterOptions($filter)
 {
     $selectedOptions = array();
     // run through all the filter options and check if one of them
     // has been selected.
     foreach ($filter['options'] as $option) {
         // Is the filter option selected in the frontend via piVars
         // or in the backend via flexform configuration ("preselected filters")?
         $selected = false;
         if ($this->pObj->piVars['filter'][$filter['uid']] == $option['tag']) {
             $selected = true;
         } else {
             if (is_array($this->pObj->piVars['filter'][$filter['uid']])) {
                 $isInArray = TYPO3\CMS\Core\Utility\GeneralUtility::inArray($this->pObj->piVars['filter'][$filter['uid']], $option['tag']);
                 if ($isInArray) {
                     $selected = true;
                 }
             } else {
                 if (!isset($this->pObj->piVars['filter'][$filter['uid']]) && !is_array($this->pObj->piVars['filter'][$filter['uid']])) {
                     if (is_array($this->pObj->preselectedFilter) && $this->pObj->in_multiarray($option['tag'], $this->pObj->preselectedFilter)) {
                         $selected = true;
                         // add preselected filter to piVars
                         $this->pObj->piVars['filter'][$filter['uid']] = array($option['uid'] => $option['tag']);
                     }
                 }
             }
         }
         if ($selected) {
             $selectedOptions[] = $option['uid'];
         }
     }
     return $selectedOptions;
 }
 /**
  * Test ordering if no searchword was given
  * @test
  */
 public function checkOrderingWithoutNeededConditions()
 {
     // Test with showSortInFrontend = false
     $this->conf = array('showSortInFrontend' => false, 'sortByVisitor' => 'sortdate,title,tstamp');
     $this->numberOfResults = 35;
     $lib = new tx_kesearch_lib();
     $this->assertEquals('', $lib->renderOrdering());
     // Test with sortByVisitor = empty
     $this->conf = array('showSortInFrontend' => true, 'sortByVisitor' => '');
     $this->numberOfResults = 35;
     $this->assertEquals('', $lib->renderOrdering());
     // Test with numberOfResults = 0
     $this->conf = array('showSortInFrontend' => true, 'sortByVisitor' => 'sortdate,title,tstamp');
     $this->numberOfResults = 0;
     $this->assertEquals('', $lib->renderOrdering());
 }
 /**
  * generate the link for normal textlinks
  *
  * @param string $filterUid
  * @param string $option
  * @return string The complete link as A-Tag
  */
 public function generateLink($filterUid, $option)
 {
     $filters = $this->pObj->filters->getFilters();
     $params = array();
     $params[] = '[page]=1';
     $params[] = '[filter][' . $filterUid . '][' . $option['uid'] . ']=' . $option['tag'];
     $excludes = array();
     $excludes[] = 'id';
     $excludes[] = 'tx_kesearch_pi1[multi]';
     // hook: modifyParamsForTextlinks
     // This is useful if you want to define special sortings for each textlink
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyParamsForTextlinks'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyParamsForTextlinks'] as $_classRef) {
             $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
             $_procObj->modifyParamsForTextlinks($params, $excludes, $option, $this->conf, $this->pObj);
         }
     }
     foreach ($params as $key => $value) {
         $params[$key] = $this->cObj->wrap($value, $this->pObj->prefixId . '|');
     }
     $conf = array();
     $conf['parameter'] = $this->conf['resultPage'];
     $conf['addQueryString'] = '1';
     $conf['addQueryString.']['exclude'] = implode(',', $excludes);
     $conf['additionalParams'] = '&' . implode('&', $params);
     $number_of_results = $this->pObj->renderNumberOfResultsString($option['results'], $filters[$filterUid]);
     return $this->cObj->typoLink($option['title'] . $number_of_results, $conf);
 }
 /**
  * generate the link for the given sorting value
  *
  * @param string $field
  * @param string $sortByDir
  * @return string The complete link as A-Tag
  */
 public function generateSortingLink($field, $sortByDir)
 {
     $params = array();
     $params['sortByField'] = $field;
     $params['sortByDir'] = $sortByDir;
     foreach ($params as $key => $value) {
         $params[$key] = $this->cObj->wrap($value, $this->pObj->prefixId . '[' . $key . ']=|');
     }
     $conf = array();
     $conf['parameter'] = $GLOBALS['TSFE']->id;
     $conf['addQueryString'] = '1';
     $conf['addQueryString.']['exclude'] = 'id,tx_kesearch_pi1[multi],cHash';
     $conf['additionalParams'] = '&' . implode('&', $params);
     return $this->cObj->typoLink($this->pObj->pi_getLL('orderlink_' . $field, $field), $conf);
 }