本文整理汇总了PHP中vB_Search_Core类的典型用法代码示例。如果您正苦于以下问题:PHP vB_Search_Core类的具体用法?PHP vB_Search_Core怎么用?PHP vB_Search_Core使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vB_Search_Core类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index_thread
/**
* Index a thread
*
* By default this will look up all of the posts in a thread and calls the core
* indexer for each one
*
* @param int $id the thread id
*/
public function index_thread($id)
{
global $vbulletin;
$thread = vB_Legacy_Thread::create_from_id($id);
// make sure thread comes from the CMS comment forum
if ($thread->get_field('forumid') != $vbulletin->options['vbcmsforumid'])
{
return;
}
$set = $vbulletin->db->query_read("
SELECT post.* FROM " . TABLE_PREFIX . "post AS post WHERE threadid = " . intval($id)
);
$indexer = vB_Search_Core::get_instance()->get_core_indexer();
while ($row = $vbulletin->db->fetch_array($set))
{
$post = vB_Legacy_Post::create_from_record($row, $thread);
$fields = $this->post_to_indexfields($post);
if ($fields)
{
$indexer->index($fields);
}
}
}
示例2: indexQueue
/**
* vb_Search_Indexcontroller_Queue::indexQueue()
*
* Index an item based on a map of fieldname/value pairs
*
* @param string $package : the package which we are indexing
* @param string $contenttype : text string with the type of content
* @param string $operation: the index action, which will vary depending on the action.
* usually it will just be "index"
* @param data : If we have fourth parameter we take it as an associative array of field values
* @return : boolean success indicator
*/
public static function indexQueue($package, $contenttype, $operation)
{
$data = array_slice(func_get_args(), 3);
global $vbulletin;
$db = vB_Search_Core::get_db();
//For now we need to compose an sql query. Parameters are not available.
//First make sure we've got good data. If we don't have the three parameters
if (isset($package)) {
$dbfields['package'] = "'" . $db->escape_string($package) . "'";
} else {
return false;
}
if (isset($contenttype)) {
$dbfields['contenttype'] = "'" . $db->escape_string($contenttype) . "'";
} else {
return false;
}
if (isset($operation)) {
$dbfields['operation'] = "'" . $db->escape_string($operation) . "'";
}
if (!$vbulletin->options['searchqueueupdates']) {
// we just call indexNow. It checks for valid data.
return vB_Search_Indexcontroller_QueueProcessor::indexNow($package, $contenttype, $operation, $data);
}
$dbfields['data'] = "'" . $db->escape_string(serialize($data)) . "'";
$sql = "INSERT INTO " . TABLE_PREFIX . "indexqueue (" . implode(', ', array_keys($dbfields)) . ")\n\t\t\tVALUES ( " . implode(', ', $dbfields) . " )";
$db->query_write($sql);
return true;
}
示例3: index
/**
* vBForum_Search_IndexController_VisitorMessage::index()
*
* @param integer $id : the record id to be indexed
*/
public function index($id)
{
global $vbulletin;
//we just pull a record from the database.
if ($rst = $vbulletin->db->query_read("SELECT visitormessage.* FROM " . TABLE_PREFIX . "visitormessage AS visitormessage WHERE vmid = {$id}") and $row = $vbulletin->db->fetch_array($rst)) {
vB_Search_Core::get_instance()->get_core_indexer()->index($this->recordToIndexfields($row));
}
}
示例4: delete
/**
* Delete "group message" (blog entry).
*
* Due to stupid schema design, indexed data placed in `blog_text`
* table. But we receive ID from `blog` table. Should remap it,
* prior to place to queue
*
* @param int $id
*/
public function delete($id)
{
$blog_text_id = $this->_get_blog_text_id($id);
if (!$blog_text_id) {
return false;
}
$indexer = vB_Search_Core::get_instance()->get_core_indexer();
return $indexer->delete($this->get_contenttypeid(), $blog_text_id);
}
示例5: init
/**
* Enter description here...
*
*/
static function init()
{
//register implementation objects with the search system.
$search = vB_Search_Core::get_instance();
$search->register_core_indexer(new vBDBSearch_Indexer());
$search->register_index_controller('vBForum', 'Post', new vBDBSearch_PostIndexController());
$__vBDBSearch_CoreSearchController = new vBDBSearch_CoreSearchController();
$search->register_default_controller($__vBDBSearch_CoreSearchController);
// $search->register_search_controller('vBForum', 'Post',$__vBDBSearch_CoreSearchController);
}
示例6: index_id_range
public function index_id_range($start, $finish)
{
global $vbulletin;
$indexer = vB_Search_Core::get_instance()->get_core_indexer();
$set = $vbulletin->db->query_read_slave($q = $this->make_query("forum.forumid BETWEEN " . intval($start) . " AND " . intval($finish)));
while ($row = $vbulletin->db->fetch_array($set)) {
$fields = $this->record_to_indexfields($row);
$indexer->index($fields);
}
}
示例7: index_id_range
/**
* Index group message range
*
* @param int $start
* @param int $end
*/
public function index_id_range($start, $end)
{
global $vbulletin;
$set = $vbulletin->db->query($this->get_query("m.gmid >= " . intval($start) . " AND m.gmid <= " . intval($end)));
$indexer = vB_Search_Core::get_instance()->get_core_indexer();
while ($row = $vbulletin->db->fetch_array($set)) {
$indexer->index($this->record_to_indexfields($row));
}
$vbulletin->db->free_result($set);
}
示例8: init
/**
* Mandatory to overwrite for init specific search components
*
*/
static function init()
{
//register implementation objects with the search system.
$search = vB_Search_Core::get_instance();
$search->register_core_indexer(new vBSphinxSearch_Indexer());
$search->register_index_controller('vBForum', 'Post', new vBSphinxSearch_Search_IndexController_Post());
$search->register_index_controller('vBBlog', 'BlogComment', new vBSphinxSearch_Search_IndexController_BlogComment());
$search->register_index_controller('vBBlog', 'BlogEntry', new vBSphinxSearch_Search_IndexController_BlogEntry());
$search->register_index_controller('vBForum', 'SocialGroupMessage', new vBSphinxSearch_Search_IndexController_SocialGroupMessage());
$__vBSphinxSearch_CoreSearchController = new vBSphinxSearch_CoreSearchController();
$search->register_default_controller($__vBSphinxSearch_CoreSearchController);
self::_init_index_map();
}
示例9: get_instance
/**
* Returns the singleton instance for the search core
*
* @return vB_Search_Core
*/
public static function get_instance()
{
if (is_null(self::$instance)) {
self::$instance = new vB_Search_Core();
//initialize the search implementation
global $vbulletin;
if (!empty($vbulletin->options['searchimplementation'])) {
call_user_func(array($vbulletin->options['searchimplementation'], 'init'));
}
// self::$instance->register_search_controller('vb', 'Tag', new vb_Search_SearchController_Tag());
}
return self::$instance;
}
示例10: get_results
public function get_results($user, $criteria)
{
global $vbulletin;
$db = $vbulletin->db;
$range_filters = $criteria->get_range_filters();
//get thread/post results.
$lastpost_where = array();
$post_lastpost_where = array();
if (!empty($range_filters['markinglimit'][0])) {
$cutoff = $range_filters['markinglimit'][0];
$marking_join = "\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "discussionread AS discussionread ON\n\t\t\t\t\t(discussionread.discussionid = discussion.discussionid AND discussionread.userid = " . $vbulletin->userinfo['userid'] . ")\n\t\t\t";
$lastpost_where[] = "discussion.lastpost > IF(discussionread.readtime IS NULL,\n\t\t\t\t{$cutoff}, discussionread.readtime)";
$lastpost_where[] = "discussion.lastpost > {$cutoff}";
$post_lastpost_where[] = "groupmessage.dateline > IF(discussionread.readtime IS NULL,\n\t\t\t\t{$cutoff}, discussionread.readtime)";
$post_lastpost_where[] = "groupmessage.dateline > {$cutoff}";
} else {
//get date cut -- but only if we're not using the threadmarking filter
if (isset($range_filters['datecut'])) {
//ignore any upper limit
$datecut = $range_filters['datecut'][0];
} else {
return $results;
}
$marking_join = '';
$lastpost_where[] = "discussion.lastpost >= {$datecut}";
$post_lastpost_where[] = "groupmessage.dateline >= {$datecut}";
}
$this->process_orderby($criteria);
if ($criteria->get_grouped() == vB_Search_Core::GROUP_NO) {
$where = array_merge($lastpost_where, $post_lastpost_where);
$contenttypeid = vB_Search_Core::get_instance()->get_contenttypeid('vBForum', 'SocialGroupMessage');
$set = $db->query_read_slave("\n\t\t\t\tSELECT groupmessage.gmid, discussion.discussionid\n\t\t\t\tFROM " . TABLE_PREFIX . "groupmessage AS groupmessage\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "discussion AS discussion ON\n\t\t\t\t\t(discussion.discussionid = groupmessage.discussionid)\n\t\t\t\t{$marking_join}\n\t\t\t\t" . implode("\n", $this->orderby_join) . "\n\t\t\t\tWHERE " . implode(' AND ', $where) . "\n\t\t\t\tORDER BY {$this->orderby}\n\t\t\t\tLIMIT " . intval($vbulletin->options['maxresults']));
while ($row = $db->fetch_array($set)) {
$results[] = array($contenttypeid, $row['gmid'], $row['discussionid']);
}
} else {
$contenttypeid = vB_Search_Core::get_instance()->get_contenttypeid('vBForum', 'SocialGroupDiscussion');
$set = $db->query_read_slave("\n\t\t\t\tSELECT discussion.discussionid\n\t\t\t\tFROM " . TABLE_PREFIX . "discussion AS discussion\n\t\t\t\t{$marking_join}\n\t\t\t\t" . implode("\n", $this->orderby_join) . "\n\t\t\t\tWHERE " . implode(' AND ', $lastpost_where) . "\n\t\t\t\tORDER BY {$this->orderby}\n\t\t\t\tLIMIT " . intval($vbulletin->options['maxresults']));
while ($row = $db->fetch_array($set)) {
$results[] = array($contenttypeid, $row['discussionid'], $row['discussionid']);
}
}
return $results;
}
示例11: get_results
public function get_results($user, $criteria)
{
global $vbulletin;
$db = $vbulletin->db;
$range_filters = $criteria->get_range_filters();
//$equals_filters = $criteria->get_equals_filters();
//$notequals_filter = $criteria->get_equals_filters();
$results = array();
//get date cut -- no marking, just use the datecut.
if (isset($range_filters['datecut']))
{
//ignore any upper limit
$datecut = $range_filters['datecut'][0];
}
else
{
return $results;
}
$this->process_orderby($criteria);
$contenttypeid = vB_Search_Core::get_instance()->get_contenttypeid('vBForum', 'Event');
$set = $db->query_read_slave($q = "
SELECT event.eventid
FROM " . TABLE_PREFIX . "event AS event " . implode(" ", $this->joins) . "
WHERE
event.dateline >= $datecut
ORDER BY {$this->orderby}
LIMIT " . intval($vbulletin->options['maxresults'])
);
while ($row = $db->fetch_array($set))
{
$results[] = array($contenttypeid, $row['eventid'], $row['eventid']);
}
return $results;
}
示例12: output
public function output()
{
global $vbulletin, $db;
$vbulletin->input->clean_array_gpc('r', array('userids' => TYPE_STR, 'contenttypeids' => TYPE_STR));
$vbulletin->GPC['userids'] = convert_urlencoded_unicode($vbulletin->GPC['userids']);
$userids = $vbulletin->GPC['userids'];
$vbulletin->GPC['contenttypeids'] = convert_urlencoded_unicode($vbulletin->GPC['contenttypeids']);
$contenttypeids = $vbulletin->GPC['contenttypeids'];
require_once DIR . "/vb/search/core.php";
require_once DIR . "/vb/legacy/currentuser.php";
require_once DIR . "/vb/search/resultsview.php";
require_once DIR . "/vb/search/searchtools.php";
$search_core = vB_Search_Core::get_instance();
$current_user = new vB_Legacy_CurrentUser();
if (!$vbulletin->options['enablesearches']) {
return $this->error('searchdisabled');
}
$criteria = $search_core->create_criteria(vB_Search_Core::SEARCH_ADVANCED);
$userids_a = explode(',', $userids);
$contenttypeids_a = explode(',', $contenttypeids);
if (empty($userids_a)) {
return $this->error('invalidid');
}
$criteria->add_userid_filter($userids_a, vB_Search_Core::GROUP_NO);
if (!empty($contenttypeids_a)) {
$criteria->add_contenttype_filter($contenttypeids_a);
}
$results = null;
if (!($vbulletin->debug or $vbulletin->GPC_exists['nocache'] and $vbulletin->GPC['nocache'])) {
$results = vB_Search_Results::create_from_cache($current_user, $criteria);
}
if (!$results) {
$results = vB_Search_Results::create_from_criteria($current_user, $criteria);
}
return array("response" => array("errormessage" => "search"), "show" => array("searchid" => $results->get_searchid()));
}
示例13: delete_id_range
/**
* Delete a range of items
*
* @param int $start
* @param int $end
*/
public function delete_id_range($start, $end)
{
$indexer = vB_Search_Core::get_instance()->get_core_indexer();
for ($i = $start; $i <= $end; $i++) {
$indexer->delete($id);
}
}
示例14: get_groups
private function get_groups($types)
{
//no types filters
if (!$types) {
return array();
}
//sort types into group by default/item by default buckets
$search = vB_Search_Core::get_instance();
$group_types = array();
$item_types = array();
foreach ($types as $typeid) {
$type = $search->get_search_type_from_id($typeid);
if ($type->can_group()) {
$group_types[] = $type->get_groupcontenttypeid();
} else {
$group_types[] = $typeid;
}
}
return $group_types;
}
示例15: merge_group
/**
* We just pass this to the core indexer, which knows how to do this.
*/
public function merge_group($oldid, $newid)
{
$indexer = vB_Search_Core::get_instance()->get_core_indexer();
$indexer->merge_group($this->groupcontenttypeid, $oldid, $newid);
}