Categories++
This commit is contained in:
parent
95e6500993
commit
63fe327fe4
@ -135,4 +135,15 @@ class dbList extends dbJSON
|
||||
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
|
||||
// ============================================================================
|
||||
|
||||
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']);
|
||||
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
|
||||
// ============================================================================
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
global $L;
|
||||
|
@ -13,7 +13,7 @@ HTML::formOpen(array('class'=>'uk-form-stacked'));
|
||||
// Key input
|
||||
HTML::formInputHidden(array(
|
||||
'name'=>'key',
|
||||
'value'=>$_Page->key()
|
||||
'value'=>$page->key()
|
||||
));
|
||||
|
||||
// LEFT SIDE
|
||||
@ -24,7 +24,7 @@ echo '<div class="bl-publish-view uk-width-8-10">';
|
||||
// Title input
|
||||
HTML::formInputText(array(
|
||||
'name'=>'title',
|
||||
'value'=>$_Page->title(),
|
||||
'value'=>$page->title(),
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'placeholder'=>$L->g('Title')
|
||||
));
|
||||
@ -32,7 +32,7 @@ echo '<div class="bl-publish-view uk-width-8-10">';
|
||||
// Content input
|
||||
HTML::formTextarea(array(
|
||||
'name'=>'content',
|
||||
'value'=>$_Page->contentRaw(false),
|
||||
'value'=>$page->contentRaw(false),
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'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>
|
||||
';
|
||||
|
||||
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 ' <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">';
|
||||
|
||||
// Category
|
||||
/*
|
||||
HTML::formSelect(array(
|
||||
'name'=>'category',
|
||||
'label'=>$L->g('Category'),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'options'=>$dbCategories->getAll(),
|
||||
'selected'=>$_Page->category(),
|
||||
'options'=>$dbCategories->getKeyNameArray(),
|
||||
'selected'=>$page->categoryKey(),
|
||||
'tip'=>'',
|
||||
'addEmptySpace'=>true
|
||||
));
|
||||
*/
|
||||
|
||||
// Description input
|
||||
HTML::formTextarea(array(
|
||||
'name'=>'description',
|
||||
'label'=>$L->g('description'),
|
||||
'value'=>$_Page->description(),
|
||||
'value'=>$page->description(),
|
||||
'rows'=>'4',
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'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">';
|
||||
|
||||
// --- BLUDIT COVER IMAGE ---
|
||||
HTML::bluditCoverImage($_Page->coverImage(false));
|
||||
HTML::bluditCoverImage($page->coverImage(false));
|
||||
|
||||
// --- BLUDIT QUICK IMAGES ---
|
||||
HTML::bluditQuickImages();
|
||||
@ -118,8 +117,8 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||
HTML::tags(array(
|
||||
'name'=>'tags',
|
||||
'label'=>$L->g('Tags'),
|
||||
'allTags'=>$dbTags->getAll(),
|
||||
'selectedTags'=>$_Page->tags(true)
|
||||
'allTags'=>$dbTags->getKeyNameArray(),
|
||||
'selectedTags'=>$page->tags(true)
|
||||
));
|
||||
|
||||
echo '</li>';
|
||||
@ -135,25 +134,34 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||
'label'=>$L->g('Status'),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'options'=>array('published'=>$L->g('Published'), 'draft'=>$L->g('Draft')),
|
||||
'selected'=>($_Page->draft()?'draft':'published'),
|
||||
'selected'=>($page->draft()?'draft':'published'),
|
||||
'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(count($_Page->children())===0)
|
||||
if(count($page->children())===0)
|
||||
{
|
||||
// Parent input
|
||||
$options = array();
|
||||
$options[NO_PARENT_CHAR] = '('.$Language->g('No parent').')';
|
||||
$options += $dbPages->parentKeyList();
|
||||
unset($options[$_Page->key()]);
|
||||
unset($options[$page->key()]);
|
||||
|
||||
HTML::formSelect(array(
|
||||
'name'=>'parent',
|
||||
'label'=>$L->g('Parent'),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'options'=>$options,
|
||||
'selected'=>$_Page->parentKey(),
|
||||
'selected'=>$page->parentKey(),
|
||||
'tip'=>''
|
||||
));
|
||||
}
|
||||
@ -161,16 +169,16 @@ if(count($_Page->children())===0)
|
||||
// Position input
|
||||
HTML::formInputText(array(
|
||||
'name'=>'position',
|
||||
'value'=>$_Page->position(),
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'value'=>$page->position(),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'label'=>$L->g('Position')
|
||||
));
|
||||
|
||||
// Slug input
|
||||
HTML::formInputText(array(
|
||||
'name'=>'slug',
|
||||
'value'=>$_Page->slug(),
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'value'=>$page->slug(),
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'tip'=>$L->g('you-can-modify-the-url-which-identifies'),
|
||||
'label'=>$L->g('Friendly URL')
|
||||
));
|
||||
@ -191,6 +199,8 @@ $(document).ready(function()
|
||||
{
|
||||
var key = $("#jskey").val();
|
||||
|
||||
$("#jsdate").datetimepicker({format:"<?php echo DB_DATE_FORMAT ?>"});
|
||||
|
||||
$("#jsslug").keyup(function() {
|
||||
var text = $(this).val();
|
||||
var parent = $("#jsparent").val();
|
||||
|
@ -127,7 +127,7 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||
HTML::formInputText(array(
|
||||
'name'=>'date',
|
||||
'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'),
|
||||
'label'=>$L->g('Date')
|
||||
));
|
||||
@ -153,7 +153,7 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||
HTML::formInputText(array(
|
||||
'name'=>'position',
|
||||
'value'=>'1',
|
||||
'class'=>'uk-width-1-1 uk-form-large',
|
||||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'label'=>$L->g('Position')
|
||||
));
|
||||
|
||||
@ -161,7 +161,7 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
||||
HTML::formInputText(array(
|
||||
'name'=>'slug',
|
||||
'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'),
|
||||
'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::formSelect(array(
|
||||
'name'=>'postsperpage',
|
||||
'label'=>$L->g('Posts per page'),
|
||||
'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'),
|
||||
'selected'=>$Site->postsPerPage(),
|
||||
'selected'=>$Site->itemsPerPage(),
|
||||
'class'=>'uk-width-1-3 uk-form-medium',
|
||||
'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(
|
||||
'name'=>'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')
|
||||
));
|
||||
|
||||
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::formInputText(array(
|
||||
@ -49,14 +59,6 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||
|
||||
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(
|
||||
'name'=>'uriPage',
|
||||
'label'=>$L->g('Pages'),
|
||||
@ -73,15 +75,6 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||
'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(
|
||||
'name'=>'uriCategory',
|
||||
'label'=>$L->g('Category'),
|
||||
@ -89,7 +82,7 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'tip'=>''
|
||||
));
|
||||
*/
|
||||
|
||||
echo '<div class="uk-form-row">
|
||||
<div class="uk-form-controls">
|
||||
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
|
||||
|
@ -271,6 +271,9 @@ $Url->checkFilters( $Site->uriFilters() );
|
||||
// --- Objects shortcuts ---
|
||||
$L = $Language;
|
||||
|
||||
// --- CONSTANTS with dependency ---
|
||||
define('ORDER_BY', $Site->orderBy());
|
||||
|
||||
// DEBUG: Print constants
|
||||
// $arr = array_filter(get_defined_constants(), 'is_string');
|
||||
// echo json_encode($arr);
|
||||
|
@ -214,7 +214,7 @@ class dbPages extends dbJSON
|
||||
public function delete($key)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ class dbPages extends dbJSON
|
||||
// Return an array with the database for a page, FALSE otherwise.
|
||||
public function getPageDB($key)
|
||||
{
|
||||
if( $this->pageExists($key) ) {
|
||||
if( $this->exists($key) ) {
|
||||
return $this->db[$key];
|
||||
}
|
||||
|
||||
@ -316,6 +316,12 @@ class dbPages extends dbJSON
|
||||
return $db;
|
||||
}
|
||||
|
||||
// Return TRUE if the page exists, FALSE otherwise.
|
||||
public function exists($key)
|
||||
{
|
||||
return isset( $this->db[$key] );
|
||||
}
|
||||
|
||||
// Sort pages by date
|
||||
public function sortByDate($HighToLow=true)
|
||||
{
|
||||
@ -340,7 +346,7 @@ class dbPages extends dbJSON
|
||||
// Set a field of the database
|
||||
public function setField($key, $field, $value)
|
||||
{
|
||||
if( $this->pageExists($key) ) {
|
||||
if( $this->exists($key) ) {
|
||||
settype($value, gettype($this->dbFields[$key]['value']));
|
||||
$this->db[$key][$field] = $value;
|
||||
}
|
||||
@ -348,11 +354,7 @@ class dbPages extends dbJSON
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return TRUE if the page exists, FALSE otherwise.
|
||||
public function pageExists($key)
|
||||
{
|
||||
return isset($this->db[$key]);
|
||||
}
|
||||
|
||||
|
||||
public function parentKeyList()
|
||||
{
|
||||
|
@ -26,7 +26,8 @@ class dbSite extends dbJSON
|
||||
'facebook'=> array('inFile'=>false, 'value'=>''),
|
||||
'googlePlus'=> 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()
|
||||
@ -123,6 +124,11 @@ class dbSite extends dbJSON
|
||||
return $this->getField('googlePlus');
|
||||
}
|
||||
|
||||
public function orderBy()
|
||||
{
|
||||
return $this->getField('orderBy');
|
||||
}
|
||||
|
||||
// Returns the site title
|
||||
public function title()
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ function buildPage($key)
|
||||
{
|
||||
global $dbPages;
|
||||
global $dbUsers;
|
||||
global $dbCategories;
|
||||
global $Parsedown;
|
||||
global $Site;
|
||||
|
||||
@ -49,6 +50,10 @@ function buildPage($key)
|
||||
$username = $page->username();
|
||||
$page->setField('user', $dbUsers->getUser($username));
|
||||
|
||||
// Category
|
||||
$categoryKey = $page->categoryKey();
|
||||
$page->setField('categoryMap', $dbCategories->getMap($categoryKey));
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,30 @@ class Page {
|
||||
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
|
||||
// (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
|
||||
public function tags($returnsArray=false)
|
||||
{
|
||||
global $Url;
|
||||
|
||||
$tags = $this->getField('tags');
|
||||
|
||||
if($returnsArray) {
|
||||
|
||||
if($tags==false) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $tags;
|
||||
}
|
||||
else {
|
||||
if($tags==false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return string with tags separeted by comma.
|
||||
return implode(', ', $tags);
|
||||
}
|
||||
@ -314,12 +332,6 @@ class Page {
|
||||
return $this->getField('readMore');
|
||||
}
|
||||
|
||||
//
|
||||
public function category()
|
||||
{
|
||||
return $this->getField('category');
|
||||
}
|
||||
|
||||
public function uuid()
|
||||
{
|
||||
return $this->getField('uuid');
|
||||
|
Loading…
Reference in New Issue
Block a user