<?php // $Id: downloads.php,v 1.15 2001/11/29 17:16:34 hdonner Exp $ $Name: $
// ----------------------------------------------------------------------
// Post-Nuke: Content Management System
// ====================================
// Module: Search/downloads plugin
//
// Copyright (c) 2001 by the Post Nuke development team
// http://www.postnuke.com
// ----------------------------------------------------------------------
// Search Module
// ===========================
//
// Copyright (c) 2001 by Patrick Kellum (hide@address.com)
// http://www.ctarl-ctarl.com
//
// This program is free software. You can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License.
// ----------------------------------------------------------------------
// Filename: includes/search/downloads.php
// Original Author: Patrick Kellum
// Purpose: Search downloads
// ----------------------------------------------------------------------
// Download plugin: adam_baum, based on Patrick Kellum's reviews plugin.
// ----------------------------------------------------------------------
$search_modules[] = array(
'title' => 'Downloads',
'func_search' => 'search_downloads',
'func_opt' => 'search_downloads_opt'
);
function search_downloads_opt($vars) {
global
$bgcolor1,
$bgcolor2,
$bgcolor3,
$textcolor1,
$textcolor2
;
print "<table border=\"0\" width=\"100%\"><tr bgcolor=\"$bgcolor2\"><td><font class=\"pn-normal\" style=\"$text-color:$textcolor1\"><input type=\"checkbox\" name=\"active_downloads\" id=\"active_downloads\" value=\"1\" checked> <label for=\"active_downloads\">"._SEARCH_DOWNLOADS."</label></font></td></tr></table>";
}
function search_downloads($vars) {
if(!$vars['active_downloads']) {
return;
}
global
$bgcolor1,
$bgcolor2,
$bgcolor3,
$bgcolor4,
$textcolor1,
$textcolor2,
$pntable,
$dbconn
;
$w = search_split_query($vars[q]);
$flag = false;
// fifers: have to explicitly name the columns so that if the underlying DB column names change, the code to access them doesn't. We use the column names in assoc array later...
$column = &$pntable['downloads_downloads_column'];
$query = "SELECT $column[lid] as lid, $column[title] as title, $column[totalvotes] as totalvotes, $column[hits] as hits, $column[name] as name, $column[description] as description FROM $pntable[downloads_downloads] WHERE \n";
foreach($w as $word) {
if($flag) {
switch($vars['bool']) {
case 'AND' :
$query .= ' AND ';
break;
case 'OR' :
default :
$query .= ' OR ';
break;
}
}
$query .= '(';
// downloads
$query .= "$column[description] LIKE '$word' OR \n";
$query .= "$column[submitter] LIKE '$word' OR \n";
$query .= "$column[name] LIKE '$word' OR \n";
$query .= "$column[homepage] LIKE '$word' \n";
$query .= ')';
$flag = true;
}
$query .= " ORDER BY $column[lid]";
$result = $dbconn->Execute($query);
//FTO Replace record count by counter
// $total_rows = $result->PO_Record Count();
$total_rows=0;
if($vars['overview']) {
$result->Close();
$result = $dbconn->SelectLimit($query,3);
}
if(!$result->EOF) {
print "<font class=\"pn-normal\">"._DOWNLOADS.":</font>";
$output="" ;
while(!$result->EOF) {
$total_rows++;
$row = $result->GetRowAssoc(false);
$output.= "<li><a class=\"pn-normal\" href=\"modules.php?op=modload&name=Downloads&file=index&req=getit&lid=$row[lid]\">$row[title]</a> <font class=\"pn-normal\">(votes: $row[totalvotes] - hits: $row[hits])</font><br>"
."Uploader: $row[name]<br>"
."$row[description]</li>\n";
$result->MoveNext();
}
if($total_rows > 3 && $vars['overview']) {
print " <a class=\"pn-normal\" href=\"modules.php?op=modload&name=Search&file=index&action=search&active_downloads=1&bool=$vars[bool]&q=$vars[q]\">"._SEEALL." $total_rows "._RESULTS."...</a>";
}
print "<ul>";
print $output;
print "</ul>\n";
} else {
print '<font class=\"pn-normal\">'._SEARCH_NO_DOWNLOADS.'</font>';
}
print "<br>";
}
?>