<?php
$statuses = array(
	'draft' => 'Черновик',
	'published' => 'Опублована',
	'system' => 'Системная',
	'moderation' => 'На модерации',
	'del' => 'Удалена',
);
?><div id="pageSmoothBackground" style="background-image: url(<?= $randomPoint->getImg('middle') ?>);"></div>
<div class="container darkHeader">
	<div class="topDiv">
		Персональный блог пользователя
	</div>
	<div class="userPic">
		<img src="/img/avatars/<?= $user->id ?>.jpg"> <?= $user->nick ?>
	</div>
	<div class="socialNetworks">
		В социальных сетях: <a href="<?= $user->profile ?>" target="_blank"><img src="/img/social/<?= $user->network ?>.png" /></a>
		<br/><br/>
		Создано точек: <b><a href="/page/points/user/<?= $user->id ?>" class="toPoints"><?= $user->getPointsCount() ?></a></b>
	</div>
</div>
<div class="container lightBody">
	<div class="row">
		<div class="col-md-12 articlesList">
			<h2>
				<?php if ($imAuthor) : ?>
					<a href="/article/new/" class="pull-right btn btn-success"><span class="glyphicon glyphicon-plus"></span> Новая запись</a>
				<?php endif; ?>
				Записи:
			</h2>

			<?php if ($articles): foreach ($articles as $article): ?>
					<div class="article">
						<a href="/article/<?= $article->id ?>" target="_blank" class="h">
							<?php if ($article->photoId): ?>
								<img src="<?= $article->getImg() ?>" />
							<?php else: ?>
								<img src="/img/noPhoto200150.png" />
							<?php endif; ?>
						</a>
						<div class="pull-right date"><?= date('H:i | d.m.Y',$article->pubDate) ?></div>
						<a href="/article/<?= $article->id ?>" target="_blank" class="h"><?= $article->title ?><?= $article->status != 'published' ? ' - ['.$statuses[$article->status].']' : '' ?></a>
						<?= mb_substr(Markdown::getClear(str_replace('"', 'ʺ', $article->text)), 0, 250, 'UTF-8') ?>…
						<?php if ($imAuthor) : ?>
							<br/>
							<a href="/article/edit/id/<?= $article->id ?>" title="Редактировать" class="pull-right btn btn-sm btn-info"><span class="glyphicon glyphicon-pencil"></span></a>
							<a href="/article/del/id/<?= $article->id ?>" onclick="return confirm('Удалить запись?')" title="Удалить" class="pull-right btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
						<?php endif; ?>
						<div class="clear"></div>
					</div>
				<?php endforeach; ?>
			<?php else: ?>
				В блоге пока пусто.
			<?php endif; ?>

		</div>
	</div>

	<?php if ($photos): ?>
	<div class="row">
		<div class="col-md-12 photoList">
			<h2>Фотолента:</h2>
			<div style="text-align: center;">
					<?php foreach ($photos as $photo): ?>
						<div class="photo">
							<img src="/photos/articles/small/<?= $photo->name ?>" />
						</div>
					<?php endforeach; ?>
			</div>
		</div>
	</div>
	<?php endif; ?>

	<hr style="margin-bottom: 25px;"/>
	<?= self::renderPartial('randomPoint.php', array('randomPoint'=>$randomPoint), true)?>
</div>
