Bug fixes, filter by category and tags
This commit is contained in:
parent
4a7daf45a2
commit
818fdb453a
|
@ -24,7 +24,7 @@ class dbList extends dbJSON
|
||||||
parent::__construct($file);
|
parent::__construct($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getList($key, $amountOfItems, $pageNumber)
|
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);
|
||||||
|
|
|
@ -7,7 +7,7 @@ class dbSite extends dbJSON
|
||||||
'slogan'=> array('inFile'=>false, 'value'=>''),
|
'slogan'=> array('inFile'=>false, 'value'=>''),
|
||||||
'description'=> array('inFile'=>false, 'value'=>''),
|
'description'=> array('inFile'=>false, 'value'=>''),
|
||||||
'footer'=> array('inFile'=>false, 'value'=>'I wanna be a pirate!'),
|
'footer'=> array('inFile'=>false, 'value'=>'I wanna be a pirate!'),
|
||||||
'itemsPerPage'=> array('inFile'=>false, 'value'=>''),
|
'itemsPerPage'=> array('inFile'=>false, 'value'=>6),
|
||||||
'language'=> array('inFile'=>false, 'value'=>'en'),
|
'language'=> array('inFile'=>false, 'value'=>'en'),
|
||||||
'locale'=> array('inFile'=>false, 'value'=>'en_US'),
|
'locale'=> array('inFile'=>false, 'value'=>'en_US'),
|
||||||
'timezone'=> array('inFile'=>false, 'value'=>'America/Argentina/Buenos_Aires'),
|
'timezone'=> array('inFile'=>false, 'value'=>'America/Argentina/Buenos_Aires'),
|
||||||
|
|
|
@ -115,6 +115,7 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false)
|
||||||
{
|
{
|
||||||
global $dbPages;
|
global $dbPages;
|
||||||
global $dbCategories;
|
global $dbCategories;
|
||||||
|
global $dbTags;
|
||||||
global $Site;
|
global $Site;
|
||||||
global $Url;
|
global $Url;
|
||||||
global $pagesByKey;
|
global $pagesByKey;
|
||||||
|
|
|
@ -153,6 +153,7 @@ class Page {
|
||||||
{
|
{
|
||||||
global $Url;
|
global $Url;
|
||||||
|
|
||||||
|
$key = $this->getField('key');
|
||||||
if($absolute) {
|
if($absolute) {
|
||||||
return DOMAIN_PAGE.$key;
|
return DOMAIN_PAGE.$key;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,6 @@ class pluginCategories extends Plugin {
|
||||||
global $dbCategories;
|
global $dbCategories;
|
||||||
global $Url;
|
global $Url;
|
||||||
|
|
||||||
// URL base filter for categories
|
|
||||||
$filter = $Url->filters('category');
|
|
||||||
|
|
||||||
// HTML for sidebar
|
// HTML for sidebar
|
||||||
$html = '<div class="plugin plugin-categories">';
|
$html = '<div class="plugin plugin-categories">';
|
||||||
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
|
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
|
||||||
|
|
|
@ -29,7 +29,6 @@ class pluginMenu extends Plugin {
|
||||||
global $Language;
|
global $Language;
|
||||||
global $dbCategories;
|
global $dbCategories;
|
||||||
global $Url;
|
global $Url;
|
||||||
global $pagesByKey;
|
|
||||||
|
|
||||||
// HTML for sidebar
|
// HTML for sidebar
|
||||||
$html = '<div class="plugin plugin-menu">';
|
$html = '<div class="plugin plugin-menu">';
|
||||||
|
@ -45,7 +44,8 @@ class pluginMenu extends Plugin {
|
||||||
$html .= '<span class="category-name">'.$fields['name'].'</span>';
|
$html .= '<span class="category-name">'.$fields['name'].'</span>';
|
||||||
$html .= '<ul class="submenu">';
|
$html .= '<ul class="submenu">';
|
||||||
foreach( $pageList as $pageKey ) {
|
foreach( $pageList as $pageKey ) {
|
||||||
$page = $pagesByKey[$pageKey];
|
// Create the page object from the page key
|
||||||
|
$page = buildPage($pageKey);
|
||||||
$html .= '<li>';
|
$html .= '<li>';
|
||||||
$html .= '<a href="'.$page->permalink().'" class="page-title">';
|
$html .= '<a href="'.$page->permalink().'" class="page-title">';
|
||||||
$html .= $page->title();
|
$html .= $page->title();
|
||||||
|
|
|
@ -40,17 +40,21 @@ class pluginPages extends Plugin {
|
||||||
public function siteSidebar()
|
public function siteSidebar()
|
||||||
{
|
{
|
||||||
global $Language;
|
global $Language;
|
||||||
global $pages;
|
|
||||||
global $Url;
|
global $Url;
|
||||||
|
global $Site;
|
||||||
// URL base filter for categories
|
global $dbPages;
|
||||||
$filter = $Url->filters('page');
|
|
||||||
|
|
||||||
// Amount of pages to show
|
// Amount of pages to show
|
||||||
$amountOfItems = $this->getValue('amountOfItems');
|
$amountOfItems = $this->getValue('amountOfItems');
|
||||||
|
|
||||||
// Slice array of pages
|
// Page number the first one
|
||||||
$pages = array_slice($pages, 0, $amountOfItems);
|
$pageNumber = 1;
|
||||||
|
|
||||||
|
// Only published pages
|
||||||
|
$onlyPublished = true;
|
||||||
|
|
||||||
|
// Get the list of pages
|
||||||
|
$pages = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished, true);
|
||||||
|
|
||||||
// HTML for sidebar
|
// HTML for sidebar
|
||||||
$html = '<div class="plugin plugin-pages">';
|
$html = '<div class="plugin plugin-pages">';
|
||||||
|
@ -61,16 +65,18 @@ class pluginPages extends Plugin {
|
||||||
// Show Home page link
|
// Show Home page link
|
||||||
if( $this->getValue('homeLink') ) {
|
if( $this->getValue('homeLink') ) {
|
||||||
$html .= '<li>';
|
$html .= '<li>';
|
||||||
$html .= '<a href="'.DOMAIN_BASE.'">';
|
$html .= '<a href="'.$Site->url().'">';
|
||||||
$html .= $Language->get('Home page');
|
$html .= $Language->get('Home page');
|
||||||
$html .= '</a>';
|
$html .= '</a>';
|
||||||
$html .= '</li>';
|
$html .= '</li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// By default the database of categories are alphanumeric sorted
|
// Show page list
|
||||||
foreach( $pages as $page ) {
|
foreach( $pages as $pageKey=>$fields ) {
|
||||||
|
// Create the page object from the page key
|
||||||
|
$page = buildPage($pageKey);
|
||||||
$html .= '<li>';
|
$html .= '<li>';
|
||||||
$html .= '<a href="'.DOMAIN_BASE.$filter.'/'.$page->key().'">';
|
$html .= '<a href="'.$page->permalink().'">';
|
||||||
$html .= $page->title();
|
$html .= $page->title();
|
||||||
$html .= '</a>';
|
$html .= '</a>';
|
||||||
$html .= '</li>';
|
$html .= '</li>';
|
||||||
|
|
|
@ -370,7 +370,7 @@ function install($adminPassword, $email, $timezone)
|
||||||
'theme'=>'editorial',
|
'theme'=>'editorial',
|
||||||
'adminTheme'=>'default',
|
'adminTheme'=>'default',
|
||||||
'homepage'=>'',
|
'homepage'=>'',
|
||||||
'itemsPerPage'=>'6',
|
'itemsPerPage'=>6,
|
||||||
'uriPage'=>'/',
|
'uriPage'=>'/',
|
||||||
'uriTag'=>'/tag/',
|
'uriTag'=>'/tag/',
|
||||||
'uriCategory'=>'/category/',
|
'uriCategory'=>'/category/',
|
||||||
|
|
Loading…
Reference in New Issue