<?php // $Id: faq.php,v 1.15 2001/11/29 17:16:34 hdonner Exp $ $Name: $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// 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
//
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// adam_baum: faq.php based on Patrick Kellum's reviews.php search plugin
// purpose: search the faq database.
$search_modules[] = array(
'title' => 'FAQS',
'func_search' => 'search_faqs',
'func_opt' => 'search_faqs_opt'
);
function search_faqs_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_faqs\" id=\"active_faqs\" value=\"1\" checked> <label for=\"active_faqs\">"._SEARCH_FAQS."</label></font></td></tr></table>";
}
function search_faqs($vars) {
global $pnconfig;
if(!$vars['active_faqs']) {
return;
}
global
$bgcolor1,
$bgcolor2,
$bgcolor3,
$bgcolor4,
$textcolor1,
$textcolor2,
$pntable,
$dbconn,
$currentlang,
$multilingual
;
$w = search_split_query($vars[q]);
$flag = false;
$column = &$pntable['faqanswer_column'];
$faqcatcol = &$pntable['faqcategories_column'];
$query = "SELECT $column[id_cat] as id_cat, $column[question] as question, $column[answer] as answer
FROM $pntable[faqanswer]";
//===FTO . Test for every ORACLE compatible drivers to to execute a left
//join with the right Oracle syntax.
if ( strstr('oci8,oracle,oci8po,oracle_odbc',$pnconfig['dbtype'] ) )
{
$query .= ",$pntable[faqcategories]
WHERE $column[id_cat]=$faqcatcol[id_cat](+)";
} else { // Assume mysql
$query = " LEFT JOIN $pntable[faqcategories] ON $column[id_cat]=$faqcatcol[id_cat] WHERE 1";
}
foreach($w as $word) {
if($flag) {
switch($vars['bool']) {
case 'AND' :
$query .= ' AND ';
break;
case 'OR' :
default :
$query .= ' OR ';
break;
}
}
$query .= ' AND (';
// faqs
$query .= "$column[question] LIKE '$word' OR \n";
$query .= "$column[answer] LIKE '$word'\n";
$query .= ')';
$flag = true;
}
if ($multilingual == 1) {
$query .= " AND ($faqcatcol[flanguage]='$currentlang' OR $faqcatcol[flanguage]='')";
}
$query .= " ORDER BY $column[id]";
$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\">"._FAQ.":</font>";
$output="";
while(!$result->EOF) {
$total_rows++;
$row = $result->GetRowAssoc(false);
$output .= "<li><a class=\"pn-normal\" href=\"modules.php?op=modload&name=FAQ&file=index&myfaq=yes&id_cat=$row[id_cat]\">$row[question]</a><br>"
."Answer: $row[answer]</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_faqs=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_FAQS.'</font>';
}
print "<br>";
}
?>