plugins position

This commit is contained in:
Diego Najar 2017-07-30 23:15:33 +02:00
parent e1866d05d5
commit 3111c11ca3
10 changed files with 32 additions and 18 deletions

View File

@ -26,13 +26,19 @@ class dbList extends dbJSON
public function getList($key, $pageNumber, $amountOfItems) public function getList($key, $pageNumber, $amountOfItems)
{ {
if( !isset($this->db[$key]) ) { if (!isset($this->db[$key])) {
Log::set(__METHOD__.LOG_SEP.'Error key does not exist '.$key); Log::set(__METHOD__.LOG_SEP.'Error key does not exist '.$key);
return false; return false;
} }
$list = $this->db[$key]['list']; $list = $this->db[$key]['list'];
if ($amountOfItems==-1) {
// Invert keys to values, is necesary returns as key the key pages
$list = array_flip($list);
return $list;
}
// The first page number is 1, so the real is 0 // The first page number is 1, so the real is 0
$realPageNumber = $pageNumber - 1; $realPageNumber = $pageNumber - 1;

View File

@ -181,6 +181,11 @@ class Plugin {
return $this->getMetadata('website'); return $this->getMetadata('website');
} }
public function position()
{
return $this->getValue('position');
}
public function version() public function version()
{ {
return $this->getMetadata('version'); return $this->getMetadata('version');
@ -220,7 +225,7 @@ class Plugin {
} }
// Return TRUE if the installation success, otherwise FALSE. // Return TRUE if the installation success, otherwise FALSE.
public function install($position=0) public function install($position=1)
{ {
if($this->installed()) { if($this->installed()) {
return false; return false;

View File

@ -51,7 +51,7 @@ echo '
} }
for($i=1; $i<=Paginator::amountOfPages(); $i++) { for($i=1; $i<=Paginator::amountOfPages(); $i++) {
echo '<li><a href="'.Paginator::absoluteUrl($i).'" class="page">'.$i.'</a></li>'; echo '<li><a href="'.Paginator::numberUrl($i).'" class="page">'.$i.'</a></li>';
} }
// Show next page link // Show next page link

View File

@ -14,7 +14,7 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
HTML::formSelect(array( HTML::formSelect(array(
'name'=>'itemsPerPage', 'name'=>'itemsPerPage',
'label'=>$L->g('Items per page'), 'label'=>$L->g('Items per page'),
'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8'), 'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8', '-1'=>'All pages'),
'selected'=>$Site->itemsPerPage(), 'selected'=>$Site->itemsPerPage(),
'class'=>'uk-width-1-3 uk-form-medium', 'class'=>'uk-width-1-3 uk-form-medium',
'tip'=>$L->g('Number of items to show per page') 'tip'=>$L->g('Number of items to show per page')

View File

@ -102,6 +102,11 @@ function buildPlugins()
} }
} }
} }
uasort($plugins['siteSidebar'], function ($a, $b) {
return $a->position()>$b->position();
}
);
} }
} }

View File

@ -85,7 +85,7 @@ $pagesByParentByKey = array(PARENT=>array());
// ============================================================================ // ============================================================================
// Execute the scheduler // Execute the scheduler
if( $dbPages->scheduler() ) { if ($dbPages->scheduler()) {
// Reindex tags // Reindex tags
reindexTags(); reindexTags();
@ -103,7 +103,7 @@ if( $dbPages->scheduler() ) {
buildPagesByParent(true); buildPagesByParent(true);
// Set home page is the user defined one // Set home page is the user defined one
if( $Site->homepage() && $Url->whereAmI()==='home' ) { if ($Site->homepage() && $Url->whereAmI()==='home') {
$pageKey = $Site->homepage(); $pageKey = $Site->homepage();
if( $dbPages->exists($pageKey) ) { if( $dbPages->exists($pageKey) ) {
$Url->setSlug($pageKey); $Url->setSlug($pageKey);
@ -112,31 +112,28 @@ if( $Site->homepage() && $Url->whereAmI()==='home' ) {
} }
// Build specific page // Build specific page
if( $Url->whereAmI()==='page' ) { if ($Url->whereAmI()==='page') {
buildThePage(); buildThePage();
} }
// Build pages by tag // Build pages by tag
elseif( $Url->whereAmI()==='tag' ) { elseif ($Url->whereAmI()==='tag') {
buildPagesByTag(); buildPagesByTag();
} }
// Build pages by category // Build pages by category
elseif( $Url->whereAmI()==='category' ) { elseif ($Url->whereAmI()==='category') {
buildPagesByCategory(); buildPagesByCategory();
} }
// Build pages for the homepage // Build pages for the homepage
elseif( $Url->whereAmI()==='home' ) { elseif ($Url->whereAmI()==='home') {
buildPagesForHome(); buildPagesForHome();
} }
// Build pages for the admin area // Build pages for the admin area
elseif( $Url->whereAmI()==='admin' ) { elseif ($Url->whereAmI()==='admin') {
buildPagesForAdmin(); buildPagesForAdmin();
} }
// Set page 404 not found // Set page 404 not found
if( $Url->notFound() ) { if ($Url->notFound()) {
$Url->setWhereAmI('page');
$Url->setHttpCode(404);
$page = $Page = buildPage('error'); $page = $Page = buildPage('error');
if ($page===false) { if ($page===false) {
$page = buildErrorPage(); $page = buildErrorPage();

View File

@ -319,7 +319,7 @@ class dbPages extends dbJSON
// Remove Error page from the list // Remove Error page from the list
unset($db['error']); unset($db['error']);
if($amountOfItems==-1) { if ($amountOfItems==-1) {
return $db; return $db;
} }

View File

@ -154,7 +154,7 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) {
} }
// There are not items, invalid tag, invalid category, out of range, etc... // There are not items, invalid tag, invalid category, out of range, etc...
if( $list===false ) { if ($list===false) {
$Url->setNotFound(); $Url->setNotFound();
return false; return false;
} }

View File

@ -144,6 +144,7 @@ class Url
public function setNotFound() public function setNotFound()
{ {
$this->whereAmI = 'page';
$this->notFound = true; $this->notFound = true;
$this->httpCode = 404; $this->httpCode = 404;
$this->httpMessage = 'Not Found'; $this->httpMessage = 'Not Found';

View File

@ -30,7 +30,7 @@ div.plugin a {
cursor: pointer; cursor: pointer;
display: block; display: block;
font-size: 1.1em; font-size: 1.1em;
padding: 0.625em 0; padding: 0;
} }
/* Plugin Tags /* Plugin Tags