/**
  * The main entry point of this class
  * It will return the complete sorting HTML
  *
  * @return string HTML
  */
 public function renderSorting()
 {
     // show sorting:
     // if show Sorting is activated in FlexForm
     // if a value to sortBy is set in FlexForm (title, relevance, sortdate, what ever...)
     // if there are any entries in current search results
     if ($this->conf['showSortInFrontend'] && !empty($this->conf['sortByVisitor']) && $this->pObj->numberOfResults) {
         // loop all allowed orderings
         foreach ($this->sortBy as $field) {
             // we can't sort by score if there is no sword given
             if ($this->pObj->sword != '' || $field != 'score') {
                 $sortByDir = $this->getDefaultSortingDirection($field);
                 if (TYPO3_VERSION_INTEGER >= 7000000) {
                     $dbOrdering = TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(' ', $this->db->getOrdering());
                 } else {
                     $dbOrdering = t3lib_div::trimExplode(' ', $this->db->getOrdering());
                 }
                 /* if ordering direction is the same change it
                  *
                  * Explaintation:
                  * No ordering is active. Default Ordering by db is "sortdate desc".
                  * Default ordering by current field is also "sortdate desc".
                  * So...if you click the link for sortdate it will sort the results by "sortdate desc" again
                  * To prevent this we change the default ordering here
                  */
                 if ($field == $dbOrdering[0] && $sortByDir == $dbOrdering[1]) {
                     $sortByDir = $this->changeOrdering($sortByDir);
                 }
                 $markerArray['###FIELDNAME###'] = $field;
                 $markerArray['###URL###'] = $this->generateSortingLink($field, $sortByDir);
                 $markerArray['###CLASS###'] = $this->getClassNameForUpDownArrow($field, $dbOrdering);
                 $links .= $this->cObj->substituteMarkerArray($this->subpartArray['###SORT_LINK###'], $markerArray);
             }
         }
         $content = $this->cObj->substituteSubpart($this->subpartArray['###ORDERNAVIGATION###'], '###SORT_LINK###', $links);
         $content = $this->cObj->substituteMarker($content, '###LABEL_SORT###', $this->pObj->pi_getLL('label_sort'));
         return $content;
     } else {
         return '';
     }
 }
 /**
  * The main entry point of this class
  * It will return the complete HTML for textlinks
  *
  * @param integer $filterUid uid of the current loopd filter
  * @param array $optionsOfSearchresult All found options in current search result
  * @param object $lib
  * @return string HTML
  */
 public function renderTextlinks($filterUid, $optionsOfSearchresult, $lib)
 {
     $filters = $this->pObj->filters->getFilters();
     $filter = $filters[$filterUid];
     if (!is_array($filter) || count($filter) == 0) {
         return '';
     }
     // get options
     $optionsOfFilter = $this->getOptionsOfFilter($filter, $optionsOfSearchresult);
     if (!is_array($optionsOfFilter) || count($optionsOfFilter) == 0) {
         return '';
     }
     // alphabetical sorting of filter options
     if ($filter['alphabeticalsorting'] == 1) {
         $this->pObj->sortArrayByColumn($optionsOfFilter, 'title');
     }
     $this->maxAllowedNormalOptions = $filter['amount'];
     if (is_array($this->pObj->piVars['filter'][$filterUid]) && count($this->pObj->piVars['filter'][$filterUid])) {
         $piVarsOptionList = implode(',', array_keys($this->pObj->piVars['filter'][$filterUid]));
         $optionsOfFilter = $this->pObj->getFilterOptions($piVarsOptionList);
     }
     foreach ($optionsOfFilter as $key => $data) {
         $this->saveRenderedTextlinkToGlobalArrays($filterUid, $data);
     }
     if (is_array($this->contentOfActiveOptions) && count($this->contentOfActiveOptions)) {
         foreach ($this->contentOfActiveOptions as $option) {
             $contentOptions .= $option;
         }
     } else {
         foreach ($this->contentOfNormalOptions as $option) {
             $contentOptions .= $option;
         }
     }
     // modify filter options by hook
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyFilterOptions'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['modifyFilterOptions'] as $_classRef) {
             $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef);
             $contentOptions .= $_procObj->modifyFilterOptions($filterUid, $contentOptions, count($optionsOfFilter), $this);
         }
     }
     unset($markerArray);
     // render filter
     $contentFilters = $this->cObj->substituteSubpart($this->templateArray['filter'], '###SUB_FILTER_TEXTLINK_OPTION###', $contentOptions);
     // get title
     $filterTitle = $filter['title'];
     $filter['target_pid'] = $filter['target_pid'] ? $filter['target_pid'] : $this->conf['resultPage'];
     // fill markers
     $markerArray['###FILTERTITLE###'] = htmlspecialchars($filterTitle);
     $markerArray['###HIDDEN_FIELDS###'] = implode(CHR(10), $this->contentOfHiddenFields);
     $exclude = 'tx_kesearch_pi1[page],tx_kesearch_pi1[multi],tx_kesearch_pi1[filter][' . $filterUid . ']';
     if ($this->countActiveOptions) {
         $markerArray['###LINK_MULTISELECT###'] = '';
         $markerArray['###LINK_RESET_FILTER###'] = $this->cObj->typoLink($this->pObj->pi_getLL('reset_filter'), array('parameter' => $this->conf['resultPage'], 'addQueryString' => 1, 'addQueryString.' => array('exclude' => $exclude)));
     } else {
         // check if there is a special translation for current filter
         $linkTextMore = $this->pObj->pi_getLL('linktext_more_' . $filterUid, $this->pObj->pi_getLL('linktext_more'));
         $markerArray['###LINK_MULTISELECT###'] = $this->cObj->typoLink(sprintf($linkTextMore, $filterTitle), array('parameter' => $filter['target_pid'], 'addQueryString' => 1, 'addQueryString.' => array('exclude' => 'id,tx_kesearch_pi1[page],tx_kesearch_pi1[multi]')));
         $markerArray['###LINK_RESET_FILTER###'] = '';
     }
     $contentFilters = $this->cObj->substituteMarkerArray($contentFilters, $markerArray);
     return $contentFilters;
 }