<?php
// $Id: topics.php,v 1.1 2004/07/11 10:28:39 Farsus Exp $
// -------------------------------------------------------------------------//
//			                 RUNCMS                                         //
//                                                                          //
//	 reliable - Unique - Nocost &  Simplicity & ease off use                //
//                       < http://www.runcms.org >                          //
// -------------------------------------------------------------------------//
// Original Author: Half-Dead
// Author Website : http://www.e-xoops.com
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //

include_once("header.php");

$xoopsOption['show_rblock'] = 0;
include_once(XOOPS_ROOT_PATH."/header.php");

OpenTable();

echo '
<u><h3 align="center">'.$myts->makeTboxData4Show($meta['title']).' '._NW_TOPICS.'</h3></u>
<table align="center" border="0" cellspacing="5" cellpadding="0" width="75%"><tr>';

include_once(XOOPS_ROOT_PATH."/class/xoopstree.php");
$topic_tree = new XoopsTree($db->prefix("topics"),"topic_id","topic_pid");

$sql = "
	SELECT topic_id, topic_title , topic_imgurl
	FROM ".$db->prefix("topics")."
	WHERE topic_pid=0 ORDER BY topic_imgurl = '' ASC, topic_title ASC";

$result = $db->query($sql);
$count  = 0;

while ($myrow = $db->fetch_array($result)) {
	$title = $myts->makeTboxData4Show($myrow['topic_title']);

	echo '
	<td align="center" valign="middle">';
	if ( !empty($myrow['topic_imgurl']) ) {
		echo '<br /><a href="'.XOOPS_URL.'/modules/news/index.php?storytopic='.$myrow['topic_id'].'"><img src="'.formatURL(XOOPS_URL.'/modules/news/cache/topics/', $myrow['topic_imgurl']).'" border="0" alt="'.$title.'"></a>';
		}
	echo '<br /><a href="'.XOOPS_URL.'/modules/news/index.php?storytopic='.$myrow['topic_id'].'"><b>'.$title.'</b></a><br />';

	$arr     = array();
	$arr     = $topic_tree->getFirstChild($myrow['topic_id'], "topic_title");
	$space   = 0;
	$chcount = 0;

	foreach($arr as $ele) {
		$chtitle=$myts->makeTboxData4Show($ele['topic_title']);
		if ( $chcount > 5 ) {
			echo '...';
			break;
		}
		if ( $space > 0 ) {
			echo ', ';
		}
		echo '<a href="'.XOOPS_URL.'/modules/news/index.php?storytopic='.$ele['topic_id'].'">'.$chtitle.'</a>';
		$space++;
		$chcount++;
	} // END FOREACH

	$count++;
	if ( $count == 4 ) {
		echo '<br /></td></tr><tr>';
		$count = 0;
		} else {
			echo '<br /></td>';
		}
}
echo '</tr></table><br /><br />';

CloseTable();
include_once(XOOPS_ROOT_PATH."/footer.php");
?>
