[Comoblog-commit] comoblog/modules/mod_search README,NONE,1.1 mod_search.php,NONE,1.1 mod_search_pos
Status: Inactive
Brought to you by:
markwallis
|
From: Mark W. \(a. serialmonkey\) <mar...@us...> - 2005-10-05 00:48:34
|
Update of /cvsroot/comoblog/comoblog/modules/mod_search In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14620/mod_search Added Files: README mod_search.php mod_search_post_filter.php search_results.php Log Message: RFE: 1280296 - mod_search module --- NEW FILE: README --- This CoMoblog module adds post searching capabilities to your blog Author: Mark Wallis - mw...@se... It comes in three parts * A sidebar module that adds a search box for users to interact with * A post filter that indexes the post as they enter the system * Admin scripts to mass indexing posts If you are adding this module to an existing system you will want to mass index your existing posts. Todo this change into the root directory you have CoMoblog installed into and run the commands below after installing the module via the web interface. cd modules/mod_search/admin php -q ./mass_search_index.php Any problems please raise them in the CoMoblog SourceForge. Mark. --- NEW FILE: mod_search_post_filter.php --- <?php require_once (dirname(__FILE__).'/include/blog_search.inc.php'); index($post); ?> --- NEW FILE: mod_search.php --- <?php $mod_contents = '<div id="mod_blog_search"><table width="100%" border="0" cellspacing="0" cellpadding="0">'; $mod_contents .= '<tr><td><p>'; $mod_contents .= '<form action="./modules/mod_search/search_results.php" method="post">'; $mod_contents .= 'Search: <input type="text" name="search_txt"><input type="submit" name="search_but" value="search">'; $mod_contents .= '</form>'; $mod_contents .= '</p></td></tr></table></div>'; ?> --- NEW FILE: search_results.php --- <?php require_once ("../../include/config.inc.php"); require_once ("include/blog_search.inc.php"); // CURRENT_TIMESTAMP ////////////////////////////////////////////////////////// // $current_timestamp = ''; if(isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] != '/') { $current_date = substr($_SERVER['PATH_INFO'],1,strlen($_SERVER['PATH_INFO'])-1); $y = substr($current_date,0,4); $m = substr($current_date,4,2); $d = substr($current_date,6,2); $current_timestamp = mktime(0,0,0,$m,$d,$y); if ($current_timestamp > time() || $current_timestamp <= 0) $current_timestamp = time(); } else { $current_timestamp = time(); } // /////////////////////////////////////////////////////////////////////////////// $tpl = new XTemplate (CFG_BASE_PATH."/modules/mod_search/templates/search_results.tpl.htm", "main"); $search_string = $_POST['search_txt']; $posts = do_search ($search_string); $page_title = "Search Results for '".$search_string."'"; $tpl->assign ('PAGE_TITLE', $page_title); $tpl->assign ('SITE_URL', CFG_SITE_URL); if ($posts) { //for ($c = 0; $c < count($posts); $c++) { foreach ($posts as $post) { // clean up post $post['post_mail_from'] = antispam(htmlentities($post['post_mail_from']), true); $post['post_mail_subject'] = antispam(htmlentities($post['post_mail_subject']), true); $date = getdate($post['post_mail_date']); $post['post_mail_date'] = strftime($CAL_DATE_FORMAT." %H:%M", $post['post_mail_date']); $tpl->assign('POST', $post); // topic icon if ($post['topic_id'] != 0) $tpl->parse('main.post.topic'); // images if ($post['post_images'] > 0) { $query = " select img_thumb, concat(img_id,'.',img_extension) as img_name, concat(img_id,'_thumb.',img_extension) as img_thumb_name, img_width, img_height from ".CFG_MYSQL_TABPREFIX."images where post_id = '".$post['post_id']."' and img_display = 'attach' "; $res = mysql_query($query); while ($row = mysql_fetch_assoc($res)) { if ($row['img_thumb'] == 'Y') { $tpl->assign('IMAGE', $row); $tpl->parse('main.post.thumb_img'); } else { $tpl->assign('IMAGE', $row); $tpl->parse('main.post.img'); } } } // author email if (CFG_INTERACTION_AUTHOR == 'yes') $tpl->parse('main.post.author'); // interaction bar if (CFG_INTERACTION_COMMENTS == 'yes') $tpl->parse('main.post.comment_button'); if (CFG_INTERACTION_TRACKBACK == 'yes') { $tpl->parse('main.post.auto_discovery_trackback'); $tpl->parse('main.post.trackback_button'); } $tpl->parse('main.post'); } } else { $tpl->parse('main.noposts'); } // modules //////////////////////////////////////////////////////////////////// // if (count($SIDEBAR_MODULES) > 0) { for ($mod_cnt = 0; $mod_cnt < count($SIDEBAR_MODULES); $mod_cnt++) { include_once (CFG_BASE_PATH.'/modules/'.$SIDEBAR_MODULES[$mod_cnt].'/'.$SIDEBAR_MODULES[$mod_cnt].'.php'); $tpl->assign('SIDEBAR_MODULE',$mod_contents); $tpl->parse('main.sidebar_module'); } } if (count($TOP_MODULES) > 0) { for ($mod_cnt = 0; $mod_cnt < count($TOP_MODULES); $mod_cnt++) { include_once (CFG_BASE_PATH.'/modules/'.$TOP_MODULES[$mod_cnt].'/'.$TOP_MODULES[$mod_cnt].'.php'); $tpl->assign('TOP_MODULE',$mod_contents); $tpl->parse('main.top_bar.top_module'); } $tpl->parse('main.top_bar'); } // /////////////////////////////////////////////////////////////////////////////// $tpl->parse('main'); $tpl->out('main'); // close db connection mysql_close (); ?> |