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

// 2005-01-20 K.OHWADA
// add rss_mode_title, rss_mode_content
// add xoops_rss, xoops_atom

//================================================================
// view atom feed
// 2004-11-28 K.OHWADA
//================================================================

include "header.php";

include_once $MODULE_ROOT."/class/pagenavi.php";
$pagenavi = new pagenavi();

$xoopsOption['template_main'] = $MODULE_DIRNAME."_viewfeed.html";

include XOOPS_ROOT_PATH."/header.php";

// rss/atom auto discovery
$xoopsTpl->assign('xoops_rss',  "modules/$MODULE_DIRNAME/rss.php" );
$xoopsTpl->assign('xoops_atom', "modules/$MODULE_DIRNAME/atom.php" );

$tbl_atomfeed->set_mode_title(   $weblinksConfig['rss_mode_title'] );
$tbl_atomfeed->set_mode_content( $weblinksConfig['rss_mode_content'] );
$tbl_atomfeed->set_max_content(  $weblinksConfig['rss_max_content'] );
$tbl_atomfeed->set_max_summary(  $weblinksConfig['rss_max_summary'] );

$show = $weblinksConfig['rss_perpage'];
$pagenavi->set_show( $show );

assignIndex();

$pagenavi->get_get_parm();

assignDisplayLink();
$xoopsTpl->assign('lang_atomfeed_distribute', _WLS_ATOMFEED_DISTRIBUTE);

// uncommnent, if XOOPS can use RSS auto discovery
//$xoopsTpl->assign('lang_atomfeed_firefox', _WLS_ATOMFEED_FIREFOX);

// --- atom list ---
$total = $tbl_atomfeed->getNumAll();

if ($total > 0)
{
	$offset = $pagenavi->get_start($total);

	if ($offset == -1)
	{
		echo "system error: total = $tota_atoml <br>\n";
		include XOOPS_ROOT_PATH.'/footer.php';
		exit();
	}

	$xoopsTpl->assign('show_feeds', true);

// atom id array
	$orderby = "time_modified DESC";
	$aid_arr = $tbl_atomfeed->getAidArrayByOrderby($orderby, $show, $offset);

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

//if 2 or more items in result, show the sort menu
	if($total > 1)
	{
		$script = $MODULE_URL."/viewfeed.php";
		$navi   = $pagenavi->build_navi($script, $total);

		if ($navi == -1)
		{
			echo "system error: script = $script, total = $total <br>\n";
			include XOOPS_ROOT_PATH.'/footer.php';
			exit();
		}

		$pagenavi->assign_pagenavi($xoopsTpl, $navi);
	}

}

include XOOPS_ROOT_PATH.'/footer.php';
exit();


?>
