change amount for number
This commit is contained in:
parent
bb2023cb5b
commit
942f3c04cb
|
@ -47,7 +47,7 @@ class dbJSON {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Returns the amount of rows in the database
|
||||
// Returns the number of rows in the database
|
||||
public function count()
|
||||
{
|
||||
return count($this->db);
|
||||
|
|
|
@ -34,7 +34,7 @@ class dbList extends dbJSON
|
|||
}
|
||||
|
||||
// Returns the list of keys filter by pageNumber
|
||||
public function getList($key, $pageNumber, $amountOfItems)
|
||||
public function getList($key, $pageNumber, $numberOfItems)
|
||||
{
|
||||
if (!isset($this->db[$key])) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error key does not exist '.$key);
|
||||
|
@ -45,7 +45,7 @@ class dbList extends dbJSON
|
|||
$list = $this->db[$key]['list'];
|
||||
|
||||
// Returns all the items from the list
|
||||
if ($amountOfItems==-1) {
|
||||
if ($numberOfItems==-1) {
|
||||
// Invert keys to values, is necesary returns as key the key pages
|
||||
$list = array_flip($list);
|
||||
return $list;
|
||||
|
@ -53,7 +53,7 @@ class dbList extends dbJSON
|
|||
|
||||
// The first page number is 1, so the real is 0
|
||||
$realPageNumber = $pageNumber - 1;
|
||||
$chunks = array_chunk($list, $amountOfItems);
|
||||
$chunks = array_chunk($list, $numberOfItems);
|
||||
if (isset($chunks[$realPageNumber])) {
|
||||
return $chunks[$realPageNumber];
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ checkRole(array('admin', 'editor'));
|
|||
|
||||
// List of published pages
|
||||
$onlyPublished = true;
|
||||
$amountOfItems = ITEMS_PER_PAGE_ADMIN;
|
||||
$numberOfItems = ITEMS_PER_PAGE_ADMIN;
|
||||
$pageNumber = $url->pageNumber();
|
||||
$published = $pages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
||||
$published = $pages->getList($pageNumber, $numberOfItems, $onlyPublished);
|
||||
|
||||
// Check if out of range the pageNumber
|
||||
if (empty($published) && $url->pageNumber()>1) {
|
||||
|
|
|
@ -9,7 +9,7 @@ if (!empty($listOfFilesByPage[0])) {
|
|||
}
|
||||
}
|
||||
// Amount of pages for the paginator
|
||||
$amountOfPages = count($listOfFilesByPage);
|
||||
$numberOfPages = count($listOfFilesByPage);
|
||||
?>
|
||||
|
||||
<div id="jsbluditMediaModal" class="modal fade" tabindex="-1" role="dialog">
|
||||
|
@ -53,7 +53,7 @@ $amountOfPages = count($listOfFilesByPage);
|
|||
<!-- Paginator -->
|
||||
<nav>
|
||||
<ul class="pagination justify-content-center">
|
||||
<?php for ($i=1; $i<=$amountOfPages; $i++): ?>
|
||||
<?php for ($i=1; $i<=$numberOfPages; $i++): ?>
|
||||
<li class="page-item"><button type="button" class="btn btn-link page-link" onClick="getFiles(<?php echo $i ?>)"><?php echo $i ?></button></li>
|
||||
<?php endfor; ?>
|
||||
</ul>
|
||||
|
|
|
@ -168,7 +168,7 @@ function table($type) {
|
|||
<div class="tab-pane show active" id="pages" role="tabpanel">
|
||||
<?php table('published'); ?>
|
||||
|
||||
<?php if (Paginator::amountOfPages() > 1): ?>
|
||||
<?php if (Paginator::numberOfPages() > 1): ?>
|
||||
<!-- Paginator -->
|
||||
<nav class="paginator">
|
||||
<ul class="pagination flex-wrap justify-content-center">
|
||||
|
|
|
@ -30,7 +30,7 @@ if (isset($listOfFilesByPage[$pageNumber])) {
|
|||
array_push($tmp, basename($file));
|
||||
}
|
||||
|
||||
// Returns the amount of chunks for the paginator
|
||||
// Returns the number of chunks for the paginator
|
||||
// Returns the files inside the chunk
|
||||
exit (json_encode(array(
|
||||
'status'=>0,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// ============================================================================
|
||||
|
||||
// Array with pages, each page is a Page Object
|
||||
// Filtered by pagenumber, amount of items per page and sorted by date/position
|
||||
// Filtered by pagenumber, number of items per page and sorted by date/position
|
||||
/*
|
||||
array(
|
||||
0 => Page Object,
|
||||
|
|
|
@ -6,35 +6,35 @@ Paginator::set('currentPage', $currentPage);
|
|||
|
||||
if($url->whereAmI()=='admin') {
|
||||
$itemsPerPage = ITEMS_PER_PAGE_ADMIN;
|
||||
$amountOfItems = $pages->count(true);
|
||||
$numberOfItems = $pages->count(true);
|
||||
}
|
||||
elseif($url->whereAmI()=='tag') {
|
||||
$itemsPerPage = $site->itemsPerPage();
|
||||
$tagKey = $url->slug();
|
||||
$amountOfItems = $tags->numberOfPages($tagKey);
|
||||
$numberOfItems = $tags->numberOfPages($tagKey);
|
||||
}
|
||||
elseif($url->whereAmI()=='category') {
|
||||
$itemsPerPage = $site->itemsPerPage();
|
||||
$categoryKey = $url->slug();
|
||||
$amountOfItems = $categories->numberOfPages($categoryKey);
|
||||
$numberOfItems = $categories->numberOfPages($categoryKey);
|
||||
}
|
||||
else {
|
||||
$itemsPerPage = $site->itemsPerPage();
|
||||
$amountOfItems = $pages->count(true);
|
||||
$numberOfItems = $pages->count(true);
|
||||
}
|
||||
|
||||
// Items per page
|
||||
Paginator::set('itemsPerPage', $itemsPerPage);
|
||||
|
||||
// Amount of items
|
||||
Paginator::set('amountOfItems', $amountOfItems);
|
||||
Paginator::set('numberOfItems', $numberOfItems);
|
||||
|
||||
// Amount of pages
|
||||
$amountOfPages = (int) max(ceil($amountOfItems / $itemsPerPage), 1);
|
||||
Paginator::set('amountOfPages', $amountOfPages);
|
||||
$numberOfPages = (int) max(ceil($numberOfItems / $itemsPerPage), 1);
|
||||
Paginator::set('numberOfPages', $numberOfPages);
|
||||
|
||||
// TRUE if exists a next page to show
|
||||
$showNext = $amountOfPages > $currentPage;
|
||||
$showNext = $numberOfPages > $currentPage;
|
||||
Paginator::set('showNext', $showNext);
|
||||
|
||||
// TRUE if exists a previous page to show
|
||||
|
@ -50,5 +50,5 @@ $nextPage = max(0, $currentPage+1);
|
|||
Paginator::set('nextPage', $nextPage);
|
||||
|
||||
// Integer with the previous page
|
||||
$prevPage = min($amountOfPages, $currentPage-1);
|
||||
$prevPage = min($numberOfPages, $currentPage-1);
|
||||
Paginator::set('prevPage', $prevPage);
|
||||
|
|
|
@ -90,8 +90,8 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
|
|||
|
||||
if ($for=='home') {
|
||||
$onlyPublished = true;
|
||||
$amountOfItems = $site->itemsPerPage();
|
||||
$list = $pages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
||||
$numberOfItems = $site->itemsPerPage();
|
||||
$list = $pages->getList($pageNumber, $numberOfItems, $onlyPublished);
|
||||
|
||||
// Include sticky pages only in the first page
|
||||
if ($pageNumber==1) {
|
||||
|
@ -100,12 +100,12 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
|
|||
}
|
||||
}
|
||||
elseif ($for=='category') {
|
||||
$amountOfItems = $site->itemsPerPage();
|
||||
$list = $categories->getList($categoryKey, $pageNumber, $amountOfItems);
|
||||
$numberOfItems = $site->itemsPerPage();
|
||||
$list = $categories->getList($categoryKey, $pageNumber, $numberOfItems);
|
||||
}
|
||||
elseif ($for=='tag') {
|
||||
$amountOfItems = $site->itemsPerPage();
|
||||
$list = $tags->getList($tagKey, $pageNumber, $amountOfItems);
|
||||
$numberOfItems = $site->itemsPerPage();
|
||||
$list = $tags->getList($tagKey, $pageNumber, $numberOfItems);
|
||||
}
|
||||
|
||||
// There are not items, invalid tag, invalid category, out of range, etc...
|
||||
|
|
|
@ -4,8 +4,8 @@ class Paginator {
|
|||
|
||||
public static $pager = array(
|
||||
'itemsPerPage'=>0,
|
||||
'amountOfPages'=>1,
|
||||
'amountOfItems'=>0,
|
||||
'numberOfPages'=>1,
|
||||
'numberOfItems'=>0,
|
||||
'firstPage'=>1,
|
||||
'nextPage'=>1,
|
||||
'prevPage'=>1,
|
||||
|
@ -25,9 +25,9 @@ class Paginator {
|
|||
return self::$pager[$key];
|
||||
}
|
||||
|
||||
public static function amountOfPages()
|
||||
public static function numberOfPages()
|
||||
{
|
||||
return self::get('amountOfPages');
|
||||
return self::get('numberOfPages');
|
||||
}
|
||||
|
||||
public static function currentPage()
|
||||
|
@ -69,7 +69,7 @@ class Paginator {
|
|||
// Returns the absolute URL for the last page
|
||||
public static function lastPageUrl()
|
||||
{
|
||||
return self::numberUrl( self::amountOfPages() );
|
||||
return self::numberUrl( self::numberOfPages() );
|
||||
}
|
||||
|
||||
// Returns the absolute URL for the next page
|
||||
|
@ -148,7 +148,7 @@ class Paginator {
|
|||
|
||||
global $Language;
|
||||
|
||||
$total_pages = self::amountOfPages();
|
||||
$total_pages = self::numberOfPages();
|
||||
$howMany = 2;
|
||||
$currentPage = self::currentPage();
|
||||
$first_page = self::firstPage();
|
||||
|
|
|
@ -453,9 +453,9 @@ class Pages extends dbJSON {
|
|||
// Returns an array with a list of key of pages, FALSE if out of range
|
||||
// The database is sorted by date or by position
|
||||
// (int) $pageNumber, the page number
|
||||
// (int) $amountOfItems, amount of items to return, if -1 returns all the items
|
||||
// (int) $numberOfItems, amount of items to return, if -1 returns all the items
|
||||
// (boolean) $onlyPublished, TRUE to return only published pages
|
||||
public function getList($pageNumber, $amountOfItems, $onlyPublished=true)
|
||||
public function getList($pageNumber, $numberOfItems, $onlyPublished=true)
|
||||
{
|
||||
$db = array_keys($this->db);
|
||||
|
||||
|
@ -463,7 +463,7 @@ class Pages extends dbJSON {
|
|||
$db = $this->getPublishedDB(true);
|
||||
}
|
||||
|
||||
if ($amountOfItems==-1) {
|
||||
if ($numberOfItems==-1) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
|
@ -471,12 +471,12 @@ class Pages extends dbJSON {
|
|||
$realPageNumber = $pageNumber - 1;
|
||||
|
||||
$total = count($db);
|
||||
$init = (int) $amountOfItems * $realPageNumber;
|
||||
$end = (int) min( ($init + $amountOfItems - 1), $total );
|
||||
$init = (int) $numberOfItems * $realPageNumber;
|
||||
$end = (int) min( ($init + $numberOfItems - 1), $total );
|
||||
$outrange = $init<0 ? true : $init>$end;
|
||||
|
||||
if (!$outrange) {
|
||||
return array_slice($db, $init, $amountOfItems, true);
|
||||
return array_slice($db, $init, $numberOfItems, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -168,12 +168,18 @@ class Page {
|
|||
return $this->categoryMap('name');
|
||||
}
|
||||
|
||||
// Returns the category name
|
||||
// Returns the category template
|
||||
public function categoryTemplate()
|
||||
{
|
||||
return $this->categoryMap('template');
|
||||
}
|
||||
|
||||
// Returns the category description
|
||||
public function categoryDescription()
|
||||
{
|
||||
return $this->categoryMap('description');
|
||||
}
|
||||
|
||||
// Returns the category key
|
||||
public function categoryKey()
|
||||
{
|
||||
|
@ -196,10 +202,8 @@ class Page {
|
|||
|
||||
if ($field=='key') {
|
||||
return $this->categoryKey();
|
||||
} elseif($field=='name') {
|
||||
return $map['name'];
|
||||
} elseif($field=='list') {
|
||||
return $map['list'];
|
||||
} elseif(isset($map[$field])) {
|
||||
return $map[$field];
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -11,7 +11,7 @@ class pluginAPI extends Plugin {
|
|||
|
||||
$this->dbFields = array(
|
||||
'token'=>$token, // API Token
|
||||
'amountOfItems'=>15 // Amount of items to return
|
||||
'numberOfItems'=>15 // Amount of items to return
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class pluginAPI extends Plugin {
|
|||
|
||||
$html .= '<div>';
|
||||
$html .= '<label>'.$L->get('Amount of pages').'</label>';
|
||||
$html .= '<input id="jsamountOfItems" name="amountOfItems" type="text" value="'.$this->getValue('amountOfItems').'">';
|
||||
$html .= '<input id="jsnumberOfItems" name="numberOfItems" type="text" value="'.$this->getValue('numberOfItems').'">';
|
||||
$html .= '<span class="tip">'.$L->get('This is the maximum of pages to return when you call to').'</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
|
@ -238,13 +238,13 @@ class pluginAPI extends Plugin {
|
|||
global $pages;
|
||||
|
||||
$onlyPublished = true;
|
||||
$amountOfItems = $this->getValue('amountOfItems');
|
||||
$numberOfItems = $this->getValue('numberOfItems');
|
||||
$pageNumber = 1;
|
||||
$list = $pages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
||||
$list = $pages->getList($pageNumber, $numberOfItems, $onlyPublished);
|
||||
|
||||
$tmp = array(
|
||||
'status'=>'0',
|
||||
'message'=>'List of pages, amount of items: '.$amountOfItems,
|
||||
'message'=>'List of pages, amount of items: '.$numberOfItems,
|
||||
'data'=>array()
|
||||
);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ class pluginNavigation extends Plugin {
|
|||
$this->dbFields = array(
|
||||
'label'=>'Navigation',
|
||||
'homeLink'=>true,
|
||||
'amountOfItems'=>5
|
||||
'numberOfItems'=>5
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ class pluginNavigation extends Plugin {
|
|||
if (ORDER_BY=='date') {
|
||||
$html .= '<div>';
|
||||
$html .= '<label>'.$L->get('Amount of items').'</label>';
|
||||
$html .= '<input id="jsamountOfItems" name="amountOfItems" type="text" value="'.$this->getValue('amountOfItems').'">';
|
||||
$html .= '<input id="jsnumberOfItems" name="numberOfItems" type="text" value="'.$this->getValue('numberOfItems').'">';
|
||||
$html .= '</div>';
|
||||
}
|
||||
|
||||
|
@ -100,8 +100,8 @@ class pluginNavigation extends Plugin {
|
|||
// List of published pages
|
||||
$onlyPublished = true;
|
||||
$pageNumber = 1;
|
||||
$amountOfItems = $this->getValue('amountOfItems');
|
||||
$publishedPages = $pages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
||||
$numberOfItems = $this->getValue('numberOfItems');
|
||||
$publishedPages = $pages->getList($pageNumber, $numberOfItems, $onlyPublished);
|
||||
|
||||
foreach ($publishedPages as $pageKey) {
|
||||
try {
|
||||
|
|
|
@ -6,7 +6,7 @@ class pluginRSS extends Plugin {
|
|||
{
|
||||
// Fields and default values for the database of this plugin
|
||||
$this->dbFields = array(
|
||||
'amountOfItems'=>5
|
||||
'numberOfItems'=>5
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class pluginRSS extends Plugin {
|
|||
|
||||
$html .= '<div>';
|
||||
$html .= '<label>'.$L->get('Amount of items').'</label>';
|
||||
$html .= '<input id="jsamountOfItems" name="amountOfItems" type="text" value="'.$this->getValue('amountOfItems').'">';
|
||||
$html .= '<input id="jsnumberOfItems" name="numberOfItems" type="text" value="'.$this->getValue('numberOfItems').'">';
|
||||
$html .= '<span class="tip">'.$L->get('Amount of items to show on the feed').'</span>';
|
||||
$html .= '</div>';
|
||||
|
||||
|
@ -40,7 +40,7 @@ class pluginRSS extends Plugin {
|
|||
global $url;
|
||||
|
||||
// Amount of pages to show
|
||||
$amountOfItems = $this->getValue('amountOfItems');
|
||||
$numberOfItems = $this->getValue('numberOfItems');
|
||||
|
||||
// Page number the first one
|
||||
$pageNumber = 1;
|
||||
|
@ -49,7 +49,7 @@ class pluginRSS extends Plugin {
|
|||
$onlyPublished = true;
|
||||
|
||||
// Get the list of pages
|
||||
$list = $pages->getList($pageNumber, $amountOfItems, $onlyPublished, true);
|
||||
$list = $pages->getList($pageNumber, $numberOfItems, $onlyPublished, true);
|
||||
|
||||
$xml = '<?xml version="1.0" encoding="UTF-8" ?>';
|
||||
$xml .= '<rss version="2.0">';
|
||||
|
|
|
@ -34,9 +34,9 @@ class pluginSitemap extends Plugin {
|
|||
|
||||
// Get DB
|
||||
$pageNumber = 1;
|
||||
$amountOfItems = -1;
|
||||
$numberOfItems = -1;
|
||||
$onlyPublished = true;
|
||||
$list = $pages->getList($pageNumber, $amountOfItems, $onlyPublished);
|
||||
$list = $pages->getList($pageNumber, $numberOfItems, $onlyPublished);
|
||||
|
||||
foreach($list as $pageKey) {
|
||||
try {
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<?php endforeach ?>
|
||||
|
||||
<!-- Pagination -->
|
||||
<?php if (Paginator::amountOfPages()>1): ?>
|
||||
<?php if (Paginator::numberOfPages()>1): ?>
|
||||
<nav class="paginator">
|
||||
<ul class="pagination flex-wrap justify-content-center">
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<?php endforeach ?>
|
||||
|
||||
<!-- Pagination -->
|
||||
<?php if (Paginator::amountOfPages()>1): ?>
|
||||
<?php if (Paginator::numberOfPages()>1): ?>
|
||||
<nav class="paginator">
|
||||
<ul class="pagination flex-wrap">
|
||||
|
||||
|
|
|
@ -6,9 +6,6 @@ Things to do:
|
|||
- settings->advanced->Predefined pages->Page not found
|
||||
-- Search and select a page
|
||||
|
||||
- manage->users->edit user
|
||||
-- Change profile avatar
|
||||
|
||||
- Add to Settings
|
||||
-- time for autosave
|
||||
-- time for check user logged
|
||||
|
@ -33,3 +30,6 @@ Things to do:
|
|||
- Profile picture
|
||||
-- Convert to PNG
|
||||
-- Resize image
|
||||
|
||||
- pagex.class.php
|
||||
-- improve tags methods, compare with category
|
Loading…
Reference in New Issue