/** * Initialize the Search */ public static function initialize() { if (self::$index === false) { // Initialize the ezc/Zend Search class if (titania::$config->search_backend == 'zend') { if (!is_writable(TITANIA_ROOT . self::store_path)) { throw new exception(self::store_path . ' must be writable to use the Zend Lucene Search'); } $handler = new ezcSearchZendLuceneHandler(TITANIA_ROOT . self::store_path); } else { if (titania::$config->search_backend == 'solr') { $handler = new ezcSearchSolrHandler(titania::$config->search_backend_ip, titania::$config->search_backend_port); // In case Solr would happen to go down.. if (!$handler->connection) { // Log this as an error titania::log(TITANIA_ERROR, 'Solr Server not responding'); self::$do_not_index = true; return false; } } else { throw new exception('We need a proper search backend selected'); } } $manager = new ezcSearchEmbeddedManager(); self::$index = new ezcSearchSession($handler, $manager); return true; } }
/** * Index this post */ public function index() { titania_search::index($this->post_type, $this->post_id, array('parent_id' => $this->topic->parent_id, 'title' => $this->post_subject, 'text' => $this->post_text, 'text_uid' => $this->post_text_uid, 'text_bitfield' => $this->post_text_bitfield, 'text_options' => $this->post_text_options, 'author' => $this->post_user_id, 'date' => $this->post_time, 'url' => $this->post_url, 'access_level' => min($this->post_access, $this->topic->topic_access), 'approved' => $this->post_approved, 'reported' => $this->post_reported)); }
/** * Update data or submit new faq * * @return void */ public function submit() { // Get the FAQ count to update it $sql = 'SELECT contrib_faq_count FROM ' . TITANIA_CONTRIBS_TABLE . ' WHERE contrib_id = ' . $this->contrib_id; phpbb::$db->sql_query($sql); $contrib_faq_count = phpbb::$db->sql_fetchfield('contrib_faq_count'); phpbb::$db->sql_freeresult(); // If already submitted we need to decrement first if ($this->faq_id) { if (empty($this->sql_data)) { throw new exception('Modifying a FAQ entry requires you load it through the load() function (we require the original information).'); } $original_flags = titania_count::update_flags($this->sql_data['faq_access']); $contrib_faq_count = titania_count::decrement($contrib_faq_count, $original_flags); } // Update the FAQ count $flags = titania_count::update_flags($this->faq_access); $sql = 'UPDATE ' . TITANIA_CONTRIBS_TABLE . ' SET contrib_faq_count = \'' . phpbb::$db->sql_escape(titania_count::increment($contrib_faq_count, $flags)) . '\' WHERE contrib_id = ' . $this->contrib_id; phpbb::$db->sql_query($sql); // Submit this FAQ item parent::submit(); // Index titania_search::index(TITANIA_FAQ, $this->faq_id, array('title' => $this->faq_subject, 'text' => $this->faq_text, 'text_uid' => $this->faq_text_uid, 'text_bitfield' => $this->faq_text_bitfield, 'text_options' => $this->faq_text_options, 'author' => 0, 'date' => 0, 'url' => titania_url::unbuild_url($this->get_url()), 'access_level' => $this->faq_access)); }
/** * Index the contribution */ public function index() { $data = array('title' => $this->contrib_name, 'text' => $this->contrib_desc, 'text_uid' => $this->contrib_desc_uid, 'text_bitfield' => $this->contrib_desc_bitfield, 'text_options' => $this->contrib_desc_options, 'author' => $this->contrib_user_id, 'date' => $this->contrib_last_update, 'url' => titania_url::unbuild_url($this->get_url()), 'approved' => !titania::$config->require_validation || !titania_types::$types[$this->contrib_type]->require_validation || in_array($this->contrib_status, array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) ? true : false); titania_search::index(TITANIA_CONTRIB, $this->contrib_id, $data); }