本文整理汇总了PHP中FinderIndexerHelper类的典型用法代码示例。如果您正苦于以下问题:PHP FinderIndexerHelper类的具体用法?PHP FinderIndexerHelper怎么用?PHP FinderIndexerHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FinderIndexerHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
protected function index(FinderIndexerResult $item, $format = 'html')
{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false) {
return;
}
$item->body = FinderIndexerHelper::prepareContent($item->getElement('body'));
$item->summary = FinderIndexerHelper::prepareContent($item->getElement('body'));
$item->addTaxonomy('Type', 'FSF_FINDER_GLOSSARY');
$word = $item->title;
$anchor = strtolower(preg_replace("/[^A-Za-z0-9]/", '-', $word));
$letter = strtolower(substr($word, 0, 1));
$item->url = 'index.php?option=com_fsf&view=glossary&letter=' . $letter . '#' . $anchor;
$item->route = $item->url;
$item->state = $item->published;
$item->access = 1;
// Get content extras.
FinderIndexerHelper::getContentExtras($item);
// Index the item.
if (FSFJ3Helper::IsJ3()) {
$this->indexer->index($item);
} else {
FinderIndexer::index($item);
}
}
示例2: index
/**
* Override method to index a certain result
*
* @param FinderIndexerResult $item Finder item
* @param string $format Formatting (html or text)
*
* @return null
*/
protected function index(FinderIndexerResult $item, $format = 'html')
{
/*
if (JComponentHelper::isEnabled($this->extension) == false)
{
return;
}
*/
// Prepare the item
$item->access = 1;
// Define these items as songs
$item->addTaxonomy('Type', 'Song');
// Add artist information
$item->addInstruction(FinderIndexer::META_CONTEXT, 'artist');
$item->addTaxonomy('Artist', $item->artist);
// Set language
//$item->setLanguage();
//$item->addTaxonomy('Language', $item->language);
// Set URLs
$item->route = 'index.php?option=com_music&view=song&id=' . $item->id;
$item->url = $item->route;
$item->path = FinderIndexerHelper::getContentPath($item->route);
// Allow others to hook into our $item as well
FinderIndexerHelper::getContentExtras($item);
$this->indexer->index($item);
}
示例3: _index
/**
* Method to index an item. The item must be a FinderIndexerResult object.
*
* @param object The item to index as an FinderIndexerResult object.
* @throws Exception on database error.
*/
protected function _index(FinderIndexerResult $item)
{
// Build the necessary route and path information.
$item->url = $this->_getURL($item->topic);
$item->itemid = '100065';
$item->route = $item->url . '&post=' . $item->id . '&Itemid=' . $item->itemid . '#p' . $item->id;
$item->path = FinderIndexerHelper::getContentPath($item->route);
// Add the meta-data processing instructions.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'display_name');
// Strip slashes!
$item->title = stripslashes($item->title);
$item->summary = stripslashes($item->summary);
$item->display_name = stripslashes($item->display_name);
$item->text = FinderIndexerHelper::prepareContent($item->summary);
// Translate the access group to an access level.
//$item->cat_access = $this->_getAccessLevel($item->cat_access);
// Inherit state and access form the category.
$item->state = 1;
$item->access = 0;
// Set the language.
$item->language = FinderIndexerHelper::getDefaultLanguage();
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'Forum Post');
// Add the author taxonomy data.
if (!empty($item->author)) {
$item->addTaxonomy('Forum User', $item->display_name);
}
// Index the item.
FinderIndexer::index($item);
}
示例4: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*
* @since 3.1
*/
protected function setUp()
{
parent::setUp();
// Store the factory state so we can mock the necessary objects
$this->saveFactoryState();
// Set up our mock database
JFactory::$database = $this->getMockDatabase('Mysqli');
FinderIndexerHelper::$stemmer = FinderIndexerStemmer::getInstance('porter_en');
}
示例5: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @return void
*
* @since 3.1
*/
protected function setUp()
{
// Store the factory state so we can mock the necessary objects
$this->saveFactoryState();
// Set up our mock database
$db = JFactory::getDbo();
$db->name = 'mysqli';
JFactory::$database = $db;
FinderIndexerHelper::$stemmer = FinderIndexerStemmer::getInstance('porter_en');
}
示例6: index
protected function index(FinderIndexerResult $item, $format = 'html')
{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false) {
return;
}
$item->body = FinderIndexerHelper::prepareContent($item->getElement('body'));
$item->summary = FinderIndexerHelper::prepareContent($item->getElement('body'));
$item->addTaxonomy('Type', 'FSS_FINDER_KB_ARTICLE');
$item->url = 'index.php?option=com_fss&view=kb&kbartid=' . $item->getElement('id');
$item->route = $item->url;
$item->state = $item->getElement('pub');
// Get content extras.
FinderIndexerHelper::getContentExtras($item);
// Index the item.
if (FSSJ3Helper::IsJ3()) {
$this->indexer->index($item);
} else {
FinderIndexer::index($item);
}
}
示例7: index
protected function index(FinderIndexerResult $item, $format = 'html')
{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false || !$item->id) {
return;
}
if (!($zoo_item = $this->app->table->item->get($item->id, true))) {
return;
}
$registry = new JRegistry();
$registry->loadArray($zoo_item->getParams()->get("metadata."));
$item->metadata = $registry;
$item->metaauthor = $zoo_item->getParams()->get("metadata.author");
$item->addInstruction(FinderIndexer::META_CONTEXT, 'link');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'element_data');
$item->summary = $this->renderer->render('item.default', array('item' => $zoo_item));
$item->url = $this->getURL($item->id, $this->extension, $this->layout);
$item->route = $this->app->route->item($zoo_item, false);
$item->path = FinderIndexerHelper::getContentPath($item->route);
$item->state = $zoo_item->searchable == 1 && $zoo_item->state == 1;
$item->element_data = $this->app->database->queryResultArray('SELECT value FROM ' . ZOO_TABLE_SEARCH . ' WHERE item_id = ' . (int) $item->id);
$item->addTaxonomy('Type', $zoo_item->getType()->name);
foreach ($zoo_item->getRelatedCategories(true) as $category) {
$item->addTaxonomy('Category', $category->name);
}
foreach ($zoo_item->getTags() as $tag) {
$item->addTaxonomy('Tag', $tag);
}
FinderIndexerHelper::getContentExtras($item);
if ($this->app->joomla->version->isCompatible('3.0')) {
$this->indexer->index($item);
} else {
FinderIndexer::index($item);
}
}
示例8: testGetPrimaryLanguage
/**
* Tests the getPrimaryLanguage method
*
* @return void
*
* @since 3.0
*/
public function testGetPrimaryLanguage()
{
$this->assertThat(FinderIndexerHelper::getPrimaryLanguage('en-GB'), $this->StringContains('en'), 'The primary language is en');
}
示例9: index
/**
* Method to index an item. The item must be a FinderIndexerResult object.
*
* @param FinderIndexerResult $item The item to index as an FinderIndexerResult object.
* @param string $format The item format. Not used.
*
* @return void
*
* @since 2.5
* @throws Exception on database error.
*/
protected function index(FinderIndexerResult $item, $format = 'html')
{
$item->setLanguage();
// Check if the extension is enabled.
if (JComponentHelper::isEnabled($this->extension) == false) {
return;
}
// Initialise the item parameters.
$registry = new JRegistry();
$registry->loadString($item->params);
$item->params = JComponentHelper::getParams('com_content', true);
$item->params->merge($registry);
$registry = new JRegistry();
$registry->loadString($item->metadata);
$item->metadata = $registry;
// Trigger the onContentPrepare event.
$item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params);
$item->body = FinderIndexerHelper::prepareContent($item->body, $item->params);
// Build the necessary route and path information.
$item->url = $this->getURL($item->id, $this->extension, $this->layout);
$item->route = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->language);
$item->path = FinderIndexerHelper::getContentPath($item->route);
// Get the menu title if it exists.
$title = $this->getItemMenuTitle($item->url);
// Adjust the title if necessary.
if (!empty($title) && $this->params->get('use_menu_title', true)) {
$item->title = $title;
}
// Add the meta-author.
$item->metaauthor = $item->metadata->get('author');
// Add the meta-data processing instructions.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');
// Translate the state. Articles should only be published if the category is published.
$item->state = $this->translateState($item->state, $item->cat_state);
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'Article');
// Add the author taxonomy data.
if (!empty($item->author) || !empty($item->created_by_alias)) {
$item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author);
}
// Add the category taxonomy data.
$item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access);
// Add the language taxonomy data.
$item->addTaxonomy('Language', $item->language);
// Get content extras.
FinderIndexerHelper::getContentExtras($item);
// Index the item.
$this->indexer->index($item);
}
示例10: populateState
/**
* Method to auto-populate the model state. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field. [optional]
* @param string $direction An optional direction. [optional]
*
* @return void
*
* @since 2.5
*/
protected function populateState($ordering = null, $direction = null)
{
// Get the configuration options.
$app = JFactory::getApplication();
$input = $app->input;
$params = $app->getParams();
$user = JFactory::getUser();
$filter = JFilterInput::getInstance();
$this->setState('filter.language', JLanguageMultilang::isEnabled());
// Setup the stemmer.
if ($params->get('stem', 1) && $params->get('stemmer', 'porter_en')) {
FinderIndexerHelper::$stemmer = FinderIndexerStemmer::getInstance($params->get('stemmer', 'porter_en'));
}
$request = $input->request;
$options = array();
// Get the empty query setting.
$options['empty'] = $params->get('allow_empty_query', 0);
// Get the static taxonomy filters.
$options['filter'] = $request->getInt('f', $params->get('f', ''));
// Get the dynamic taxonomy filters.
$options['filters'] = $request->get('t', $params->get('t', array()), '', 'array');
// Get the query string.
$options['input'] = $request->getString('q', $params->get('q', ''));
// Get the query language.
$options['language'] = $request->getCmd('l', $params->get('l', ''));
// Get the start date and start date modifier filters.
$options['date1'] = $request->getString('d1', $params->get('d1', ''));
$options['when1'] = $request->getString('w1', $params->get('w1', ''));
// Get the end date and end date modifier filters.
$options['date2'] = $request->getString('d2', $params->get('d2', ''));
$options['when2'] = $request->getString('w2', $params->get('w2', ''));
// Load the query object.
$this->query = new FinderIndexerQuery($options);
// Load the query token data.
$this->excludedTerms = $this->query->getExcludedTermIds();
$this->includedTerms = $this->query->getIncludedTermIds();
$this->requiredTerms = $this->query->getRequiredTermIds();
// Load the list state.
$this->setState('list.start', $input->get('limitstart', 0, 'uint'));
$this->setState('list.limit', $input->get('limit', $app->get('list_limit', 20), 'uint'));
/* Load the sort ordering.
* Currently this is 'hard' coded via menu item parameter but may not satisfy a users need.
* More flexibility was way more user friendly. So we allow the user to pass a custom value
* from the pool of fields that are indexed like the 'title' field.
* Also, we allow this parameter to be passed in either case (lower/upper).
*/
$order = $input->getWord('filter_order', $params->get('sort_order', 'relevance'));
$order = JString::strtolower($order);
switch ($order) {
case 'date':
$this->setState('list.ordering', 'l.start_date');
break;
case 'price':
$this->setState('list.ordering', 'l.list_price');
break;
case $order == 'relevance' && !empty($this->includedTerms):
$this->setState('list.ordering', 'm.weight');
break;
// custom field that is indexed and might be required for ordering
// custom field that is indexed and might be required for ordering
case 'title':
$this->setState('list.ordering', 'l.title');
break;
default:
$this->setState('list.ordering', 'l.link_id');
break;
}
/* Load the sort direction.
* Currently this is 'hard' coded via menu item parameter but may not satisfy a users need.
* More flexibility was way more user friendly. So we allow to be inverted.
* Also, we allow this parameter to be passed in either case (lower/upper).
*/
$dirn = $input->getWord('filter_order_Dir', $params->get('sort_direction', 'desc'));
$dirn = JString::strtolower($dirn);
switch ($dirn) {
case 'asc':
$this->setState('list.direction', 'ASC');
break;
default:
case 'desc':
$this->setState('list.direction', 'DESC');
break;
}
// Set the match limit.
$this->setState('match.limit', 1000);
// Load the parameters.
$this->setState('params', $params);
// Load the user state.
$this->setState('user.id', (int) $user->get('id'));
$this->setState('user.groups', $user->getAuthorisedViewLevels());
//.........这里部分代码省略.........
示例11: populateState
/**
* Method to auto-populate the model state. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
*
* @return void
*
* @since 2.5
*/
protected function populateState($ordering = null, $direction = null)
{
// Get the configuration options.
$app = JFactory::getApplication();
$input = $app->input;
$params = JComponentHelper::getParams('com_finder');
$user = JFactory::getUser();
// Get the query input.
$this->setState('input', $input->request->get('q', '', 'string'));
// Set the query language
if (JLanguageMultilang::isEnabled()) {
$lang = JFactory::getLanguage()->getTag();
} else {
$lang = FinderIndexerHelper::getDefaultLanguage();
}
$lang = FinderIndexerHelper::getPrimaryLanguage($lang);
$this->setState('language', $lang);
// Load the list state.
$this->setState('list.start', 0);
$this->setState('list.limit', 10);
// Load the parameters.
$this->setState('params', $params);
// Load the user state.
$this->setState('user.id', (int) $user->get('id'));
}
示例12: index
/**
* Method to index an item. The item must be a FinderIndexerResult object.
*
* @param FinderIndexerResult $item The item to index as an FinderIndexerResult object.
* @param string $format The item format
*
* @return void
*
* @since 2.5
* @throws Exception on database error.
*/
protected function index(FinderIndexerResult $item, $format = 'html')
{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false) {
return;
}
// Initialize the item parameters.
$registry = new JRegistry();
$registry->loadString($item->params);
$item->params = $registry;
$registry = new JRegistry();
$registry->loadString($item->metadata);
$item->metadata = $registry;
// Build the necessary route and path information.
$item->url = $this->getURL($item->id, $this->extension, $this->layout);
$item->route = WeblinksHelperRoute::getWeblinkRoute($item->slug, $item->catslug);
$item->path = FinderIndexerHelper::getContentPath($item->route);
/*
* Add the meta-data processing instructions based on the newsfeeds
* configuration parameters.
*/
// Add the meta-author.
$item->metaauthor = $item->metadata->get('author');
// Handle the link to the meta-data.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'link');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'Web Link');
// Add the category taxonomy data.
$item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access);
// Add the language taxonomy data.
$item->addTaxonomy('Language', $item->language);
// Get content extras.
FinderIndexerHelper::getContentExtras($item);
// Index the item.
FinderIndexer::index($item);
}
示例13: index
/**
* Method to index an item. The item must be a FinderIndexerResult object.
*
* @param FinderIndexerResult $item The item to index as an FinderIndexerResult object.
* @param string $format The item format
*
* @return void
*
* @since 2.5
* @throws Exception on database error.
*/
protected function index(FinderIndexerResult $item, $format = 'html')
{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false) {
return;
}
// Initialize the item parameters.
$registry = new JRegistry();
$registry->loadString($item->params);
$item->params = JComponentHelper::getParams('com_jshopping', true);
$item->params->merge($registry);
// Trigger the onContentPrepare event.
$item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params);
$item->body = FinderIndexerHelper::prepareContent($item->body, $item->params);
// Build the necessary route and path information.
$item->url = 'index.php?option=com_jshopping&controller=product&task=view&category_id=' . $item->category_id . '&product_id=' . $item->product_id;
$item->route = 'index.php?option=com_jshopping&controller=product&task=view&category_id=' . $item->category_id . '&product_id=' . $item->product_id;
$item->path = FinderIndexerHelper::getContentPath($item->route);
// Get the menu title if it exists.
$title = $this->getItemMenuTitle($item->url);
// Adjust the title if necessary.
if (!empty($title) && $this->params->get('use_menu_title', true)) {
$item->title = $title;
}
// Add the meta-author.
// Add the meta-data processing instructions.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'link');
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'Product');
// Add the category taxonomy data.
$item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access);
// Get content extras.
FinderIndexerHelper::getContentExtras($item);
// Index the item.
if (version_compare(JVERSION, '3.0.0', 'ge')) {
$this->indexer->index($item);
} else {
FinderIndexer::index($item);
}
}
示例14: setup
/**
* Method to setup the indexer to be run.
*
* @return boolean True on success.
*
* @since 2.5
*/
protected function setup()
{
// Load dependent classes.
require_once JPATH_SITE . '/components/com_contact/helpers/route.php';
// This is a hack to get around the lack of a route helper.
FinderIndexerHelper::getContentPath('index.php?option=com_contact');
return true;
}
示例15: processString
//.........这里部分代码省略.........
}
} else {
// The phrase is <= 3 words so we can use it as is.
$phrases[] = $match;
$terms[] = $match;
}
}
}
}
// Add the remaining terms if present.
if (!empty($input)) {
$terms = array_merge($terms, explode(' ', $input));
}
// An array of our boolean operators. $operator => $translation
$operators = array('AND' => JString::strtolower(JText::_('COM_FINDER_QUERY_OPERATOR_AND')), 'OR' => JString::strtolower(JText::_('COM_FINDER_QUERY_OPERATOR_OR')), 'NOT' => JString::strtolower(JText::_('COM_FINDER_QUERY_OPERATOR_NOT')));
// If language debugging is enabled you need to ignore the debug strings in matching.
if (JDEBUG) {
$debugStrings = array('**', '??');
$operators = str_replace($debugStrings, '', $operators);
}
/*
* Iterate through the terms and perform any sorting that needs to be
* done based on boolean search operators. Terms that are before an
* and/or/not modifier have to be handled in relation to their operator.
*/
for ($i = 0, $c = count($terms); $i < $c; $i++) {
// Check if the term is followed by an operator that we understand.
if (isset($terms[$i + 1]) && in_array($terms[$i + 1], $operators)) {
// Get the operator mode.
$op = array_search($terms[$i + 1], $operators);
// Handle the AND operator.
if ($op === 'AND' && isset($terms[$i + 2])) {
// Tokenize the current term.
$token = FinderIndexerHelper::tokenize($terms[$i], $lang, true);
$token = $this->getTokenData($token);
// Set the required flag.
$token->required = true;
// Add the current token to the stack.
$this->included[] = $token;
$this->highlight = array_merge($this->highlight, array_keys($token->matches));
// Skip the next token (the mode operator).
$this->operators[] = $terms[$i + 1];
// Tokenize the term after the next term (current plus two).
$other = FinderIndexerHelper::tokenize($terms[$i + 2], $lang, true);
$other = $this->getTokenData($other);
// Set the required flag.
$other->required = true;
// Add the token after the next token to the stack.
$this->included[] = $other;
$this->highlight = array_merge($this->highlight, array_keys($other->matches));
// Remove the processed phrases if possible.
if (($pk = array_search($terms[$i], $phrases)) !== false) {
unset($phrases[$pk]);
}
if (($pk = array_search($terms[$i + 2], $phrases)) !== false) {
unset($phrases[$pk]);
}
// Remove the processed terms.
unset($terms[$i]);
unset($terms[$i + 1]);
unset($terms[$i + 2]);
// Adjust the loop.
$i += 2;
continue;
} elseif ($op === 'OR' && isset($terms[$i + 2])) {
// Tokenize the current term.