<?php if ($mod==""){
	header('location:../../404.php');
}else{
?>
<!-- 
*******************************************************
	Include Header Template
******************************************************* 
-->
<?php include_once "po-content/$folder/header.php"; ?>


<!-- 
*******************************************************
	Main Content Template
******************************************************* 
-->
<?php
	$iddcat = mysql_real_escape_string(stripslashes(strip_tags(htmlspecialchars($_GET['idc'],ENT_QUOTES))));
	$tabledcat = new PoTable('category');
	$currentDcat = $tabledcat->findByAnd(id_category, $iddcat, active, 'Y');
	$currentDcat = $currentDcat->current();
?>
<?php if ($currentDcat != "0"){ ?>
	<div id="content" class="container">
		<div id="main" class="row-fluid">
			<div id="main-left" class="span8">
			<?php
				$p = new Paging;
				$batas = 5;
				$posisi = $p->cariPosisi($batas);

				$tabledcpost = new PoTable('post');
				$dcposts = $tabledcpost->findAllLimitByAnd(id_post, id_category, active, "$iddcat", "Y", "DESC", "$posisi,$batas");
				foreach($dcposts as $dcpost){
				$tabledccom = new PoTable('comment');
				$totaldccom = $tabledccom->numRowByAnd(id_post, $dcpost->id_post, active, 'Y');
				$tableuser = new PoTable('users');
				$currentUser = $tableuser->findBy(id_user, $dcpost->editor);
				$currentUser = $currentUser->current();
			?>
				<article class="post">
					<h2 class="entry-title">
						<a href="<?php echo "detailpost-$dcpost->id_post-$dcpost->seotitle.html"; ?>" title="<?php echo $dcpost->title; ?>" rel="bookmark"><?php echo $dcpost->title; ?></a>
						<span class="entry-cat"><a href="<?php echo "category-$currentDcat->id_category-$currentDcat->seotitle.html"; ?>" title="<?php echo $currentDcat->title; ?>" rel="category tag"><?php echo $currentDcat->title; ?></a></span>
					</h2>
					<div class="entry-meta row-fluid">
						<ul class="clearfix">
							<li><img src="po-content/<?php echo $folder; ?>/images/gravatar.png" height="15" width="15" alt=""><a href="#" title="Di Tulis Admin" rel="author"><?php echo $currentUser->nama_lengkap; ?></a></li>
							<li><img src="po-content/<?php echo $folder; ?>/images/time.png" alt=""><?php echo tgl_indo($dcpost->date); ?></li>
							<li><img src="po-content/<?php echo $folder; ?>/images/komen.png" alt=""><a href="#" title="<?php echo $totaldccom; ?> Komentar"><?php echo $totaldccom; ?> Komentar</a></li>
						</ul>
					</div>
					<div class="entry-content">
						<a href="<?php echo "detailpost-$dcpost->id_post-$dcpost->seotitle.html"; ?>" title="<?php echo $dcpost->title; ?>" rel="bookmark">
							<img src="po-content/po-upload/<?php echo $dcpost->picture; ?>" alt="<?php echo $dcpost->title; ?>" style="width:100%;" />
						</a>
						<p><?php echo cuthighlight('post', $dcpost->content, '500'); ?>...</p>
						<p class="moretag"><a href="<?php echo "detailpost-$dcpost->id_post-$dcpost->seotitle.html"; ?>">Read more</a></p>
					</div>
				</article>
			<?php } ?>

			<div class="pagination magz-pagination">
				<ul class="pagination pull-right">
				<?php
					$getpage = mysql_real_escape_string(stripslashes(strip_tags(htmlspecialchars($_GET['page'],ENT_QUOTES))));
					$jmldata = $tabledcpost->numRowByAnd(id_category, "$iddcat", active, "Y");
					$jmlhalaman = $p->jumlahHalaman($jmldata, $batas);
					$linkHalaman = $p->navHalaman($getpage, $jmlhalaman, $iddcat, "category", $currentDcat->seotitle);
					echo "$linkHalaman";
				?>
				</ul>
				<div class="clearfix"></div>
			</div>

			</div><!-- #main-left -->

			<!-- 
			*******************************************************
				Include Sidebar Template
			******************************************************* 
			-->
			<?php include_once "po-content/$folder/sidebar.php"; ?>

			<div class="clearfix"></div>
		</div><!-- #main -->
	</div><!-- #content -->
<?php }else{ ?>
	<div id="content" class="container">
		<div id="main" class="row-fluid">
			<div align="center">
				<header class="not-found-header">
					<h1>404</h1>
					<h2>Whoops! Terjadi kesalahan...
				</header><!-- .entry-header -->
				<article id="post-0" class="post not-found">
					<div class="entry-content">
						<p>Maaf halaman yang dicari tidak ditemukan,<br /> atau sudah dihapus. Kembali ke <a href="<?php echo $website_url; ?>" title="<?php echo $website_name; ?>" rel="home">halaman utama</a>.</p>
					</div><!-- .entry-content -->
				</article><!-- #post-0 -->
			</div>
			<div class="clearfix"></div>
		</div><!-- #main -->
	</div><!-- #content -->
<?php } ?>


<!-- 
*******************************************************
	Include Footer Template
******************************************************* 
-->
<?php include_once "po-content/$folder/footer.php"; ?>
<?php } ?>