Skip to content
This repository has been archived by the owner on Jul 15, 2020. It is now read-only.

Commit

Permalink
rex_asd_pager, CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Schlegel committed Sep 23, 2014
1 parent 18f7b5e commit a547152
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 7 deletions.
2 changes: 2 additions & 0 deletions classes/rex_asd_news.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ class rex_asd_news
public static $SEO_ADDON = null;
public static $SEO_URL_CONTROL = false;

/** @var rex_sql $sql */
public $sql;


public static $month_de = array(
1 => 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni',
'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'
Expand Down
57 changes: 57 additions & 0 deletions classes/rex_asd_pager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

class rex_asd_pager extends rex_pager
{
private $rowCount;
private $rowsPerPage;
private $cursorName;

public function __construct($rowsPerPage = 30, $cursorName = 'page')
{
parent::__construct($rowsPerPage, $cursorName);

$this->cursorName = $cursorName;
$this->rowsPerPage = $rowsPerPage;
}

/**
* Returns the number of the current page
* @return int The current page number
*/
public function getCurrentPage()
{
return rex_request($this->cursorName, 'int', 0);
}

public function filterList($list)
{
global $REX;

$currentPage = $this->getCursor();
$startNews = $this->getCursor($currentPage);

if (count($list) > $startNews) {
while (key($list) < $startNews) {
unset($list[key($list)]);
}
reset($list);
}

$newList = array();
$list = array_values($list);

array_map(function ($value) use ($REX, &$newList) {

if (count($newList) < $REX['ADDON']['asd_news']['config']['max-per-page']) {
$newList[] = $value;
}
return $value;

}, $list);

return $newList;

}
}

?>
1 change: 1 addition & 0 deletions config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
require_once rex_path::addon('asd_news', 'classes/rex_news_form.php');
require_once rex_path::addon('asd_news', 'classes/rex_asd_news.php');
require_once rex_path::addon('asd_news', 'classes/rex_asd_news_utils.php');
require_once rex_path::addon('asd_news', 'classes/rex_asd_pager.php');

// Seo Addon setzen
foreach (array('rexseo', 'yrewrite', 'seo42') as $seoAddon) {
Expand Down
30 changes: 24 additions & 6 deletions files/news.css
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
.asd-news {
position:relative;
clear:both;
margin:3px 0;
position: relative;
clear: both;
margin: 10px 0;
}

.asd-news h3 {

}

.asd-picture {
margin:3px 0;
border:2px solid #fff;
margin: 3px 0;
border: 2px solid #fff;
}

.asd-news-date {
font-weight: bold;
margin:2px 0 8px 0;
margin: 2px 0 8px 0;
}

.asd-pager-left, .asd-pager-right {
padding: 6px 12px;
border-radius: 4px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
background:#fff;
}

.asd-pager-right {
float: right;
}

.asd-pager-right:after {
content: "";
display: block;
clear: both;
}
19 changes: 18 additions & 1 deletion modules/modulAusgabe.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,22 @@

} else {

foreach (rex_asd_news::getNewsByCategory('REX_VALUE[1]') as $news) {
$newsList = rex_asd_news::getNewsByCategory('REX_VALUE[1]');

$pager = new rex_asd_pager($REX['ADDON']['asd_news']['config']['max-per-page'], 'page');
$pager->setRowCount(count($newsList));

$newsList = $pager->filterList($newsList);

foreach ($newsList as $news) {
/** @var rex_asd_news $news */

$title = $news->getValue('title');
$url = $news->getUrl();
$id = $news->getValue('id');
$date = $news->getPublishDate();


?>
<div class="asd-news" id="news-<?php echo $id; ?>">
<h3><?php echo $title; ?></h3>
Expand All @@ -51,6 +59,15 @@

}

if($pager->getPageCount() > 1) {
if($pager->getCurrentPage() != $pager->getPrevPage()) {
echo '<a class="button asd-pager-left" href="' . rex_getUrl('', '', array($pager->getCursorName() => $pager->getPrevPage())) . '">prev</a>';
}

if($pager->getCurrentPage() != $pager->getNextPage()) {
echo '<a class="button asd-pager-right" href="' . rex_getUrl('', '', array($pager->getCursorName() => $pager->getNextPage())) . '">next</a>';
}
}
}

?>

0 comments on commit a547152

Please sign in to comment.