<?php
/*
* @package LabCMS
* @copyright (c) 2006 Alexander Levin aka Loki (loki_angel@mail.ru)
* @support http://labcms.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
//запрос id тем
function forum_search_count($query_text)
{
	$search=Db::instance()->selectCol("SELECT DISTINCT(ft.theme_id) FROM ?_forum_posts fp JOIN ?_forum_themes ft ON fp.theme_id=ft.theme_id WHERE (MATCH(fp.msg) AGAINST(? IN BOOLEAN MODE) OR MATCH(ft.subject) AGAINST(? IN BOOLEAN MODE))", $query_text, $query_text);
	return $search;
}

//выборка результатов
function forum_search_result($search, $start, $limit, $module)
{
	$forum_path=Db::instance()->selectCell("SELECT path FROM ?_includes ai, ?_tree t WHERE ai.tree_id=t.tree_id AND module_id=? LIMIT 1", $module['module_id']);
	$results=Db::instance()->select("SELECT theme_id, subject FROM ?_forum_themes WHERE theme_id IN (?a) ORDER BY  last_post DESC LIMIT ?d, ?d", $search, $start, $limit);
	$search_result=array();
	foreach($results as $result)
	{
			$search_result[]=array('name_html'=>getbb($result['subject'], 'nolinks'), 'path'=>LabCMS::instance()->url(array($result['theme_id'], 1, $_GET['search']), 'theme', false, $forum_path));
	}
	return $search_result;
}
?>