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)
{
if( !isset($this->db[$key]) ) {
if (!isset($this->db[$key])) {
Log::set(__METHOD__.LOG_SEP.'Error key does not exist '.$key);
return false;
}
$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
$realPageNumber = $pageNumber - 1;

View File

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

View File

@ -51,7 +51,7 @@ echo '
}
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

View File

@ -14,7 +14,7 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
HTML::formSelect(array(
'name'=>'itemsPerPage',
'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(),
'class'=>'uk-width-1-3 uk-form-medium',
'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
if( $dbPages->scheduler() ) {
if ($dbPages->scheduler()) {
// Reindex tags
reindexTags();
@ -103,7 +103,7 @@ if( $dbPages->scheduler() ) {
buildPagesByParent(true);
// Set home page is the user defined one
if( $Site->homepage() && $Url->whereAmI()==='home' ) {
if ($Site->homepage() && $Url->whereAmI()==='home') {
$pageKey = $Site->homepage();
if( $dbPages->exists($pageKey) ) {
$Url->setSlug($pageKey);
@ -112,31 +112,28 @@ if( $Site->homepage() && $Url->whereAmI()==='home' ) {
}
// Build specific page
if( $Url->whereAmI()==='page' ) {
if ($Url->whereAmI()==='page') {
buildThePage();
}
// Build pages by tag
elseif( $Url->whereAmI()==='tag' ) {
elseif ($Url->whereAmI()==='tag') {
buildPagesByTag();
}
// Build pages by category
elseif( $Url->whereAmI()==='category' ) {
elseif ($Url->whereAmI()==='category') {
buildPagesByCategory();
}
// Build pages for the homepage
elseif( $Url->whereAmI()==='home' ) {
elseif ($Url->whereAmI()==='home') {
buildPagesForHome();
}
// Build pages for the admin area
elseif( $Url->whereAmI()==='admin' ) {
elseif ($Url->whereAmI()==='admin') {
buildPagesForAdmin();
}
// Set page 404 not found
if( $Url->notFound() ) {
$Url->setWhereAmI('page');
$Url->setHttpCode(404);
if ($Url->notFound()) {
$page = $Page = buildPage('error');
if ($page===false) {
$page = buildErrorPage();

View File

@ -319,7 +319,7 @@ class dbPages extends dbJSON
// Remove Error page from the list
unset($db['error']);
if($amountOfItems==-1) {
if ($amountOfItems==-1) {
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...
if( $list===false ) {
if ($list===false) {
$Url->setNotFound();
return false;
}

View File

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

View File

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