На странице пользователя вывел кусочек фотоленты

This commit is contained in:
Krivchikov Dmitry 2015-09-25 17:56:59 +03:00
parent dcfe9258c7
commit ab04c51680
4 changed files with 52 additions and 18 deletions

View File

@ -43,9 +43,12 @@ class UserController extends Controller
$randomPoint->description = mb_substr($randomPoint->description, 0, 400, 'UTF-8'); $randomPoint->description = mb_substr($randomPoint->description, 0, 400, 'UTF-8');
$randomPoint->description = Helper::replaceLinks($randomPoint->description); $randomPoint->description = Helper::replaceLinks($randomPoint->description);
$photos = ArticlePhotos::model()->getByUser($id, 5);
self::render('user/index.php', array( self::render('user/index.php', array(
'user' => $user, 'user' => $user,
'articles' => $articles, 'articles' => $articles,
'photos' => $photos,
'imAuthor' => App::$user && App::$user->id == $id, 'imAuthor' => App::$user && App::$user->id == $id,
'randomPoint' => $randomPoint, 'randomPoint' => $randomPoint,
)); ));

View File

@ -15,4 +15,16 @@ class ArticlePhotos extends Model
return new self(); return new self();
} }
function getByUser($userId, $limit = 0)
{
$params = array(
'where' => '`owner` = '.(int)$userId,
);
if ($limit > 0) {
$params['limit'] = (int) $limit;
}
return $this->getAll($params);
}
} }

View File

@ -16,28 +16,44 @@
<div class="row"> <div class="row">
<div class="col-md-12 articlesList"> <div class="col-md-12 articlesList">
<h2>Статьи: </h2> <h2>Записи: </h2>
<?php if ($articles): foreach ($articles as $article): ?> <?php if ($articles): foreach ($articles as $article): ?>
<div class="article"> <div class="article">
<a href="/article/<?= $article->id ?>" target="_blank" class="h"> <a href="/article/<?= $article->id ?>" target="_blank" class="h">
<?php if($article->photoId): ?> <?php if ($article->photoId): ?>
<img src="<?= $article->getImg() ?>" /> <img src="<?= $article->getImg() ?>" />
<?php else: ?> <?php else: ?>
<img src="/img/noPhoto200150.png" /> <img src="/img/noPhoto200150.png" />
<?php endif; ?> <?php endif; ?>
</a> </a>
<a href="/article/<?= $article->id ?>" target="_blank" class="h"><?= $article->title ?></a> <a href="/article/<?= $article->id ?>" target="_blank" class="h"><?= $article->title ?></a>
<?= mb_substr(Markdown::getClear(str_replace('"', 'ʺ', $article->text)), 0, 250, 'UTF-8') ?> <?= mb_substr(Markdown::getClear(str_replace('"', 'ʺ', $article->text)), 0, 250, 'UTF-8') ?>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
<?php endforeach; <?php endforeach; ?>
else: ?> <?php else: ?>
Пока нет статей. В блоге пока пусто.
<?php endif;?> <?php endif; ?>
</div> </div>
</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: 50px;"/> <hr style="margin-bottom: 50px;"/>
<!--googleoff: all--> <!--googleoff: all-->
<!--noindex--> <!--noindex-->

View File

@ -11,3 +11,6 @@
.articlesList .article {border: solid 1px #ddd; border-radius: 3px; padding: 4px; margin-bottom: 5px;background-color: rgba(255,255,255, 0.8);} .articlesList .article {border: solid 1px #ddd; border-radius: 3px; padding: 4px; margin-bottom: 5px;background-color: rgba(255,255,255, 0.8);}
.articlesList .article img {width: 100px; float: left; margin-right: 10px;} .articlesList .article img {width: 100px; float: left; margin-right: 10px;}
.articlesList .article .h {font-size: 18px; font-weight: bold; display: block;} .articlesList .article .h {font-size: 18px; font-weight: bold; display: block;}
.photoList {}
.photoList .photo {display: inline-block; border: solid 3px #fff; margin: 3px;}