This commit is contained in:
Krivchikov Dmitry 2015-10-17 19:51:01 +03:00
parent 55fcd7c39b
commit 6c4a89faa9
3 changed files with 31 additions and 11 deletions

View File

@ -22,6 +22,7 @@ class FeedController extends Controller
// --------- POINTS // --------- POINTS
$points = Point::model()->getAll(array( $points = Point::model()->getAll(array(
'where' => '`moderate` = 1',
'order' => '`date` DESC', 'order' => '`date` DESC',
'limit' => 5, 'limit' => 5,
)); ));
@ -36,6 +37,7 @@ class FeedController extends Controller
// --------- ARTICLES // --------- ARTICLES
$articles = Article::model()->getAll(array( $articles = Article::model()->getAll(array(
'where' => '`status` = "published"',
'order' => '`id` DESC', 'order' => '`id` DESC',
'limit' => 5, 'limit' => 5,
)); ));

View File

@ -31,4 +31,17 @@ class Article extends Model
return $size == 'small' ? '/img/noPhoto200150.png' : '/img/logo.png'; return $size == 'small' ? '/img/noPhoto200150.png' : '/img/logo.png';
} }
public function hasImg()
{
$imgId = (int)$this->photoId;
if ($imgId) {
$img = ArticlePhotos::model()->getByPK($imgId);
if ($img) {
return TRUE;
}
}
return FALSE;
}
} }

View File

@ -7,31 +7,36 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-2"> <div class="col-md-2">
<h2>Новости</h2>
<?php foreach ($news as $item) : ?> <?php foreach ($news as $item) : ?>
<div style="margin: 3px; padding: 3px; border: solid 1px #999;"> <div style="margin: 3px; padding: 3px">
<h4><?= $item->title ?></h4> <h4><?= $item->title ?></h4>
<?= mb_substr($item->text, 0, 400, 'UTF-8') ?> <?= mb_substr($item->text, 0, 400, 'UTF-8') ?>
</div> </div>
<?php endforeach;?> <?php endforeach;?>
</div> </div>
<div class="col-md-5"> <div class="col-md-5">
<h2>Точки</h2>
<?php foreach ($points as $item) : ?> <?php foreach ($points as $item) : ?>
<div style="margin: 3px; padding: 3px; border: solid 1px #999;"> <div style="margin: 3px; padding: 3px">
<h4><?= $item->name ?></h4> <a href="/article/<?= $item->id ?>">
<img src="<?= $item->getImg() ?>" style="width: 200px; margin: 0 10px 5px 0;"/><br/> <h4><?= $item->name ?></h4>
<?= mb_substr($item->description, 0, 400, 'UTF-8') ?> </a>
<img src="<?= $item->getImg() ?>" style="width: 200px; float: left; margin: 0 10px 5px 0;"/>
<?= mb_substr($item->description, 0, 400, 'UTF-8') ?>
<a href="/article/<?= $item->id ?>">&gt;&gt;&gt;</a>
</div> </div>
<?php endforeach;?> <?php endforeach;?>
</div> </div>
<div class="col-md-5"> <div class="col-md-5">
<h2>Статьи</h2>
<?php foreach ($articles as $item) : ?> <?php foreach ($articles as $item) : ?>
<div style="margin: 3px; padding: 3px; border: solid 1px #999;"> <div style="margin: 3px; padding: 3px">
<h4><?= $item->title ?></h4> <a href="/article/<?= $item->id ?>">
<h4><?= $item->title ?></h4>
</a>
<?php if($item->hasImg()): ?>
<img src="<?= $item->getImg() ?>" style="width: 200px; float: left; margin: 0 10px 5px 0;"/> <img src="<?= $item->getImg() ?>" style="width: 200px; float: left; margin: 0 10px 5px 0;"/>
<?= mb_substr($item->text, 0, 400, 'UTF-8') ?> <?php endif; ?>
<?= mb_substr(Markdown::getClear($item->text), 0, 400, 'UTF-8') ?>
<a href="/article/<?= $item->id ?>">&gt;&gt;&gt;</a>
<div style="clear: both;"></div> <div style="clear: both;"></div>
</div> </div>
<?php endforeach;?> <?php endforeach;?>