/**
  * 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;
 }
Esempio n. 2
0
 /**
  * @return array|null
  */
 public function execute()
 {
     $marker = array();
     if ($this->configuration->getSearchSorting() && $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;
 }
Esempio n. 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;
 }
Esempio n. 4
0
 /**
  * @return string
  */
 protected function getPageBrowserRange()
 {
     $label = '';
     $resultsFrom = $this->search->getResponseBody()->start + 1;
     $resultsTo = $resultsFrom + count($this->search->getResultDocumentsEscaped()) - 1;
     $resultsTotal = $this->search->getNumberOfResults();
     $label = strtr($this->parentPlugin->pi_getLL('results_range'), array('@resultsFrom' => $resultsFrom, '@resultsTo' => $resultsTo, '@resultsTotal' => $resultsTotal));
     return $label;
 }
Esempio n. 5
0
 /**
  * Executes the command, renders the template subpart markers if faceting
  * is activated.
  *
  * @return array|null Array of faceting markers or null if faceting is deactivated
  */
 public function execute()
 {
     $marker = array();
     if ($this->configuration->getSearchFaceting() && ($this->search->getNumberOfResults() || $this->configuration->getSearchInitializeWithEmptyQuery() || $this->configuration->getSearchInitializeWithQuery())) {
         $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;
 }
 /**
  * Index Action, provides an array of documents indexed for a given page.
  *
  * @param integer $pageId The current page's uid.
  * @return \stdClass
  */
 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;
 }