Suchmodul so ändern, dass man einen Baum auswählen kann !!!
Verfasst: Do 23. Sep 2004, 09:26
Hallo Leute, ich habe folgendes Problem. Ich habe einen "deutschen"-Baum und einen "englischen" nun soll es in jedem Baum eine Suchmaschine geben. Dafür habe ich folgenden Quellcode (Suchmodul) eingebaut:
Kann man dieses Suchmodul so ändern, dass man einen Baum auswählt, indem die Suchmaschine sucht? Falls nicht, gibt es ein solches Modul, welches ich einbauen kann? Habe ein kleines Zeitproblem...da die Seite bald online gehen soll. Danke für eure Hilfe... DANKE!!!!
Code: Alles auswählen
<?php
echo '<form name="suche" method="POST" action="'.$auth->url().'">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input type="text" size="40" style="width:300px" name="suche" value="'.$suche.'"></td><td></td>
</tr>
<tr>
<td><br><INPUT TYPE="submit" VALUE="Suchen" style="width:80px" class="button"></td><td></td>
</tr>
<tr>
<td colspan=2><br></td>
</tr>
<tr>
<td class="subnavigation"><input type="radio" name="verknuepfung" value="und" checked> alle Begriffe müssen enthalten sein</td><td></td>
</tr>
<tr>
<td class="subnavigation"><input type="radio" name="verknuepfung" value="oder"> mindestens ein Begriff muss enthalten sein</td><td></td>
</tr>
<tr>
<td colspan=2><br></td>
</tr>
</table>
</FO'.'RM>';
if($suche){
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
$ignore_konj = array("und","oder","als","wenn","auch","wo","wie");
$ignore_art = array("der","die","das","ein","eine");
$ignore = array("ich","du","er","sie","es","wir","ihr","sie");
$suche = trim($suche);
$suchliste = explode(" ",strtolower($suche));
$suchliste = array_diff ($suchliste, $ignore_konj, $ignore_art, $ignore);
$suche = trim(implode(" ",$suchliste));
if($verknuepfung=="oder"){
$suchregexp = "(".str_replace(" ",")|(",$suche).")";
$s=ereg_replace("ü", "%FC",strtolower($suche));
$s=ereg_replace("ä", "%E4",$s);
$s=ereg_replace("ö", "%F6",$s);
$suchregexp .= "|$s";
$sql = "SELECT A.title AS title,A.idart AS idart,A.summary AS comment,B.idcat AS idcat,D.value AS content,A.idartlang AS sideid ";
$sql .= "FROM ".$cfg["tab"]["art_lang"]." AS A, ".$cfg["tab"]["cat_art"]." AS B, ".$cfg["tab"]["cat"]." AS C, ".$cfg["tab"]["content"]." AS D ";
$sql .= "WHERE A.idart=B.idart AND A.idartlang=D.idartlang AND B.idcat=C.idcat AND C.idclient='$client' AND idlang='$lang' AND online='1'";
$sql .= " AND (D.value REGEXP '".$suchregexp."' OR A.title REGEXP '".$suchregexp."' OR A.summary REGEXP '".$suchregexp."')";
} else {
$sql = "SELECT A.title AS title,A.idart AS idart,A.summary AS comment,B.idcat AS idcat,D.value AS content,A.idartlang AS sideid ";
$sql .= "FROM ".$cfg["tab"]["art_lang"]." AS A, ".$cfg["tab"]["cat_art"]." AS B, ".$cfg["tab"]["cat"]." AS C, ".$cfg["tab"]["content"]." AS D ";
$sql .= "WHERE A.idart=B.idart AND A.idartlang=D.idartlang AND B.idcat=C.idcat AND C.idclient='$client' AND idlang='$lang' AND online='1'";
while(list($key, $val) = each($suchliste)) {
$suchregexp = "(".str_replace(" ",")|(",$val).")";
$s=ereg_replace("ü", "%FC",strtolower($val));
$s=ereg_replace("ä", "%E4",$s);
$s=ereg_replace("ö", "%F6",$s);
$suchregexp .= "|$s";
$sql .= " AND (D.value REGEXP '".$suchregexp."' OR A.title REGEXP '".$suchregexp."' OR A.summary REGEXP '".$suchregexp."')";
} reset($suchliste);
}
$db->query($sql);
if ($db->num_rows() != 0){
for ($i=0; $i<$db->num_rows(); $i++) {
$db->next_record();
if ($auth->auth["uid"] == "nobody"){
$sql2 = "SELECT public FROM ".$cfg["tab"]["cat_lang"]." WHERE idcat='".$db->f("idcat")."'";
$db2 = new DB_Contenido; $db2->query($sql2); $db2->next_record();
if($db2->f("public") == 0)continue;
};
$num = 0 + $db->f("sideid");
$results[$num][link] = "front_content.php?client=".$client."&la"."ng=".$lang."&idcat=".$db->f("idcat")."&idart=".$db->f("idart")."";
$results[$num][title] = $db->f("title");
$results[$num][text] .= substr(strip_tags(urldecode($db->f("content"))),0,100)."...";
//switch ("CMS_VALUE[2]") {
//case 0: $results[$num][text] = "";break;
//case 1: $results[$num][text] = $db->f("comment");break;
//case 2: $results[$num][text] .= substr(strip_tags(urldecode($db->f("content"))),0,100)."...";
//};
while(list($key, $val) = each($suchliste)) {
$hits[$num] += substr_count(strip_tags(urldecode(strtolower($db->f("title")))), $val) +
substr_count(strtolower(strip_tags(urldecode($db->f("comment")))), $val) +
substr_count(strtolower(strip_tags(urldecode($db->f("content")))), $val);
// echo $num.': '.$val.'='.$hits[$num].$db->f("content").'<br>';
}; reset($suchliste);
};
if(count($hits) > 0){
echo '<tr><td class=text><b>Suchergebnisse für "'.$suche.'"</b><br><br></td></tr> ';
$hits = array_values($hits);
$results = array_values($results);
array_multisort ($results, SORT_DESC, SORT_NUMERIC, $hits, SORT_DESC, SORT_NUMERIC);
for ($i=0; $i<count($hits); $i++){
echo "<tr><td align=left class=text><a href=\"".$results[$i][link]."\"";
echo "><b>".$results[$i][title]."</b></a><br>";
echo $results[$i][text]." <a href=\"".$results[$i][link]."\"";
echo ">mehr</a><br><br></td></tr>";
};
} else { echo "<tr><td align=left class=text><p><b>Keine passenden Seiten gefunden</b></p></td></tr>"; };
} else { echo "<tr><td align=left class=text><p><b>Keine passenden Seiten gefunden</b></p></td></tr>"; };
echo '</table>';
}
?>