/**
  * Resolves the current iteration index (relative) of a loop to the absolute
  * number counting from zero of the total number of results.
  *
  * @param array $arguments
  * @return	string
  */
 public function execute(array $arguments = array())
 {
     $numberOfResults = $this->search->getNumberOfResults();
     $currentIterationIndex = $arguments[0];
     $resultsPerPage = $this->search->getResultsPerPage();
     $currentPage = 0;
     $getParameters = GeneralUtility::_GET('tx_solr');
     if (isset($getParameters['page'])) {
         $currentPage = intval($getParameters['page']);
     }
     return $currentPage * $resultsPerPage + $currentIterationIndex;
 }
 public function execute()
 {
     $marker = array();
     if ($this->configuration['search.']['sorting'] != 0 && $this->search->getNumberOfResults()) {
         $marker['loop_sort|sort'] = $this->getSortingLinks();
     }
     if (count($marker) === 0) {
         // in case we didn't fill any markers - like when there are no
         // search results - we set markers to NULL to signal that we
         // want to have the subpart removed completely
         $marker = NULL;
     }
     return $marker;
 }
Exemple #3
0
 /**
  * Creates the HTML for the relevance output
  *
  * @param array $arguments Array of arguments, [0] is expected to contain the result document.
  * @return string The score as percent value.
  */
 public function execute(array $arguments = array())
 {
     $content = '';
     $document = $arguments[0];
     if (count($arguments) > 1) {
         // a pipe character caused the serialized document to be split up
         $document = implode('|', $arguments);
     }
     if ($this->search->hasSearched() && $this->search->getNumberOfResults()) {
         $score = $this->getScore($document);
         $maximumScore = $this->getMaximumScore($document);
         $content = $this->render($score, $maximumScore);
     }
     return $content;
 }
Exemple #4
0
 /**
  * Executes the command, renders the template subpart markers if facetting
  * is activated.
  *
  * @return array|null Array of facetting markers or null if facetting is deactivated
  */
 public function execute()
 {
     $marker = array();
     if ($this->configuration['search.']['faceting'] && ($this->search->getNumberOfResults() || $this->configuration['search.']['initializeWithEmptyQuery'] || $this->configuration['search.']['initializeWithQuery'])) {
         $marker['subpart_available_facets'] = $this->renderAvailableFacets();
         $marker['subpart_used_facets'] = $this->renderUsedFacets();
         $marker['active'] = $this->facetsActive ? '1' : '0';
         $marker['search_has_results'] = $this->search->getNumberOfResults() ? 1 : 0;
         $this->addFacetingJavascript();
     }
     if (count($marker) === 0) {
         // in case we didn't fill any markers - like when there are no
         // search results - we set markers to NULL to signal that we
         // want to have the subpart removed completely
         $marker = NULL;
     }
     return $marker;
 }
 protected function getPageBrowserRange()
 {
     $label = '';
     $resultsFrom = $this->search->getResponseBody()->start + 1;
     $resultsTo = $resultsFrom + count($this->search->getResultDocuments()) - 1;
     $resultsTotal = $this->search->getNumberOfResults();
     $label = strtr($this->parentPlugin->pi_getLL('results_range'), array('@resultsFrom' => $resultsFrom, '@resultsTo' => $resultsTo, '@resultsTotal' => $resultsTotal));
     return $label;
 }
 /**
  * Index Action, provides an array of documents indexed for a given page.
  *
  * @param	integer	$pageId The current page's uid.
  */
 public function indexAction($pageId)
 {
     $this->initialize($pageId);
     $responseDocuments = array();
     $documents = $this->getIndexDocuments();
     foreach ($documents as $key => $document) {
         $responseDocuments[$key] = array('id' => $document->id, 'type' => $document->type, 'title' => $document->title, '__data' => $this->formatDocumentData($document));
     }
     $response = new stdClass();
     $response->success = TRUE;
     $response->metaData = $this->buildResponseMetaData();
     $response->numFound = $this->search->getNumberOfResults();
     $response->documents = $responseDocuments;
     return $response;
 }