Skip to content

Commit

Permalink
Adding a sort by recency to the community page
Browse files Browse the repository at this point in the history
  • Loading branch information
okvivi committed Nov 20, 2012
1 parent 0f1a6b1 commit 523ad26
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
4 changes: 3 additions & 1 deletion www/hooks/add_new_link.php
Expand Up @@ -58,7 +58,9 @@ function addLinkToNewsQueue($link, $uid, $userDisplayName, $origin) {


if (addLinkToNewsQueue($link, $uid, $userDisplayName, $origin)) {
echo "Link-ul este acum în coada de moderare. <br>Poți verifica statusul " .
echo "Link-ul este acum în coada de moderare. ".
"Aprobarea durează <b>maxim 5 minute</b>.".
"<br>Poți verifica statusul " .
"resurselor trimise de tine pe " .
"<a href='/?cid=profile'>pagina ta de profil</a>";
} else {
Expand Down
8 changes: 6 additions & 2 deletions www/hp-includes/news.php
Expand Up @@ -282,7 +282,7 @@ function extractDomainFromLink($link) {
* @return unknown_type
*/
function getMostRecentUgcLinks($count, $restrict_to_ids=NULL, $uid=0,
$since=0, $linkId=NULL) {
$since=0, $linkId=NULL, $order_by=NULL) {
$where_clause = '';
if ($restrict_to_ids) {
$ids = implode(",", $restrict_to_ids);
Expand All @@ -298,6 +298,10 @@ function getMostRecentUgcLinks($count, $restrict_to_ids=NULL, $uid=0,
$where_clause = "AND a.id = {$linkId}";
}

if (!$order_by) {
$order_by = "a.score DESC, a.votes DESC, a.time DESC";
}

$s = mysql_query("
SELECT
a.id, a.title, a.link, a.time, a.place, a.photo, p.idperson,
Expand All @@ -309,7 +313,7 @@ function getMostRecentUgcLinks($count, $restrict_to_ids=NULL, $uid=0,
{$where_clause}
{$user_restrict}
GROUP BY a.id
ORDER BY a.score DESC, a.votes DESC, a.time DESC
ORDER BY {$order_by}
LIMIT 0, $count");

$news = array();
Expand Down
3 changes: 2 additions & 1 deletion www/my_account.php
Expand Up @@ -52,7 +52,8 @@ function getMostRecentNewPeople() {

$t->assign('followed_people', followedPeopleAsArray());

$t->assign('links', getMostRecentUgcLinks(100, NULL, $uid));
$t->assign('links', getMostRecentUgcLinks(30, NULL, $uid, 0, NULL,
"a.time DESC"));

$t->display('my_account_summary.tpl');

Expand Down
10 changes: 9 additions & 1 deletion www/pages/misc/community.php
Expand Up @@ -29,7 +29,15 @@
$people_restrict = NULL;
}

$t->assign('news', getMostRecentUgcLinks(30, $people_restrict, 0));
if (isSet($_GET["sort"])) {
$t->assign('news', getMostRecentUgcLinks(30, $people_restrict, 0,
0, NULL, "a.time DESC"));
$t->assign('sort', 'time');
} else {
$t->assign('news', getMostRecentUgcLinks(30, $people_restrict, 0));
}



$t->display('pages_misc_community.tpl');
}
Expand Down
2 changes: 1 addition & 1 deletion www/styles.css
Expand Up @@ -339,7 +339,7 @@ body {
}

.recent_news_block .black_link a:visited {
color: #999;
color: #666;
}

.news_list_mention {
Expand Down
11 changes: 10 additions & 1 deletion www/templates/pages_misc_community.tpl
Expand Up @@ -10,7 +10,16 @@
<div class="big">
<b>Resurse adăugate și votate de comunitatea Hărții Politicii</b>
</div>
<br>

<span class="gray">Ordonează după</span>:
{if $sort=='time'}
<a href="/?cid=comunitate">număr voturi</a> |
recență
{else}
număr voturi |
<a href="/?cid=comunitate&sort=1">recență</a>
{/if}
<br><br>
<div class="bigger_news_list">
{include file="news_list_ugc.tpl" news=$news}
</div>
Expand Down

0 comments on commit 523ad26

Please sign in to comment.