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); } }
/** * 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); }
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); } }
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); } }
/** * Main index function run when indexing happens * * @param FinderIndexerResult $item * @return bool|void */ protected function index(FinderIndexerResult $item) { // Check if the extension is enabled if (JComponentHelper::isEnabled($this->extension) == false) { return; } //Add the instructions foreach ($this->instructions as $type => $instructions) { foreach ($instructions as $instruction) { $item->addInstruction($type, $instruction); } } // Add the type taxonomy data. $item->addTaxonomy('Type', $this->type_title); FinderIndexerHelper::getContentExtras($item); // Index the item. if (method_exists('FinderIndexer', 'getInstance')) { FinderIndexer::getInstance()->index($item); } else { FinderIndexer::index($item); } }
/** * Tests the resetState method * * @return void * * @since 3.0 */ public function testResetState() { // Reset the state FinderIndexer::resetState(); // Test we get a null object $this->assertNull(JFactory::getSession()->get('_finder.state', null)); }
/** * Method to optimize the index and perform any necessary cleanup. * * @return void * * @since 2.5 */ public function optimize() { // We don't want this form to be cached. header('Pragma: no-cache'); header('Cache-Control: no-cache'); header('Expires: -1'); // Check for a valid token. If invalid, send a 403 with the error message. JSession::checkToken('request') or $this->sendResponse(new Exception(JText::_('JINVALID_TOKEN'), 403)); // Put in a buffer to silence noise. ob_start(); // Import the finder plugins. JPluginHelper::importPlugin('finder'); try { // Optimize the index FinderIndexer::getInstance()->optimize(); // Get the indexer state. $state = FinderIndexer::getState(); $state->start = 0; $state->complete = 1; // Send the response. $this->sendResponse($state); } catch (Exception $e) { $this->sendResponse($e); } }
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_k2', 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 = K2HelperRoute::getItemRoute($item->slug, $item->catslug); $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); // Translate the trash state. Articles should only be accesible if the category is accessible. if ($item->trash || $item->cat_trash) { $item->state = 0; } // Add the type taxonomy data. $item->addTaxonomy('Type', 'K2 Item'); // 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('K2 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); }
/** * 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 * * @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; } if ($this->jVer == 3) { $item->setLanguage(); } // Initialize the item parameters. $registry = new JRegistry; $registry->loadString($item->params); $item->params = JComponentHelper::getParams('com_jem', 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->fulltext, $item->params); // Build the necessary route and path information. $item->url = $this->getURL($item->id, $this->extension, $this->layout); $item->route = JEMHelperRoute::getEventRoute($item->slug, $item->catslug); $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. // TODO: // $item->addInstruction(FinderIndexer::META_CONTEXT, 'meta_description'); // 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', 'Event'); // 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); // Add the venue taxonomy data. if(!empty($item->venue)) { $item->addTaxonomy('Venue', $item->venue, $item->loc_published); } // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. // On J! 3.x we must use indexer member which doesn't exist on J! 2.5 if ($this->jVer == 3) { $this->indexer->index($item); } else { FinderIndexer::index($item); } }
/** * Method to reset the indexer state. * * @return void * * @since 2.5 */ public static function resetState() { // Reset the internal state to null. self::$state = null; // Reset the session state to null. $session = JFactory::getSession(); $session->set('_finder.state', null); }
/** * Run the indexer * * @return void * * @since 2.5 */ private function _index() { // initialize the time value $this->_time = microtime(true); // import library dependencies require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/indexer.php'; jimport('joomla.application.component.helper'); // fool the system into thinking we are running as JSite with Finder as the active component JFactory::getApplication('site'); $_SERVER['HTTP_HOST'] = 'domain.com'; define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/com_finder'); // Disable caching. $config = JFactory::getConfig(); $config->set('caching', 0); $config->set('cache_handler', 'file'); // Reset the indexer state. FinderIndexer::resetState(); // Import the finder plugins. JPluginHelper::importPlugin('finder'); // Starting Indexer. $this->out(JText::_('FINDER_CLI_STARTING_INDEXER'), true); // Trigger the onStartIndex event. JDispatcher::getInstance()->trigger('onStartIndex'); // Remove the script time limit. @set_time_limit(0); // Get the indexer state. $state = FinderIndexer::getState(); // Setting up plugins. $this->out(JText::_('FINDER_CLI_SETTING_UP_PLUGINS'), true); // Trigger the onBeforeIndex event. JDispatcher::getInstance()->trigger('onBeforeIndex'); // Startup reporting. $this->out(JText::sprintf('FINDER_CLI_SETUP_ITEMS', $state->totalItems, round(microtime(true) - $this->_time, 3)), true); // Get the number of batches. $t = (int) $state->totalItems; $c = (int) ceil($t / $state->batchSize); $c = $c === 0 ? 1 : $c; // Process the batches. for ($i = 0; $i < $c; $i++) { // Set the batch start time. $this->_qtime = microtime(true); // Reset the batch offset. $state->batchOffset = 0; // Trigger the onBuildIndex event. JDispatcher::getInstance()->trigger('onBuildIndex'); // Batch reporting. $this->out(JText::sprintf('FINDER_CLI_BATCH_COMPLETE', $i + 1, round(microtime(true) - $this->_qtime, 3)), true); } // Total reporting. $this->out(JText::sprintf('FINDER_CLI_PROCESS_COMPLETE', round(microtime(true) - $this->_time, 3)), true); // Reset the indexer state. FinderIndexer::resetState(); }
/** * 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); } }
/** * Indexes a post on the site * * @since 5.0 * @access public * @param FinderIndexerResult The item to index * @param string The item's format * @return void */ protected function index(FinderIndexerResult $item, $format = 'html') { // Check if the extension is enabled if (!$this->exists()) { return; } // Build the necessary route and path information. $item->url = 'index.php?option=com_easyblog&view=entry&id=' . $item->id; $item->route = EBR::getRoutedURL($item->url, false, true); // Remove any /administrator/ segments from the url since the indexer could be executed from the back end $item->route = $this->removeAdminSegment($item->route); // Get the content path $item->path = FinderIndexerHelper::getContentPath($item->route); // If there is access defined, just set it to 2 which is special privileges. if (!$item->access || $item->access == 0) { $item->access = 1; } else { if ($item->access > 0) { $item->access = 2; } } // Load up the post item $post = EB::post(); $post->load($item->id); // Get the intro text of the content $item->summary = $post->getIntro(); // Get the contents $item->body = $post->getContent('entry', false); // If the post is password protected, we do not want to display the contents if ($post->isPasswordProtected()) { $item->summary = JText::_('PLG_FINDER_EASYBLOG_PASSWORD_PROTECTED'); } else { // we want to get custom fields values. $fields = $post->getCustomFields(); $fieldlib = EB::fields(); $customfields = array(); if ($fields) { foreach ($fields as $field) { if ($field->group->hasValues($post)) { foreach ($field->fields as $customField) { $eachField = $fieldlib->get($customField->type); $customfields[] = $eachField->text($customField, $post); } } } $customfieldvalues = implode(' ', $customfields); $item->body = $item->body . ' ' . $customfieldvalues; } } // Add the author's meta data $item->metaauthor = !empty($item->created_by_alias) ? $item->created_by_alias : $item->author; $item->author = !empty($item->created_by_alias) ? $item->created_by_alias : $item->author; // If the post has an image, use it $image = $post->getImage('thumbnail', false, true); // If there's no image, try to scan the contents for an image to be used if (!$image && $post->isLegacy()) { $image = EB::string()->getImage($item->body); } // If we still can't locate any images, use the placeholder image if (!$image) { $image = EB::getPlaceholderImage(); } $registry = new JRegistry(); $registry->set('image', $image); $item->params = $registry; // 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'); // Add the type taxonomy data. $item->addTaxonomy('Type', 'EasyBlog'); // 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. if (empty($item->language)) { $item->language = '*'; } $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // For Joomla 3.0, the indexer is assigned to the property // Index the item. if (EB::isJoomla30()) { return $this->indexer->index($item); } return FinderIndexer::index($item); }
/** * 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_jevents', 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. $itemid = $this->params->get("target_itemid", 0); $item->url = "index.php?option=com_jevents&task=icalevent.detail&evid=" . $item->eventid . "&Itemid=" . $itemid; //$this->getURL($item->id, $this->extension, $this->layout); $item->route = "index.php?option=com_jevents&task=icalevent.detail&evid=" . $item->eventid . "&Itemid=" . $itemid; $item->path = FinderIndexerHelper::getContentPath($item->route); // title is already set //$item->title; // Events should only be published if the category is published.etc. - do this later //$item->state; // Add the type taxonomy data. $item->addTaxonomy('Type', 'Event'); // Add the creator taxonomy data. if (!empty($item->creator) || !empty($item->created_by_alias)) { $item->addTaxonomy('Creator', !empty($item->created_by_alias) ? $item->created_by_alias : $item->creator); } // Add the category taxonomy data. - can we do multiple categories? $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); // Add the language taxonomy data. //$item->addTaxonomy('Language', $item->language); // Get jevents extras. FinderIndexerHelper::getContentExtras($item); // Index the item. if (JevJoomlaVersion::isCompatible("3.0.0")) { $this->indexer->index($item); } else { FinderIndexer::index($item); } }
/** * 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; } $access = 1; if (is_null($item->privacy)) { $privacy = FD::privacy($item->user_id); $privacyValue = $privacy->getValue('albums', 'view'); $item->privacy = $privacyValue; } if ($item->privacy == SOCIAL_PRIVACY_PUBLIC) { $access = 1; } else { if ($item->privacy == SOCIAL_PRIVACY_MEMBER) { $access = 2; } else { // this is not public / member items. do not index this item return; } } // $sql->select('a.id, a.title, a.alias, a.introtext AS summary, a.fulltext AS body'); // $sql->select('a.state, a.catid, a.created AS start_date, a.created_by'); // $sql->select('a.created_by_alias, a.modified, a.modified_by, a.attribs AS params'); // $sql->select('a.metakey, a.metadesc, a.metadata, a.language, a.access, a.version, a.ordering'); // $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); // $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); // album onwer $user = FD::user($item->user_id); $userAlias = $user->getAlias(false); $album = FD::table('Album'); $album->load($item->id); $albumAlias = $album->getAlias(); // Build the necessary route and path information. // we need to pass in raw url so that smart search will not create another duplicate item. // index.php?option=com_easysocial&view=albums&id=171:collection&layout=item&uid=84:jenny-siew&type=user $item->url = 'index.php?option=com_easysocial&view=albums&id=' . $albumAlias . '&layout=item&uid=' . $userAlias . '&type=' . $album->type; $item->route = $album->getPermalink(); $item->route = $this->removeAdminSegment($item->route); $item->path = FinderIndexerHelper::getContentPath($item->route); $category = ''; if ($album->core == SOCIAL_ALBUM_PROFILE_PHOTOS) { $category = 'avatar album'; } else { if ($album->core == SOCIAL_ALBUM_PROFILE_COVERS) { $category = 'cover album'; } else { if ($album->core == SOCIAL_ALBUM_STORY_ALBUM) { $category = 'story album'; } else { $category = 'user album'; } } } $item->access = $access; $item->alias = $albumAlias; $item->state = 1; $item->catid = $album->core; $item->start_date = $album->created; $item->created_by = $album->user_id; $item->created_by_alias = $userAlias; $item->modified = $album->assigned_date; $item->modified_by = $album->user_id; $item->params = ''; $item->metakey = $category . ' ' . $album->title; $item->metadesc = $album->title . ' ' . $album->caption; $item->metadata = ''; $item->publish_start_date = $album->assigned_date; $item->category = $category; $item->cat_state = 1; $item->cat_access = 0; $item->summary = empty($album->caption) ? $album->title : $album->caption; $item->body = $album->title . ' ' . $album->caption; // Add the meta-author. $item->metaauthor = $userAlias; $item->author = $userAlias; // add image param $registry = FD::registry(); $registry->set('image', $album->getCover()); $item->params = $registry; // 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'); // Add the type taxonomy data. $item->addTaxonomy('Type', 'EasySocial.Albums'); // Add the author taxonomy data. $item->addTaxonomy('Author', $userAlias); // Add the category taxonomy data. $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); // Add the language taxonomy data. $langParams = JComponentHelper::getParams('com_languages'); $item->language = $langParams->get('site', 'en-GB'); $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. if (FD::isJoomla30()) { $this->indexer->index($item); } else { FinderIndexer::index($item); } }
/** * Run the indexer. * * @return void * * @since 2.5 */ private function index() { require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/indexer.php'; // Disable caching. $config = JFactory::getConfig(); $config->set('caching', 0); $config->set('cache_handler', 'file'); // Reset the indexer state. FinderIndexer::resetState(); // Import the finder plugins. JPluginHelper::importPlugin('finder'); // Starting Indexer. $this->out(JText::_('FINDER_CLI_STARTING_INDEXER'), true); // Trigger the onStartIndex event. JFactory::getApplication()->triggerEvent('onStartIndex'); // Remove the script time limit. @set_time_limit(0); // Get the indexer state. $state = FinderIndexer::getState(); // Setting up plugins. $this->out(JText::_('FINDER_CLI_SETTING_UP_PLUGINS'), true); // Trigger the onBeforeIndex event. JFactory::getApplication()->triggerEvent('onBeforeIndex'); // Startup reporting. $this->out(JText::sprintf('FINDER_CLI_SETUP_ITEMS', $state->totalItems, round(microtime(true) - $this->time, 3)), true); // Get the number of batches. $t = (int) $state->totalItems; $c = (int) ceil($t / $state->batchSize); $c = $c === 0 ? 1 : $c; try { // Process the batches. for ($i = 0; $i < $c; $i++) { // Set the batch start time. $this->qtime = microtime(true); // Reset the batch offset. $state->batchOffset = 0; // Trigger the onBuildIndex event. JFactory::getApplication()->triggerEvent('onBuildIndex'); // Batch reporting. $this->out(JText::sprintf('FINDER_CLI_BATCH_COMPLETE', $i + 1, round(microtime(true) - $this->qtime, 3)), true); } } catch (Exception $e) { // Display the error $this->out($e->getMessage(), true); // Reset the indexer state. FinderIndexer::resetState(); // Close the app $this->close($e->getCode()); } // Reset the indexer state. FinderIndexer::resetState(); }
/** * 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; } // load foundry config $config = FD::config(); $privacy = FD::privacy($item->user_id); //default access $access = 1; if ($config->get('users.indexer.privacy', 1)) { $privacyValue = $privacy->getValue('profiles', 'search'); $item->privacy = $privacyValue; if ($item->privacy == SOCIAL_PRIVACY_PUBLIC) { $access = 1; } else { if ($item->privacy == SOCIAL_PRIVACY_MEMBER) { $access = 2; } else { // this is not public / member items. let set the access to 'special' $access = 3; } } } $user = FD::user($item->user_id); $userAlias = $user->getAlias(false); $contentSnapshot = array(); $userName = $user->getName($config->get('users.indexer.name')); $userEmail = $config->get('users.indexer.email') ? $user->email : ''; $contentSnapshot[] = $userName; if ($userEmail) { // we need to check for the email field privacy if ($config->get('users.indexer.privacy', 1)) { $privacyModel = FD::model('Privacy'); $fieldPrivacyValue = $privacyModel->getFieldValue('field.joomla_email', $user->id); if ($fieldPrivacyValue == SOCIAL_PRIVACY_PUBLIC || $fieldPrivacyValue == SOCIAL_PRIVACY_MEMBER) { $contentSnapshot[] = $userEmail; } else { $userEmail = ''; } } else { $contentSnapshot[] = $userEmail; } } // get data from customfields // get customfields. // $fieldsLib = FD::fields(); // $fieldModel = FD::model( 'Fields' ); // $fieldsResult = array(); // $options = array(); // $options['data'] = true; // $options['dataId'] = $user->user_id; // $options['dataType'] = SOCIAL_TYPE_USER; // $options['searchable'] = 1; // //todo: get customfields. // $fields = $fieldModel->getCustomFields( $options ); // if( count( $fields ) > 0 ) // { // //foreach( $fields as $item ) // foreach( $fields as $field ) // { // $userFieldData = isset( $field->data ) ? $field->data : ''; // $args = array( $userFieldData ); // $f = array( &$field ); // $dataResult = @$fieldsLib->trigger( 'onIndexer' , SOCIAL_FIELDS_GROUP_USER , $f , $args ); // if( $dataResult !== false && count( $dataResult ) > 0 ) // $fieldsResult[] = $dataResult[0]; // } // if( $fieldsResult ) // { // $customFieldsContent = implode( ' ', $fieldsResult ); // $contentSnapshot[] = $customFieldsContent; // } // } $content = implode(' ', $contentSnapshot); // Build the necessary route and path information. // we need to pass in raw url so that if the site on sef, smart serach will not create new item. // index.php?option=com_easysocial&view=profile&id=84:jenny-siew // $item->url = 'index.php?option=com_easysocial&view=profile&id=' . $userAlias; $item->url = 'index.php?option=com_easysocial&view=profile&id=' . $user->id; $item->route = $user->getPermalink(); $item->route = $this->removeAdminSegment($item->route); $item->path = FinderIndexerHelper::getContentPath($item->route); $userProfile = $user->getProfile(); $metaKey = $userName; if ($userEmail) { $metaKey .= ', ' . $userEmail; } $item->title = $userName; $item->access = $access; $item->alias = $userAlias; $item->state = 1; $item->start_date = $user->registerDate; $item->created_by = $item->user_id; $item->created_by_alias = $userAlias; $item->modified = $user->registerDate; $item->modified_by = $item->user_id; $item->params = ''; $item->metakey = $metaKey; $item->metadesc = $content; $item->metadata = ''; $item->publish_start_date = $user->registerDate; // let put user profile as category $item->catid = $userProfile->id; $item->category = $userProfile->getTitle(); $item->cat_state = 1; $item->cat_access = 0; $item->summary = $content; $item->body = $content; // Add the meta-author. $item->metaauthor = $userAlias; $item->author = $userAlias; // add image param $registry = FD::registry(); $registry->set('image', $user->getAvatar()); $item->params = $registry; // 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'); // Add the type taxonomy data. $item->addTaxonomy('Type', 'EasySocial.Users'); // Add the author taxonomy data. $item->addTaxonomy('Author', $userAlias); // Add the category taxonomy data. $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); // Add the language taxonomy data. // $langParams = JComponentHelper::getParams('com_languages'); // $item->language = $langParams->get( 'site', 'en-GB'); // $item->language = '*'; $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. if (FD::isJoomla30()) { $this->indexer->index($item); } else { FinderIndexer::index($item); } }
/** * Method to remove an item from the index. * * @param string $id The ID of the item to remove. * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ protected function remove($id) { JLog::add('FinderIndexerAdapter::remove', JLog::INFO); // Get the item's URL $url = $this->db->quote($this->getUrl($id, $this->extension, $this->layout)); // Get the link ids for the content items. $query = $this->db->getQuery(true); $query->select($this->db->quoteName('link_id')); $query->from($this->db->quoteName('#__finder_links')); $query->where($this->db->quoteName('url') . ' = ' . $url); $this->db->setQuery($query); $items = $this->db->loadColumn(); // Check for a database error. if ($this->db->getErrorNum()) { // Throw database error exception. throw new Exception($this->db->getErrorMsg(), 500); } // Check the items. if (empty($items)) { return true; } // Remove the items. foreach ($items as $item) { FinderIndexer::remove($item); } return true; }
/** * Method to optimize the index and perform any necessary cleanup. * * @return void * * @since 2.5 */ public function optimize() { // We don't want this form to be cached. $app = JFactory::getApplication(); $app->setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true); $app->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true); $app->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false); $app->setHeader('Pragma', 'no-cache'); // Check for a valid token. If invalid, send a 403 with the error message. JSession::checkToken('request') or $this->sendResponse(new Exception(JText::_('JINVALID_TOKEN'), 403)); // Put in a buffer to silence noise. ob_start(); // Import the finder plugins. JPluginHelper::importPlugin('finder'); try { // Optimize the index FinderIndexer::getInstance()->optimize(); // Get the indexer state. $state = FinderIndexer::getState(); $state->start = 0; $state->complete = 1; // Send the response. $this->sendResponse($state); } catch (Exception $e) { $this->sendResponse($e); } }
/** * Method to remove an item from the index. * * @param string $id The ID of the item to remove. * * @return boolean True on success. * * @since 2.5 * @throws Exception on database error. */ protected function remove($id) { // Get the item's URL $url = $this->db->quote($this->getUrl($id, $this->extension, $this->layout)); // Get the link ids for the content items. $query = $this->db->getQuery(true)->select($this->db->quoteName('link_id'))->from($this->db->quoteName('#__finder_links'))->where($this->db->quoteName('url') . ' = ' . $url); $this->db->setQuery($query); $items = $this->db->loadColumn(); // Check the items. if (empty($items)) { return true; } // Remove the items. foreach ($items as $item) { $this->indexer->remove($item); } return true; }
/** * Method to index an item. The item must be a FinderIndexerResult object. * * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. * * @return void * * @throws Exception on database error. */ protected function index(FinderIndexerResult $item) { // Check if the extension is enabled if (JComponentHelper::isEnabled($this->extension) == false) { return; } // Add the meta-data processing instructions. $item->addInstruction(FinderIndexer::META_CONTEXT, 'author'); // Add the type taxonomy data. $item->addTaxonomy('Type', 'Forum Post'); // Add the author taxonomy data. if (!empty($item->author)) { $item->addTaxonomy('Author', $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. FinderIndexer::index($item); }
public function createIndexes(InputInterface $input, OutputInterface $output) { $output->writeln(\JText::_('FINDER_CLI_INDEX_PURGE')); require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/indexer.php'; // Initialize the time value. $this->time = microtime(true); // Remove the script time limit. @set_time_limit(0); $_SERVER['HTTP_HOST'] = 'domain.com'; // Disable caching. $config = \JFactory::getConfig(); $config->set('caching', 0); $config->set('cache_handler', 'file'); // Reset the indexer state. \FinderIndexer::resetState(); // Import the finder plugins. \JPluginHelper::importPlugin('finder'); // Starting Indexer. $output->writeln(\JText::_('FINDER_CLI_STARTING_INDEXER')); // Trigger the onStartIndex event. \JEventDispatcher::getInstance()->trigger('onStartIndex'); // Remove the script time limit. @set_time_limit(0); // Get the indexer state. $state = \FinderIndexer::getState(); // Setting up plugins. $output->writeln(\JText::_('FINDER_CLI_SETTING_UP_PLUGINS')); // Trigger the onBeforeIndex event. \JEventDispatcher::getInstance()->trigger('onBeforeIndex'); // Startup reporting. $output->writeln(\JText::sprintf('FINDER_CLI_SETUP_ITEMS', $state->totalItems, round(microtime(true) - $this->time, 3)), true); // Get the number of batches. $t = (int) $state->totalItems; $c = (int) ceil($t / $state->batchSize); $c = $c === 0 ? 1 : $c; try { // Process the batches. for ($i = 0; $i < $c; $i++) { // Set the batch start time. $this->qtime = microtime(true); // Reset the batch offset. $state->batchOffset = 0; // Trigger the onBuildIndex event. \JEventDispatcher::getInstance()->trigger('onBuildIndex'); // Batch reporting. $output->writeln("<info>" . \JText::sprintf('FINDER_CLI_BATCH_COMPLETE', $i + 1, round(microtime(true) - $this->qtime, 3)) . "</info>"); } } catch (Exception $e) { // Reset the indexer state. \FinderIndexer::resetState(); throw new \RuntimeException($e->getMessage()); } // Reset the indexer state. \FinderIndexer::resetState(); }
/** * Method to parse input, tokenize it, and then add it to the database. * * @param mixed $input String or resource to use as input. A resource * input will automatically be chunked to conserve * memory. Strings will be chunked if longer than * 2K in size. * @param integer $context The context of the input. See context constants. * @param string $lang The language of the input. * @param string $format The format of the input. * * @return integer The number of tokens extracted from the input. * * @since 2.5 */ protected static function tokenizeToDB($input, $context, $lang, $format) { $count = 0; $buffer = null; // If the input is a resource, batch the process out. if (is_resource($input)) { // Batch the process out to avoid memory limits. while (!feof($input)) { // Read into the buffer. $buffer .= fread($input, 2048); // If we haven't reached the end of the file, seek to the last // space character and drop whatever is after that to make sure // we didn't truncate a term while reading the input. if (!feof($input)) { // Find the last space character. $ls = strrpos($buffer, ' '); // Adjust string based on the last space character. if ($ls) { // Truncate the string to the last space character. $string = substr($buffer, 0, $ls); // Adjust the buffer based on the last space for the // next iteration and trim. $buffer = JString::trim(substr($buffer, $ls)); } else { $string = $buffer; } } else { $string = $buffer; } // Parse the input. $string = FinderIndexerHelper::parse($string, $format); // Check the input. if (empty($string)) { continue; } // Tokenize the input. $tokens = FinderIndexerHelper::tokenize($string, $lang); // Add the tokens to the database. $count += FinderIndexer::addTokensToDB($tokens, $context); // Check if we're approaching the memory limit of the token table. if ($count > self::$state->options->get('memory_table_limit', 30000)) { FinderIndexer::toggleTables(false); } unset($string); unset($tokens); } } elseif (strlen($input) > 2048) { $start = 0; $end = strlen($input); $chunk = 2048; // As it turns out, the complex regular expressions we use for // sanitizing input are not very efficient when given large // strings. It is much faster to process lots of short strings. while ($start < $end) { // Setup the string. $string = substr($input, $start, $chunk); // Find the last space character if we aren't at the end. $ls = $start + $chunk < $end ? strrpos($string, ' ') : false; // Truncate to the last space character. if ($ls !== false) { $string = substr($string, 0, $ls); } // Adjust the start position for the next iteration. $start += $ls !== false ? $ls + 1 - $chunk + $chunk : $chunk; // Parse the input. $string = FinderIndexerHelper::parse($string, $format); // Check the input. if (empty($string)) { continue; } // Tokenize the input. $tokens = FinderIndexerHelper::tokenize($string, $lang); // Add the tokens to the database. $count += FinderIndexer::addTokensToDB($tokens, $context); // Check if we're approaching the memory limit of the token table. if ($count > self::$state->options->get('memory_table_limit', 30000)) { FinderIndexer::toggleTables(false); } } } else { // Parse the input. $input = FinderIndexerHelper::parse($input, $format); // Check the input. if (empty($input)) { return $count; } // Tokenize the input. $tokens = FinderIndexerHelper::tokenize($input, $lang); // Add the tokens to the database. $count = FinderIndexer::addTokensToDB($tokens, $context); } return $count; }
/** * 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; // Build the necessary route and path information. $item->url = $this->getURL($item->id, $this->extension, $this->layout); $item->route = ContactHelperRoute::getContactRoute($item->slug, $item->catslug); $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-data processing instructions based on the contact * configuration parameters. */ // Handle the contact position. if ($item->params->get('show_position', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'position'); } // Handle the contact street address. if ($item->params->get('show_street_address', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'address'); } // Handle the contact city. if ($item->params->get('show_suburb', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'city'); } // Handle the contact region. if ($item->params->get('show_state', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'region'); } // Handle the contact country. if ($item->params->get('show_country', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'country'); } // Handle the contact zip code. if ($item->params->get('show_postcode', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'zip'); } // Handle the contact telephone number. if ($item->params->get('show_telephone', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'telephone'); } // Handle the contact fax number. if ($item->params->get('show_fax', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'fax'); } // Handle the contact e-mail address. if ($item->params->get('show_email', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'email'); } // Handle the contact mobile number. if ($item->params->get('show_mobile', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'mobile'); } // Handle the contact webpage. if ($item->params->get('show_webpage', true)) { $item->addInstruction(FinderIndexer::META_CONTEXT, 'webpage'); } // Handle the contact user name. $item->addInstruction(FinderIndexer::META_CONTEXT, 'user'); // Add the type taxonomy data. $item->addTaxonomy('Type', 'Contact'); // 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); // Add the region taxonomy data. if (!empty($item->region) && $this->params->get('tax_add_region', true)) { $item->addTaxonomy('Region', $item->region); } // Add the country taxonomy data. if (!empty($item->country) && $this->params->get('tax_add_country', true)) { $item->addTaxonomy('Country', $item->country); } // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. FinderIndexer::index($item); }
/** * Tests the resetState method * * @return void * * @since 3.0 */ public function testResetState() { // Override the database in this method $this->saveFactoryDatabase(); // Reset the state FinderIndexer::resetState(); // Test we get a null object $this->assertThat(JFactory::getSession()->get('_finder.state', null), $this->isNull()); // Restore the database $this->restoreFactoryDatabase(); }
/** * 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; } // Need to import component route helpers dynamically, hence the reason it's handled here if (JFile::exists(JPATH_SITE . '/components/' . $item->extension . '/helpers/route.php')) { include_once JPATH_SITE . '/components/' . $item->extension . '/helpers/route.php'; } $extension = ucfirst(substr($item->extension, 4)); // Initialize the item parameters. $registry = new JRegistry(); $registry->loadString($item->params); $item->params = $registry; $registry = new JRegistry(); $registry->loadString($item->metadata); $item->metadata = $registry; /* Add the meta-data processing instructions based on the categories * 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'); // Trigger the onContentPrepare event. $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params); // Build the necessary route and path information. $item->url = $this->getURL($item->id, $item->extension, $this->layout); $class = $extension . 'HelperRoute'; if (class_exists($class) && method_exists($class, 'getCategoryRoute')) { $item->route = $class::getCategoryRoute($item->id); } else { $item->route = ContentHelperRoute::getCategoryRoute($item->slug, $item->catid); } $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; } // Translate the state. Categories should only be published if the parent category is published. $item->state = $this->translateState($item->state); // Add the type taxonomy data. $item->addTaxonomy('Type', 'Category'); // Add the language taxonomy data. $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. FinderIndexer::index($item); }
/** * 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; } $access = 1; if (is_null($item->privacy)) { $privacy = FD::privacy($item->user_id); $privacyValue = $privacy->getValue('photos', 'view'); $item->privacy = $privacyValue; } if ($item->privacy == SOCIAL_PRIVACY_PUBLIC) { $access = 1; } else { if ($item->privacy == SOCIAL_PRIVACY_MEMBER) { $access = 2; } else { // this is not public / member items. do not index this item return; } } // $sql->select('a.id, a.title, a.alias, a.introtext AS summary, a.fulltext AS body'); // $sql->select('a.state, a.catid, a.created AS start_date, a.created_by'); // $sql->select('a.created_by_alias, a.modified, a.modified_by, a.attribs AS params'); // $sql->select('a.metakey, a.metadesc, a.metadata, a.language, a.access, a.version, a.ordering'); // $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); // $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); // album onwer $user = FD::user($item->user_id); $userAlias = $user->getAlias(false); $photo = FD::table('Photo'); $photo->load($item->id); // Build the necessary route and path information. // index.php?option=com_easysocial&view=photos&layout=item&id=510:00000690&type=user&uid=84:jenny-siew $item->url = 'index.php?option=com_easysocial&view=photos&layout=item&id=' . $photo->getAlias() . '&type=' . $photo->type . '&uid=' . $userAlias; $item->route = $photo->getPermalink(); $item->route = $this->removeAdminSegment($item->route); $item->path = FinderIndexerHelper::getContentPath($item->route); $category = 'user photo'; if ($item->type == SOCIAL_TYPE_GROUP) { $category = 'group photo'; } $item->access = $access; $item->alias = $photo->getAlias(); $item->state = 1; $item->catid = $photo->type == SOCIAL_TYPE_GROUP ? 2 : 1; $item->start_date = $photo->created; $item->created_by = $photo->user_id; $item->created_by_alias = $userAlias; $item->modified = $photo->assigned_date == '0000-00-00 00:00:00' ? $photo->created : $photo->assigned_date; $item->modified_by = $photo->user_id; $item->params = ''; $item->metakey = $category . ' ' . $photo->title; $item->metadesc = $category . ' ' . $photo->title; $item->metadata = ''; $item->publish_start_date = $item->modified; $item->category = $category; $item->cat_state = 1; $item->cat_access = 0; $item->summary = $photo->title; $item->body = $photo->title; // Add the meta-author. $item->metaauthor = $userAlias; $item->author = $userAlias; // add image param $registry = FD::registry(); $registry->set('image', $photo->getSource()); $item->params = $registry; // 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'); // Add the type taxonomy data. $item->addTaxonomy('Type', 'EasySocial.Photos'); // Add the author taxonomy data. $item->addTaxonomy('Author', $userAlias); // Add the category taxonomy data. $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); // Add the language taxonomy data. $langParams = JComponentHelper::getParams('com_languages'); $item->language = $langParams->get('site', 'en-GB'); $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. if (FD::isJoomla30()) { $this->indexer->index($item); } else { FinderIndexer::index($item); } }
/** * 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); }
/** * 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; } $access = 1; if ($item->type == SOCIAL_EVENT_TYPE_PRIVATE) { $access = 2; } // $sql->select('a.id, a.title, a.alias, a.introtext AS summary, a.fulltext AS body'); // $sql->select('a.state, a.catid, a.created AS start_date, a.created_by'); // $sql->select('a.created_by_alias, a.modified, a.modified_by, a.attribs AS params'); // $sql->select('a.metakey, a.metadesc, a.metadata, a.language, a.access, a.version, a.ordering'); // $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date'); // $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access'); // album onwer $user = FD::user($item->creator_uid); $userAlias = $user->getAlias(false); $event = FD::event($item->id); // Build the necessary route and path information. // index.php?option=com_easysocial&view=groups&id=7:chogokin&layout=item&Itemid=799 $item->url = 'index.php?option=com_easysocial&view=events&id=' . $event->getAlias() . '&layout=item'; $item->route = $event->getPermalink(); $item->route = $this->removeAdminSegment($item->route); $item->path = FinderIndexerHelper::getContentPath($item->route); $item->access = $access; $item->alias = $event->getAlias(); $item->state = 1; $item->catid = $event->category_id; $item->start_date = $event->created; $item->created_by = $event->creator_uid; $item->created_by_alias = $userAlias; $item->modified = $event->created; $item->modified_by = $event->creator_uid; $item->params = ''; $item->metakey = $item->category . ' ' . $event->title; $item->metadesc = $event->title . ' ' . $event->description; $item->metadata = ''; $item->publish_start_date = $event->created; $item->category = $item->category; $item->cat_state = 1; $item->cat_access = 0; $item->summary = $event->title . ' ' . $event->description; $item->body = $event->title . ' ' . $event->description; // Add the meta-author. $item->metaauthor = $userAlias; $item->author = $userAlias; // add image param $registry = FD::registry(); $registry->set('image', $event->getAvatar()); $item->params = $registry; // 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'); // Add the type taxonomy data. $item->addTaxonomy('Type', 'EasySocial.Events'); // Add the author taxonomy data. $item->addTaxonomy('Author', $userAlias); // Add the category taxonomy data. $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access); // Add the language taxonomy data. $langParams = JComponentHelper::getParams('com_languages'); $item->language = $langParams->get('site', 'en-GB'); $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. if (FD::isJoomla30()) { $this->indexer->index($item); } else { FinderIndexer::index($item); } }