$v ) { $qs[$k] = ' like '.dbdt('S',"%$v%"); } $this->set("q",htmlentities( $q, ENT_COMPAT,rgd::$charset) ); if (!isset($sa)) $sa = 1; $twhere = ''; $awhere = ''; if ( $qs ) { foreach( array( 'name','summary','description' ) as $k => $fld ) { $twhere .= ( $k ? ' OR ' : '' ) . '( topic.'.$fld . join(' AND topic.'.$fld, $qs) .' )'; } $twhere = '( exclude_search = 0 ) AND ( '. $twhere .' )'; foreach( array( 'title','abstract','content' ) as $k => $fld ) { $awhere .= ( $k ? ' OR ' : '' ) . '( article.'.$fld . join(' AND article.'.$fld, $qs) .' )'; } } if ($tllist) { $twhere = "id IN ".$tllist." AND ".$twhere; $awhere = "topic IN ".$tllist." AND ".$awhere; } if ($pwhere) $awhere = $pwhere." AND ".$awhere; $awhere .= " AND EXISTS(SELECT id FROM topic WHERE id = article.topic AND exclude_search = 0) AND exclude_search = 0"; if (!isset($nc)) { $res = rgd::$db->execute("SELECT (SELECT COUNT(id) FROM topic WHERE $twhere)+(SELECT COUNT(id) FROM article WHERE $awhere) AS cnt"); $nc = $res->EOF ? 0 : $res->fields['cnt']; } $cp = isset($_REQUEST['cp']) ? $_REQUEST['cp'] : 1; $mgdc_rs_currpage = $cp; $mgdc_rs_rows = 10; $nr = $mgdc_rs_rows; $np = 0; if ($nc > 0) $np = ceil($nc / $nr); $cp = min($np,$mgdc_rs_currpage); $sa = ($cp-1) * $nr+1; $surl = $_SERVER['PHP_SELF']."?q=$q&nc=$nc&nr=$nr"; $resnav = ''; for ($i=1;$i<=$np;$i++) { if ($i == $cp) { $resnav .= "$i "; } else { $resnav .= "$i "; } } if (($sa+$nr-1) < $nc) { $er = ($sa+$nr-1); } else { $er = ($nc); } $info = array( 'q' => $q, 'sa' => $sa, 'er' => $er, 'nc' => $nc, 'resnav' => $resnav ); if ( $cp > 1) { $info[ 'ppurl' ] = "$surl&cp=".($cp-1); } if ($cp < $np) { $info[ 'npurl' ] = "$surl&cp=".($cp+1); } $sql = "( SELECT 'topic' AS lnktype,id,name AS title,description AS content,summary AS abstract FROM topic WHERE $twhere )"; $sql .= " UNION "; $sql .= "( SELECT 'article' AS lnktype,id,title,content,abstract FROM article WHERE $awhere )"; $artlist = new rgd_base; $artlist->_rs = rgd::$db->Execute($sql); if (is_object($artlist->_rs) && $artlist->_rs->_numOfRows) { $this->block('/results', $info); $artlist->_rs->Move($sa-1); $i=$sa; while (($i < ($sa + $nr)) && $artlist->fetch()) { $content = (trim($artlist->content)) ? $artlist->content : $artlist->abstract; $data = array('id' => $artlist->id,'lnk' => $artlist->lnktype,'i' => $i++,'title' => substr($artlist->title,0,70),'content' => substr(strip_tags($content),0,350)); $this->block('/results/resultlist',$data); } } else { $this->block('/notfound', array('q' => $q)); } $mgdc_rs_currpage = 0; $mgdc_rs_rows = 0; rgd::$db->debug = 0; } ?> Musicweb - Zoeken

Zoeken