Initial commit
This commit is contained in:
commit
43ad32700c
7085 changed files with 447606 additions and 0 deletions
212
modules/search/search.output.php
Normal file
212
modules/search/search.output.php
Normal file
|
@ -0,0 +1,212 @@
|
|||
<?php
|
||||
If (!defined("in_astat")) {
|
||||
die("Dieses Script kann nicht ausserhalb des Frameworks laufen!");
|
||||
}
|
||||
|
||||
$session->page_begin("search", FALSE);
|
||||
|
||||
class search extends module{
|
||||
|
||||
function output(){
|
||||
global $session,$config,$db,$tpl,$core,$plugin;
|
||||
|
||||
if ($_POST['search']!='' || $_GET['websearch']==1 || $_GET['searchid']!='') {
|
||||
|
||||
$wh[]='r.`appr`=\'1\'';
|
||||
$count=20;
|
||||
|
||||
if($_GET['websearch']=="1"){
|
||||
$data=$_GET;
|
||||
}else{
|
||||
$data=$_POST;
|
||||
}
|
||||
|
||||
$search=$db->escape($data['search']);
|
||||
$sexact=$db->escape($data['sexact']);
|
||||
$wh[]=' r.`typ`<>\'2\'';
|
||||
switch($data['art']){
|
||||
case 'book':
|
||||
$wh[]=' r.`typ`=\'1\'';
|
||||
break;
|
||||
|
||||
/*case 'cd':
|
||||
$wh[]=' r.`typ`=\'2\'';
|
||||
break;*/
|
||||
|
||||
case 'dvd':
|
||||
$wh[]=' r.`typ`=\'3\'';
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if($sexact==""){
|
||||
$sexact="0";
|
||||
}
|
||||
|
||||
if($data['styp']==""){
|
||||
if($sexact==0){
|
||||
$wh[]="(`interpret` LIKE '%".$search."%' OR `title` LIKE '%".$search."%' OR `isbn` LIKE '%".$search."%' OR `review` LIKE '%".$search."%' OR `description` LIKE '%".$search."%' OR `publisher` LIKE '%".$search."%' OR `author` LIKE '%".$search."%')";
|
||||
}else{
|
||||
$wh[]="(`interpret` LIKE '".$search."' OR `title` LIKE '".$search."' OR `isbn` LIKE '".$search."' OR `review` LIKE '".$search."' OR `description` LIKE '".$search."' OR `publisher` LIKE '".$search."' OR `author` LIKE '".$search."')";
|
||||
}
|
||||
}else{
|
||||
foreach($data['styp'] as $key){
|
||||
if($sexact==0){
|
||||
$wo[]='`'.$key.'` LIKE \'%'.$search.'%\'';
|
||||
}else{
|
||||
$wo[]='`'.$key.'` LIKE \''.$search.'\'';
|
||||
}
|
||||
}
|
||||
if(is_array($wo))
|
||||
$wh[]='('.Join(" OR ",$wo).')';
|
||||
}
|
||||
|
||||
if(is_array($wh))
|
||||
$WS=Join(" AND ",$wh);
|
||||
if(!$_GET['searchid']){
|
||||
$resultc = $db->query("SELECT r.`id` FROM `".$config['prefix']."reviews` r WHERE ".$WS." ORDER BY r.`timestamp` DESC") or die($db->error());
|
||||
$numrows = $db->num_rows($resultc);
|
||||
$pages=ceil($numrows/$count);
|
||||
|
||||
if(!$_GET['page'] || $_GET['page']=="first"){
|
||||
$start=0;
|
||||
}elseif($_GET['page']=="last"){
|
||||
$page=$pages-1;
|
||||
}elseif($_GET['page']>=1){
|
||||
$page=$_GET['page']-1;
|
||||
}
|
||||
$start=$page*$count;
|
||||
if($pages>1){
|
||||
while($res=$db->fetch_array($resultc)){
|
||||
$ids[]=$res['id'];
|
||||
}
|
||||
$sid=$session->generate_Key(10);
|
||||
$db->query("INSERT INTO`".$config['prefix']."searches` (`sid`,`term`,`results`,`time`) VALUES('".$sid."','".$search."','".serialize($ids)."','".time()."')");
|
||||
$add='/'.$sid;
|
||||
}
|
||||
$sql="SELECT r.`id`,r.`title`,r.`interpret`,r.`author`,r.`result`,r.`review`,r.`typ`, r.`pyear`,sum(v.`vote`) AS `voteresult` FROM `".$config['prefix']."reviews` r LEFT JOIN `".$config['prefix']."votes` v ON v.`rid`=r.`id` WHERE ".$WS." GROUP BY r.`id` ORDER BY r.`timestamp` DESC LIMIT ".$start.", ".$count;
|
||||
}else{
|
||||
$resultc = $db->query("SELECT `results` FROM `".$config['prefix']."searches` s WHERE `sid`='".$db->escape($_GET['searchid'])."'");
|
||||
while($res=$db->fetch_array($resultc)){
|
||||
$rs=unserialize($res['results']);
|
||||
}
|
||||
if(!$rs){
|
||||
$core->message("Fehler.", "Diese Suchanfrage ist ungültig oder nicht mehr aktuell",TRUE,"/");
|
||||
}
|
||||
$pages=ceil(count($rs)/$count);
|
||||
|
||||
if(!$_GET['page'] || $_GET['page']=="first"){
|
||||
$start=0;
|
||||
}elseif($_GET['page']=="last"){
|
||||
$page=$pages-1;
|
||||
}elseif($_GET['page']>=1){
|
||||
$page=$_GET['page']-1;
|
||||
}
|
||||
$start=$page*$count;
|
||||
$ru=array_slice($rs,$start,$count);
|
||||
foreach($ru as $key=>$val){
|
||||
if(!$rids)
|
||||
$rids='\''.$val.'\'';
|
||||
else
|
||||
$rids.=',\''.$val.'\'';
|
||||
}
|
||||
$add='/'.$_GET['searchid'];
|
||||
$sql="SELECT r.`id`,r.`title`,r.`interpret`,r.`author`,r.`result`,r.`review`,r.`typ`, r.`pyear`,sum(v.`vote`) AS `voteresult` FROM `".$config['prefix']."reviews` r LEFT JOIN `".$config['prefix']."votes` v ON v.`rid`=r.`id` WHERE r.`id` in(".$rids.") GROUP BY r.`id` ORDER BY r.`timestamp` DESC";
|
||||
}
|
||||
|
||||
$resultr = $db->query($sql);
|
||||
$i=1;
|
||||
while($row=$db->fetch_array($resultr)){
|
||||
$row["nr"]=$i+$start;
|
||||
if($row['voteresult']==""){
|
||||
$row['voteresult']=0;
|
||||
}
|
||||
if($row["typ"]==1){
|
||||
$row["img"]="book.png";
|
||||
$row["imgalt"]="Buchreview";
|
||||
$row["art"]="books";
|
||||
}elseif($row["typ"]==2){
|
||||
$row["img"]="cd.gif";
|
||||
$row["imgalt"]="CD Review";
|
||||
$row["art"]="cd";
|
||||
}else{
|
||||
$row["img"]="dvd.png";
|
||||
$row["imgalt"]="DVD Review";
|
||||
$row["art"]="dvd";
|
||||
}
|
||||
$row['urlname']=urlencode($row['title']);
|
||||
if($row["review"]!=""){
|
||||
$row["hasreviewimg"]="review.png";
|
||||
$row["hasreviewimgalt"]="Review vorhanden";
|
||||
}else{
|
||||
$row["hasreviewimg"]="noreview.png";
|
||||
$row["hasreviewimgalt"]="Kein Review vorhanden";
|
||||
}
|
||||
|
||||
$reviews[]=$row;
|
||||
$i++;
|
||||
}
|
||||
if($page>4){
|
||||
$from=$page-4;
|
||||
}else{
|
||||
$from=1;
|
||||
}
|
||||
|
||||
if($page == $pages)
|
||||
{
|
||||
$to = $pages;
|
||||
}
|
||||
elseif($page == $pages-1)
|
||||
{
|
||||
$to = $page+1;
|
||||
}
|
||||
elseif($page == $pages-2)
|
||||
{
|
||||
$to = $page+2;
|
||||
}
|
||||
elseif($page == $pages-3)
|
||||
{
|
||||
$to = $page+3;
|
||||
}
|
||||
else
|
||||
{
|
||||
$to = $page+4;
|
||||
}
|
||||
|
||||
if($pages > 1){
|
||||
if($page > 0){
|
||||
$pagination=$pagination.' <a href="'.$add.'/first.html"><< Erste</a>';
|
||||
$pagination=$pagination. ' <a href="'.$add.'/' . $page . '.html">< Zurück</a> ';
|
||||
}else{
|
||||
$pagination=$pagination.' <a style="color:orange;"><< Erste</a>';
|
||||
$pagination=$pagination. ' <a style="color:orange;">< Zurück</a> ';
|
||||
}
|
||||
|
||||
for($i = $from; $i <= $to; $i++){
|
||||
If($i==$page+1){
|
||||
$pagination=$pagination.' '.'<a style="color:orange;">'.$i.'</a>';
|
||||
}else{
|
||||
$pagination=$pagination.' <a href="'.$add.'/' . $i .'.html">'.$i.'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if($to > $page+1){
|
||||
$pagination=$pagination.' <a href="'.$add.'/' . ($page + 2) .'.html">Weiter ></a> ';
|
||||
$pagination=$pagination.' <a href="'.$add.'/last.html">Letzte >></a><br />';
|
||||
}else{
|
||||
$pagination=$pagination.' <a style="color:orange;">Weiter ></a> ';
|
||||
$pagination=$pagination.' <a style="color:orange;">Letzte >></a><br />';
|
||||
}
|
||||
}
|
||||
$this->tpl->assign('reviews',$reviews);
|
||||
$this->tpl->assign('pagination',$pagination);
|
||||
return $this->tpl->fetch('listsearch.tpl', 'listsearch');
|
||||
}else{
|
||||
return $this->tpl->fetch('search.tpl', 'seach');
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue