| Server IP : 127.0.0.1 / Your IP : 216.73.216.109 Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10 System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64 User : SERVERWEB ( 0) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/laragon/backup/www/ |
Upload File : |
<?php
include('php/prensa.php');
$catList = getList("categories");
$userList =getListC("users");
$tagList = getListC("tags");
$noticias =[];
$itemsPerPage = 5;
$currentPage = 1;
$url = "https://prensa.quillacollo.gob.bo/wp-json/wp/v2/posts";
if (isset($_POST['page'])) {
$currentPage = max(1, intval($_POST['page']));
}
$url=$url."?per_page={$itemsPerPage}&page={$currentPage}";
$category = isset($_POST['category']) ? $_POST['category'] : null;
if($category!=null ){
if ((string)$category == $category) {
foreach($catList as $cat){
if($cat['name'] == $category){
$categoryId=$cat['id'];
$url = $url."&categories={$categoryId}";
}
}
}
if ((integer)$category == $category) {
$categoryId = $category;
$url = $url."&categories={$categoryId}";
}
$itemsCount = decode_api("https://prensa.quillacollo.gob.bo/wp-json/wp/v2/categories/{$categoryId}");
$totalPages = ceil($itemsCount['count'] / $itemsPerPage);
} else{
$totalPages=10;
}
if (isset($_POST['author'])) {
$author = $_POST['author'];
if($author!=null ){
$url = $url."&author={$author}";
}
}
$noticias = decode_api($url);
?>
<div class="section ">
<div class="section_wrapper clearfix">
<?php if($category==null ): ?>
<div class="column one column_fancy_heading">
<div class="fancy_heading fancy_heading_icon">
<h2 class="title">Ultimas Publicaciones</h2>
</div>
</div>
<?php endif?>
<div class="column one column_blog">
<div class="blog_wrapper isotope_wrapper">
<div class="posts_group lm_wrapper timeline">
<?php
foreach($noticias as $post){
$content = $post['content']['rendered'];
if (preg_match('/<img[^>]+src="([^"]+)"/', $content, $matches)) {
$firstImageURL = $matches[1];
}
if (preg_match('/<a href="([^"]+)">/', $content, $matches)) {
$firstDocURL = $matches[1];
}
foreach ($userList as $authorData) {
if ($authorData['id'] == $post['author']) {
$author = $authorData;
break;
}
}
$categories = [];
foreach ($catList as $cat) {
if(!empty($post['categories'])){
foreach ($post['categories'] as $catPost) {
if ($cat['id'] == $catPost) {
$categories[] = $cat;
if($cat['id']==26 && empty($firstImageURL)){
$firstImageURL="images/leyes.jpg";}
}
} }
}
if(!empty($firstImageURL) || !empty($firstDocURL)){
?>
<div class="post format-image has-post-thumbnail category-motion category-photography post-item isotope-item clearfix">
<div class="date_label">
<?php echo date("d-m-Y", strtotime($post['date_gmt']));?>
</div>
<div class="image_frame post-photo-wrapper scale-with-grid">
<div class="image_wrapper">
<div class="mask"></div>
<?php if(!empty($firstImageURL)){?>
<a href="<?php $post['link']?>">
<img width="576" height="750" src="<?= $firstImageURL ?>" class="scale-with-grid wp-post-image" />
</a>
<div class="image_links double">
<a href="<?= $firstImageURL ?>" class="zoom" rel="prettyphoto"><i class="icon-search"></i></a>
<a href="<?= $post['link'] ?>" class="link"><i class="icon-link"></i></a>
</div>
<?php }else if(!empty($firstDocURL)){?>
<object class="wp-block-file__embed" data="<?=$firstDocURL?>" style="width:100%;height:600px" aria-label="Incrustado de Carta-de-Inscripcion."></object>
<?php }?>
</div>
</div>
<div class="post-desc-wrapper">
<div class="post-desc">
<div class="post-meta clearfix">
<div class="author-date">
<span class="author"><span>Publicado por </span>
<i class="icon-user"></i> <a href="#"><?= $author['name'] ?></a>
</span>
<span class="date"><span> Fecha </span><i class="icon-clock"></i>
<?php echo date("d-m-Y", strtotime($post['date_gmt']));?>
</span>
</div>
<div class="category">
<span class="cat-btn">Categoría <i class="icon-down-dir"></i></span>
<div class="cat-wrapper">
<ul class="post-categories">
<?php foreach($categories as $cat){?>
<li>
<a href="<?= $cat['link']?>" rel="category tag"><?= $cat['name']?></a>
</li>
<?php }?>
</ul>
</div>
</div>
</div>
<div class="post-title">
<h3 class="entry-title">
<a href="<?= $post['link'] ?>"><?= $post['title']['rendered'] ?></a>
</h3>
</div>
<div class="post-excerpt">
<p>
<?= $post['excerpt']['rendered'] ?>
</p>
</div>
<div class="post-footer">
<div class="button-love">
<span class="love-text">Compartir : </span>
</div>
<div class="button-love">
<a href="https://www.facebook.com/sharer/sharer.php?u=<?= $post['link'] ?>" class="icon_bar icon_bar_facebook icon_bar_small">
<span class="t"><i class="icon-facebook"></i></span><span class="b"><i class="icon-facebook"></i></span></a>
<a href="https://twitter.com/intent/tweet?url=<?= $post['link'] ?>&text=Leer Publicacion: <?php echo $post['title']?>" class="icon_bar icon_bar_twitter icon_bar_small">
<span class="t"><i class="icon-twitter"></i></span><span class="b"><i class="icon-twitter"></i></span></a>
<a href="whatsapp://send?text=Visita %20-%20<?= $post['link'] ?>" class="icon_bar icon_bar_whatsaap icon_bar_small">
<span class="t"><i class="icon-comment-line"></i></span><span class="b"><i class="icon-comment-line"></i></span></a>
</div>
<div class="post-links">
<!-- <i class="icon-comment-empty-fa"></i>
<a href="blog-single-content-builder.html#comments" class="post-comments"></a> -->
<i class="icon-doc-text"></i>
<a href="<?= $post['link'] ?>" class="post-more">Leer más...</a>
</div>
</div>
</div>
</div>
</div>
<?php } else if(!empty($firstVideoURL)){?>
<div class="post format-video has-post-thumbnail category-mobile category-photography tag-css3 tag-zend post-item isotope-item clearfix">
<div class="date_label">
<?php echo date("d-m-Y", strtotime($post['date_gmt']));?>
</div>
<div class="image_frame post-photo-wrapper scale-with-grid">
<div class="image_wrapper">
<div id="jp_container_102" class="jp-video mfn-jcontainer">
<div class="jp-type-single">
<div id="jquery_jplayer_102" class="jp-jplayer mfn-jplayer" data-m4v="<?= $firstVideoURL ?>" data-img="images/blog_html5-576x399.jpg">
</div>
<div class="jp-gui">
<div class="jp-video-play">
<a href="javascript:;" class="jp-video-play-icon" tabindex="1">play</a>
</div>
<div class="jp-interface">
<div class="jp-progress">
<div class="jp-seek-bar">
<div class="jp-play-bar"></div>
</div>
</div>
<div class="jp-current-time"></div>
<div class="jp-duration"></div>
<div class="jp-controls-holder">
<ul class="jp-controls">
<li>
<a href="javascript:;" class="jp-play" tabindex="1">play</a>
</li>
<li>
<a href="javascript:;" class="jp-pause" tabindex="1">pause</a>
</li>
<li>
<a href="javascript:;" class="jp-stop" tabindex="1">stop</a>
</li>
<li>
<a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a>
</li>
<li>
<a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a>
</li>
<li>
<a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a>
</li>
</ul>
<div class="jp-volume-bar">
<div class="jp-volume-bar-value"></div>
</div>
<ul class="jp-toggles">
<li>
<a href="javascript:;" class="jp-full-screen" tabindex="1" title="full screen">full screen</a>
</li>
<li>
<a href="javascript:;" class="jp-restore-screen" tabindex="1" title="restore screen">restore screen</a>
</li>
<li>
<a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat">repeat</a>
</li>
<li>
<a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off">repeat off</a>
</li>
</ul>
</div>
<div class="jp-title">
<ul>
<li>
<a href="<?= $post['link'] ?>"><?= $post['title']['rendered'] ?></a>
</li>
</ul>
</div>
</div>
</div>
<div class="jp-no-solution">
<span>Update Required</span>To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>
</div>
</div>
</div>
</div>
</div>
<div class="post-desc-wrapper">
<div class="post-desc">
<div class="post-meta clearfix">
<div class="author-date">
<span class="author">
<span>Publicado por </span>
<i class="icon-user"></i> <a href="#"><?= $author['name'] ?></a>
</span>
<span class="date"><span>
Fecha </span><i class="icon-clock"></i>
<?php echo date("d-m-Y", strtotime($post['date_gmt']));?>
</span>
</div>
<div class="category">
<span class="cat-btn">Categoría <i class="icon-down-dir"></i></span>
<div class="cat-wrapper">
<ul class="post-categories">
<?php foreach($categories as $cat){?>
<li>
<a href="<?= $cat['link']?>" rel="category tag"><?= $cat['name']?></a>
</li>
<?php }?>
</ul>
</div>
</div>
</div>
<div class="post-title">
<h2 class="entry-title">
<a href="<?= $post['link'] ?>"><?= $post['title']['rendered'] ?></a>
</a></h2>
</div>
<div class="post-excerpt">
<span class="big">
<?= $post['excerpt']['rendered'] ?>
</span>
</div>
<div class="post-footer">
<div class="post-links">
<i class="icon-doc-text"></i>
<a href="<?= $post['link'] ?>" class="post-more">Leer más...</a>
</div>
</div>
</div>
</div>
</div>
<?php }else{?>
<div class="post format-quote tag-css3 tag-design post-item isotope-item clearfix no-img">
<div class="date_label">
<?php echo date("d-m-Y", strtotime($post['date_gmt']));?>
</div>
<div class="image_frame post-photo-wrapper scale-with-grid">
<div class="image_wrapper"></div>
</div>
<div class="post-desc-wrapper">
<div class="post-desc">
<div class="post-meta clearfix">
<div class="author-date">
<span class="author">
<span>Publicado por </span>
<i class="icon-user"></i> <a href="#"><?= $author['name'] ?></a>
</span>
<span class="date">
<span> Fecha </span><i class="icon-clock"></i>
<?php echo date("d-m-Y", strtotime($post['date_gmt']));?>
</span>
</div>
<div class="category">
<span class="cat-btn">Categoría <i class="icon-down-dir"></i></span>
<div class="cat-wrapper">
<ul class="post-categories">
<?php foreach($categories as $cat):?>
<li>
<a href="<?= $cat['link']?>" rel="category tag"><?= $cat['name']?></a>
</li>
<?php endforeach?>
</ul>
</div>
</div>
</div>
<div class="post-title">
<h4 class="entry-title">
<a href="<?= $post['link'] ?>"><?= $post['title']['rendered'] ?></a>
</h4>
</div>
<div class="post-excerpt">
<span class="big">
<?= $post['excerpt']['rendered'] ?>
</span>
</div>
<div class="post-footer">
<div class="post-links">
<i class="icon-comment-empty-fa"></i>
<a href="blog-single-video.html#comments" class="post-comments">0</a>
<i class="icon-doc-text"></i>
<a href="<?= $post['link'] ?>" class="post-more">Leer más...</a>
</div>
</div>
</div>
</div>
</div>
<?php }?>
<?php }?>
</div>
<div class="column one pager_wrapper">
<div class="pager">
<?php
$maxPagesToShow = 8;
$midpoint = ceil($maxPagesToShow / 2);
// Calculate the range of pages to show around the current page
$startPage = max($currentPage - $midpoint, 1);
$endPage = min($startPage + $maxPagesToShow - 1, $totalPages);
if ($startPage === 1) {
$endPage = min($maxPagesToShow, $totalPages);
}
if ($currentPage > 1): ?>
<a class="prev_page" href="?page=<?= ($currentPage - 1) ?><?= $category ? '&category=' . $category : '' ?>">
<i class="icon-left-open"></i> Atras
</a>
<?php endif; ?>
<div class="pages">
<?php
if ($startPage > 1) {
echo '<a href="?page=1' . ($category ? '&category=' . $category : '') . '">1</a>';
if ($startPage > 2) {
echo '<span class="ellipsis">...</span>';
}
}
for ($i = $startPage; $i <= $endPage; $i++): ?>
<a href="?page=<?= $i ?><?= $category ? '&category=' . $category : '' ?>" class="<?= $currentPage == $i ? 'active' : '' ?>">
<?= $i ?>
</a>
<?php endfor;
if ($endPage < $totalPages) {
if ($endPage < $totalPages - 1) {
echo '<span class="ellipsis">...</span>';
}
echo '<a href="?page=' . $totalPages . ($category ? '&category=' . $category : '') . '">' . $totalPages . '</a>';
} ?>
</div>
<?php if ($currentPage < $totalPages): ?>
<a class="next_page" href="?page=<?= ($currentPage + 1) ?><?= $category ? '&category=' . $category : '' ?>">
Siguiente <i class="icon-right-open"></i>
</a>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>