<?php
// $Id: index.php,v 1.3 2005/10/28 11:56:02 ohwada Exp $

// 2005-01-20 K.OHWADA
// add $weblinksConfig
// add set_mode_title

// 2004-12-12 K.OHWADA
// correspond to order of category arrange

// 2004-11-28 K.OHWADA
// atomfeed

// 2004-10-20 K.OHWADA
// except broken link

// 2004-08-20 Tom_G3X
// admin can change the display number of subcategory 

// 2004/08/10 K.OHWADA
// use class weblinksCatlink
// enable to install this module two or more. 

//================================================================
// index.php
// use class weblinksCategory, weblinksLink
// 2004/01/14 K.OHWADA
//================================================================

include "header.php";
include XOOPS_ROOT_PATH."/header.php";

// for debug
//print_time('start');

// enable to install this module two or more. 
$xoopsOption['template_main'] = $MODULE_DIRNAME."_index.html";

assignIndex();

//$image_mode = $xoopsModuleConfig['catimage_use'] + 1;
$image_mode = $weblinksConfig['cat_img_mode'];

$xoopsTpl->assign('category_image_mode', $image_mode);

// --- category list ---
$count = 1;
$tbl_category->getAll();
$child_arr = $tbl_category->getCidArrayByPid(0);

foreach ($child_arr as $ch_id)
{
	$title  = $tbl_category->getValueByCid($ch_id, 'title', 'S');
	$imgurl = $tbl_category->getValueByCid($ch_id, 'imgurl');

	$image     = $tbl_category->makeImageLink($imgurl);
	$totallink = $tbl_catlink->getLinkNumByCid($ch_id);

// by Tom
// admin can change the display number of subcategory 
	list ($space, $chcount, $subcategories) =
		$tbl_category->makeSubcategorys($ch_id, $weblinksConfig['cat_sub']);

	$xoopsTpl->append('categories', array(
		'image'     => $image,
		'id'        => $ch_id,
		'title'     => $title,
		'totallink' => $totallink,
		'count'     => $count,
		'subcategories' => $subcategories,
		));

	$count++;
}

$total_link = $tbl_link->getNumPublic();
$xoopsTpl->assign('lang_thereare', sprintf(_WLS_THEREARE,$total_link));
assignDisplayLink();


// --- link list ---
$records = $tbl_link->getRowsLatest($xoopsModuleConfig['newlinks'], 0);
foreach ($records as $record) 
{
	$xoopsTpl->append('links', $tbl_link->makeDisplay($record) );
}


// --- atomfeed list ---
// atom id array
$tbl_atomfeed->set_mode_title( 0 );	// not allow HTML tag
$tbl_atomfeed->set_max_summary(  $weblinksConfig['rss_max_summary'] );
$aid_arr = $tbl_atomfeed->getAidArrayLatest( $weblinksConfig['rss_new'] );

// each atom
foreach ($aid_arr as $aid) 
{
	$rec2  = $tbl_atomfeed->getRowByAid($aid);
	$feed  = $tbl_atomfeed->makeDisplay($rec2);
	$xoopsTpl->append('feeds', $feed);
}


// for debug
//print_time('end');

include XOOPS_ROOT_PATH.'/footer.php';

exit();

?>
