本文整理汇总了PHP中ApacheSolrForTypo3\Solr\Util类的典型用法代码示例。如果您正苦于以下问题:PHP Util类的具体用法?PHP Util怎么用?PHP Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Util类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: initializeSearchComponent
/**
* Initializes the search component.
*
* Sets the debug query parameter
*
*/
public function initializeSearchComponent()
{
$solrConfiguration = Util::getSolrConfiguration();
if ($solrConfiguration->getEnabledDebugMode()) {
$this->query->setDebugMode();
}
}
开发者ID:sitegeist,项目名称:ext-solr,代码行数:13,代码来源:DebugComponent.php
示例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'];
}
}
开发者ID:kalypso63,项目名称:ext-solr,代码行数:12,代码来源:Multivalue.php
示例3: getConfiguration
/**
* @return TypoScriptConfiguration|array
*/
protected function getConfiguration()
{
if ($this->configuration == null) {
$this->configuration = Util::getSolrConfiguration();
}
return $this->configuration;
}
开发者ID:hnadler,项目名称:ext-solr,代码行数:10,代码来源:HtmlContentExtractor.php
示例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');
}
}
开发者ID:sitegeist,项目名称:ext-solr,代码行数:29,代码来源:SearchResultSetServiceTest.php
示例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);
}
开发者ID:sitegeist,项目名称:ext-solr,代码行数:41,代码来源:Link.php
示例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;
}
开发者ID:sitegeist,项目名称:ext-solr,代码行数:31,代码来源:UsedFacetRenderer.php
示例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;
}
开发者ID:sitegeist,项目名称:ext-solr,代码行数:31,代码来源:Ts.php
示例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;
}
开发者ID:hnadler,项目名称:ext-solr,代码行数:40,代码来源:SortIndicator.php
示例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;
}
开发者ID:sitegeist,项目名称:ext-solr,代码行数:39,代码来源:Typo3PageContentExtractor.php
示例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');
}
}
开发者ID:hnadler,项目名称:ext-solr,代码行数:13,代码来源:Date.php
示例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);
}
开发者ID:sitegeist,项目名称:ext-solr,代码行数:15,代码来源:FacetOption.php
示例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();
}
开发者ID:hnadler,项目名称:ext-solr,代码行数:13,代码来源:Search.php
示例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;
}
开发者ID:kalypso63,项目名称:ext-solr,代码行数:13,代码来源:IndexQueueWorkerTask.php
示例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');
}
}
开发者ID:sitegeist,项目名称:ext-solr,代码行数:13,代码来源:Date.php
示例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';
}
}
开发者ID:Gregor-Agnes,项目名称:ext-solr,代码行数:12,代码来源:StatisticsComponent.php
示例16: __construct
/**
* Constructor.
*
* @param string $facetName Facet Name
* @param integer|string $facetOptionValue Facet option value
* @param integer $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['search.']['faceting.']['facets.'][$this->facetName . '.'];
}
开发者ID:neufeind,项目名称:ext-solr,代码行数:15,代码来源:FacetOption.php
示例17: process
/**
* Expects a timestamp and converts it to an ISO 8601 date as needed by Solr.
*
* Example date output format: 1995-12-31T23:59:59Z
* The trailing "Z" designates UTC time and is mandatory
*
* @param array Array of values, an array because of multivalued fields
* @return array Modified array of values
*/
public function process(array $values)
{
$results = array();
foreach ($values as $timestamp) {
$results[] = Util::timestampToIso($timestamp);
}
return $results;
}
开发者ID:sitegeist,项目名称:ext-solr,代码行数:17,代码来源:TimestampToIsoDate.php
示例18: 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();
$this->cleanIndex();
$executionSucceeded = TRUE;
return $executionSucceeded;
}
开发者ID:nxpthx,项目名称:ext-solr,代码行数:14,代码来源:IndexQueueWorkerTask.php
示例19: getSiteHashForDomain
/**
* @test
*/
public function getSiteHashForDomain()
{
$oldKey = $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = 'testKey';
$hash1 = Util::getSiteHashForDomain('www.test.de');
$hash2 = Util::getSiteHashForDomain('www.test.de');
$this->assertEquals('b17ca8164881e80e96a96529c16b19cc405c9bd0', $hash1);
$this->assertEquals('b17ca8164881e80e96a96529c16b19cc405c9bd0', $hash2);
$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = $oldKey;
}
开发者ID:sitegeist,项目名称:ext-solr,代码行数:13,代码来源:UtilTest.php
示例20: __construct
/**
* @param TypoScriptConfiguration $solrConfiguration
*/
public function __construct($solrConfiguration = null)
{
if (!is_null($solrConfiguration)) {
$this->configuration = $solrConfiguration;
} else {
$this->configuration = Util::getSolrConfiguration();
}
$this->allConfiguredFacets = $this->configuration->getSearchFacetingFacets();
$this->facetRendererFactory = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Facet\\FacetRendererFactory', $this->allConfiguredFacets);
}
开发者ID:sitegeist,项目名称:ext-solr,代码行数:13,代码来源:Faceting.php
注:本文中的ApacheSolrForTypo3\Solr\Util类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论