* along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
*
*/
+$currentGetParameters['p'] = 'overview';
+
$_requestMode = false;
if(isset($_GET['m']) && !empty($_GET['m'])) {
$_requestMode = trim($_GET['m']);
- $_requestMode = Summoner::validate($_requestMode,'nospace') ? $_requestMode : "all";
+ $_requestMode = Summoner::validate($_requestMode,'nospace') ? $_requestMode : false;
}
$_id = false;
$_id = trim($_GET['id']);
$_id = Summoner::validate($_id,'digit') ? $_id : false;
}
+
$_curPage = 1;
if(isset($_GET['page']) && !empty($_GET['page'])) {
$_curPage = trim($_GET['page']);
$_curPage = Summoner::validate($_curPage,'digit') ? $_curPage : 1;
}
+$_sort = false;
+if(isset($_GET['s']) && !empty($_GET['s'])) {
+ $_sort = trim($_GET['s']);
+ $_sort = Summoner::validate($_sort,'nospace') ? $_sort : false;
+}
+
+$_sortDirection = false;
+if(isset($_GET['sd']) && !empty($_GET['sd'])) {
+ $_sortDirection = trim($_GET['sd']);
+ $_sortDirection = Summoner::validate($_sortDirection,'nospace') ? $_sortDirection : false;
+}
+
$linkCollection = array();
$subHeadline = false;
$tagCollection = array();
$pagination = array('pages' => 0);
$displayEditButton = false;
$isAwm = false;
+$sortLink = array();
if(Summoner::simpleAuthCheck() === true) {
$displayEditButton = true;
}
+$sortLink['active'] = 'default';
+$sortLink['activeDirection'] = false;
+
+if(!empty($_sort) && $_sort === 'name') {
+ $currentGetParameters['s'] = 'name';
+ $sortLink['active'] = 'name';
+}
+if(!empty($_sortDirection) && $_sortDirection === 'asc') {
+ $currentGetParameters['sd'] = 'asc';
+ $sortLink['activeDirection'] = true;
+}
+
switch($_requestMode) {
case 'tag':
+ $currentGetParameters['m'] = 'tag';
if(!empty($_id)) {
$tagObj = new Tag($DB);
$tagObj->initbyid($_id);
$subHeadline = $tagname.' <i class="ion-md-pricetag"></i>';
$linkCollection = $Management->linksByTag($_id,false,RESULTS_PER_PAGE, (RESULTS_PER_PAGE * ($_curPage-1)));
+
+ $currentGetParameters['id'] = $_id;
}
else {
# show all the tags we have
}
break;
case 'category':
+ $currentGetParameters['m'] = 'category';
if(!empty($_id)) {
$catObj = new Category($DB);
$catObj->initbyid($_id);
$catname = $catObj->getData('name');
$subHeadline = $catname.' <i class="ion-md-filing"></i>';
+
$linkCollection = $Management->linksByCategory($_id,false,RESULTS_PER_PAGE, (RESULTS_PER_PAGE * ($_curPage-1)));
+
+ $currentGetParameters['id'] = $_id;
}
else {
# show all the categories we have
}
break;
case 'awm':
+ $currentGetParameters['m'] = 'awm';
Summoner::simpleAuth();
$isAwm = true;
$subHeadline = 'Awaiting moderation';
$Management->setShowAwm(true);
+
$linkCollection = $Management->links(RESULTS_PER_PAGE, (RESULTS_PER_PAGE * ($_curPage-1)));
break;
case 'all':
# show all
$linkCollection = $Management->links(RESULTS_PER_PAGE, (RESULTS_PER_PAGE * ($_curPage-1)));
}
+
if(!empty($linkCollection['amount'])) {
$pagination['pages'] = ceil($linkCollection['amount'] / RESULTS_PER_PAGE);
$pagination['curPage'] = $_curPage;
- $pagination['linkadd'] = '&m='.$_requestMode;
- if(!empty($_id)) {
- $pagination['linkadd'] .= '&id='.$_id;
- }
+
+ $currentGetParameters['page'] = $_curPage;
}
if($pagination['pages'] > 11) {
else {
$pagination['visibleRange'] = range(1,$pagination['pages']);
}
+
+$sortLink['default'] = Summoner::createFromParameterLinkQuery($currentGetParameters,array('s'=>false,'sd'=>false));
+$sortLink['name'] = Summoner::createFromParameterLinkQuery($currentGetParameters,array('s'=>'name','sd'=>false));
+$sortLink['direction'] = Summoner::createFromParameterLinkQuery($currentGetParameters,array('sd'=>'asc'));
\ No newline at end of file
</div>
</div>
- <?php if($pagination['pages'] > 1) { ?>
- <nav class="pagination is-centered" role="navigation" aria-label="pagination">
- <?php if($pagination['curPage'] > 1) {
- echo '<a href="index.php?p=overview'.$pagination['linkadd'].'&page='.($pagination['curPage']-1).'"
- class="pagination-previous">Previous</a>';
- }
- if($pagination['curPage'] < $pagination['pages']) {
- echo '<a href="index.php?p=overview'.$pagination['linkadd'].'&page='.($pagination['curPage']+1).'"
- class="pagination-next">Next</a>';
- }
- ?>
- <ul class="pagination-list">
- <?php
- $ellipsisShown = 0;
- for($i=1;$i<=$pagination['pages'];$i++) {
- $active = '';
- if($i == $pagination['curPage']) $active = 'is-current';
+ <div class="columns">
+ <div class="column is-half">
+ <?php if($pagination['pages'] > 1) { ?>
+ <nav class="pagination is-small" role="navigation" aria-label="pagination">
+ <?php if($pagination['curPage'] > 1) {
+ echo '<a href="index.php?'.Summoner::createFromParameterLinkQuery($currentGetParameters,array('page'=>($pagination['curPage']-1))).'"
+ class="pagination-previous">Previous</a>';
+ }
+ if($pagination['curPage'] < $pagination['pages']) {
+ echo '<a href="index.php?'.Summoner::createFromParameterLinkQuery($currentGetParameters,array('page'=>($pagination['curPage']+1))).'"
+ class="pagination-next">Next</a>';
+ }
+ ?>
+ <ul class="pagination-list">
+ <?php
+ $ellipsisShown = 0;
+ for($i=1;$i<=$pagination['pages'];$i++) {
+ $active = '';
+ if($i == $pagination['curPage']) $active = 'is-current';
- if(in_array($i,$pagination['visibleRange'])) {
- echo '<li><a href="index.php?p=overview' . $pagination['linkadd'] . '&page=' . $i . '"
- class="pagination-link ' . $active . '"
- aria-label="Goto page ' . $i . '">' . $i . '</a></li>';
- }
- else {
- if($i < $pagination['currentRangeStart'] && $ellipsisShown == 0) {
- echo '<li><span class="pagination-ellipsis">…</span></li>';
- $ellipsisShown = 1;
- }
- if($i > $pagination['currentRangeEnd'] && ($ellipsisShown == 0 || $ellipsisShown == 1)) {
- echo '<li><span class="pagination-ellipsis">…</span></li>';
- $ellipsisShown = 2;
- }
- }
- }
- ?>
- </ul>
- </nav>
- <?php } ?>
+ if(in_array($i,$pagination['visibleRange'])) {
+ echo '<li><a href="index.php?'.Summoner::createFromParameterLinkQuery($currentGetParameters,array('page'=>$i)).'"
+ class="pagination-link ' . $active . '"
+ aria-label="Goto page ' . $i . '">' . $i . '</a></li>';
+ }
+ else {
+ if($i < $pagination['currentRangeStart'] && $ellipsisShown == 0) {
+ echo '<li><span class="pagination-ellipsis">…</span></li>';
+ $ellipsisShown = 1;
+ }
+ if($i > $pagination['currentRangeEnd'] && ($ellipsisShown == 0 || $ellipsisShown == 1)) {
+ echo '<li><span class="pagination-ellipsis">…</span></li>';
+ $ellipsisShown = 2;
+ }
+ }
+ }
+ ?>
+ </ul>
+ </nav>
+ <?php } ?>
+ </div>
+ <div class="column is-half">
+ <div class="is-pulled-right">
+ <a href="index.php?<?php echo $sortLink['default']; ?>"
+ class="button is-small <?php if($sortLink['active'] === 'default') { ?>is-link<?php } ?>">default</a>
+ <a href="index.php?<?php echo $sortLink['name']; ?>"
+ class="button is-small <?php if($sortLink['active'] === 'name') { ?>is-link<?php } ?>">name</a>
+ <a href="index.php?<?php echo $sortLink['direction']; ?>"
+ class="button is-small <?php if($sortLink['activeDirection'] === true) { ?>is-link<?php } ?>"><span class="icon"><i class="ion-md-arrow-dropup"></i></span></a>
+ </div>
+ </div>
+ </div>
</section>
<section class="section">