Search for content for a given $searchText and returns a pager.

@param string $searchText to be looked up
@param int $currentPage to be displayed
@param array $languages to include in the search

@return \Pagerfanta\Pagerfanta
776672
public function searchForPaginatedContent($searchText, $currentPage, $languages)
    {
        // Generating query
        $query = new Query();
        $query->query = new Criterion\FullText($searchText);
        $query->filter = new Criterion\LogicalAnd(
            array(
                new Criterion\Visibility(Criterion\Visibility::VISIBLE),
                new Criterion\LanguageCode($languages, true),
            )
        );

        // Initialize pagination.
        $pager = new Pagerfanta(
            new ContentSearchAdapter($query, $this->searchService)
        );
        $pager->setMaxPerPage($this->searchListLimit);
        $pager->setCurrentPage($currentPage);

        return $pager;
    }
1351260
protected function setCurrentPage($currentPage, $pageName)
    {
        $currentPage = $currentPage ?: static::resolveCurrentPage($pageName);

        return $this->isValidPageNumber($currentPage) ? (int) $currentPage : 1;
    }
877383
public function find($translations, $term = null, $page = 1, $perPage = 20)
    {
        $keys = [];
        foreach ($translations as $key => $translation) {
            foreach ($translation as $lang => $value) {
                if (empty($term) || str_contains(strtoupper($value), strtoupper($term))
                    || str_contains(strtoupper($key), strtoupper($term))) {
                    $keys[$key] = $translation;

                    continue;
                }
            }
        }

        return $this->paginate($keys, $page, $perPage);
    }
768572
protected function _addPageNrParam($url, $currentPage, $languageId = null)
    {
        if (\OxidEsales\Eshop\Core\Registry::getUtils()->seoIsActive() && ($category = $this->getActiveCategory())) {
            if ($currentPage) {
                // only if page number > 0
                $url = $category->getBaseSeoLink($languageId, $currentPage);
            }
        } else {
            $url = parent::_addPageNrParam($url, $currentPage, $languageId);
        }

        return $url;
    }
297679
public function getCurrentPage($contextId = null)
    {
        $pager = $this->offsetGet($contextId) ?: $this->offsetGet('');

        return ($pager) ? $pager->current : 1;
    }
990562
private function seek($search, $selectors, $current) {
		if (!($search instanceof \DOMElement)) {
			return FALSE;
		}
		list ($tag, $key, $val, $exp, $no_key) = $selectors [$current];
		$pass = TRUE;
		if ($tag === '*' && !$key) {
			exit('tag为*时，key不能为空');
		}
		if ($tag && $tag != $search->tagName && $tag !== '*') {
			$pass = FALSE;
		}
		if ($pass && $key) {
			if ($no_key) {
				if ($search->hasAttribute($key)) {
					$pass = FALSE;
				}
			} else {
				if ($key != "plaintext" && !$search->hasAttribute($key)) {
					$pass = FALSE;
				}
			}
		}
		if ($pass && $key && $val && $val !== '*') {
			if ($key == "plaintext") {
				$nodeKeyValue = $this->text($search);
			} else {
				$nodeKeyValue = $search->getAttribute($key);
			}
			$check = $this->match($exp, $val, $nodeKeyValue);
			if (!$check && strcasecmp($key, 'class') === 0) {
				foreach (explode(' ', $search->getAttribute($key)) as $k) {
					if (!empty ($k)) {
						$check = $this->match($exp, $val, $k);
						if ($check) {
							break;
						}
					}
				}
			}
			if (!$check) {
				$pass = FALSE;
			}
		}
		if ($pass) {
			$current--;
			if ($current < 0) {
				return $search;
			} elseif ($this->seek($this->getParent($search), $selectors, $current)) {
				return $search;
			} else {
				return FALSE;
			}
		} else {
			return FALSE;
		}
	}
846088
public function substring($text, $searchword, $length = 200)
    {
        $textlen = AnHelperString::strlen($text);
        $lsearchword = AnHelperString::strtolower($searchword);
        $wordfound = false;
        $pos = 0;

        while ($wordfound === false && $pos < $textlen) {
            if (($wordpos = @AnHelperString::strpos($text, ' ', $pos + $length)) !== false) {
                $chunk_size = $wordpos - $pos;
            } else {
                $chunk_size = $length;
            }

            $chunk = AnHelperString::substr($text, $pos, $chunk_size);
            $wordfound = AnHelperString::strpos(AnHelperString::strtolower($chunk), $lsearchword);

            if ($wordfound === false) {
                $pos += $chunk_size + 1;
            }
        }//while

        if ($wordfound !== false) {
            return (($pos > 0) ? '...&nbsp;' : '').$chunk.'&nbsp;...';
        } else {
            if (($wordpos = @AnHelperString::strpos($text, ' ', $length)) !== false) {
                return AnHelperString::substr($text, 0, $wordpos).'&nbsp;...';
            } else {
                return AnHelperString::substr($text, 0, $length);
            }
        }
    }
