本文整理汇总了PHP中Tx_Solr_Util类的典型用法代码示例。如果您正苦于以下问题:PHP Tx_Solr_Util类的具体用法?PHP Tx_Solr_Util怎么用?PHP Tx_Solr_Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tx_Solr_Util类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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 = Tx_Solr_Util::getSolrConfiguration();
$contentObject = t3lib_div::makeInstance('tslib_cObj');
$defaultImagePrefix = 'EXT:solr/Resources/Images/Indicator';
switch ($sortDirection) {
case 'asc':
$imageConfiguration = $configuration['viewHelpers.']['sortIndicator.']['up.'];
if (!isset($imageConfiguration['file'])) {
$imageConfiguration['file'] = $defaultImagePrefix . 'Up.png';
}
$content = $contentObject->IMAGE($imageConfiguration);
break;
case 'desc':
$imageConfiguration = $configuration['viewHelpers.']['sortIndicator.']['down.'];
if (!isset($imageConfiguration['file'])) {
$imageConfiguration['file'] = $defaultImagePrefix . 'Down.png';
}
$content = $contentObject->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:raimundlandig,项目名称:winkel.de-DEV,代码行数:39,代码来源:SortIndicator.php
示例2: 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, interprete it as a page ID
$linkArgument = trim($arguments[1]);
if (is_numeric($linkArgument)) {
$linkTarget = intval($linkArgument);
} elseif (!empty($linkArgument) && is_string($linkArgument)) {
if (Tx_Solr_Util::isValidTypoScriptPath($linkArgument)) {
try {
$typoscript = Tx_Solr_Util::getTypoScriptObject($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 (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($linkArgument) || \TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl(\TYPO3\CMS\Core\Utility\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:punktDe,项目名称:solr,代码行数:39,代码来源:Link.php
示例3: initializeSearchComponent
/**
* Initializes the search component.
*
* Sets the debug query parameter
*
*/
public function initializeSearchComponent()
{
$solrConfiguration = Tx_Solr_Util::getSolrConfiguration();
if ($solrConfiguration['enableDebugMode']) {
$this->query->setDebugMode();
}
}
开发者ID:romaincanon,项目名称:ext-solr,代码行数:13,代码来源:DebugComponent.php
示例4: __construct
/**
* Constructor for class Tx_Solr_ViewHelper_Multivalue
*
*/
public function __construct(array $arguments = array())
{
$configuration = Tx_Solr_Util::getSolrConfiguration();
if (!empty($configuration['viewhelpers.']['multivalue.']['glue'])) {
$this->glue = $configuration['viewhelpers.']['multivalue.']['glue'];
}
}
开发者ID:romaincanon,项目名称:ext-solr,代码行数:11,代码来源:Multivalue.php
示例5: 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[] = Tx_Solr_Util::timestampToIso($timestamp);
}
return $results;
}
开发者ID:romaincanon,项目名称:ext-solr,代码行数:17,代码来源:TimestampToIsoDate.php
示例6: initializeSearchComponent
/**
* Initializes the search component.
*
*/
public function initializeSearchComponent()
{
$solrConfiguration = Tx_Solr_Util::getSolrConfiguration();
if (!empty($solrConfiguration['statistics'])) {
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['modifySearchQuery']['statistics'] = 'Tx_Solr_Query_Modifier_Statistics';
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['processSearchResponse']['statistics'] = 'Tx_Solr_Response_Processor_StatisticsWriter';
}
}
开发者ID:raimundlandig,项目名称:winkel.de-DEV,代码行数:12,代码来源:StatisticsComponent.php
示例7: __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 = Tx_Solr_Util::getSolrConfiguration();
$this->facetConfiguration = $solrConfiguration['search.']['faceting.']['facets.'][$this->facetName . '.'];
}
开发者ID:raimundlandig,项目名称:winkel.de-DEV,代码行数:15,代码来源:FacetOption.php
示例8: 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.
* @see typo3/sysext/scheduler/tx_scheduler_Task#execute()
*/
public function execute()
{
$executionSucceeded = FALSE;
$this->configuration = Tx_Solr_Util::getSolrConfigurationFromPageId($this->site->getRootPageId());
$this->indexItems();
$this->cleanIndex();
$executionSucceeded = TRUE;
return $executionSucceeded;
}
开发者ID:raimundlandig,项目名称:winkel.de-DEV,代码行数:15,代码来源:IndexQueueWorkerTask.php
示例9: __construct
/**
* Constructor.
*
* @param Tx_Solr_Facet_Facet $facet The facet to render.
*/
public function __construct(Tx_Solr_Facet_Facet $facet)
{
$this->search = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Solr_Search');
$this->facet = $facet;
$this->facetName = $facet->getName();
$this->solrConfiguration = Tx_Solr_Util::getSolrConfiguration();
$this->facetConfiguration = $this->solrConfiguration['search.']['faceting.']['facets.'][$this->facetName . '.'];
$this->linkTargetPageId = $GLOBALS['TSFE']->id;
$this->queryLinkBuilder = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Solr_Query_LinkBuilder', $this->search->getQuery());
}
开发者ID:punktDe,项目名称:solr,代码行数:15,代码来源:AbstractFacetRenderer.php
示例10: decodeFilter
/**
* Parses the given date range from a GET parameter and returns a Solr
* date range filter.
*
* @param string $rangeFilter The range filter query string from the query URL
* @param array $configuration Facet configuration
* @return string Lucene query language filter to be used for querying Solr
*/
public function decodeFilter($dateRange, array $configuration = array())
{
list($dateRangeStart, $dateRangeEnd) = explode(self::DELIMITER, $dateRange);
$dateRangeEnd .= '59';
// adding 59 seconds
// TODO for PHP 5.3 use date_parse_from_format() / date_create_from_format() / DateTime::createFromFormat()
$dateRangeFilter = '[' . Tx_Solr_Util::timestampToIso(strtotime($dateRangeStart));
$dateRangeFilter .= ' TO ';
$dateRangeFilter .= Tx_Solr_Util::timestampToIso(strtotime($dateRangeEnd)) . ']';
return $dateRangeFilter;
}
开发者ID:romaincanon,项目名称:ext-solr,代码行数:19,代码来源:DateRange.php
示例11: __construct
/**
* Constructor.
*
* @param Tx_Solr_Query $query Solr query
*/
public function __construct(Tx_Solr_Query $query)
{
$this->solrConfiguration = Tx_Solr_Util::getSolrConfiguration();
$this->contentObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_cObj');
$this->query = $query;
$targetPageUid = $this->contentObject->stdWrap($this->solrConfiguration['search.']['targetPage'], $this->solrConfiguration['search.']['targetPage.']);
$this->linkTargetPageId = $targetPageUid;
if (empty($this->linkTargetPageId)) {
$this->linkTargetPageId = $GLOBALS['TSFE']->id;
}
}
开发者ID:punktDe,项目名称:solr,代码行数:16,代码来源:LinkBuilder.php
示例12: setUp
public function setUp()
{
Tx_Solr_Util::initializeTsfe('1');
$GLOBALS['TSFE']->tmpl->getFileName_backPath = PATH_site;
$GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['search.']['targetPage'] = '0';
$GLOBALS['TSFE']->tmpl->setup['config.']['tx_realurl_enable'] = '0';
// setup up ts objects
$GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['search.']['detailPage'] = 5050;
$GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['renderObjects.'] = array('testContent' => 'TEXT', 'testContent.' => array('field' => 'argument_0'), 'testContent2' => 'TEXT', 'testContent2.' => array('field' => 'argument_1', 'stripHtml' => 1));
$this->fixtures = array('argument content', '<span>argument content with html</span>', 'third argument content');
$this->viewHelper = new Tx_Solr_viewhelper_Ts();
}
开发者ID:romaincanon,项目名称:ext-solr,代码行数:12,代码来源:TsTest.php
示例13: __construct
/**
* constructor for class Tx_Solr_ViewHelper_Crop
*/
public function __construct(array $arguments = array())
{
$configuration = Tx_Solr_Util::getSolrConfiguration();
if (!empty($configuration['viewHelpers.']['crop.']['maxLength'])) {
$this->maxLength = $configuration['viewHelpers.']['crop.']['maxLength'];
}
if (!empty($configuration['viewHelpers.']['crop.']['cropIndicator'])) {
$this->cropIndicator = $configuration['viewHelpers.']['crop.']['cropIndicator'];
}
if (isset($configuration['viewHelpers.']['crop.']['cropFullWords'])) {
$this->cropFullWords = (bool) $configuration['viewHelpers.']['crop.']['cropFullWords'];
}
}
开发者ID:punktDe,项目名称:solr,代码行数:16,代码来源:Crop.php
示例14: setUp
public function setUp()
{
Tx_Solr_Util::initializeTsfe('1');
$GLOBALS['TSFE']->tmpl->getFileName_backPath = PATH_site;
$GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['search.']['targetPage'] = '0';
$GLOBALS['TSFE']->tmpl->setup['config.']['tx_realurl_enable'] = '0';
$facetName = 'TestFacet';
$facetOptions = array('testoption' => 1);
$facetConfiguration = array('selectingSelectedFacetOptionRemovesFilter' => 0, 'renderingInstruction');
$parentPlugin = t3lib_div::makeInstance('Tx_Solr_PiResults_Results');
$parentPlugin->cObj = t3lib_div::makeInstance('tslib_cObj');
$parentPlugin->main('', array());
$query = t3lib_div::makeInstance('Tx_Solr_Query', array('test'));
$this->facetRenderer = t3lib_div::makeInstance('Tx_Solr_Facet_SimpleFacetRenderer', $facetName, $facetOptions, $facetConfiguration, $parentPlugin->getTemplate(), $query);
$this->facetRenderer->setLinkTargetPageId($parentPlugin->getLinkTargetPageId());
}
开发者ID:raimundlandig,项目名称:winkel.de-DEV,代码行数:16,代码来源:SimpleFacetRendererTest.php
示例15: modifyResultDocument
/**
* Modifies the given document and returns the modified document as result.
*
* @param Tx_Solr_PiResults_ResultsCommand $resultCommand The search result command
* @param array $resultDocument Result document as array
* @return array The document with fields as array
*/
public function modifyResultDocument($resultCommand, array $resultDocument)
{
$this->search = $resultCommand->getParentPlugin()->getSearch();
$configuration = Tx_Solr_Util::getSolrConfiguration();
$highlightedContent = $this->search->getHighlightedContent();
$highlightFields = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $configuration['search.']['results.']['resultsHighlighting.']['highlightFields'], TRUE);
foreach ($highlightFields as $highlightField) {
if (!empty($highlightedContent->{$resultDocument['id']}->{$highlightField}[0])) {
$fragments = array();
foreach ($highlightedContent->{$resultDocument['id']}->{$highlightField} as $fragment) {
$fragments[] = tx_solr_Template::escapeMarkers($fragment);
}
$resultDocument[$highlightField] = implode(' ' . $configuration['search.']['results.']['resultsHighlighting.']['fragmentSeparator'] . ' ', $fragments);
}
}
return $resultDocument;
}
开发者ID:punktDe,项目名称:solr,代码行数:24,代码来源:HighlightingResultDocumentModifier.php
示例16: processResponse
/**
* Processes a query and its response after searching for that query.
*
* @param Tx_Solr_Query The query that has been searched for.
* @param Apache_Solr_Response The response for the last query.
*/
public function processResponse(Tx_Solr_Query $query, Apache_Solr_Response $response)
{
$urlParameters = t3lib_div::_GP('tx_solr');
$keywords = $query->getKeywords();
$filters = isset($urlParameters['filter']) ? $urlParameters['filter'] : array();
if (empty($keywords)) {
// do not track empty queries
return;
}
$keywords = t3lib_div::removeXSS($keywords);
$keywords = htmlentities($keywords, ENT_QUOTES, $GLOBALS['TSFE']->metaCharset);
$configuration = Tx_Solr_Util::getSolrConfiguration();
if ($configuration['search.']['frequentSearches.']['useLowercaseKeywords']) {
$keywords = strtolower($keywords);
}
$ipMaskLength = (int) $configuration['statistics.']['anonymizeIP'];
$insertFields = array('pid' => $GLOBALS['TSFE']->id, 'root_pid' => $GLOBALS['TSFE']->tmpl->rootLine[0]['uid'], 'tstamp' => $GLOBALS['EXEC_TIME'], 'language' => $GLOBALS['TSFE']->sys_language_uid, 'num_found' => $response->response->numFound, 'suggestions_shown' => (int) get_object_vars($response->spellcheck->suggestions), 'time_total' => $response->debug->timing->time, 'time_preparation' => $response->debug->timing->prepare->time, 'time_processing' => $response->debug->timing->process->time, 'feuser_id' => (int) $GLOBALS['TSFE']->fe_user->user['uid'], 'cookie' => $GLOBALS['TSFE']->fe_user->id, 'ip' => $this->applyIpMask(t3lib_div::getIndpEnv('REMOTE_ADDR'), $ipMaskLength), 'page' => (int) $urlParameters['page'], 'keywords' => $keywords, 'filters' => serialize($filters), 'sorting' => $urlParameters['sort'] ? $urlParameters['sort'] : '', 'parameters' => serialize($response->responseHeader->params));
$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_solr_statistics', $insertFields);
}
开发者ID:raimundlandig,项目名称:winkel.de-DEV,代码行数:25,代码来源:StatisticsWriter.php
示例17: resolveTypoScriptPath
/**
* Resolves a TS path and returns its value
*
* @param string $path a TS path, separated with dots
* @return string
* @throws InvalidArgumentException
*/
protected function resolveTypoScriptPath($path, $arguments = NULL)
{
$value = '';
$pathExploded = explode('.', trim($path));
$lastPathSegment = array_pop($pathExploded);
$pathBranch = Tx_Solr_Util::getTypoScriptObject($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:romaincanon,项目名称:ext-solr,代码行数:30,代码来源:Ts.php
示例18: render
/**
* Renders the block of used / applied facets.
*
* @see Tx_Solr_FacetRenderer::render()
* @return string Rendered HTML representing the used facet.
*/
public function render()
{
$solrConfiguration = Tx_Solr_Util::getSolrConfiguration();
$facetOption = t3lib_div::makeInstance('Tx_Solr_Facet_FacetOption', $this->facetName, $this->filterValue);
$facetLinkBuilder = t3lib_div::makeInstance('Tx_Solr_Facet_LinkBuilder', $this->query, $this->facetName, $facetOption);
/* @var $facetLinkBuilder Tx_Solr_Facet_LinkBuilder */
$facetLinkBuilder->setLinkTargetPageId($this->linkTargetPageId);
if ($this->facetConfiguration['type'] == 'hierarchy') {
// FIXME decouple this
$filterEncoder = t3lib_div::makeInstance('Tx_Solr_Query_FilterEncoder_Hierarchy');
$facet = t3lib_div::makeInstance('Tx_Solr_Facet_Facet', $this->facetName);
$facetRenderer = t3lib_div::makeInstance('Tx_Solr_Facet_HierarchicalFacetRenderer', $facet);
$facetText = $facetRenderer->getLastPathSegmentFromHierarchicalFacetOption($filterEncoder->decodeFilter($this->filterValue));
} else {
$facetText = $facetOption->render();
}
$contentObject = t3lib_div::makeInstance('tslib_cObj');
$facetLabel = $contentObject->stdWrap($solrConfiguration['search.']['faceting.']['facets.'][$this->facetName . '.']['label'], $solrConfiguration['search.']['faceting.']['facets.'][$this->facetName . '.']['label.']);
$removeFacetText = strtr($solrConfiguration['search.']['faceting.']['removeFacetLinkText'], 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:raimundlandig,项目名称:winkel.de-DEV,代码行数:30,代码来源:UsedFacetRenderer.php
示例19: getConfigIndexEnableStatus
/**
* Checks whether config.index_enable is set to 1, otherwise indexing will
* not work.
*
* @return NULL|tx_reports_reports_status_Status An error status is returned for each site root page config.index_enable = 0.
*/
protected function getConfigIndexEnableStatus()
{
$status = NULL;
$rootPages = $this->getRootPages();
$rootPagesWithIndexingOff = array();
foreach ($rootPages as $rootPage) {
try {
Tx_Solr_Util::initializeTsfe($rootPage['uid']);
if (!$GLOBALS['TSFE']->config['config']['index_enable']) {
$rootPagesWithIndexingOff[] = $rootPage;
}
} catch (RuntimeException $rte) {
$rootPagesWithIndexingOff[] = $rootPage;
} catch (t3lib_error_http_ServiceUnavailableException $sue) {
if ($sue->getCode() == 1294587218) {
// No TypoScript template found, continue with next site
$rootPagesWithIndexingOff[] = $rootPage;
continue;
}
}
}
if (!empty($rootPagesWithIndexingOff)) {
foreach ($rootPagesWithIndexingOff as $key => $rootPageWithIndexingOff) {
$rootPagesWithIndexingOff[$key] = '[' . $rootPageWithIndexingOff['uid'] . '] ' . $rootPageWithIndexingOff['title'];
}
$status = t3lib_div::makeInstance('tx_reports_reports_status_Status', 'Page Indexing', 'Indexing is disabled', 'You need to set config.index_enable = 1 to allow page indexing.
The following sites were found with indexing disabled:
<ul><li>' . implode('</li><li>', $rootPagesWithIndexingOff) . '</li></ul>', tx_reports_reports_status_Status::ERROR);
}
return $status;
}
开发者ID:raimundlandig,项目名称:winkel.de-DEV,代码行数:37,代码来源:SolrConfigurationStatus.php
示例20: setLogging
/**
* Enables logging dependent on the configuration of the item's site
*
* @param Tx_Solr_IndexQueue_Item $item An item being indexed
* @return void
*/
protected function setLogging(Tx_Solr_IndexQueue_Item $item)
{
// reset
$this->loggingEnabled = FALSE;
$solrConfiguration = Tx_Solr_Util::getSolrConfigurationFromPageId($item->getRootPageUid());
if (!empty($solrConfiguration['logging.']['indexing']) || !empty($solrConfiguration['logging.']['indexing.']['queue']) || !empty($solrConfiguration['logging.']['indexing.']['queue.'][$item->getIndexingConfigurationName()])) {
$this->loggingEnabled = TRUE;
}
}
开发者ID:punktDe,项目名称:solr,代码行数:15,代码来源:Indexer.php
注:本文中的Tx_Solr_Util类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论