Location: PHPKode > projects > ProNuke. Postnuke To Oracle > postnuke/html/includes/search/reviews.php
<?php // $Id: reviews.php,v 1.20 2001/12/06 19:29:06 proca Exp $ $Name:  $
/************************************************************************/
/* Post-Nuke: Content Management System                                 */
/* ====================================                                 */
/* Module: Search/reviews plugin                                        */
/*                                                                      */
/* Copyright (c) 2001 by the Post Nuke development team                 */
/* http://www.postnuke.com                                              */
/************************************************************************/
/************************/
/* Modified version of: */
/************************************************************************/
/* 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/reviews.php                                */
/* Original Author: Patrick Kellum                                      */
/* Purpose: Search reviews                                  */
/************************************************************************/

$search_modules[] = array(
    'title' => 'Reviews',
    'func_search' => 'search_reviews',
    'func_opt' => 'search_reviews_opt'
);
function search_reviews_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_reviews\" id=\"active_reviews\" value=\"1\" checked>&nbsp;<label for=\"active_reviews\">"._SEARCH_REVIEWS."</label></font></td></tr></table>";
}
function search_reviews($vars) {
    if(!$vars['active_reviews']) {
        return;
    }
    global
        $bgcolor1,
        $bgcolor2,
        $bgcolor3,
        $bgcolor4,
        $textcolor1,
        $textcolor2,
        $pntable,
        $dbconn,
        $currentlang,
        $multilingual
    ;
    $w = search_split_query($vars[q]);
    $flag = false;

    $revcol = &$pntable['reviews_column'];
    $comcol = &$pntable['reviews_comments_column'];
    $query = "SELECT DISTINCT $revcol[id] as id, $revcol[title] as title, $revcol[score] as score, $revcol[hits] as hits, $revcol[reviewer] as reviewer, $revcol[date] AS fdate
              FROM $pntable[reviews] LEFT JOIN $pntable[reviews_comments] ON $comcol[rid]=$revcol[id]
              WHERE \n";
    foreach($w as $word) {
        if($flag) {
            switch($vars['bool']) {
                case 'AND' :
                    $query .= ' AND ';
                    break;
                case 'OR' :
                default :
                    $query .= ' OR ';
                    break;
            }
        }
        $query .= '(';
        // reviews
        $query .= "$revcol[title] LIKE '$word' OR \n";
        $query .= "$revcol[text] LIKE '$word' OR \n";
        $query .= "$revcol[reviewer] LIKE '$word' OR \n";
        $query .= "$revcol[cover] LIKE '$word' OR \n";
        $query .= "$revcol[url] LIKE '$word' OR \n";
        $query .= "$revcol[url_title] LIKE '$word' OR \n";
        // reviews_comments
        $query .= "$comcol[comments] LIKE '$word'\n";
        $query .= ')';
        $flag = true;
    }
    if ($multilingual == 1) {
           $query .= " AND ($revcol[rlanguage]='$currentlang' OR $revcol[rlanguage]='')";
    }
    $query .= " ORDER BY $revcol[date]";
    $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\">"._REVIEWS.":</font>";

        $output="";
        while(!$result->EOF) {
            $total_rows++;
            $row = $result->GetRowAssoc(false);
            $row['fdate'] = strftime(_DATELONG,$result->UnixTimeStamp($row['fdate']));
			$output .= "<li><a class=\"pn-normal\" href=\"modules.php?op=modload&amp;name=Reviews&amp;file=index&amp;req=showcontent&id=$row[id]\">$row[title]</a> <font class=\"pn-sub\">(score: $row[score] - hits: $row[hits])</font><br>"
                ."$row[reviewer]<br>"
                ."$row[fdate]</li>\n";
            $result->MoveNext();
        }
        if($total_rows > 3 && $vars['overview']) {
            print " <a class=\"pn-normal\" href=\"modules.php?op=modload&amp;name=Search&amp;file=index&amp;action=search&amp;active_reviews=1&amp;bool=$vars[bool]&amp;q=$vars[q]\">"._SEEALL." $total_rows "._RESULTS."...</a>";
        }
        print "<ul>";

        print $output;

        print "</ul>\n";
    } else {
        print '<font class=\"pn-normal\">'._SEARCH_NO_REVIEWS.'</font>';
    }
    print "<br>";
}
?>
Return current item: ProNuke. Postnuke To Oracle