467494
public function getSupportedLanguages($currentID)
    {
        $environment  = $this->getEnvironment();
        $dataProvider = $environment->getDataProvider();

        // Check if current data provider supports multi language.
        if ($dataProvider instanceof MultiLanguageDataProviderInterface) {
            $supportedLanguages = $dataProvider->getLanguages($currentID);
        } else {
            $supportedLanguages = null;
        }

        // Check if we have some languages.
        if (null === $supportedLanguages) {
            return [];
        }

        $translator = $environment->getTranslator();

        // Make an array from the collection.
        $languages = [];
        foreach ($supportedLanguages as $value) {
            /** @var LanguageInformationInterface $value */
            $locale = $value->getLocale();

            $languages[$locale] = $translator->translate('LNG.' . $locale, 'languages');
        }

        return $languages;
    }
1093609
public function getCurrentPageStrategyInstance()
    {
        if ($this->currentPageStrategy === null) {
            $this->currentPageStrategy = new CurrentPageStrategyImpl($this);
        }
        return $this->currentPageStrategy;
    }
124816
public function getById($languageId, array $queryParams = [])
    {
        $response = $this->api->languages()->getById($languageId, $queryParams);

        return new LanguageResponse($response);
    }
1076261
public function searchHulu($searchText)
		{
			global $urlData;

			if (empty($this->dataFile)) {
				$this->dataFile = $this->setDataFile();
			}

			foreach ($this->dataFile as $value) {
				$fileName = $value;
				$doc = new \DOMDocument;
				$doc->preserveWhiteSpace = false;
				$file = realpath($this->dataFolder.'/'.$fileName);
				$doc->load($file);
				$xpath = new \DOMXpath($doc);
				$query = "/*/*[contains(.,' ".$searchText." ')]";
				$results = $xpath->query($query);
				$c = count($this->huluResult);

				foreach ($results as $result) {
					$this->processNode($result);
					$this->huluResult[$c]['loc'] 					= $urlData['url']['loc'];
					$this->huluResult[$c]['thumbnail_loc'] 			= $urlData['video:video']['video:thumbnail_loc'];
					$this->huluResult[$c]['title'] 					= $urlData['video:video']['video:title'];
					$this->huluResult[$c]['description'] 			= $urlData['video:video']['video:description'];
					$this->huluResult[$c]['family_friendly'] 		= $urlData['video:video']['video:family_friendly'];
					$this->huluResult[$c]['duration'] 				= $urlData['video:video']['video:duration'];
					$this->huluResult[$c]['rating'] 				= $urlData['video:video']['video:rating'];
					$this->huluResult[$c]['publication_date'] 		= $urlData['video:video']['video:publication_date'];
					$this->huluResult[$c]['season_number'] 			= $urlData['video:video']['video:season_number'];
					$this->huluResult[$c]['video_type'] 			= $urlData['video:video']['video:video_type'];
					$this->huluResult[$c]['air_date'] 				= $urlData['video:video']['video:air_date'];
					$this->huluResult[$c]['added_date'] 			= $urlData['video:video']['video:added_date'];
					$this->huluResult[$c]['company'] 				= $urlData['video:video']['video:company'];
					$this->huluResult[$c]['requires_subscription'] 	= $urlData['video:video']['video:requires_subscription'];
					$this->huluResult[$c]['content_id'] 			= $urlData['video:video']['hulu-video:content_id'];
					$this->huluResult[$c]['show_id'] 				= $urlData['video:video']['hulu-video:show_id'];
					$this->huluResult[$c]['seriesDescription']	 	= $urlData['video:video']['hulu:seriesDescription'];
					$this->huluResult[$c]['mediaType'] 				= $urlData['video:video']['hulu:mediaType'];
					$this->huluResult[$c]['channel'] 				= $urlData['video:video']['hulu:channel'];
					$this->huluResult[$c]['hulu']['season_number'] 	= $urlData['video:video']['hulu-video:season_number'];
					$this->huluResult[$c]['hulu']['air_date'] 		= $urlData['video:video']['hulu-video:air_date'];
					$this->huluResult[$c]['hulu']['company'] 		= $urlData['video:video']['hulu-video:company'];
					$this->huluResult[$c]['show']['show_title'] 	= $urlData['video:tvshow']['video:show_title'];
					$this->huluResult[$c]['show']['video_type'] 	= $urlData['video:tvshow']['video:video_type'];
					$this->huluResult[$c]['show']['episode_title'] 	= $urlData['video:tvshow']['video:episode_title'];
					$this->huluResult[$c]['show']['premier_date'] 	= $urlData['video:tvshow']['video:premier_date'];
					$c++;
				}

				$doc 	= null;
				$xpath 	= null;
			}
		}
