<?php // $Id: links.php,v 1.14 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/links.php
// Original Author: Patrick Kellum
// Purpose: Search web_links
// ----------------------------------------------------------------------
// Download plugin: adam_baum, based on Patrick Kellum's reviews plugin.
// ----------------------------------------------------------------------
$search_modules[] = array(
'title' => 'Web Links',
'func_search' => 'search_weblinks',
'func_opt' => 'search_weblinks_opt'
);
function search_weblinks_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_weblinks\" id=\"active_weblinks\" value=\"1\" checked> <label for=\"active_weblinks\">"._SEARCH_LINKS."</label></font></td></tr></table>";
}
function search_weblinks($vars) {
if(!$vars['active_weblinks']) {
return;
}
global
$bgcolor1,
$bgcolor2,
$bgcolor3,
$bgcolor4,
$textcolor1,
$textcolor2,
$pntable,
$dbconn
;
$w = search_split_query($vars[q]);
$flag = false;
$column = &$pntable['links_links_column'];
$query = "SELECT $column[url] as url, $column[title] as title, $column[linkratingsummary] as linkratingsummary, $column[totalcomments] as totalcomments, $column[hits] as hits, $column[submitter] as submitter, $column[description] as description
FROM $pntable[links_links]
WHERE \n";
foreach($w as $word) {
if($flag) {
switch($vars['bool']) {
case 'AND' :
$query .= ' AND ';
break;
case 'OR' :
default :
$query .= ' OR ';
break;
}
}
$query .= '(';
// web links
$query .= "$column[description] LIKE '$word' OR \n";
$query .= "$column[url] LIKE '$word' OR \n";
$query .= "$column[submitter] LIKE '$word' OR \n";
$query .= "$column[title] LIKE '$word' \n";
$query .= ')';
$flag = true;
}
$query .= " ORDER BY $column[lid]";
$result = $dbconn->Execute($query);
//FTO Replace record count by a 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\">"._WEBLINKS.":</font>";
$output="";
while(!$result->EOF) {
$total_rows++;
$row = $result->GetRowAssoc(false);
$output .= "<li><a class=\"pn-normal\" href=\"$row[url]\" target=\"_new\">$row[title]</a> <font class=\"pn-normal\">(rating: $row[linkratingsummary] - comments: $row[totalcomments] - hits: $row[hits])</font><br>"
."Submitter: $row[submitter]<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_weblinks=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_LINKS.'</font>';
}
print "<br>";
}
?>