本文整理汇总了PHP中ApacheSolrForTypo3\Solr\Util类的典型用法代码示例。如果您正苦于以下问题:PHP Util类的具体用法?PHP Util怎么用?PHP Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initializeSearchComponent
/**
* Initializes the search component.
*
* Sets the debug query parameter
*
*/
public function initializeSearchComponent()
{
$solrConfiguration = Util::getSolrConfiguration();
if ($solrConfiguration->getEnabledDebugMode()) {
$this->query->setDebugMode();
}
}
示例2: __construct
/**
* Constructor
*
* @param array $arguments
*/
public function __construct(array $arguments = array())
{
$configuration = Util::getSolrConfiguration();
if (!empty($configuration['viewhelpers.']['multivalue.']['glue'])) {
$this->glue = $configuration['viewhelpers.']['multivalue.']['glue'];
}
}
示例3: getConfiguration
/**
* @return TypoScriptConfiguration|array
*/
protected function getConfiguration()
{
if ($this->configuration == null) {
$this->configuration = Util::getSolrConfiguration();
}
return $this->configuration;
}
示例4: canGetVariants
/**
* @test
*/
public function canGetVariants()
{
$this->indexPageIdsFromFixture('can_get_searchResultSet.xml', [1, 2, 3, 4, 5, 6, 7, 8]);
sleep(1);
$solrConnection = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\ConnectionManager')->getConnectionByPageId(1, 0, 0);
$typoScriptConfiguration = Util::getSolrConfiguration();
$typoScriptConfiguration->mergeSolrConfiguration(['search.' => ['variants' => 1, 'variants.' => ['variantField' => 'subTitle', 'expand' => 1, 'limit' => 11]]]);
$this->assertTrue($typoScriptConfiguration->getSearchVariants(), 'Variants are not enabled');
$this->assertEquals('subTitle', $typoScriptConfiguration->getSearchVariantsField());
$this->assertEquals(11, $typoScriptConfiguration->getSearchVariantsLimit());
$search = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Search', $solrConnection);
/** @var $searchResultsSetService \ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResultSetService */
$searchResultsSetService = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Domain\\Search\\ResultSet\\SearchResultSetService', $typoScriptConfiguration, $search);
/** @var $searchRequest SearchRequest */
$searchRequest = GeneralUtility::makeInstance(SearchRequest::class);
$searchRequest->setRawQueryString('*');
$searchResultSet = $searchResultsSetService->search($searchRequest);
$searchResults = $searchResultSet->getSearchResults();
$firstResult = $searchResults[0];
// We assume that the first result has three variants.
$this->assertSame(3, count($firstResult->getVariants()));
// And every variant is indicated to be a variant.
foreach ($firstResult->getVariants() as $variant) {
$this->assertTrue($variant->getIsVariant(), 'Document should be a variant');
}
}
示例5: execute
/**
* Creates a link to a given page with a given link text
*
* @param array Array of arguments, [0] is the link text, [1] is the (optional) page Id to link to (otherwise TSFE->id), [2] are additional URL parameters, [3] use cache, defaults to FALSE, [4] additional A tag parameters
* @return string complete anchor tag with URL and link text
*/
public function execute(array $arguments = array())
{
$linkText = $arguments[0];
$additionalParameters = $arguments[2] ? $arguments[2] : '';
$useCache = $arguments[3] ? true : false;
$ATagParams = $arguments[4] ? $arguments[4] : '';
// by default or if no link target is set, link to the current page
$linkTarget = $GLOBALS['TSFE']->id;
// if the link target is a number, interpret it as a page ID
$linkArgument = trim($arguments[1]);
if (is_numeric($linkArgument)) {
$linkTarget = intval($linkArgument);
} elseif (!empty($linkArgument) && is_string($linkArgument)) {
/** @var \ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration $configuration */
$configuration = Util::getSolrConfiguration();
if ($configuration->isValidPath($linkArgument)) {
try {
$typoscript = $configuration->getObjectByPath($linkArgument);
$pathExploded = explode('.', $linkArgument);
$lastPathSegment = array_pop($pathExploded);
$linkTarget = intval($typoscript[$lastPathSegment]);
} catch (\InvalidArgumentException $e) {
// ignore exceptions caused by markers, but accept the exception for wrong TS paths
if (substr($linkArgument, 0, 3) != '###') {
throw $e;
}
}
} elseif (GeneralUtility::isValidUrl($linkArgument) || GeneralUtility::isValidUrl(GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST') . '/' . $linkArgument)) {
// $linkTarget is an URL
$linkTarget = filter_var($linkArgument, FILTER_SANITIZE_URL);
}
}
$linkConfiguration = array('useCacheHash' => $useCache, 'no_cache' => false, 'parameter' => $linkTarget, 'additionalParams' => $additionalParameters, 'ATagParams' => $ATagParams);
return $this->contentObject->typoLink($linkText, $linkConfiguration);
}
示例6: render
/**
* Renders the block of used / applied facets.
*
* @return string Rendered HTML representing the used facet.
*/
public function render()
{
$solrConfiguration = Util::getSolrConfiguration();
$facetOption = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Facet\\FacetOption', $this->facetName, $this->filterValue);
$facetLinkBuilder = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Facet\\LinkBuilder', $this->query, $this->facetName, $facetOption);
/* @var $facetLinkBuilder LinkBuilder */
$facetLinkBuilder->setLinkTargetPageId($this->linkTargetPageId);
if ($this->facetConfiguration['type'] == 'hierarchy') {
// FIXME decouple this
$filterEncoder = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Query\\FilterEncoder\\Hierarchy');
$facet = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Facet\\Facet', $this->facetName);
$facetRenderer = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Facet\\HierarchicalFacetRenderer', $facet);
$facetText = $facetRenderer->getLastPathSegmentFromHierarchicalFacetOption($filterEncoder->decodeFilter($this->filterValue));
} else {
$facetText = $facetOption->render();
}
$facetText = $this->getModifiedFacetTextFromHook($facetText);
$contentObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
$facetConfiguration = $solrConfiguration->getSearchFacetingFacetByName($this->facetName);
$facetLabel = $contentObject->stdWrap($facetConfiguration['label'], $facetConfiguration['label.']);
$removeFacetText = strtr($solrConfiguration->getSearchFacetingRemoveFacetLinkText(), array('@facetValue' => $this->filterValue, '@facetName' => $this->facetName, '@facetLabel' => $facetLabel, '@facetText' => $facetText));
$removeFacetLink = $facetLinkBuilder->getRemoveFacetOptionLink($removeFacetText);
$removeFacetUrl = $facetLinkBuilder->getRemoveFacetOptionUrl();
$facetToRemove = array('link' => $removeFacetLink, 'url' => $removeFacetUrl, 'text' => $removeFacetText, 'value' => $this->filterValue, 'facet_name' => $this->facetName);
return $facetToRemove;
}
示例7: resolveTypoScriptPath
/**
* Resolves a TS path and returns its value
*
* @param string $path a TS path, separated with dots
* @return string
*/
protected function resolveTypoScriptPath($path, $arguments = null)
{
$value = '';
$pathExploded = explode('.', trim($path));
$lastPathSegment = array_pop($pathExploded);
/** @var \ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration $configuration */
$configuration = Util::getSolrConfiguration();
$pathBranch = $configuration->getObjectByPath($path);
// generate ts content
$cObj = $this->getContentObject();
if (!isset($pathBranch[$lastPathSegment . '.'])) {
$value = htmlspecialchars($pathBranch[$lastPathSegment]);
} else {
if (count($arguments)) {
$data = array('arguments' => $arguments);
$numberOfArguments = count($arguments);
for ($i = 0; $i < $numberOfArguments; $i++) {
$data['argument_' . $i] = $arguments[$i];
}
$cObj->start($data);
}
$value = $cObj->cObjGetSingle($pathBranch[$lastPathSegment], $pathBranch[$lastPathSegment . '.']);
}
return $value;
}
示例8: execute
/**
* Returns an URL that switches the sorting indicator according to the
* given sorting direction
*
* @param array $arguments Expects 'asc' or 'desc' as sorting direction in key 0
* @return string
* @throws \InvalidArgumentException when providing an invalid sorting direction
*/
public function execute(array $arguments = array())
{
$content = '';
$sortDirection = trim($arguments[0]);
$configuration = Util::getSolrConfiguration();
$contentObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
$defaultImagePrefix = 'EXT:solr/Resources/Public/Images/Indicator';
$sortViewHelperConfiguration = $configuration->getViewHelpersSortIndicatorConfiguration();
switch ($sortDirection) {
case 'asc':
$imageConfiguration = $sortViewHelperConfiguration['up.'];
if (!isset($imageConfiguration['file'])) {
$imageConfiguration['file'] = $defaultImagePrefix . 'Up.png';
}
$content = $contentObject->cObjGetSingle('IMAGE', $imageConfiguration);
break;
case 'desc':
$imageConfiguration = $sortViewHelperConfiguration['down.'];
if (!isset($imageConfiguration['file'])) {
$imageConfiguration['file'] = $defaultImagePrefix . 'Down.png';
}
$content = $contentObject->cObjGetSingle('IMAGE', $imageConfiguration);
break;
case '###SORT.CURRENT_DIRECTION###':
case '':
// ignore
break;
default:
throw new \InvalidArgumentException('Invalid sorting direction "' . $arguments[0] . '", must be "asc" or "desc".', 1390868460);
}
return $content;
}
示例9: excludeContentByClass
/**
* Exclude some html parts by class inside content wrapped with TYPO3SEARCH_begin and TYPO3SEARCH_end
* markers.
*
* @param string $indexableContent HTML markup
* @return string HTML
*/
public function excludeContentByClass($indexableContent)
{
if (empty(trim($indexableContent))) {
return html_entity_decode($indexableContent);
}
$excludeClasses = $this->getConfiguration()->getIndexQueuePagesExcludeContentByClassArray();
if (count($excludeClasses) === 0) {
return html_entity_decode($indexableContent);
}
$isInContent = Util::containsOneOfTheStrings($indexableContent, $excludeClasses);
if (!$isInContent) {
return html_entity_decode($indexableContent);
}
$doc = new \DOMDocument('1.0', 'UTF-8');
libxml_use_internal_errors(true);
$doc->loadHTML('<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL . $indexableContent);
$xpath = new \DOMXPath($doc);
foreach ($excludeClasses as $excludePart) {
$elements = $xpath->query("//*[contains(@class,'" . $excludePart . "')]");
if (count($elements) == 0) {
continue;
}
foreach ($elements as $element) {
$element->parentNode->removeChild($element);
}
}
$html = $doc->saveHTML($doc->documentElement->parentNode);
// remove XML-Preamble, newlines and doctype
$html = preg_replace('/(<\\?xml[^>]+\\?>|\\r?\\n|<!DOCTYPE.+?>)/imS', '', $html);
$html = str_replace(array('<html>', '</html>', '<body>', '</body>'), array('', '', '', ''), $html);
return $html;
}
示例10: __construct
/**
* Constructor
*
* @param array $arguments
*/
public function __construct(array $arguments = array())
{
if (is_null($this->dateFormat) || is_null($this->contentObject)) {
$configuration = Util::getSolrConfiguration();
$this->dateFormat = $configuration['general.']['dateFormat.'];
$this->contentObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
}
}
示例11: __construct
/**
* Constructor.
*
* @param string $facetName Facet Name
* @param int|string $facetOptionValue Facet option value
* @param int $facetOptionNumberOfResults number of results to be returned when applying this option's filter
*/
public function __construct($facetName, $facetOptionValue, $facetOptionNumberOfResults = 0)
{
$this->facetName = $facetName;
$this->value = $facetOptionValue;
$this->numberOfResults = intval($facetOptionNumberOfResults);
$solrConfiguration = Util::getSolrConfiguration();
$this->facetConfiguration = $solrConfiguration->getSearchFacetingFacetByName($this->facetName);
}
示例12: __construct
/**
* Constructor
*
* @param SolrService $solrConnection The Solr connection to use for searching
*/
public function __construct(SolrService $solrConnection = null)
{
$this->solr = $solrConnection;
if (is_null($solrConnection)) {
$this->solr = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\ConnectionManager')->getConnectionByPageId($GLOBALS['TSFE']->id, $GLOBALS['TSFE']->sys_language_uid);
}
$this->configuration = Util::getSolrConfiguration();
}
示例13: execute
/**
* Works through the indexing queue and indexes the queued items into Solr.
*
* @return boolean Returns TRUE on success, FALSE if no items were indexed or none were found.
*/
public function execute()
{
$executionSucceeded = false;
$this->configuration = Util::getSolrConfigurationFromPageId($this->site->getRootPageId());
$this->indexItems();
$executionSucceeded = true;
return $executionSucceeded;
}
示例14: __construct
/**
* Constructor
*
* @param array $arguments
*/
public function __construct(array $arguments = array())
{
if (is_null($this->dateFormat) || is_null($this->contentObject)) {
$configuration = Util::getSolrConfiguration();
$this->dateFormat = $configuration->getValueByPathOrDefaultValue('plugin.tx_solr.general.dateFormat.', array('date' => 'd.m.Y H:i'));
$this->contentObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
}
}
示例15: initializeSearchComponent
/**
* Initializes the search component.
*
*/
public function initializeSearchComponent()
{
$solrConfiguration = Util::getSolrConfiguration();
if (!empty($solrConfiguration['statistics'])) {
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['modifySearchQuery']['statistics'] = 'ApacheSolrForTypo3\\Solr\\Query\\Modifier\\Statistics';
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['processSearchResponse']['statistics'] = 'ApacheSolrForTypo3\\Solr\\Response\\Processor\\StatisticsWriter';
}
}