From: <mo...@us...> - 2005-08-29 03:15:08
|
Update of /cvsroot/tikiwiki/tiki/lib/search In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15308/lib/search Modified Files: refresh-functions.php searchlib.php Log Message: Instant-Auto-Merge from BRANCH-1-9 to HEAD Index: refresh-functions.php =================================================================== RCS file: /cvsroot/tikiwiki/tiki/lib/search/refresh-functions.php,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- refresh-functions.php 16 Jun 2005 20:11:02 -0000 1.10 +++ refresh-functions.php 29 Aug 2005 03:14:44 -0000 1.11 @@ -61,7 +61,7 @@ function random_refresh_index_blogs() { global $tikilib; - // get random blog + // get random blog $cant=$tikilib->getOne("select count(*) from `tiki_blogs`",array()); if($cant>0) { $query="select * from `tiki_blogs`"; @@ -100,7 +100,7 @@ function random_refresh_index_faqs() { global $tikilib; - // get random faq + // get random faq $cant=$tikilib->getOne("select count(*) from `tiki_faqs`",array()); if($cant>0) { $query="select * from `tiki_faqs`"; @@ -113,7 +113,7 @@ function random_refresh_index_faq_questions() { global $tikilib; - // get random faq + // get random faq $cant=$tikilib->getOne("select count(*) from `tiki_faq_questions`",array()); if($cant>0) { $query="select * from `tiki_faq_questions`"; @@ -126,7 +126,7 @@ function random_refresh_index_blog_posts() { global $tikilib; - // get random blog + // get random blog $cant=$tikilib->getOne("select count(*) from `tiki_blog_posts`",array()); if($cant>0) { $query="select * from `tiki_blog_posts`"; @@ -179,7 +179,7 @@ function random_refresh_index_tracker_items() { global $tikilib; - $cant=$tikilib->getOne("select count(*) from `tiki_tracker_item_fields` f, `tiki_tracker_fields` tf + $cant=$tikilib->getOne("select count(*) from `tiki_tracker_item_fields` f, `tiki_tracker_fields` tf where tf.`type` in (?,?) and tf.`fieldId`=f.`fieldId`",array("t","a")); if($cant>0) { $query="select f.`value`, f.`itemId`, f.`fieldId` @@ -283,7 +283,7 @@ $words[strtolower($value)]++; } - return($words); + return $words; } function insert_index(&$words,$location,$page) { Index: searchlib.php =================================================================== RCS file: /cvsroot/tikiwiki/tiki/lib/search/searchlib.php,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- searchlib.php 16 Jun 2005 20:11:02 -0000 1.27 +++ searchlib.php 29 Aug 2005 03:14:44 -0000 1.28 @@ -1,5 +1,5 @@ <?php - +// $Id$ //this script may only be included - so its better to die if called directly. if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) { header("location: index.php"); @@ -37,7 +37,7 @@ } } - function &find($where,$words,$offset, $maxRecords) { + function find($where,$words,$offset, $maxRecords) { $exact=$this->find_exact($where,$words,$offset, $maxRecords); $part=$this->find_part($where,$words,$offset, $maxRecords); if (count($part)) foreach ($part["data"] as $p) { @@ -61,7 +61,7 @@ } - function &find_part($where,$words,$offset, $maxRecords) { + function find_part($where,$words,$offset, $maxRecords) { $words=preg_split("/[\s]+/",$words,-1,PREG_SPLIT_NO_EMPTY); if (count($words)>0) { switch($where) { @@ -98,15 +98,15 @@ case "files": return $this->find_part_files($words,$offset, $maxRecords); break; - + default: return $this->find_part_all($words,$offset, $maxRecords); break; } } } - - function &refresh_lru_wordlist($syllable) { + + function refresh_lru_wordlist($syllable) { global $search_max_syllwords; global $search_lru_length; global $search_lru_purge_rate; @@ -131,9 +131,9 @@ $now=time(); $this->query("insert into `tiki_searchsyllable`(`syllable`,`lastUsed`,`lastUpdated`) values (?,?,?)", array($syllable,(int) $now,(int) $now)); - + // at random rate: check length of lru list and purge these that - // have not been used for long time. This is what a lru list + // have not been used for long time. This is what a lru list // basically does list($usec, $sec) = explode(" ",microtime()); srand (ceil($sec+100*$usec)); @@ -160,8 +160,9 @@ return $ret; } - function &get_lru_wordlist($syllable) { + function get_lru_wordlist($syllable) { if(!isset($this->wordlist_cache[$syllable])) { + $this->wordlist_cache[$syllable] = array(); $query="select `searchword` from `tiki_searchwords` where `syllable`=?"; $result=$this->query($query,array($syllable)); while ($res = $result->fetchRow()) { @@ -171,7 +172,7 @@ return $this->wordlist_cache[$syllable]; } - function &get_wordlist_from_syllables($syllables) { + function get_wordlist_from_syllables($syllables) { $ret=array(); global $search_syll_age; foreach($syllables as $syllable) { @@ -194,59 +195,59 @@ return $ret; } - function &find_part_wiki($words,$offset, $maxRecords) { + function find_part_wiki($words,$offset, $maxRecords) { return $this->find_exact_wiki($this->get_wordlist_from_syllables($words),$offset, $maxRecords); } - function &find_part_articles($words,$offset, $maxRecords) { + function find_part_articles($words,$offset, $maxRecords) { return $this->find_exact_articles($this->get_wordlist_from_syllables($words),$offset, $maxRecords); } - function &find_part_forums($words,$offset, $maxRecords) { + function find_part_forums($words,$offset, $maxRecords) { return $this->find_exact_forums($this->get_wordlist_from_syllables($words),$offset, $maxRecords); } - function &find_part_blogs($words,$offset, $maxRecords) { + function find_part_blogs($words,$offset, $maxRecords) { return $this->find_exact_blogs($this->get_wordlist_from_syllables($words),$offset, $maxRecords); } - function &find_part_blog_posts($words,$offset, $maxRecords) { + function find_part_blog_posts($words,$offset, $maxRecords) { return $this->find_exact_blog_posts($this->get_wordlist_from_syllables($words),$offset, $maxRecords); } - function &find_part_faqs($words,$offset, $maxRecords) { + function find_part_faqs($words,$offset, $maxRecords) { return $this->find_exact_faqs($this->get_wordlist_from_syllables($words),$offset, $maxRecords); } - function &find_part_directory($words,$offset, $maxRecords) { + function find_part_directory($words,$offset, $maxRecords) { return $this->find_exact_directory($this->get_wordlist_from_syllables($words),$offset, $maxRecords); } - function &find_part_imggals($words,$offset, $maxRecords) { + function find_part_imggals($words,$offset, $maxRecords) { return $this->find_exact_imggals($this->get_wordlist_from_syllables($words),$offset, $maxRecords); } - function &find_part_img($words,$offset, $maxRecords) { + function find_part_img($words,$offset, $maxRecords) { return $this->find_exact_img($this->get_wordlist_from_syllables($words),$offset, $maxRecords); } - function &find_part_trackers($words,$offset, $maxRecords) { + function find_part_trackers($words,$offset, $maxRecords) { return $this->find_exact_trackers($this->get_wordlist_from_syllables($words),$offset, $maxRecords); } - - function &find_part_files($words,$offset, $maxRecords) { + + function find_part_files($words,$offset, $maxRecords) { return $this->find_exact_files($this->get_wordlist_from_syllables($words),$offset, $maxRecords); } - function &find_part_all($words,$offset, $maxRecords) { - + function find_part_all($words,$offset, $maxRecords) { + global $feature_wiki, $feature_directory, $feature_galleries, $feature_file_galleries, $feature_articles, $feature_forums, $feature_blogs, $feature_faqs, $feature_trackers; global $tiki_p_view, $tiki_p_view_directory, $tiki_p_view_image_gallery, $tiki_p_view_file_gallery, $tiki_p_read_article, $tiki_p_forum_read, $tiki_p_read_blog, $tiki_p_view_faqs, $tiki_p_view_trackers, $tiki_p_download_files; - + if ($feature_wiki == 'y' && $tiki_p_view == 'y') { $wikiresults=$this->find_part_wiki($words,$offset, $maxRecords); } else { @@ -344,7 +345,7 @@ return ($res); } - function &find_exact($where,$words,$offset, $maxRecords) { + function find_exact($where,$words,$offset, $maxRecords) { $words=preg_split("/[\s]+/",$words,-1,PREG_SPLIT_NO_EMPTY); if (count($words)>0) { switch($where) { @@ -389,12 +390,12 @@ } } - function &find_exact_all($words,$offset, $maxRecords) { + function find_exact_all($words,$offset, $maxRecords) { global $feature_wiki, $feature_directory, $feature_galleries, $feature_file_galleries, $feature_articles, $feature_forums, $feature_blogs, $feature_faqs, $feature_trackers, $feature_file_galleries; global $tiki_p_view, $tiki_p_view_directory, $tiki_p_view_image_gallery, $tiki_p_view_file_gallery, $tiki_p_read_article, $tiki_p_forum_read, $tiki_p_read_blog, $tiki_p_view_faqs, $tiki_p_view_trackers, $tiki_p_download_files; - + if ($feature_wiki == 'y' && $tiki_p_view == 'y') { $wikiresults=$this->find_exact_wiki($words,$offset, $maxRecords); } else { @@ -461,7 +462,7 @@ $trackerresults['data'] = NULL; $trackerresults['cant'] = 0; } - + /* // should check if feature is enabled before searching $artresults=$this->find_exact_articles($words,$offset, $maxRecords); $forumresults=$this->find_exact_forums($words,$offset, $maxRecords); @@ -490,7 +491,7 @@ } - function &find_exact_trackers($words,$offset, $maxRecords) { + function find_exact_trackers($words,$offset, $maxRecords) { global $feature_trackers, $tiki_p_view_trackers_pending, $tiki_p_view_trackers_closed, $tikilib; global $user; global $trklib; include_once("lib/trackers/trackerlib.php"); @@ -519,7 +520,7 @@ ); } } - + //tracker items $ret2=array(); $cant2=0; @@ -533,7 +534,7 @@ } $query="select distinct s.`page`, s.`location`, s.`last_update`, s.`count`, - t.`lastModif`,t.`trackerId`, t.`status` from + t.`lastModif`,t.`trackerId`, t.`status` from `tiki_searchindex` s, `tiki_tracker_items` t where `searchword` in (".implode(',',array_fill(0,count($words),'?')).") and s.`location`='trackeritem' and @@ -541,7 +542,7 @@ $result=$this->query($query,$words,$maxRecords,$offset); $cant2=0; while ($res = $result->fetchRow()) { - if($this->user_has_perm_on_object($user,$res['trackerId'],'tracker','tiki_p_view_trackers') && + if($this->user_has_perm_on_object($user,$res['trackerId'],'tracker','tiki_p_view_trackers') && ($res["status"] == 'o' || ($res["status"] == 'p' && $tiki_p_view_trackers_pending == "y") || ($res["status"] == 'c' && $tiki_p_view_trackers_closed == "y"))) { ++$cant2; list($itemId, $fieldId) = split("#", $res["page"]); @@ -570,7 +571,7 @@ - function &find_exact_imggals($words,$offset, $maxRecords) { + function find_exact_imggals($words,$offset, $maxRecords) { global $feature_galleries; global $user; if ($feature_galleries == 'y' && count($words) >0) { @@ -604,7 +605,7 @@ } } - function &find_exact_img($words,$offset, $maxRecords) { + function find_exact_img($words,$offset, $maxRecords) { global $feature_galleries; global $user; if ($feature_galleries == 'y' && count($words) >0) { @@ -639,7 +640,7 @@ } } - function &find_exact_blogs($words,$offset, $maxRecords) { + function find_exact_blogs($words,$offset, $maxRecords) { global $feature_blogs; global $user; if ($feature_blogs == 'y' && count($words) >0) { @@ -674,7 +675,7 @@ } - function &find_exact_blog_posts($words,$offset, $maxRecords) { + function find_exact_blog_posts($words,$offset, $maxRecords) { global $feature_blogs; global $user; if ($feature_blogs == 'y' && count($words) >0) { @@ -709,7 +710,7 @@ } } - function &find_exact_articles($words,$offset, $maxRecords) { + function find_exact_articles($words,$offset, $maxRecords) { global $feature_articles; global $user; if ($feature_articles == 'y' && count($words) >0) { @@ -742,8 +743,8 @@ return array('data' => array(),'cant' => 0); } } - - function &find_exact_wiki($words,$offset, $maxRecords) { + + function find_exact_wiki($words,$offset, $maxRecords) { global $feature_wiki; global $user; if ($feature_wiki == 'y' && count($words) >0) { @@ -779,7 +780,7 @@ } } - function &find_exact_directory($words,$offset, $maxRecords) { + function find_exact_directory($words,$offset, $maxRecords) { global $feature_directory; global $user; if ($feature_directory== 'y' && count($words) >0) { @@ -823,7 +824,7 @@ `tiki_searchindex` s, `tiki_directory_sites` d ,`tiki_category_sites` cs where `searchword` in (".implode(',',array_fill(0,count($words),'?')).") and s.`location`='dir_site' and - ".$this->sql_cast("s.`page`","int")."=d.`siteId` and + ".$this->sql_cast("s.`page`","int")."=d.`siteId` and cs.`siteId`=d.`siteId` order by `hits` desc"; $result=$this->query($query,$words,$maxRecords,$offset); @@ -845,14 +846,15 @@ ); //} } - return array('data' => $ret,'cant' => $cant); + $return = array('data' => $ret,'cant' => $cant); } else { - return array('data' => array(),'cant' => 0); + $return = array('data' => array(),'cant' => 0); } + return $return; } - function &find_exact_faqs($words,$offset, $maxRecords) { + function find_exact_faqs($words,$offset, $maxRecords) { global $feature_faqs; global $user; if ($feature_faqs== 'y' && count($words) >0) { @@ -887,7 +889,7 @@ } } - function &find_exact_faqquestions($words,$offset, $maxRecords) { + function find_exact_faqquestions($words,$offset, $maxRecords) { global $feature_faqs; global $user; if ($feature_faqs== 'y' && count($words) >0) { @@ -923,7 +925,7 @@ } - function &find_exact_forums($words,$offset, $maxRecords) { + function find_exact_forums($words,$offset, $maxRecords) { global $feature_forums; global $user; if ($feature_forums== 'y' && count($words) >0) { @@ -958,7 +960,7 @@ } } - function &find_exact_forumcomments($words,$offset, $maxRecords) { + function find_exact_forumcomments($words,$offset, $maxRecords) { global $feature_forums; global $user; if ($feature_forums == 'y' && count($words) >0) { @@ -992,11 +994,11 @@ return array('data' => array(),'cant' => 0); } } - function &find_exact_files($words,$offset, $maxRecords) { + function find_exact_files($words,$offset, $maxRecords) { global $feature_file_galleries; global $user; if ($feature_file_galleries == 'y' && count($words) >0) { - $query="select distinct s.`page`, s.`location`, s.`last_update`, s.`count`, f.`search_data`, + $query="select distinct s.`page`, s.`location`, s.`last_update`, s.`count`, f.`search_data`, f.`data`,f.`lastModif`, f.`filename`, f.`downloads`, f.`description`, f.`name`, g.`name` as `galName` from `tiki_searchindex` s, `tiki_files` f, `tiki_file_galleries` g where `searchword` in (".implode(',',array_fill(0,count($words),'?')).") and |