query("select parent from $default->owl_folders_table where id = '$parent'"); while($sql->next_record()) { $path = fid_to_name($sql->f("parent"))."/".$path; $parent = $sql->f("parent"); } } return $path; } // This Layout section will not be needed as it is going to change // BEGIN patch Scott Tigr // patch for layout include("./lib/header.inc"); print("table_expand_width BGCOLOR=$default->main_header_bgcolor CELLSPACING=0 CELLPADDING=0 BORDER=$default->table_border HEIGHT=30>"); print(""); print(""); print(""); print(""); print(""); print("
"); print("
"); print uid_to_name($userid); print(" : $lang_logout 
"); print "
"; print "
"; if ($expand == 1) { // long view print("\t\ttable_expand_width."\" border=\"0\">\n"); } else { print("\t\t
table_collapse_width>\n"); } print("\t\t\t
".$lang_search.": "); print(gen_navbar($parent) . "
"); // END patch Scott Tigr $groupid = owlusergroup($userid); // first we have to find out what we can search // we need a list of all folder that can be searched // so we need to see which folders the user can read $sql = new Owl_DB; $sql->query("SELECT id,creatorid,groupid,security FROM $default->owl_folders_table"); // // get all the folders that the user can read while($sql->next_record()) { $id = $sql->f("id"); if(check_auth($id, "folder_view", $userid) == 1) $folders[$id] = $id; } // // get all the files in those folders that the user can read foreach($folders as $item) { $sql->query("SELECT * FROM $default->owl_files_table where parent = '$item'"); while($sql->next_record()) { $id = $sql->f("id"); if(check_auth($id, "file_download", $userid) == 1) { $files[$id][id] = $id; $files[$id][n] = $sql->f("name"); $files[$id][m] = explode(" ", $sql->f("metadata")); $files[$id][d] = explode(" ", $sql->f("description")); $files[$id][f] = $sql->f("filename"); $files[$id][c] = $sql->f("checked_out"); $files[$id][u] = $sql->f("url"); $files[$id][p] = $sql->f("parent"); $files[$id][score] = 0; } } } // // right now we have the array $files with all possible files that the user has read access to // BEGIN bufix Scott Tigr // error_handler if query empty if (strlen(trim($query))>0) { // END bugfix Scott Tigr // // break up our query string $query = explode(" ", $query); // // the is the meat of the matching if(sizeof($files) > 0) { foreach($query as $keyword) { foreach(array_keys($files) as $key) { // BEGIN enhancement Sunil Savkar // if the $parent string contains a keyword to be searched, then the score is // adjusted. This takes into account the hierarchy. // if keyword is found in the path if(eregi("$keyword", find_path($files[$key][p]))) { $files[$key][score] = $files[$key][score] + 4; } //if keyword is found in the files array if(eregi("$keyword", $files[$key][n])) { $files[$key][score] = $files[$key][score] + 4; } if(eregi("$keyword", $files[$key][f])) { $files[$key][score] = $files[$key][score] + 3; } // if keyword is found in metadata foreach($files[$key][m] as $metaitem) { // add 2 to the score if we find it in metadata (key search items) if(eregi("$keyword", $metaitem)) { $files[$key][score] = $files[$key][score] + 2; } } // if keyword is found in description foreach($files[$key][d] as $descitem) { // only add 1 for regular description matches if(eregi("$keyword", $descitem)) { $files[$key][score] = $files[$key][score] + 1; } } } } } // // gotta find order to the scores...any better ideas? print "$lang_search_results_for \"".implode(" ", $query)."\"



"; $max = 30; $hit = 1; $CountLines = 0; $iconfiles = array("html","htm","gif","jpg","bmp","zip","tar","doc","mdb","xls","ppt","pdf","gz","mp3","tgz"); //if array exists print out the results based on their score of relavence // This section will have to change as the interface is changing if(sizeof($files) > 0) { while($max > 0) { foreach(array_keys($files) as $key) { if($files[$key][score] == $max) { $name = find_path($files[$key][p])."/".$files[$key][n]; $filename = $files[$key][f]; $choped = split("\.", $filename); $pos = count($choped); $ext = strtolower($choped[$pos-1]); print("table_expand_width BORDER=$default->table_border CELLSPACING=1 CELLPADDING=1>"); $CountLines++; $PrintLines = $CountLines % 2; if ($PrintLines == 0) { print(""); } else print(""); print ""; print(""; print(""); print("
"; //for ($i=$max; $i>0; $i--) { //} // display results based on relevance (different graphics) and score $t_score = $max; for ($c=$max; $c>=1; $c--) { if ( $t_score >= 10) { if ( 0 == ($c % 10)) { print ""; $t_score = $t_score - 10; } } else { if ( (0 == ($t_score % 2)) && $t_score > 0 ) { print ""; } $t_score = $t_score - 1; } } //print "
($lang_score $max)"; print "
"); print "$hit. ".$name.""); if ($files[$key][u] == "1") print(" "); else { if (preg_grep("/$ext/",$iconfiles)) print(" "); else print(" "); } print("  $filename"); printFileIcons($files[$key][id],$name,$files[$key][c],$files[$key][u],$default->owl_version_control,$ext); print("
"); //print "
".implode(" ", $files[$key][d])."

"; $hit++; } } $max--; } } print "
table_expand_width."\" ALIGN=\"center\">
"; print "

"; // BEGIN bugfix Scott Tigr // error_handler if query empty } // end of check strlen(query) else { // if query was empty print("

" . $lang_query_empty . "

"); } include("./lib/footer.inc"); // END bugfix Scott Tigr ?>