mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-09-01 18:58:56 +00:00
Change ordering in all->groups menu to order by group name, remove extra ordering code.
This commit is contained in:
@@ -34,37 +34,16 @@ class Groups
|
||||
/**
|
||||
* Get all group rows.
|
||||
*/
|
||||
public function getAll($orderby = null)
|
||||
public function getAll()
|
||||
{
|
||||
$order = ($orderby == null) ? 'name_desc' : $orderby;
|
||||
$orderArr = explode("_", $order);
|
||||
switch ($orderArr[0]) {
|
||||
case 'name':
|
||||
$orderfield = 'groups.name';
|
||||
break;
|
||||
case 'description':
|
||||
$orderfield = 'groups.description';
|
||||
break;
|
||||
case 'releases':
|
||||
$orderfield = 'num_releases';
|
||||
break;
|
||||
case 'updated':
|
||||
$orderfield = 'groups.last_updated';
|
||||
break;
|
||||
default:
|
||||
$orderfield = 'groups.name';
|
||||
break;
|
||||
}
|
||||
$ordersort = (isset($orderArr[1]) && preg_match('/^asc|desc$/i', $orderArr[1])) ? $orderArr[1] : 'desc';
|
||||
$orderby = $orderfield . " " . $ordersort;
|
||||
|
||||
|
||||
return $this->pdo->query(sprintf("SELECT groups.*, COALESCE(rel.num, 0) AS num_releases
|
||||
FROM groups
|
||||
LEFT OUTER JOIN
|
||||
( SELECT groupid, COUNT(id) AS num FROM releases group by groupid ) rel ON rel.groupid = groups.id
|
||||
ORDER BY %s", $orderby
|
||||
)
|
||||
return $this->pdo->query(
|
||||
"SELECT groups.*,
|
||||
COALESCE(rel.num, 0) AS num_releases
|
||||
FROM groups
|
||||
LEFT OUTER JOIN
|
||||
(SELECT groupid, COUNT(id) AS num FROM releases GROUP BY groupid) rel
|
||||
ON rel.groupid = groups.id
|
||||
ORDER BY groups.name"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
require_once(WWW_DIR."/lib/groups.php");
|
||||
if (!$users->isLoggedIn()) {
|
||||
$page->show403();
|
||||
}
|
||||
|
||||
$groups = new Groups(['Settings' => $page->settings]);
|
||||
|
||||
$grouplist = $groups->getAll();
|
||||
$page->smarty->assign('results', $grouplist);
|
||||
|
||||
$page->meta_title = "Browse Groups";
|
||||
$page->meta_keywords = "browse,groups,description,details";
|
||||
$page->meta_description = "Browse groups";
|
||||
|
||||
$page->content = $page->smarty->fetch('browsegroup.tpl');
|
||||
$page->render();
|
||||
@@ -1,34 +1,31 @@
|
||||
|
||||
<h1>Browse Groups</h1>
|
||||
|
||||
|
||||
{$site->adbrowse}
|
||||
|
||||
{if $results|@count > 0}
|
||||
|
||||
<table style="width:100%;" class="data highlight" id="browsetable">
|
||||
<tr>
|
||||
<th>name<br/><a title="Sort Descending" href="{$orderbyname_desc}"><img src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_down.gif" alt="Sort Descending" /></a><a title="Sort Ascending" href="{$orderbyname_asc}"><img src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_up.gif" alt="Sort Ascending" /></a></th>
|
||||
<th>description<br/><a title="Sort Descending" href="{$orderbydescription_desc}"><img src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_down.gif" alt="Sort Descending" /></a><a title="Sort Ascending" href="{$orderbydescription_asc}"><img src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_up.gif" alt="Sort Ascending" /></a></th>
|
||||
<th>updated<br/><a title="Sort Descending" href="{$orderbyupdated_desc}"><img src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_down.gif" alt="Sort Descending" /></a><a title="Sort Ascending" href="{$orderbyupdated_asc}"><img src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_up.gif" alt="Sort Ascending" /></a></th>
|
||||
<th>releases<br/><a title="Sort Descending" href="{$orderbyreleases_desc}"><img src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_down.gif" alt="Sort Descending" /></a><a title="Sort Ascending" href="{$orderbyreleases_asc}"><img src="{$smarty.const.WWW_TOP}/templates/nntmux/images/sorting/arrow_up.gif" alt="Sort Ascending" /></a></th>
|
||||
</tr>
|
||||
|
||||
{foreach from=$results item=result}
|
||||
{if $result.num_releases > 0}
|
||||
<tr class="{cycle values=",alt"}">
|
||||
<td>
|
||||
<a title="Browse releases from {$result.name|replace:"alt.binaries":"a.b"}" href="{$smarty.const.WWW_TOP}/browse?g={$result.name}">{$result.name|replace:"alt.binaries":"a.b"}</a>
|
||||
</td>
|
||||
<td>
|
||||
{$result.description}
|
||||
</td>
|
||||
<td class="less">{$result.last_updated|timeago} ago</td>
|
||||
<td class="less">{$result.num_releases}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
</table>
|
||||
|
||||
{if $site->adbrowse}
|
||||
{$site->adbrowse}
|
||||
{/if}
|
||||
<h1>Browse Groups</h1>
|
||||
{if $results|@count > 0}
|
||||
<table style="width:100%;" class="data highlight Sortable" id="browsetable">
|
||||
<tr>
|
||||
<th>name</th>
|
||||
<th>description</th>
|
||||
<th>updated</th>
|
||||
<th>releases</th>
|
||||
</tr>
|
||||
|
||||
{foreach from=$results item=result}
|
||||
{if $result.num_releases > 0}
|
||||
<tr class="{cycle values=",alt"}">
|
||||
<td>
|
||||
<a title="Browse releases from {$result.name|replace:"alt.binaries":"a.b"}" href="{$smarty.const.WWW_TOP}/browse?g={$result.name}">{$result.name|replace:"alt.binaries":"a.b"}</a>
|
||||
</td>
|
||||
<td>
|
||||
{$result.description}
|
||||
</td>
|
||||
<td class="less">{$result.last_updated|timeago} ago</td>
|
||||
<td class="less">{$result.num_releases}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
</table>
|
||||
|
||||
{/if}
|
||||
Reference in New Issue
Block a user