<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
// www.bcoos.net 2006-09 1.0.2 GPL
//v1.6 www.exoops.info 2006/03 
// $Id: index.php,v 1.5 2003/03/19 07:01:24 half-dead Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: The Xoops Project
// Author Website : http://www.xoops.org
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
include_once('header.php');
$bcoosConfig['title'] .= " - ".$xoopsModule->name;
if ( $bcoosConfig['startpage'] == $xoopsModule->dirname() ) {
	$xoopsOption['show_rblock'] = 1;
	include_once(XOOPS_ROOT_PATH.'/header.php');
	$start = intval($_GET['start']);
	if ( empty($start) ) {
		make_cblock();
		echo '<br />';
	}
	} else {
		$xoopsOption['show_rblock'] = 0;
		include_once(XOOPS_ROOT_PATH.'/header.php');
	}
include_once(XOOPS_ROOT_PATH.'/class/xoopspagenav.php');
include_once(XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->dirname().'/cache/config.php');
include_once('class/class.newsstory.php');
if ( isset($_GET['storytopic']) && is_numeric($_GET['storytopic']) ) {
	$xoopsOption['storytopic'] = intval($_GET['storytopic']);
	} else {
		$xoopsOption['storytopic'] = 0;
	}
if ( isset($_GET['storynum']) && is_numeric($_GET['storynum']) ) {
	$xoopsOption['storynum'] = intval($_GET['storynum']);
	} else {
		$xoopsOption['storynum'] = $newsConfig['storyhome'];
	}
if ( $newsConfig['displaynav'] == 1 ) {
	echo "<br /><form name='form1' action='./index.php' method='get'>";
	$xt = new XoopsTopic($db->prefix("topics"));
	$xt->makeTopicSelBox(1, $xoopsOption['storytopic'], "storytopic");
	echo "<select class='select' name='storynum'>";
	for ($i=5; $i<=30; $i=$i+5) {
		$sel = "";
		if ( $i == $xoopsOption['storynum'] ) {
			$sel = " selected='selected'";
		}
		echo "<option value='$i'$sel>$i</option>";
	}
	echo "</select><input type='submit' class='button' value='"._GO."' /></form>";
}
$sarray     = NewsStory::getAllPublished($xoopsOption['storynum'], $start, $xoopsOption['storytopic']);
$storycount = NewsStory::countByTopic($xoopsOption['storytopic']);
$pagenav    = new XoopsPageNav($storycount, $xoopsOption['storynum'], $start, "storytopic=".$xoopsOption['storytopic']."&amp;storynum=".$xoopsOption['storynum']."&amp;start", "");
if ($newsConfig['rss_enable'] == 1) {
	echo "<table width='100%' border='0' cellspacing='2' cellpadding='0'>
  <tr>
    <td width='100%'><div align='right'><a href='".XOOPS_URL."/modules/news/pda.php'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."menu_d_tree_pda.gif' alt='pda' vspace=2 /></a></div></td>
    <td><div align='right'><a href='./cache/news.xml'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."xml.gif' border='0' vspace=2 ></a></div></td>
  </tr>
</table>
";
} else {
echo " <div align='right'><a href='".XOOPS_URL."/modules/news/pda.php'><img src='".XOOPS_URL."/images/icons/".$bcoosConfig['iconset']."menu_d_tree_pda.gif' alt='pda' vspace=2 /></a></div>";
}
foreach ($sarray as $story) {
	$poster = $story->uname();
	if ( $poster != false ) {
		$poster = "<a href='".XOOPS_URL."/userinfo.php?uid=".$story->uid()."'>".$poster."</a>";
		} else {
			$poster = $bcoosConfig['anonymous'];
		}
	$created    = formatTimestamp($story->published());
	$hometext   = $story->hometext();
	$introcount = strlen($hometext);
	$fullcount  = strlen($story->bodytext());
	$totalcount = ($introcount + $fullcount);
	$morelink   = "";
	if ( $fullcount > 1 ) {
		$morelink .= "<a href='".XOOPS_URL."/modules/".$xoopsModule->dirname()."/article.php?storyid=".$story->storyid()."";
		$morelink .= "'><b>"._NW_READMORE."</b></a> | ";
		$morelink .= sprintf(_NW_BYTESMORE, $totalcount);
		$morelink .= " | ";
	}
$count     = $story->getCommentsCount();
$morelink .= "<a href='".XOOPS_URL."/modules/".$xoopsModule->dirname()."/article.php?storyid=".$story->storyid()."";
$morelink2 = "<a href='".XOOPS_URL."/modules/".$xoopsModule->dirname()."/article.php?storyid=".$story->storyid()."";
if ($count == 0) {
	$morelink .= "'>"._NW_COMMENTS."?</a>";
	} else {
		if ($fullcount < 1) {
			if ($count == 1) {
				$morelink .= "'><b>"._NW_READMORE."</b></a> | $morelink2'>"._NW_ONECOMMENT."</a>";
				} else {
					$morelink .= "'><b>"._NW_READMORE."</b></a> | $morelink2'>";
					$morelink .= sprintf(_NW_NUMCOMMENTS, $count);
					$morelink .= "</a>";
				}
			} else {
				if ($count == 1) {
					$morelink .= "'>"._NW_ONECOMMENT.'</a>';
					} else {
						$morelink .= "'>";
						$morelink .= sprintf(_NW_NUMCOMMENTS, $count);
						$morelink .= '</a>';
					}
			}
	}
	$thetext    = $hometext;
	$storytopic = $story->topic();
	$adminlink  = '&nbsp;';
	if ($xoopsUser) {
		if ( $xoopsUser->isAdmin($xoopsModule->mid()) ) {
			$adminlink = $story->adminlink();
		}
	}
	$imglink = '';
	if ( $story->topicdisplay() ) {
		$imglink = $story->imglink();
	}
	$title = $story->textlink().' : '.$story->title();
	// formatting story ends here
	// now, display the story
	themenews($poster, $created, $title, $story->counter(), $thetext, $imglink, $adminlink, $morelink);
}
// Show navigation bar
echo '<div align="center">'.$pagenav->renderNav(3, 3).'</div>';
include_once(XOOPS_ROOT_PATH.'/footer.php');
?>
