<?php
$oldIndex = $pagesCount+1;
?>
<div id="pageSmoothBackground" style="background-image: url(<?= $randomPoint->getImg('middle') ?>);"></div>

<div class="container" style="background-color: rgba(255,255,255, 0.8);margin-top: -10px;padding-bottom: 30px;">
	<div class="row">
		<div class="col-md-12">
			<h1 style="text-align: right;">Лента статей</h1>
			<div class="coords-container">
				Перейти: <a href="/">на карту</a> или <a href="/page/points">к точкам</a>
			</div>
			<div style="text-align: justify;">
				<div class="pointsWall">
					<?php foreach ($articles as $article): ?>
					<a href="/article/<?= $article['id'] ?>">
						<div style="background-image: url('<?= $article['photoId']>0?$article['img']:'/img/no-background.png' ?>');" class="point">
							<span class="header">
								<?= $article['title'] ?>
							</span>
							<?php if($article['photoId'] == 0): ?>
							<div>
								<?= $article['text'] ?>… <nobr>читать далее »</nobr>
							</div>
							<?php endif; ?>
						</div>
					</a>
					<?php endforeach; ?>
				</div>
			</div>
		</div>
	</div>
	<?php if ($pagesCount > 1):?>
	<nav>
		<ul class="pagination">
			<li class="<?= ($page >= $pagesCount) ? 'disabled' : '' ?>">
				<a href="<?= ($page >= $pagesCount) ? '#' : '?page='.($page+1) ?>" aria-label="Previous">
					<span aria-hidden="true">&laquo;</span>
				</a>
			</li>
			<?php foreach ($pages as $index => $val): ?>
				<?php if ($oldIndex-$index != 1):?>
					<li><a href="?page=<?= $index + ceil(($oldIndex-$index)/2) ?>" style="<?= $index==$page ? 'background-color: #eeeeed;' : '' ?>">...</a></li>
				<?php endif; ?>
			<li><a href="?page=<?= $index ?>" style="<?= $index==$page ? 'background-color: #eeeeed;' : '' ?>"><?= $index ?></a></li>
			<?php $oldIndex = $index; ?>
			<?php endforeach; ?>
			<li class="<?= ($page <= 1) ? 'disabled' : '' ?>">
				<a href="<?= ($page <= 1) ? '#' : '?page='.($page-1) ?>" aria-label="Next">
					<span aria-hidden="true">&raquo;</span>
				</a>
			</li>
		</ul>
	</nav>
	<?php else: ?>
	<br/>
	<?php endif; ?>
	<div class="row">
		<div class="col-md-12" style="text-align: center;">
			<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
			<!-- Point - DOWN -->
			<ins class="adsbygoogle"
				 style="display:block"
				 data-ad-client="ca-pub-0069680015252793"
				 data-ad-slot="4972494746"
				 data-ad-format="auto"></ins>
			<script>
			(adsbygoogle = window.adsbygoogle || []).push({});
			</script>
		</div>
	</div>
	<hr/>
	<?= self::renderPartial('randomPoint.php', array('randomPoint'=>$randomPoint), true)?>
</div>
