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


<!-- 
*******************************************************
	Main Content Template
******************************************************* 
-->
<?php
	$kata = trim($_POST['search']);
	$kata = htmlentities(htmlspecialchars($kata), ENT_QUOTES);

	$pisah_kata = explode(" ",$kata);
	$jml_katakan = (integer)count($pisah_kata);
	$jml_kata = $jml_katakan-1;

	$tablesearch = new PoTable('post');
	$searchposts = $tablesearch->findSearchPost($pisah_kata, $jml_kata);
	
	$numsearchposts = $tablesearch->numRowSearchPost($pisah_kata, $jml_kata);

	if ($numsearchposts > 0){
?>
	<div id="content" class="container">
		<div id="main" class="row-fluid">
			<div id="main-left" class="span8">
			<?php
				foreach($searchposts as $searchpost){
					$tabledscom = new PoTable('comment');
					$totaldscom = $tabledscom->numRowByAnd(id_post, $searchpost->id_post, active, 'Y');
					$tablecatds = new PoTable('category');
					$currentCatds = $tablecatds->findBy(id_category, $searchpost->id_category);
					$currentCatds = $currentCatds->current();
					$tableuser = new PoTable('users');
					$currentUser = $tableuser->findBy(id_user, $searchpost->editor);
					$currentUser = $currentUser->current();
			?>
				<article class="post">
					<h2 class="entry-title">
						<a href="<?php echo "detailpost-$searchpost->id_post-$searchpost->seotitle.html"; ?>" title="<?php echo $searchpost->title; ?>" rel="bookmark"><?php echo $searchpost->title; ?></a>
						<span class="entry-cat"><a href="<?php echo "category-$currentCatds->id_category-$currentCatds->seotitle.html"; ?>" title="<?php echo $currentCatds->title; ?>" rel="category tag"><?php echo $currentCatds->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($searchpost->date); ?></li>
							<li><img src="po-content/<?php echo $folder; ?>/images/komen.png" alt=""><a href="#" title="<?php echo $totaldscom; ?> Komentar"><?php echo $totaldscom; ?> Komentar</a></li>
						</ul>
					</div>
					<div class="entry-content">
						<a href="<?php echo "detailpost-$searchpost->id_post-$searchpost->seotitle.html"; ?>" title="<?php echo $searchpost->title; ?>" rel="bookmark">
							<img src="po-content/po-upload/<?php echo $searchpost->picture; ?>" alt="<?php echo $searchpost->title; ?>" style="width:100%;" />
						</a>
						<p><?php echo cuthighlight('post', $searchpost->content, '500'); ?>...</p>
						<p class="moretag"><a href="<?php echo "detailpost-$searchpost->id_post-$searchpost->seotitle.html"; ?>">Read more</a></p>
					</div>
				</article>
			<?php } ?>

			</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! Pencarian tidak ditemukan...
				</header><!-- .entry-header -->
				<article id="post-0" class="post not-found">
					<div class="entry-content">
						<p>Maaf kata yang anda cari tidak ditemukan.<br />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 } ?>