Location: PHPKode > projects > PapyrusBB > PapyrusBB-0.6/include/admin/enableSearch.php
<?php
defined('WikyBlog') or die("Not an entry point...");

pluginIncludeFile('include/allForumScripts.php');
wbLang::pluginFile('admin.php');

class enableSearch{
	
	//similar to the update function of bbSearch
	// just not limited to a single file_id
	function enableSearch(){
		global $page,$dbObject,$langA,$wbPluginSpace,$pageOwner,$wbConfig;
		$dbObject->links[$langA['search']] = '/Admin/'.$pageOwner['username'].'/'.$wbPluginSpace.'/SyncSearch';

		
		switch($page->userCmd){
			
			case 'fill':
				$this->fill();
			break;
		}
		
		
		ob_start();
		
		echo '<table style="margin:1em auto 1em auto"><tr><td>';
		
		if( $wbConfig['search'] ){
			echo wbLinks::admin($wbPluginSpace.'/SyncSearch?cmd=fill','synchronize_search');
		}else{
			echo wbLinks::admin('SearchOptions','WIKYBLOG_ENABLE_SEARCH');
		}
		
		echo '</td></tr></table>';
		
		
		
		$page->contentA[$langA['search']] = wb::get_clean();
		
	}
	
	function fill(){
		global $wbTables;
		
		//Get it started with bb_topics
		$query = 'INSERT INTO '.$wbTables['all_search'];
		$query .= ' (`file_id`,`all_title`,`all_content`) ';
		$query .= ' SELECT ';
		$query .= ' `file_id` ';
		$query .= ', `title` ';
		$query .= ', "" ';
		$query .= ' FROM '.$wbTables['bb_topics'];
		$query .= ' ON DUPLICATE KEY UPDATE `all_title` = `title` ';
		$query .= ' , `all_content` = "" ';
		wbDB::runQuery($query);
		if( !wbDB::runQuery($query) ){
			trigger_error('bbSearch::enableSearch()');
		}
		
		//add all the posts
		$query = 'INSERT INTO '.$wbTables['all_search'];
		$query .= ' (`file_id`) ';
		$query .= ' SELECT ';
		$query .= ' `file_id` ';
		$query .= ' FROM '.$wbTables['bb_posts'];
		$query .= ' ORDER BY `id` ASC ';
		$query .= ' ON DUPLICATE KEY UPDATE ';
		$query .= ' `all_content` = CONCAT_WS(" ", `all_content`, `text` )';
		
		if( !wbDB::runQuery($query) ){
			trigger_error('bbSearch::enableSearch()');
		}
		message('SEARCH_SYNCRONIZED');
	}
}
new enableSearch();
Return current item: PapyrusBB