<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
//v1.4 www.exoops.info 2006/03 
// $Id: index.php,v 1.3 2003/03/19 07:02:25 half-dead Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Kazumi Ono
// Author Website : http://www.mywebaddons.com/ , http://www.myweb.ne.jp
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
include_once("header.php");
$bcoosConfig['title'] .= " - "._MI_XOOPSFAQ_NAME;
if ($bcoosConfig['startpage'] == "xoopsfaq") {
	$xoopsOption['show_rblock'] = 1;
	include_once(XOOPS_ROOT_PATH."/header.php");
	make_cblock();
	} else {
		$xoopsOption['show_rblock'] = 0;
		include_once(XOOPS_ROOT_PATH."/header.php");
	}
include_once("./cache/config.php");
OpenTable();
$cat_id = intval($_GET['cat_id']);
if ( empty($cat_id) ) {
	echo "
	<table width='100%' border='0'><tr>
	<td><h4 style='text-align:left;'>"._XD_DOCS."</h4></td>
	<td align='right' valign='top'>";
	if ($xoopsfaqConfig['rss_enable'] == 1) {
		echo "<a href='./cache/faq.xml'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."xml.gif' border='0' alt=''></a>";
		} else {
			echo "&nbsp;";
		}
	echo "</td></tr></table>";
	echo "<table width='100%' cellpadding='4' cellspacing='0' border='0'><tr><td><b>" ._CATEGORIES."</b></td></tr><tr><td>";
	$result = $db->query("SELECT category_id, category_title FROM ".$db->prefix("xoopsfaq_categories")." ORDER BY category_order ASC");
	while ( list($cat_id, $category) = $db->fetchRow($result) ) {
		echo "&nbsp;&nbsp;<img src='".XOOPS_URL."/modules/xoopsfaq/images/folder.gif' width='14' height='14' border='0' />&nbsp;<a href='index.php?cat_id=".$cat_id."'>".$category."</a>";
		$category = $myts->makeTboxData4Show($category);
		$sql      = "SELECT contents_id, contents_title FROM ".$db->prefix("xoopsfaq_contents")." WHERE contents_visible=1 AND category_id='".$cat_id."' ORDER BY contents_order ASC";
		$result2  = $db->query($sql);
		$list     = "";
		$count    = 0;
		while ( $myrow = $db->fetchArray($result2) ) {
			$list  .= "<li><a href='index.php?cat_id=".$cat_id."#".$myrow['contents_id']."'>".$myts->makeTboxData4Show($myrow['contents_title'])."</a></li>";
			$count += 1;
		}
		if ($count > 0) {
			echo "<ul style='list-style-image:url(images/question.gif);'>".$list."</ul>";
			} else {
				echo "<br />";
			}
	}
	echo"</td></tr></table>";
	} else {
		$result = $db->query("SELECT category_title FROM ".$db->prefix("xoopsfaq_categories")." WHERE category_id='".$cat_id."'");
		list($category) = $db->fetchRow($result);
		$category = $myts->makeTboxData4Show($category);
		echo "<h4 style='text-align:left;'>"._XD_DOCS."</h4><a id='top' name='top'><a href='index.php'>" ._MAIN."</a>&nbsp;<span style='font-weight:bold;'>&raquo;&raquo;</span>&nbsp;<b>".$category."</b><br /><br />";
		$filename = XOOPS_ROOT_PATH."/modules/xoopsfaq/cache/doc".$cat_id.".php";
		if (@file_exists($filename)) {
			include_once($filename);
		}
		echo "<br /><br /><b>[ <a href='index.php'>" ._XD_BACKTOINDEX."</a> ]</b>";
	}
CloseTable();
include_once(XOOPS_ROOT_PATH."/footer.php");
?>
