BUGFIXING: version 0.6.1, update on the pagination

This commit is contained in:
Stephan Kasdorf
2019-01-04 19:15:57 +01:00
parent 4b73d2602d
commit f7e47b05bf
2 changed files with 57 additions and 55 deletions

View File

@@ -1,6 +1,6 @@
# Nibiru
### Rapid Prototyping PHP Framework
Version 0.6.0 beta
Version 0.6.1 beta
## Introduction
<div style="word-spacing: 2px; letter-spacing: 0.1px; font-size: 12px; margin-bottom: 15px;">Nibiru is a rapid prototyping framework written in PHP and based on the MVC design pattern. Now one may say that writing <br>
@@ -95,5 +95,11 @@ Engine Implementation.</div>
<li>A soap extension will not be part of the system anymore, since that is just a bad habit, so this will be replaced with a REST api.</li>
</ul>
<h1>Bugfixing</h1>
<p>Version 0.6.1 beta 04.01.2019</p>
<ul>
<li>Bugfix for the pagination in the core files, used not to work on more then three pages, is now fixed.</li>
</ul>
<div style="word-spacing: 2px; letter-spacing: 0.1px; font-size: 15px; margin-bottom: 15px;">The start is done, have success with PHP prototyping, and always remember to have fun!</div>
Author: Stephan Kasdorf<br><br>

View File

@@ -1,16 +1,22 @@
<?php
namespace Nibiru;
namespace Nibiru\Module;
/**
* Created by PhpStorm.
* User: mithril
* User: Stephan Kasdorf
* Date: 15.09.18
* Time: 03:16
* Last Update: 04.01.2019
* Time: 19:13
*/
use Nibiru\Adapter;
use Nibiru\Config;
use Nibiru\Controller;
use Nibiru\Router;
use Nibiru\View;
abstract class Pageination implements IPageination
abstract class Pageination implements Adapter\Pageination
{
use Attributes\Pageination;
use \Nibiru\Messages\Pageination;
private static $_table = false;
private static $_current_page_content = array();
private static $_current_number = 0;
@@ -82,49 +88,39 @@ abstract class Pageination implements IPageination
private static function setPageEntryIndex( )
{
$PagesWithFullEntriesIndex = floor(self::getMaxPageEntries()/self::getEntriesPerPage());
$limit = array();
for($i=1; $i<$PagesWithFullEntriesIndex+1; $i++)
{
if(!array_key_exists($i-1, $limit))
$limit = array();
if($i==1)
{
$limit[$i] = array(
$limit = array(
'start' => 0,
'end' => self::getEntriesPerPage()
);
}
else
{
if(array_key_exists($i, $limit))
{
if(array_key_exists('start', $limit[$i]))
{
$start = $limit[$i]['start'];
}
else
{
$start = self::PAGE_ITERATION;
}
}
else
{
$start = self::PAGE_ITERATION;
}
$limit[$i] = array(
$laststart = self::getPageEntryIndex()[$i-1]['start'];
$limit = array(
'start' => $laststart + self::getEntriesPerPage(),
'end' => self::getEntriesPerPage(),
'start' => $start + self::getEntriesPerPage()
);
}
self::$_page_entry_index[$i] = $limit;
}
$fullEntriesOnPages = $PagesWithFullEntriesIndex*self::getEntriesPerPage();
if($fullEntriesOnPages<self::getMaxPageEntries())
{
$lastPageEntries = self::getMaxPageEntries()-($PagesWithFullEntriesIndex*self::getEntriesPerPage());
$limit[$i] = array(
'start' => $limit[$i-1]['start'] + self::getEntriesPerPage(),
$limit = array(
'start' => self::getPageEntryIndex()[$i-1]['start']+self::getEntriesPerPage(),
'end' => $lastPageEntries
);
self::$_page_entry_index[$i] = $limit;
}
self::$_page_entry_index = $limit;
self::setUriPaginationPath();
self::loadPaginationToTemplate();
}
@@ -144,7 +140,7 @@ abstract class Pageination implements IPageination
{
self::$_entries_per_page = Config::getInstance()->getConfig()[View::NIBIRU_SETTINGS]['entriesperpage'];
}
/**
* @return int
*/
@@ -163,7 +159,7 @@ abstract class Pageination implements IPageination
self::setMaxPageEntries( self::getTable()->loadTableRowCount( $tableinfo[0], $where ));
self::$_max_pages = ceil(self::getMaxPageEntries()/self::getEntriesPerPage());
}
/**
* @return boolean
*/
@@ -230,38 +226,38 @@ abstract class Pageination implements IPageination
protected static function setCurrentNumber( )
{
try {
$page = false;
$uri = explode('/', $_SERVER['REQUEST_URI']);
foreach ($uri as $uripart)
$page = false;
$uri = explode('/', $_SERVER['REQUEST_URI']);
foreach ($uri as $uripart)
{
if($page)
{
if($page)
if(is_numeric($uripart))
{
if(is_numeric($uripart))
{
self::$_current_number = $uripart;
Controller::getInstance()->varname(View::getInstance()->getEngine(), array('pagenumber' => self::getCurrentNumber()));
$page = false;
self::setNextPageNumber();
self::setPreviousPageNumber();
}
else
{
throw new \Exception('ERROR: the pagenumber has to be a nummeric value!');
}
self::$_current_number = $uripart;
Controller::getInstance()->varname(View::getInstance()->getEngine(), array('pagenumber' => self::getCurrentNumber()));
$page = false;
self::setNextPageNumber();
self::setPreviousPageNumber();
}
if($uripart == 'page')
else
{
$page = true;
throw new \Exception('ERROR: the pagenumber has to be a nummeric value!');
}
}
if(self::getCurrentNumber() == self::CURRENT_PAGE)
if($uripart == 'page')
{
throw new \Exception('ERROR: URL parameter [page] is missing, please check your class and add the parameter!');
$page = true;
}
self::setNextPageNumber();
self::setPreviousPageNumber();
}
if(self::getCurrentNumber() == self::CURRENT_PAGE)
{
throw new \Exception('ERROR: URL parameter [page] is missing, please check your class and add the parameter!');
}
self::setNextPageNumber();
self::setPreviousPageNumber();
}
catch (\Exception $e)
{
echo '<pre>';