diff --git a/bl-kernel/admin/controllers/content.php b/bl-kernel/admin/controllers/content.php index 425199bb..dc505093 100644 --- a/bl-kernel/admin/controllers/content.php +++ b/bl-kernel/admin/controllers/content.php @@ -34,6 +34,7 @@ if (empty($published) && $Url->pageNumber()>1) { $drafts = $dbPages->getDraftDB(true); $scheduled = $dbPages->getScheduledDB(true); $static = $dbPages->getStaticDB(true); +$sticky = $dbPages->getStickyDB(true); // Title of the page $layout['title'] .= ' - '.$Language->g('Manage content'); \ No newline at end of file diff --git a/bl-kernel/admin/views/content.php b/bl-kernel/admin/views/content.php index 617db95e..8cf77788 100644 --- a/bl-kernel/admin/views/content.php +++ b/bl-kernel/admin/views/content.php @@ -29,6 +29,7 @@ function table($status, $icon='arrow-circle-o-down') { global $drafts; global $scheduled; global $static; + global $sticky; if ($status=='published') { $list = $published; @@ -38,6 +39,8 @@ function table($status, $icon='arrow-circle-o-down') { $list = $scheduled; } elseif ($status=='static') { $list = $static; + } elseif ($status=='sticky') { + $list = $sticky; } if (!empty($list)) { @@ -109,6 +112,7 @@ if ($Url->pageNumber()==1) { table('draft', 'spinner'); table('scheduled', 'clock-o'); table('static', 'thumb-tack'); + table('sticky', 'sticky-note-o'); } table('published', ''); diff --git a/bl-kernel/admin/views/edit-content.php b/bl-kernel/admin/views/edit-content.php index 3df876cc..2b0bd483 100644 --- a/bl-kernel/admin/views/edit-content.php +++ b/bl-kernel/admin/views/edit-content.php @@ -143,6 +143,7 @@ echo '
'; 'options'=>array( 'published'=>$L->g('Published'), 'static'=>$L->g('Static'), + 'sticky'=>$L->g('Sticky'), 'draft'=>$L->g('Draft') ), 'selected'=>$page->status(), diff --git a/bl-kernel/admin/views/new-content.php b/bl-kernel/admin/views/new-content.php index 8760b836..d323a4d2 100644 --- a/bl-kernel/admin/views/new-content.php +++ b/bl-kernel/admin/views/new-content.php @@ -121,6 +121,7 @@ echo '
'; 'options'=>array( 'published'=>$L->g('Published'), 'static'=>$L->g('Static'), + 'sticky'=>$L->g('Sticky'), 'draft'=>$L->g('Draft') ), 'selected'=>'published', diff --git a/bl-kernel/dbpages.class.php b/bl-kernel/dbpages.class.php index ad1cdd4e..9283d3f2 100644 --- a/bl-kernel/dbpages.class.php +++ b/bl-kernel/dbpages.class.php @@ -10,7 +10,7 @@ class dbPages extends dbJSON 'description'=> array('inFile'=>false, 'value'=>''), 'username'=> array('inFile'=>false, 'value'=>''), 'tags'=> array('inFile'=>false, 'value'=>array()), - 'status'=> array('inFile'=>false, 'value'=>'published'), // published, draft, scheduled + 'status'=> array('inFile'=>false, 'value'=>'published'), // published, draft, sticky, scheduled 'type'=> array('inFile'=>false, 'value'=>'post'), // post, page 'date'=> array('inFile'=>false, 'value'=>''), 'dateModified'=> array('inFile'=>false, 'value'=>''), @@ -372,6 +372,21 @@ class dbPages extends dbJSON return $tmp; } + // Returns an array with a list of keys of sticky pages + public function getStickyDB($onlyKeys=true) + { + $tmp = $this->db; + foreach ($tmp as $key=>$fields) { + if($fields['status']!='sticky') { + unset($tmp[$key]); + } + } + if ($onlyKeys) { + return array_keys($tmp); + } + return $tmp; + } + // Return an array with the database for a page, FALSE otherwise public function getPageDB($key) { diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 0c3ff608..cb2e6c87 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -159,6 +159,12 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false) { $onlyPublished = true; $amountOfItems = $Site->itemsPerPage(); $list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished); + + // Include sticky pages only in the first page + if ($pageNumber==1) { + $sticky = $dbPages->getStickyDB(); + $list = array_merge($sticky, $list); + } } elseif ($for=='category') { $amountOfItems = $Site->itemsPerPage();