<?php echo !defined("GUVENLIK") ? die("Erisim Engellendi!.") : null;?>
<?php 
$page = @intval($_GET['s']);
if(!$page) $page = 1;
$ttsorgu = $db->prepare("SELECT COUNT(*) FROM haberler WHERE durum = ? AND dil = ?");
$ttsorgu->execute(array("1",$_SESSION['k_dil']));
$total = $ttsorgu->fetchColumn();
$limit= $limitayar['limit_sayfahaber'];
$page_count = ceil($total/$limit);
if($page > $page_count) $page = 1;
$show = $page * $limit - $limit;
$BSorgu = $db->prepare("SELECT * FROM haberler WHERE durum = ? AND dil = ? ORDER BY sira ASC LIMIT $show,$limit");
$BSorgu->execute(array("1",$_SESSION['k_dil']));
$Bislem = $BSorgu->fetchALL(PDO::FETCH_ASSOC);
$menubul 	= $db->query("SELECT * FROM menu WHERE menu_url = '".$htc['haberurl']."' OR link = '".$htc['haberurl']."' AND dil = '{$_SESSION['k_dil']}'")->fetch(PDO::FETCH_ASSOC);
$menubas 	= $db->query("SELECT * FROM menu WHERE id = '{$menubul['menu_ust']}' AND dil = '{$_SESSION['k_dil']}'")->fetch(PDO::FETCH_ASSOC);
?>
<!-- Start main-content -->
<div class="main-content">
    <!-- Section: inner-header -->
    <section class="inner-header bg-lighter">
		<div class="container pt-10 pb-10">
			<!-- Section Content -->
			<div class="section-content">
				<div class="row d-ortala">
					<div class="col-md-11">
						<h3 class="font-30 mb-0 mt-10"><?=@$dil['txt102'];?></h3>
						<ol class="breadcrumb text-black mt-0 mb-10">
							<li><a href="<?php echo $htc['anaurl'];?><?php echo $html;?>"><?=@$dil['txt56'];?></a></li>
							<?php if($menubas['menu_isim'] != ""){?>
							<li><a href="<?php echo($menubas['menu_url'] == "0" ? $menubas['link'] : $menubas['menu_url'].$html);?>"><?php echo ilkbuyuk($menubas['menu_isim']);?></a></li>
							<?php }?>
							<li class="active text-theme-colored"><?=@$dil['txt102'];?></li>
						</ol>
					</div>
					<div class="col-md-1">
						<a href="javascript:history.back();" class="sayfa-geri"><span class="icon"><i class="fas fa-arrow-left"></i></span><?=@$dil['txt57'];?></a>
					</div>
				</div>
			</div>
		</div>
	</section>

    <!-- Section: Blog -->
    <section>
        <div class="container pt-50 pb-50">
            <div class="row blog-posts">
                <div class="col-md-12">
					<?php if($BSorgu->rowCount() != "0"){?>					
                    <!-- Blog Masonry -->
                    <div class="row masonry gutter-30 clearfix">
                        <!-- Blog Item Start -->
						<?php foreach ( $Bislem as $BSonuc ){?>
                        <div class="gallery-item col-lg-<?php echo $limitayar['limit_haber'];?> col-md-<?php echo $limitayar['limit_haber'];?>">
                            <article class="post clearfix mb-30 bg-lighter">
                                <div class="entry-header">
                                    <div class="post-thumb thumb haberler">
                                        <img src="<?php echo tema;?>/uploads/haberler/<?php echo $BSonuc['resim']; ?>" alt="<?php echo $BSonuc['adi']; ?>" class="img-responsive img-fullwidth">
                                    </div>
                                </div>
                                <div class="entry-content border-1px p-20 pr-10">
                                    <div class="entry-meta media mt-0 no-bg no-border">
                                        <div class="media-body">
                                            <div class="event-content pull-left flip min-h80">
                                                <h4 class="entry-title text-white m-0 mt-5"><a class="font-weight-700" href="<?php echo $htc['haberdetayurl']; ?>/<?php echo $BSonuc['seo']; ?><?php echo $html;?>"><?php echo kisa(strip_tags($BSonuc['adi']),60); ?></a></h4>
                                                <span class="mb-10 text-gray-darkgray mr-10 font-13"><i class="far fa-clock mr-5 text-theme-colored"></i> <?php echo tarih2($BSonuc['tarih']);?></span>
                                            </div>
                                        </div>
                                    </div>
                                    <p class="mt-10 min-h100"><?php echo $BSonuc['spot']; ?></p>
                                    <a href="<?php echo $htc['haberdetayurl']; ?>/<?php echo $BSonuc['seo']; ?><?php echo $html;?>" class="btn-read-more"><?=@$dil['txt49'];?></a>
                                    <div class="clearfix"></div>
                                </div>
                            </article>
                        </div>
                        <!-- Blog Item End -->
						<?php }?>
                    </div>
                    <!-- Blog Masonry -->
					<?php }else{?>
					<div class="alert alert-warning text-left " style="width:100%;" role="alert">
						<p><strong><?=@$dil['txt59'];?></strong></p>
						<?=@$dil['txt60'];?></br>
						<?=@$dil['txt61'];?>
					</div>
					<?php }?>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
					<p><?php echo $total;?> <?=@$dil['txt62'];?>  <?php echo $page;?> - <?php echo $limitayar['limit_sayfahaber'];?> <?=@$dil['txt63'];?></p>
                    <nav>
                        <ul class="pagination theme-colored xs-pull-center m-0">
						<?php
						if($limitayar['limit_sayfahaber'] < $total && $limitayar['limit_sayfahaber'] > 0){
						$showing = 3;
						if($page > 1){?>
						<?php $previous = $page - 1;?>
						<li><a href="<?php echo $htc['haberurl'];?>/<?php echo $previous;?><?php echo $html;?>" aria-label="Previous"> <span aria-hidden="true">«</span> </a> </li>
						<?php }
						for($i= $page - $showing; $i < $page + $showing + 1; $i++){
						if($i > 0 and $i <= $page_count){
						if($i == $page){?>
						<li class="active"><a href="javascript:void(0);"><?php echo $i; ?></a></li>
						<?php }else{?>
						<li><a href="<?php echo $htc['haberurl'];?>/<?php echo $i; ?><?php echo $html;?>"><?php echo $i; ?></a></li>
						<?php }
						}
						}
						if($page != $page_count){?>
						<?php  $next = $page +1;?>
						<li> <a href="<?php echo $htc['haberurl'];?>/<?php echo $next; ?><?php echo $html;?>" aria-label="Next"> <span aria-hidden="true">»</span> </a> </li>
						<?php }} ?>	
                        </ul>
                    </nav>
                </div>
            </div>
        </div>
    </section>
</div>
<!-- end main-content -->