585847
public function processPaginated(array $pages = [], $perPage = 50, $currentPage = 0)
    {
        $models = [];

        foreach ($pages as $results) {
            // Go through each page and process the results into an objects array.
            $models = array_merge($models, $this->process($results));
        }

        $models = $this->processSort($models)->toArray();

        return $this->newPaginator($models, $perPage, $currentPage, count($pages));
    }
979706
public void setCurrentPage(int currentPage) throws CmsIllegalArgumentException {

        if (getSize() != 0) {
            if ((currentPage < 1) || (currentPage > getNumberOfPages())) {
                throw new CmsIllegalArgumentException(
                    Messages.get().container(Messages.ERR_LIST_INVALID_PAGE_1, new Integer(currentPage)));
            }
        }
        m_currentPage = currentPage;
    }
326637
public function search($locale, $partialCode, $perPage = 0)
    {
        // Get the namespace, if any:
        $colonIndex = stripos($partialCode, '::');
        $query      = $this->model->whereLocale($locale);
        if ($colonIndex === 0) {
            $query = $query->where('namespace', '!=', '*');
        } elseif ($colonIndex > 0) {
            $namespace   = substr($partialCode, 0, $colonIndex);
            $query       = $query->where('namespace', 'like', "%{$namespace}%");
            $partialCode = substr($partialCode, $colonIndex + 2);
        }

        // Divide the code in segments by .
        $elements = explode('.', $partialCode);
        foreach ($elements as $element) {
            if ($element) {
                $query = $query->where(function ($query) use ($element) {
                    $query->where('group', 'like', "%{$element}%")->orWhere('item', 'like', "%{$element}%")->orWhere('text', 'like', "%{$element}%");
                });
            }
        }

        return $perPage ? $query->paginate($perPage) : $query->get();
    }
1080136
public function indexSearch($searchText, $maxResults)
    {
        // split the phrase into words
        $words = SearchAnalyser::analyse($searchText);
        if (!$words) {
            return [];
        }

        $query = $this->_em->createQueryBuilder()
            ->select('o')
            ->from($this->_entityName, 'o')
            ->setMaxResults($maxResults);

        $parameters = [];
        foreach ($words as $k => $word) {
            $subquery = $this->_em->createQueryBuilder()
                ->select("i$k.keyword")
                ->from($this->getSearchIndexClass(), "i$k")
                ->where("i$k.object = o")
                ->andWhere("i$k.keyword ILIKE :search$k");
            $query->andWhere($query->expr()->exists($subquery->getDql()));
            $parameters["search$k"] = '%' . $word . '%';
        }
        $query->setParameters($parameters);

        $results = $query->getQuery()->execute();

        return $results;
    }
193358
public function setCurrentSite($siteId, $siteName, $siteDefaultLanguage, array $languages)
    {
        parent::setSite($siteId, $siteName, $siteDefaultLanguage, $languages);
    }
509845
public function paginate($perPage = 50, $currentPage = 0, $isCritical = true)
    {
        // Stores all LDAP entries in a page array
        $pages = [];

        $cookie = '';

        do {
            $this->connection->controlPagedResult($perPage, $isCritical, $cookie);

            $results = $this->connection->search($this->adldap->getBaseDn(), $this->getQuery(), $this->getSelects());

            if ($results) {
                $this->connection->controlPagedResultResponse($results, $cookie);

                $pages[] = $results;
            }
        } while ($cookie !== null && !empty($cookie));

        if (count($pages) > 0) {
            return $this->processPaginatedResults($pages, $perPage, $currentPage);
        }

        return false;
    }