ADD top5 authors

This commit is contained in:
Krivchikov Dmitry 2016-04-08 15:41:30 +03:00
parent 8345e5029e
commit 894f7bc5a3
3 changed files with 29 additions and 1 deletions

View File

@ -51,9 +51,17 @@ class FeedController extends Controller
}
// --------- SORT
krsort($feed);
// --------- AUTHORS
$authors = array();
$authorIds = App::DB()->query('SELECT `author` , COUNT( * ) `cnt` FROM `points` GROUP BY `author` ORDER BY `cnt` DESC LIMIT 0 , 6')->fetchAll(PDO::FETCH_ASSOC);
foreach ($authorIds as $authorId) {
$author = User::model()->getByPK($authorId['author']);
$author->pointsCount = $authorId['cnt'];
$authors[] =$author;
}
self::$layout = 'layouts/page.php';
self::addScript('/js/jquery-2.1.0.min.js');
self::addScript('/js/jquery-ui-1.10.4.custom.min.js');
@ -70,6 +78,7 @@ class FeedController extends Controller
'news' => $news,
'articles' => $articles,
'points' => $points,
'authors' => $authors,
));
}
}

View File

@ -88,6 +88,7 @@ nav.navbar.navbar-inverse .navbar-nav>li>a {color: #ddd;}
nav.navbar.navbar-inverse .navbar-nav>li.important {background-color: #3c3c3c;}
span.notifications {font-weight: bolder; color: red;}
div.top5authors {width: 16.66666667%; float: left; display: inline-block;}
/*BOX*/
body.openBox div#box {display: block; z-index: 100; overflow-y: scroll;overflow-x: hidden;}
@ -148,6 +149,8 @@ img.imageInArticle {border: solid 3px white;max-width: 100%;}
padding: 3px!important;
margin: 0!important;
}
div.top5authors {width: 33.33333334%;}
h4.top5authors {text-align: center;}
}
@media screen and (max-width:815px) {
@ -179,4 +182,6 @@ img.imageInArticle {border: solid 3px white;max-width: 100%;}
div.container.feed div.row.elements div.element {width: 100%;}
div.container.feed div.row.elements div.element a.imgContainer {margin: 0 0 10px 0; display: block; width: 100%;text-align: center;}
div.container.feed div.row.elements div.element a img.elementImg {margin: 0; display: inline;max-width: 100%; float: none;}
div.top5authors {width: 50%;}
}

View File

@ -1,5 +1,19 @@
<div id="pageSmoothBackground" style="background-image: url(<?= current($points)->getImg('middle') ?>);"></div>
<div class="container feed">
<div class="row elements">
<div class="col-md-12">
<h4 class="top5authors">Самые активные авторы</h4>
<?php foreach ($authors as $author):?>
<div class="top5authors text-center">
<a href="/user/<?= $author->id;?>">
<img src="/img/avatars/<?= $author->id;?>.jpg"><br/>
<nobr><b><?= $author->nick;?></b> [<?= $author->pointsCount;?>]</nobr>
</a><br/>
</div>
<?php endforeach;?>
</div>
</div>
<hr class="onlySmallScreen"/>
<div class="row elements">
<div class="col-md-2">
<h4 class="onlySmallScreen text-center">Новости</h4>