Categories++
This commit is contained in:
parent
95e6500993
commit
63fe327fe4
|
@ -135,4 +135,15 @@ class dbList extends dbJSON
|
||||||
return isset( $this->db[$key] );
|
return isset( $this->db[$key] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns an array with a portion of the database filtered by key
|
||||||
|
// Returns array( 'name'=>'', 'list'=>array() )
|
||||||
|
public function getMap($key)
|
||||||
|
{
|
||||||
|
if( isset($this->db[$key]) ) {
|
||||||
|
return $this->db[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -81,10 +81,9 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||||
// Main after POST
|
// Main after POST
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
if(!$dbPages->pageExists($layout['parameters']))
|
if( !$dbPages->exists($layout['parameters']) ) {
|
||||||
{
|
|
||||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$layout['parameters']);
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$layout['parameters']);
|
||||||
Redirect::page('admin', 'manage-pages');
|
Redirect::page('pages');
|
||||||
}
|
}
|
||||||
|
|
||||||
$_Page = $pages[$layout['parameters']];
|
$page = $pagesKey[$layout['parameters']];
|
||||||
|
|
|
@ -58,21 +58,4 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||||
// Main after POST
|
// Main after POST
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
// Default home page
|
|
||||||
$_homePageList = array(''=>$Language->g('Show blog'));
|
|
||||||
foreach($pagesParents as $parentKey=>$pageList)
|
|
||||||
{
|
|
||||||
foreach($pageList as $Page)
|
|
||||||
{
|
|
||||||
if($parentKey!==NO_PARENT_CHAR) {
|
|
||||||
$parentTitle = $pages[$Page->parentKey()]->title().'->';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$parentTitle = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if($Page->published()) {
|
|
||||||
$_homePageList[$Page->key()] = $Language->g('Page').': '.$parentTitle.$Page->title();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -70,6 +70,32 @@ class HTML {
|
||||||
echo $html;
|
echo $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// label, name, value, tip
|
||||||
|
public static function formInputRadio($args)
|
||||||
|
{
|
||||||
|
$id = 'js'.$args['name'];
|
||||||
|
$type = isset($args['type']) ? $args['type'] : 'text';
|
||||||
|
$class = empty($args['class']) ? '' : 'class="'.$args['class'].'"';
|
||||||
|
$placeholder = empty($args['placeholder']) ? '' : 'placeholder="'.$args['placeholder'].'"';
|
||||||
|
$disabled = empty($args['disabled']) ? '' : 'disabled';
|
||||||
|
|
||||||
|
$html = '<div class="uk-form-row">';
|
||||||
|
|
||||||
|
$html .= '<div class="uk-form-controls">';
|
||||||
|
$html .= '<label for="'.$id.'" class="uk-form-label">';
|
||||||
|
$html .= '<input id="'.$id.'" name="'.$args['name'].'" type="'.$type.'" '.$class.' '.$placeholder.' autocomplete="off" '.$disabled.' value="'.$args['value'].'">';
|
||||||
|
$html .= $args['label'].'</label>';
|
||||||
|
|
||||||
|
if(!empty($args['tip'])) {
|
||||||
|
$html .= '<p class="uk-form-help-block">'.$args['tip'].'</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= '</div>';
|
||||||
|
$html .= '</div>';
|
||||||
|
|
||||||
|
echo $html;
|
||||||
|
}
|
||||||
|
|
||||||
public static function tags($args)
|
public static function tags($args)
|
||||||
{
|
{
|
||||||
global $L;
|
global $L;
|
||||||
|
|
|
@ -13,7 +13,7 @@ HTML::formOpen(array('class'=>'uk-form-stacked'));
|
||||||
// Key input
|
// Key input
|
||||||
HTML::formInputHidden(array(
|
HTML::formInputHidden(array(
|
||||||
'name'=>'key',
|
'name'=>'key',
|
||||||
'value'=>$_Page->key()
|
'value'=>$page->key()
|
||||||
));
|
));
|
||||||
|
|
||||||
// LEFT SIDE
|
// LEFT SIDE
|
||||||
|
@ -24,7 +24,7 @@ echo '<div class="bl-publish-view uk-width-8-10">';
|
||||||
// Title input
|
// Title input
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
'name'=>'title',
|
'name'=>'title',
|
||||||
'value'=>$_Page->title(),
|
'value'=>$page->title(),
|
||||||
'class'=>'uk-width-1-1 uk-form-large',
|
'class'=>'uk-width-1-1 uk-form-large',
|
||||||
'placeholder'=>$L->g('Title')
|
'placeholder'=>$L->g('Title')
|
||||||
));
|
));
|
||||||
|
@ -32,7 +32,7 @@ echo '<div class="bl-publish-view uk-width-8-10">';
|
||||||
// Content input
|
// Content input
|
||||||
HTML::formTextarea(array(
|
HTML::formTextarea(array(
|
||||||
'name'=>'content',
|
'name'=>'content',
|
||||||
'value'=>$_Page->contentRaw(false),
|
'value'=>$page->contentRaw(false),
|
||||||
'class'=>'uk-width-1-1 uk-form-large',
|
'class'=>'uk-width-1-1 uk-form-large',
|
||||||
'placeholder'=>''
|
'placeholder'=>''
|
||||||
));
|
));
|
||||||
|
@ -44,7 +44,7 @@ echo '<div class="bl-publish-view uk-width-8-10">';
|
||||||
<button class="uk-button uk-button-primary" type="button" id="jsSaveDraft">'.$L->g('Save as draft').'</button>
|
<button class="uk-button uk-button-primary" type="button" id="jsSaveDraft">'.$L->g('Save as draft').'</button>
|
||||||
';
|
';
|
||||||
|
|
||||||
if(count($_Page->children())===0)
|
if(count($page->children())===0)
|
||||||
{
|
{
|
||||||
echo ' <button id="jsdelete" name="delete-page" class="uk-button" type="submit">'.$L->g('Delete').'</button>';
|
echo ' <button id="jsdelete" name="delete-page" class="uk-button" type="submit">'.$L->g('Delete').'</button>';
|
||||||
echo ' <a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'manage-posts">'.$L->g('Cancel').'</a>';
|
echo ' <a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'manage-posts">'.$L->g('Cancel').'</a>';
|
||||||
|
@ -66,22 +66,21 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||||
echo '<li id="sidebar-general-view" class="sidebar-view">';
|
echo '<li id="sidebar-general-view" class="sidebar-view">';
|
||||||
|
|
||||||
// Category
|
// Category
|
||||||
/*
|
|
||||||
HTML::formSelect(array(
|
HTML::formSelect(array(
|
||||||
'name'=>'category',
|
'name'=>'category',
|
||||||
'label'=>$L->g('Category'),
|
'label'=>$L->g('Category'),
|
||||||
'class'=>'uk-width-1-1 uk-form-medium',
|
'class'=>'uk-width-1-1 uk-form-medium',
|
||||||
'options'=>$dbCategories->getAll(),
|
'options'=>$dbCategories->getKeyNameArray(),
|
||||||
'selected'=>$_Page->category(),
|
'selected'=>$page->categoryKey(),
|
||||||
'tip'=>'',
|
'tip'=>'',
|
||||||
'addEmptySpace'=>true
|
'addEmptySpace'=>true
|
||||||
));
|
));
|
||||||
*/
|
|
||||||
// Description input
|
// Description input
|
||||||
HTML::formTextarea(array(
|
HTML::formTextarea(array(
|
||||||
'name'=>'description',
|
'name'=>'description',
|
||||||
'label'=>$L->g('description'),
|
'label'=>$L->g('description'),
|
||||||
'value'=>$_Page->description(),
|
'value'=>$page->description(),
|
||||||
'rows'=>'4',
|
'rows'=>'4',
|
||||||
'class'=>'uk-width-1-1 uk-form-medium',
|
'class'=>'uk-width-1-1 uk-form-medium',
|
||||||
'tip'=>$L->g('this-field-can-help-describe-the-content')
|
'tip'=>$L->g('this-field-can-help-describe-the-content')
|
||||||
|
@ -95,7 +94,7 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||||
echo '<li id="sidebar-images-view" class="sidebar-view">';
|
echo '<li id="sidebar-images-view" class="sidebar-view">';
|
||||||
|
|
||||||
// --- BLUDIT COVER IMAGE ---
|
// --- BLUDIT COVER IMAGE ---
|
||||||
HTML::bluditCoverImage($_Page->coverImage(false));
|
HTML::bluditCoverImage($page->coverImage(false));
|
||||||
|
|
||||||
// --- BLUDIT QUICK IMAGES ---
|
// --- BLUDIT QUICK IMAGES ---
|
||||||
HTML::bluditQuickImages();
|
HTML::bluditQuickImages();
|
||||||
|
@ -118,8 +117,8 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||||
HTML::tags(array(
|
HTML::tags(array(
|
||||||
'name'=>'tags',
|
'name'=>'tags',
|
||||||
'label'=>$L->g('Tags'),
|
'label'=>$L->g('Tags'),
|
||||||
'allTags'=>$dbTags->getAll(),
|
'allTags'=>$dbTags->getKeyNameArray(),
|
||||||
'selectedTags'=>$_Page->tags(true)
|
'selectedTags'=>$page->tags(true)
|
||||||
));
|
));
|
||||||
|
|
||||||
echo '</li>';
|
echo '</li>';
|
||||||
|
@ -135,25 +134,34 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||||
'label'=>$L->g('Status'),
|
'label'=>$L->g('Status'),
|
||||||
'class'=>'uk-width-1-1 uk-form-medium',
|
'class'=>'uk-width-1-1 uk-form-medium',
|
||||||
'options'=>array('published'=>$L->g('Published'), 'draft'=>$L->g('Draft')),
|
'options'=>array('published'=>$L->g('Published'), 'draft'=>$L->g('Draft')),
|
||||||
'selected'=>($_Page->draft()?'draft':'published'),
|
'selected'=>($page->draft()?'draft':'published'),
|
||||||
'tip'=>''
|
'tip'=>''
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Date input
|
||||||
|
HTML::formInputText(array(
|
||||||
|
'name'=>'date',
|
||||||
|
'value'=>$page->dateRaw(),
|
||||||
|
'class'=>'uk-width-1-1 uk-form-medium',
|
||||||
|
'tip'=>$L->g('To schedule the post just select the date and time'),
|
||||||
|
'label'=>$L->g('Date')
|
||||||
|
));
|
||||||
|
|
||||||
// If the page is parent then doesn't can have a parent.
|
// If the page is parent then doesn't can have a parent.
|
||||||
if(count($_Page->children())===0)
|
if(count($page->children())===0)
|
||||||
{
|
{
|
||||||
// Parent input
|
// Parent input
|
||||||
$options = array();
|
$options = array();
|
||||||
$options[NO_PARENT_CHAR] = '('.$Language->g('No parent').')';
|
$options[NO_PARENT_CHAR] = '('.$Language->g('No parent').')';
|
||||||
$options += $dbPages->parentKeyList();
|
$options += $dbPages->parentKeyList();
|
||||||
unset($options[$_Page->key()]);
|
unset($options[$page->key()]);
|
||||||
|
|
||||||
HTML::formSelect(array(
|
HTML::formSelect(array(
|
||||||
'name'=>'parent',
|
'name'=>'parent',
|
||||||
'label'=>$L->g('Parent'),
|
'label'=>$L->g('Parent'),
|
||||||
'class'=>'uk-width-1-1 uk-form-medium',
|
'class'=>'uk-width-1-1 uk-form-medium',
|
||||||
'options'=>$options,
|
'options'=>$options,
|
||||||
'selected'=>$_Page->parentKey(),
|
'selected'=>$page->parentKey(),
|
||||||
'tip'=>''
|
'tip'=>''
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -161,16 +169,16 @@ if(count($_Page->children())===0)
|
||||||
// Position input
|
// Position input
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
'name'=>'position',
|
'name'=>'position',
|
||||||
'value'=>$_Page->position(),
|
'value'=>$page->position(),
|
||||||
'class'=>'uk-width-1-1 uk-form-large',
|
'class'=>'uk-width-1-1 uk-form-medium',
|
||||||
'label'=>$L->g('Position')
|
'label'=>$L->g('Position')
|
||||||
));
|
));
|
||||||
|
|
||||||
// Slug input
|
// Slug input
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
'name'=>'slug',
|
'name'=>'slug',
|
||||||
'value'=>$_Page->slug(),
|
'value'=>$page->slug(),
|
||||||
'class'=>'uk-width-1-1 uk-form-large',
|
'class'=>'uk-width-1-1 uk-form-medium',
|
||||||
'tip'=>$L->g('you-can-modify-the-url-which-identifies'),
|
'tip'=>$L->g('you-can-modify-the-url-which-identifies'),
|
||||||
'label'=>$L->g('Friendly URL')
|
'label'=>$L->g('Friendly URL')
|
||||||
));
|
));
|
||||||
|
@ -191,6 +199,8 @@ $(document).ready(function()
|
||||||
{
|
{
|
||||||
var key = $("#jskey").val();
|
var key = $("#jskey").val();
|
||||||
|
|
||||||
|
$("#jsdate").datetimepicker({format:"<?php echo DB_DATE_FORMAT ?>"});
|
||||||
|
|
||||||
$("#jsslug").keyup(function() {
|
$("#jsslug").keyup(function() {
|
||||||
var text = $(this).val();
|
var text = $(this).val();
|
||||||
var parent = $("#jsparent").val();
|
var parent = $("#jsparent").val();
|
||||||
|
|
|
@ -127,7 +127,7 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
'name'=>'date',
|
'name'=>'date',
|
||||||
'value'=>Date::current(DB_DATE_FORMAT),
|
'value'=>Date::current(DB_DATE_FORMAT),
|
||||||
'class'=>'uk-width-1-1 uk-form-large',
|
'class'=>'uk-width-1-1 uk-form-medium',
|
||||||
'tip'=>$L->g('To schedule the post just select the date and time'),
|
'tip'=>$L->g('To schedule the post just select the date and time'),
|
||||||
'label'=>$L->g('Date')
|
'label'=>$L->g('Date')
|
||||||
));
|
));
|
||||||
|
@ -153,7 +153,7 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
'name'=>'position',
|
'name'=>'position',
|
||||||
'value'=>'1',
|
'value'=>'1',
|
||||||
'class'=>'uk-width-1-1 uk-form-large',
|
'class'=>'uk-width-1-1 uk-form-medium',
|
||||||
'label'=>$L->g('Position')
|
'label'=>$L->g('Position')
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
'name'=>'slug',
|
'name'=>'slug',
|
||||||
'value'=>'',
|
'value'=>'',
|
||||||
'class'=>'uk-width-1-1 uk-form-large',
|
'class'=>'uk-width-1-1 uk-form-medium',
|
||||||
'tip'=>$L->g('you-can-modify-the-url-which-identifies'),
|
'tip'=>$L->g('you-can-modify-the-url-which-identifies'),
|
||||||
'label'=>$L->g('Friendly URL')
|
'label'=>$L->g('Friendly URL')
|
||||||
));
|
));
|
||||||
|
|
|
@ -12,23 +12,14 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||||
HTML::legend(array('value'=>$L->g('General'), 'class'=>'first-child'));
|
HTML::legend(array('value'=>$L->g('General'), 'class'=>'first-child'));
|
||||||
|
|
||||||
HTML::formSelect(array(
|
HTML::formSelect(array(
|
||||||
'name'=>'postsperpage',
|
'name'=>'itemsPerPage',
|
||||||
'label'=>$L->g('Posts 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'),
|
||||||
'selected'=>$Site->postsPerPage(),
|
'selected'=>$Site->itemsPerPage(),
|
||||||
'class'=>'uk-width-1-3 uk-form-medium',
|
'class'=>'uk-width-1-3 uk-form-medium',
|
||||||
'tip'=>$L->g('number-of-posts-to-show-per-page')
|
'tip'=>$L->g('number-of-posts-to-show-per-page')
|
||||||
));
|
));
|
||||||
|
|
||||||
HTML::formSelect(array(
|
|
||||||
'name'=>'homepage',
|
|
||||||
'label'=>$L->g('Default home page'),
|
|
||||||
'options'=>$_homePageList,
|
|
||||||
'selected'=>$Site->homepage(),
|
|
||||||
'class'=>'uk-width-1-3 uk-form-medium',
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
'name'=>'url',
|
'name'=>'url',
|
||||||
'label'=>$L->g('Site URL'),
|
'label'=>$L->g('Site URL'),
|
||||||
|
@ -37,6 +28,25 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||||
'tip'=>$L->g('the-url-of-your-site')
|
'tip'=>$L->g('the-url-of-your-site')
|
||||||
));
|
));
|
||||||
|
|
||||||
|
HTML::legend(array('value'=>$L->g('Website or Blog')));
|
||||||
|
|
||||||
|
HTML::formInputRadio(array(
|
||||||
|
'name'=>'orderBy',
|
||||||
|
'type'=>'radio',
|
||||||
|
'label'=>$L->g('Website'),
|
||||||
|
'value'=>'position',
|
||||||
|
'class'=>'',
|
||||||
|
'tip'=>'Select this option if you want to order your pages by position.'
|
||||||
|
));
|
||||||
|
|
||||||
|
HTML::formInputRadio(array(
|
||||||
|
'name'=>'orderBy',
|
||||||
|
'type'=>'radio',
|
||||||
|
'label'=>$L->g('Blog'),
|
||||||
|
'value'=>'date',
|
||||||
|
'class'=>''
|
||||||
|
));
|
||||||
|
|
||||||
HTML::legend(array('value'=>$L->g('Email account settings')));
|
HTML::legend(array('value'=>$L->g('Email account settings')));
|
||||||
|
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
|
@ -49,14 +59,6 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||||
|
|
||||||
HTML::legend(array('value'=>$L->g('URL Filters')));
|
HTML::legend(array('value'=>$L->g('URL Filters')));
|
||||||
|
|
||||||
HTML::formInputText(array(
|
|
||||||
'name'=>'uriPost',
|
|
||||||
'label'=>$L->g('Posts'),
|
|
||||||
'value'=>$Site->uriFilters('post'),
|
|
||||||
'class'=>'uk-width-1-2 uk-form-medium',
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
'name'=>'uriPage',
|
'name'=>'uriPage',
|
||||||
'label'=>$L->g('Pages'),
|
'label'=>$L->g('Pages'),
|
||||||
|
@ -73,15 +75,6 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||||
'tip'=>''
|
'tip'=>''
|
||||||
));
|
));
|
||||||
|
|
||||||
HTML::formInputText(array(
|
|
||||||
'name'=>'uriBlog',
|
|
||||||
'label'=>$L->g('Blog'),
|
|
||||||
'value'=>$Site->uriFilters('blog'),
|
|
||||||
'class'=>'uk-width-1-2 uk-form-medium',
|
|
||||||
'tip'=>''
|
|
||||||
));
|
|
||||||
|
|
||||||
/*
|
|
||||||
HTML::formInputText(array(
|
HTML::formInputText(array(
|
||||||
'name'=>'uriCategory',
|
'name'=>'uriCategory',
|
||||||
'label'=>$L->g('Category'),
|
'label'=>$L->g('Category'),
|
||||||
|
@ -89,7 +82,7 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||||
'class'=>'uk-width-1-2 uk-form-medium',
|
'class'=>'uk-width-1-2 uk-form-medium',
|
||||||
'tip'=>''
|
'tip'=>''
|
||||||
));
|
));
|
||||||
*/
|
|
||||||
echo '<div class="uk-form-row">
|
echo '<div class="uk-form-row">
|
||||||
<div class="uk-form-controls">
|
<div class="uk-form-controls">
|
||||||
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
|
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
|
||||||
|
|
|
@ -271,6 +271,9 @@ $Url->checkFilters( $Site->uriFilters() );
|
||||||
// --- Objects shortcuts ---
|
// --- Objects shortcuts ---
|
||||||
$L = $Language;
|
$L = $Language;
|
||||||
|
|
||||||
|
// --- CONSTANTS with dependency ---
|
||||||
|
define('ORDER_BY', $Site->orderBy());
|
||||||
|
|
||||||
// DEBUG: Print constants
|
// DEBUG: Print constants
|
||||||
// $arr = array_filter(get_defined_constants(), 'is_string');
|
// $arr = array_filter(get_defined_constants(), 'is_string');
|
||||||
// echo json_encode($arr);
|
// echo json_encode($arr);
|
||||||
|
|
|
@ -214,7 +214,7 @@ class dbPages extends dbJSON
|
||||||
public function delete($key)
|
public function delete($key)
|
||||||
{
|
{
|
||||||
// Page doesn't exist in database
|
// Page doesn't exist in database
|
||||||
if(!$this->pageExists($key)) {
|
if(!$this->exists($key)) {
|
||||||
Log::set(__METHOD__.LOG_SEP.'The page does not exist. Key: '.$key);
|
Log::set(__METHOD__.LOG_SEP.'The page does not exist. Key: '.$key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ class dbPages extends dbJSON
|
||||||
// Return an array with the database for a page, FALSE otherwise.
|
// Return an array with the database for a page, FALSE otherwise.
|
||||||
public function getPageDB($key)
|
public function getPageDB($key)
|
||||||
{
|
{
|
||||||
if( $this->pageExists($key) ) {
|
if( $this->exists($key) ) {
|
||||||
return $this->db[$key];
|
return $this->db[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,6 +316,12 @@ class dbPages extends dbJSON
|
||||||
return $db;
|
return $db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return TRUE if the page exists, FALSE otherwise.
|
||||||
|
public function exists($key)
|
||||||
|
{
|
||||||
|
return isset( $this->db[$key] );
|
||||||
|
}
|
||||||
|
|
||||||
// Sort pages by date
|
// Sort pages by date
|
||||||
public function sortByDate($HighToLow=true)
|
public function sortByDate($HighToLow=true)
|
||||||
{
|
{
|
||||||
|
@ -340,7 +346,7 @@ class dbPages extends dbJSON
|
||||||
// Set a field of the database
|
// Set a field of the database
|
||||||
public function setField($key, $field, $value)
|
public function setField($key, $field, $value)
|
||||||
{
|
{
|
||||||
if( $this->pageExists($key) ) {
|
if( $this->exists($key) ) {
|
||||||
settype($value, gettype($this->dbFields[$key]['value']));
|
settype($value, gettype($this->dbFields[$key]['value']));
|
||||||
$this->db[$key][$field] = $value;
|
$this->db[$key][$field] = $value;
|
||||||
}
|
}
|
||||||
|
@ -348,11 +354,7 @@ class dbPages extends dbJSON
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return TRUE if the page exists, FALSE otherwise.
|
|
||||||
public function pageExists($key)
|
|
||||||
{
|
|
||||||
return isset($this->db[$key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function parentKeyList()
|
public function parentKeyList()
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,8 @@ class dbSite extends dbJSON
|
||||||
'facebook'=> array('inFile'=>false, 'value'=>''),
|
'facebook'=> array('inFile'=>false, 'value'=>''),
|
||||||
'googlePlus'=> array('inFile'=>false, 'value'=>''),
|
'googlePlus'=> array('inFile'=>false, 'value'=>''),
|
||||||
'instagram'=> array('inFile'=>false, 'value'=>''),
|
'instagram'=> array('inFile'=>false, 'value'=>''),
|
||||||
'github'=> array('inFile'=>false, 'value'=>'')
|
'github'=> array('inFile'=>false, 'value'=>''),
|
||||||
|
'orderBy'=> array('inFile'=>false, 'value'=>'date') // date or position
|
||||||
);
|
);
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
|
@ -123,6 +124,11 @@ class dbSite extends dbJSON
|
||||||
return $this->getField('googlePlus');
|
return $this->getField('googlePlus');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function orderBy()
|
||||||
|
{
|
||||||
|
return $this->getField('orderBy');
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the site title
|
// Returns the site title
|
||||||
public function title()
|
public function title()
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,7 @@ function buildPage($key)
|
||||||
{
|
{
|
||||||
global $dbPages;
|
global $dbPages;
|
||||||
global $dbUsers;
|
global $dbUsers;
|
||||||
|
global $dbCategories;
|
||||||
global $Parsedown;
|
global $Parsedown;
|
||||||
global $Site;
|
global $Site;
|
||||||
|
|
||||||
|
@ -49,6 +50,10 @@ function buildPage($key)
|
||||||
$username = $page->username();
|
$username = $page->username();
|
||||||
$page->setField('user', $dbUsers->getUser($username));
|
$page->setField('user', $dbUsers->getUser($username));
|
||||||
|
|
||||||
|
// Category
|
||||||
|
$categoryKey = $page->categoryKey();
|
||||||
|
$page->setField('categoryMap', $dbCategories->getMap($categoryKey));
|
||||||
|
|
||||||
return $page;
|
return $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,30 @@ class Page {
|
||||||
return '/'.$htmlPath.'/'.$tmp;
|
return '/'.$htmlPath.'/'.$tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- OLD
|
// Returns the category key
|
||||||
|
public function categoryKey()
|
||||||
|
{
|
||||||
|
return $this->getField('category');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the field from the array
|
||||||
|
// categoryMap = array( 'name'=>'', 'list'=>array() )
|
||||||
|
public function categoryMap($field)
|
||||||
|
{
|
||||||
|
$map = $this->getField('categoryMap');
|
||||||
|
|
||||||
|
if($field=='key') {
|
||||||
|
return $this->categoryKey();
|
||||||
|
}
|
||||||
|
elseif($field=='name') {
|
||||||
|
return $map['name'];
|
||||||
|
}
|
||||||
|
elseif($field=='list') {
|
||||||
|
return $map['list'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the user object
|
// Returns the user object
|
||||||
// (boolean) $field, TRUE returns the value of the field, FALSE returns the object
|
// (boolean) $field, TRUE returns the value of the field, FALSE returns the object
|
||||||
|
@ -250,23 +273,18 @@ class Page {
|
||||||
// (boolean) $returnsArray, TRUE to get the tags as an array, FALSE to get the tags separeted by comma
|
// (boolean) $returnsArray, TRUE to get the tags as an array, FALSE to get the tags separeted by comma
|
||||||
public function tags($returnsArray=false)
|
public function tags($returnsArray=false)
|
||||||
{
|
{
|
||||||
global $Url;
|
|
||||||
|
|
||||||
$tags = $this->getField('tags');
|
$tags = $this->getField('tags');
|
||||||
|
|
||||||
if($returnsArray) {
|
if($returnsArray) {
|
||||||
|
|
||||||
if($tags==false) {
|
if($tags==false) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if($tags==false) {
|
if($tags==false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return string with tags separeted by comma.
|
// Return string with tags separeted by comma.
|
||||||
return implode(', ', $tags);
|
return implode(', ', $tags);
|
||||||
}
|
}
|
||||||
|
@ -314,12 +332,6 @@ class Page {
|
||||||
return $this->getField('readMore');
|
return $this->getField('readMore');
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
public function category()
|
|
||||||
{
|
|
||||||
return $this->getField('category');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function uuid()
|
public function uuid()
|
||||||
{
|
{
|
||||||
return $this->getField('uuid');
|
return $this->getField('uuid');
|
||||||
|
|
Loading…
Reference in New Issue