Pages for Content

This commit is contained in:
Diego Najar 2017-10-02 22:42:18 +02:00
parent 825898f110
commit d4afe3b843
19 changed files with 184 additions and 176 deletions

View File

@ -28,7 +28,7 @@ $published = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
// Check if out of range the pageNumber
if (empty($published) && $Url->pageNumber()>1) {
Redirect::page('pages');
Redirect::page('content');
}
// List of drafts pages
@ -39,4 +39,4 @@ $scheduled = $dbPages->getScheduledDB();
$static = $dbPages->getStaticDB();
// Title of the page
$layout['title'] .= ' - '.$Language->g('Manage Pages');
$layout['title'] .= ' - '.$Language->g('Manage content');

View File

@ -20,18 +20,18 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if( isset($_POST['delete-page']) ) {
if( deletePage($_POST['key']) ) {
Alert::set( $Language->g('The changes have been saved') );
Redirect::page('pages');
Redirect::page('content');
}
}
else {
$key = editPage($_POST);
if( $key!==false ) {
Alert::set( $Language->g('The changes have been saved') );
Redirect::page('edit-page/'.$key);
Redirect::page('edit-content/'.$key);
}
}
Redirect::page('pages');
Redirect::page('content');
}
// ============================================================================
@ -41,8 +41,8 @@ $pageKey = $layout['parameters'];
$page = buildPage($pageKey);
if ($page===false) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$pageKey);
Redirect::page('pages');
Redirect::page('content');
}
// Title of the page
$layout['title'] .= ' - '.$Language->g('Edit page').' - '.$page->title();
$layout['title'] .= ' - '.$Language->g('Edit content').' - '.$page->title();

View File

@ -18,7 +18,7 @@
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
createPage($_POST);
Redirect::page('pages');
Redirect::page('content');
}
// ============================================================================
@ -26,4 +26,4 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// ============================================================================
// Title of the page
$layout['title'] .= ' - '.$Language->g('New page');
$layout['title'] .= ' - '.$Language->g('New content');

View File

@ -32,7 +32,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$allPublishedPages = buildAllpages(true);
// Homepage select options
$homepageOptions = array();
$homepageOptions = array(' '=>'- '.$L->g('Latest content').' -');
foreach($allPublishedPages as $key=>$page) {
$parentKey = $page->parentKey();
if ($parentKey) {

View File

@ -58,8 +58,8 @@ $(document).ready(function() {
<div class="uk-offcanvas-bar">
<ul class="uk-nav uk-nav-offcanvas">
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'dashboard' ?>"><?php $L->p('Dashboard') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><?php $L->p('New page') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-pages' ?>"><?php $L->p('Manage pages') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-content' ?>"><?php $L->p('New content') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'content' ?>"><?php $L->p('Manage content') ?></a></li>
<?php if($Login->role() == 'admin') { ?>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'categories' ?>"><?php $L->p('Manage categories') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>"><?php $L->p('Manage users') ?></a></li>
@ -102,13 +102,13 @@ $(document).ready(function() {
</li>
<li class="uk-nav-header"><?php $L->p('Publish') ?></li>
<li <?php echo ($layout['view']=='new-page')?'class="uk-active"':'' ?>>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><?php $L->p('New page') ?></a>
<li <?php echo ($layout['view']=='new-content')?'class="uk-active"':'' ?>>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-content' ?>"><?php $L->p('New content') ?></a>
</li>
<li class="uk-nav-header"><?php $L->p('Manage') ?></li>
<li <?php echo ($layout['view']=='pages')?'class="uk-active"':'' ?>>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'pages' ?>"><?php $L->p('Pages') ?></a>
<li <?php echo ($layout['view']=='content')?'class="uk-active"':'' ?>>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'content' ?>"><?php $L->p('Content') ?></a>
</li>
<li <?php echo ($layout['view']=='categories')?'class="uk-active"':'' ?>>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'categories' ?>"><?php $L->p('Categories') ?></a>
@ -145,8 +145,8 @@ $(document).ready(function() {
if( Sanitize::pathFile(PATH_ADMIN_VIEWS, $layout['view'].'.php') ) {
include(PATH_ADMIN_VIEWS.$layout['view'].'.php');
} else {
echo '<h1 style="width:100%; text-align:center">Hey!</h1>';
echo '<h2 style="width:100%; text-align:center">Have you seen my ball?</h2>';
echo '<h1 style="width:100%; text-align:center">'.$L->g('Page not found').'</h1>';
echo '<h2 style="width:100%; text-align:center">'.$L->g('Have you seen my ball').'</h2>';
}
?>
</div>

View File

@ -1,8 +1,8 @@
<?php
HTML::title(array('title'=>$L->g('Manage pages'), 'icon'=>'folder'));
HTML::title(array('title'=>$L->g('Manage content'), 'icon'=>'folder'));
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'new-page"><i class="uk-icon-plus"></i> '.$L->g('Add new page').'</a>';
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'new-content"><i class="uk-icon-plus"></i> '.$L->g('Add new content').'</a>';
echo '
<table class="uk-table uk-table-striped">
@ -50,7 +50,7 @@ function table($status, $icon='arrow-circle-o-down') {
$page = buildPage($pageKey);
echo '<tr>';
echo '<td>
<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'
<a href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'">'
.($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ')
.'</a>
</td>';

View File

@ -4,13 +4,13 @@
<div class="uk-width-medium-1-3">
<div class="uk-panel">
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><i class="uk-icon-pencil"></i> <?php $L->p('New page') ?></a></h4>
<p><?php $L->p('Create a new page for your site') ?></p>
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-content' ?>"><i class="uk-icon-pencil"></i> <?php $L->p('New content') ?></a></h4>
<p><?php $L->p('Create new content for your site') ?></p>
</div>
<div class="uk-panel">
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'pages' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Manage pages') ?></a></h4>
<p><?php $L->p('Edit or delete pages from your site') ?></p>
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'content' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Manage content') ?></a></h4>
<p><?php $L->p('Edit or delete content from your site') ?></p>
</div>
</div>
@ -19,7 +19,7 @@
<div class="uk-panel">
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-category' ?>"><i class="uk-icon-file-text-o"></i> <?php $L->p('New category') ?></a></h4>
<p><?php $L->p('Create a new category to organize your pages') ?></p>
<p><?php $L->p('Create a new category to organize your content') ?></p>
</div>
<div class="uk-panel">
@ -99,18 +99,18 @@
<div class="uk-width-1-3">
<div class="uk-panel">
<h4 class="panel-title"><?php $L->p('Scheduled pages') ?></h4>
<h4 class="panel-title"><?php $L->p('Scheduled content') ?></h4>
<ul class="uk-list">
<?php
$scheduledPages = $dbPages->getScheduledDB();
if( empty($scheduledPages) ) {
echo '<li>'.$Language->g('There are no scheduled pages').'</li>';
echo '<li>'.$Language->g('There are no scheduled content').'</li>';
}
else {
$keys = array_keys($scheduledPages);
foreach($keys as $key) {
$page = buildPage($key);
echo '<li><span class="label-time">'.$page->dateRaw(SCHEDULED_DATE_FORMAT).'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($page->title()?$page->title():'['.$Language->g('Empty title').'] ').'</a></li>';
echo '<li><span class="label-time">'.$page->dateRaw(SCHEDULED_DATE_FORMAT).'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'">'.($page->title()?$page->title():'['.$Language->g('Empty title').'] ').'</a></li>';
}
}
?>
@ -122,7 +122,7 @@
<table class="uk-table statistics">
<tbody>
<tr>
<td><?php $Language->p('Pages') ?></td>
<td><?php $Language->p('Content') ?></td>
<td><?php echo $dbPages->count() ?></td>
</tr>
<tr>
@ -138,18 +138,18 @@
<div class="uk-width-1-3">
<div class="uk-panel">
<h4 class="panel-title"><?php $L->p('Drafts') ?></h4>
<h4 class="panel-title"><?php $L->p('Draft content') ?></h4>
<ul class="uk-list">
<?php
$draftPages = $dbPages->getDraftDB();
if( empty($draftPages) ) {
echo '<li>'.$Language->g('There are no draft pages').'</li>';
echo '<li>'.$Language->g('There are no draft content').'</li>';
}
else {
$keys = array_keys($draftPages);
foreach($keys as $key) {
$page = buildPage($key);
echo '<li><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($page->title()?$page->title():'['.$Language->g('Empty title').'] ').'</a></li>';
echo '<li><a href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'">'.($page->title()?$page->title():'['.$Language->g('Empty title').'] ').'</a></li>';
}
}
?>

View File

@ -1,6 +1,6 @@
<?php
HTML::title(array('title'=>$L->g('Edit page'), 'icon'=>'file-text-o'));
HTML::title(array('title'=>$L->g('Edit content'), 'icon'=>'file-text-o'));
HTML::formOpen(array('class'=>'uk-form-stacked'));
@ -47,7 +47,7 @@ echo '<div class="bl-publish-view uk-width-8-10">';
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.'pages">'.$L->g('Cancel').'</a>';
echo ' <a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'content">'.$L->g('Cancel').'</a>';
}
echo '</div>';
@ -154,14 +154,16 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
'name'=>'date',
'value'=>$page->dateRaw(),
'class'=>'uk-width-1-1 uk-form-medium',
'tip'=>$L->g('To schedule the page select the date and time'),
'tip'=>$L->g('To schedule the content select the date and time'),
'label'=>$L->g('Date')
));
echo '<hr>';
// Parent input
// Check if the page has children
if(count($page->children())==0) {
$options = array();
$options = array(' '=>'- '.$L->g('No parent').' -');
$parentsList = $dbPages->getParents();
$parentsKey = array_keys($parentsList);
foreach($parentsKey as $pageKey) {
@ -176,20 +178,23 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
'class'=>'uk-width-1-1 uk-form-medium',
'options'=>$options,
'selected'=>$page->parentKey(),
'tip'=>'',
'addEmptySpace'=>true
'tip'=>''
));
}
echo '<hr>';
// Position input
HTML::formInputText(array(
'name'=>'position',
'value'=>$page->position(),
'class'=>'uk-width-1-1 uk-form-medium',
'label'=>$L->g('Position'),
'tip'=>$L->g('This field is used when you order the pages by position')
'tip'=>$L->g('This field is used when you order the content by position')
));
echo '<hr>';
// External Coverimage
HTML::formInputText(array(
'name'=>'externalCoverImage',
@ -199,12 +204,14 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
'tip'=>$L->g('Full image URL')
));
echo '<hr>';
// Slug input
HTML::formInputText(array(
'name'=>'slug',
'value'=>$page->slug(),
'class'=>'uk-width-1-1 uk-form-medium',
'tip'=>$L->g('URL associated with the page'),
'tip'=>$L->g('URL associated with the content'),
'label'=>$L->g('Friendly URL')
));

View File

@ -1,6 +1,6 @@
<?php
HTML::title(array('title'=>$L->g('New page'), 'icon'=>'file-text-o'));
HTML::title(array('title'=>$L->g('New content'), 'icon'=>'file-text-o'));
HTML::formOpen(array('class'=>'uk-form-stacked'));
@ -35,7 +35,7 @@ echo '<div class="bl-publish-view uk-width-8-10">';
echo '<div class="uk-form-row uk-margin-bottom">
<button class="uk-button uk-button-primary" type="submit">'.$L->g('Save').'</button>
<button class="uk-button uk-button-primary" type="button" id="jsSaveDraft">'.$L->g('Save as draft').'</button>
<a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'pages">'.$L->g('Cancel').'</a>
<a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'content">'.$L->g('Cancel').'</a>
</div>';
echo '</div>';
@ -132,12 +132,14 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
'name'=>'date',
'value'=>Date::current(DB_DATE_FORMAT),
'class'=>'uk-width-1-1 uk-form-medium',
'tip'=>$L->g('To schedule the page select the date and time'),
'tip'=>$L->g('To schedule the content select the date and time'),
'label'=>$L->g('Date')
));
echo '<hr>';
// Parent input
$options = array();
$options = array(' '=>'- '.$L->g('No parent').' -');
$parentsList = $dbPages->getParents();
$parentsKey = array_keys($parentsList);
foreach($parentsKey as $pageKey) {
@ -151,34 +153,41 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
'class'=>'uk-width-1-1 uk-form-medium',
'options'=>$options,
'selected'=>'',
'tip'=>'',
'addEmptySpace'=>true
'tip'=>''
));
echo '<hr>';
// Position input
HTML::formInputText(array(
'name'=>'position',
'value'=>'1',
'type'=>'number',
'value'=>$dbPages->nextPositionNumber(),
'class'=>'uk-width-1-1 uk-form-medium',
'label'=>$L->g('Position'),
'tip'=>$L->g('This field is used when you order the pages by position')
'tip'=>$L->g('This field is used when you order the content by position')
));
echo '<hr>';
// External Coverimage
HTML::formInputText(array(
'name'=>'externalCoverImage',
'value'=>'',
'class'=>'uk-width-1-1 uk-form-medium',
'label'=>$L->g('External Cover Image'),
'tip'=>$L->g('Full image URL')
'tip'=>$L->g('Full image URL'),
'placeholder'=>"https://"
));
echo '<hr>';
// Slug input
HTML::formInputText(array(
'name'=>'slug',
'value'=>'',
'class'=>'uk-width-1-1 uk-form-medium',
'tip'=>$L->g('URL associated with the page'),
'tip'=>$L->g('URL associated with the content'),
'label'=>$L->g('Friendly URL')
));

View File

@ -9,23 +9,24 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
'value'=>$Security->getTokenCSRF()
));
HTML::legend(array('value'=>$L->g('General'), 'class'=>'first-child'));
HTML::legend(array('value'=>$L->g('Content')));
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', '-1'=>'All pages'),
'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8', '-1'=>$L->g('All pages')),
'selected'=>$Site->itemsPerPage(),
'class'=>'uk-width-1-3 uk-form-medium',
'tip'=>$L->g('Number of items to show per page')
));
HTML::formInputText(array(
'name'=>'url',
'label'=>$L->g('Site URL'),
'value'=>$Site->url(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>$L->g('full-url-of-your-site')
HTML::formSelect(array(
'name'=>'orderBy',
'label'=>$L->g('Order content by'),
'options'=>array('date'=>$L->g('Date'),'position'=>$L->g('Position')),
'selected'=>$Site->orderBy(),
'class'=>'uk-width-1-3 uk-form-medium',
'tip'=>$L->g('order-the-content-by-date-to-build-a-blog')
));
HTML::legend(array('value'=>$L->g('Predefined pages')));
@ -36,29 +37,17 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
'options'=>$homepageOptions,
'selected'=>$Site->homepage(),
'class'=>'uk-width-1-3 uk-form-medium',
'tip'=>$L->g('Returning page for the main page'),
'addEmptySpace'=>true
'tip'=>$L->g('Returning page for the main page')
));
$homepageOptions[' '] = '- '.$L->g('Default message').' -';
HTML::formSelect(array(
'name'=>'pageNotFound',
'label'=>$L->g('Page not found'),
'options'=>$homepageOptions,
'selected'=>$Site->pageNotFound(),
'class'=>'uk-width-1-3 uk-form-medium',
'tip'=>$L->g('Returning page when the page doesnt exist'),
'addEmptySpace'=>true
));
HTML::legend(array('value'=>$L->g('Website or Blog')));
HTML::formSelect(array(
'name'=>'orderBy',
'label'=>$L->g('Order content By'),
'options'=>array('date'=>$L->g('Date'),'position'=>$L->g('Position')),
'selected'=>$Site->orderBy(),
'class'=>'uk-width-1-3 uk-form-medium',
'tip'=>$L->g('Order the content by position to build a Website')
'tip'=>$L->g('Returning page when the page doesnt exist')
));
HTML::legend(array('value'=>$L->g('Email account settings')));
@ -71,6 +60,17 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
'tip'=>$L->g('Emails will be sent from this address')
));
HTML::legend(array('value'=>$L->g('Site URL')));
HTML::formInputText(array(
'name'=>'url',
'label'=>'',
'value'=>$Site->url(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>$L->g('full-url-of-your-site'),
'placeholder'=>'https://'
));
HTML::legend(array('value'=>$L->g('URL Filters')));
HTML::formInputText(array(

View File

@ -72,7 +72,7 @@ function buildPlugins()
$Plugin = new $pluginClass;
// Check if the plugin is translated
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->locale().'.json';
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->language().'.json';
if( !Sanitize::pathFile($languageFilename) ) {
$languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.DEFAULT_LANGUAGE_FILE;
}

View File

@ -18,7 +18,7 @@ function buildThemes()
foreach($themesPaths as $themePath)
{
// Check if the theme is translated.
$languageFilename = $themePath.DS.'languages'.DS.$Site->locale().'.json';
$languageFilename = $themePath.DS.'languages'.DS.$Site->language().'.json';
if( !Sanitize::pathFile($languageFilename) ) {
$languageFilename = $themePath.DS.'languages'.DS.DEFAULT_LANGUAGE_FILE;
}

View File

@ -10,7 +10,8 @@ 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, static, draft, scheduled
'type'=> array('inFile'=>false, 'value'=>'post'), // post, page
'date'=> array('inFile'=>false, 'value'=>''),
'dateModified'=> array('inFile'=>false, 'value'=>''),
'position'=> array('inFile'=>false, 'value'=>0),
@ -66,19 +67,21 @@ class dbPages extends dbJSON
// Generate UUID
$args['uuid'] = $this->generateUUID();
// Date
$currentDate = Date::current(DB_DATE_FORMAT);
// Validate date
if ( !Valid::date($args['date'], DB_DATE_FORMAT) ) {
$args['date'] = $currentDate;
$args['date'] = Date::current(DB_DATE_FORMAT);
}
// Schedule page
if ( ($args['date']>$currentDate) && ($args['status']=='published') ) {
if ( ($args['date']>Date::current(DB_DATE_FORMAT)) && ($args['status']=='published') ) {
$args['status'] = 'scheduled';
}
// Set type
if ($args['status']=='static') {
$args['type'] = 'page';
}
foreach ($this->dbFields as $field=>$options) {
$value = $args[$field];
@ -143,7 +146,11 @@ class dbPages extends dbJSON
}
} else {
// By default is the current value
if (isset($this->db[$args['key']][$field])) {
$value = $this->db[$args['key']][$field];
} else {
$value = $options['value'];
}
}
$args[$field] = $value;
@ -158,20 +165,17 @@ class dbPages extends dbJSON
$args['date'] = $this->db[$args['key']]['date'];
}
// Date
$currentDate = Date::current(DB_DATE_FORMAT);
// Modified date
$args['dateModified'] = Date::current(DB_DATE_FORMAT);
// Validate date
if ( !Valid::date($args['date'], DB_DATE_FORMAT) ) {
$args['date'] = $currentDate;
// Schedule page
if ( ($args['date']>Date::current(DB_DATE_FORMAT)) && ($args['status']=='published') ) {
$args['status'] = 'scheduled';
}
// Schedule page
if ( ($args['date']>$currentDate) && ($args['status']=='published') ) {
$args['status'] = 'scheduled';
// Set type
if ($args['status']=='static') {
$args['type'] = 'page';
}
foreach ($this->dbFields as $field=>$options) {
@ -227,17 +231,12 @@ class dbPages extends dbJSON
public function delete($key)
{
// Page doesn't exist in database
if(!$this->exists($key)) {
if (!$this->exists($key)) {
Log::set(__METHOD__.LOG_SEP.'The page does not exist. Key: '.$key);
}
// Delete the index.txt file
if( Filesystem::rmfile(PATH_PAGES.$key.DS.FILENAME) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the file '.FILENAME);
}
// Delete the directory
if( Filesystem::rmdir(PATH_PAGES.$key) === false ) {
// Delete directory and files
if (Filesystem::deleteRecursive(PATH_PAGES.$key) === false) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the directory '.PATH_PAGES.$key);
}
@ -245,14 +244,14 @@ class dbPages extends dbJSON
unset($this->db[$key]);
// Save the database.
if( $this->save() === false ) {
if ($this->save()===false) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
}
return true;
}
// Change a value of a page
// Change a field's value
public function setField($key, $field, $value)
{
if( $this->exists($key) ) {
@ -263,12 +262,7 @@ class dbPages extends dbJSON
return false;
}
/* DEPRECATED
public function setStatus($key, $value)
{
return $this->setField($key, 'status', $value);
}
*/
// Returns a database with published pages
public function getPublishedDB()
{
@ -281,7 +275,8 @@ class dbPages extends dbJSON
return $tmp;
}
// (array) Returns a database with the static pages
// Returns an array with a list of keys/database of static pages
// By default the static pages are sort by position
public function getStaticDB()
{
$tmp = $this->db;
@ -294,11 +289,11 @@ class dbPages extends dbJSON
return $tmp;
}
// Returns a database with drafts pages
// Returns an array with a list of keys/database of draft pages
public function getDraftDB()
{
$tmp = $this->db;
foreach($tmp as $key=>$fields) {
foreach ($tmp as $key=>$fields) {
if($fields['status']!='draft') {
unset($tmp[$key]);
}
@ -306,7 +301,7 @@ class dbPages extends dbJSON
return $tmp;
}
// Returns a database with drafts pages
// Returns an array with a list of keys/database of scheduled pages
public function getScheduledDB()
{
$tmp = $this->db;
@ -318,16 +313,28 @@ class dbPages extends dbJSON
return $tmp;
}
// 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)
{
if( $this->exists($key) ) {
if ($this->exists($key)) {
return $this->db[$key];
}
return false;
}
// Returns the next number of the bigger position
public function nextPositionNumber()
{
$tmp = 1;
foreach ($this->db as $key=>$fields) {
if ($fields['position']>$tmp) {
$tmp = $fields['position'];
}
}
return ++$tmp;
}
// Returns an array with a list of pages, FALSE if out of range
// The database is sorted by date or by position
// (int) $pageNumber, the page number
@ -337,7 +344,7 @@ class dbPages extends dbJSON
{
$db = $this->db;
if( $onlyPublished ) {
if ($onlyPublished) {
$db = $this->getPublishedDB();
}
@ -353,7 +360,7 @@ class dbPages extends dbJSON
$end = (int) min( ($init + $amountOfItems - 1), $total );
$outrange = $init<0 ? true : $init>$end;
if(!$outrange) {
if (!$outrange) {
return array_slice($db, $init, $amountOfItems, true);
}
@ -394,11 +401,10 @@ class dbPages extends dbJSON
public function sortBy()
{
if( ORDER_BY=='date' ) {
if (ORDER_BY=='date') {
return $this->sortByDate(true);
} else {
return $this->sortByPosition(false);
}
return $this->sortByPosition(false);
}
// Sort pages by position
@ -406,17 +412,18 @@ class dbPages extends dbJSON
{
if($HighToLow) {
uasort($this->db, array($this, 'sortByPositionHighToLow'));
}
else {
} else {
uasort($this->db, array($this, 'sortByPositionLowToHigh'));
}
return true;
}
private function sortByPositionLowToHigh($a, $b) {
private function sortByPositionLowToHigh($a, $b)
{
return $a['position']>$b['position'];
}
private function sortByPositionHighToLow($a, $b) {
private function sortByPositionHighToLow($a, $b)
{
return $a['position']<$b['position'];
}
@ -425,17 +432,18 @@ class dbPages extends dbJSON
{
if($HighToLow) {
uasort($this->db, array($this, 'sortByDateHighToLow'));
}
else {
} else {
uasort($this->db, array($this, 'sortByDateLowToHigh'));
}
return true;
}
private function sortByDateLowToHigh($a, $b) {
private function sortByDateLowToHigh($a, $b)
{
return $a['date']>$b['date'];
}
private function sortByDateHighToLow($a, $b) {
private function sortByDateHighToLow($a, $b)
{
return $a['date']<$b['date'];
}
@ -626,34 +634,6 @@ class dbPages extends dbJSON
return Text::firstCharUp($field).': '.$value;
}
/* DEPRECATED
public function getDBFields()
{
return $this->dbFields;
}
*/
/* DEPRECATED
public function parentKeyList()
{
return $this->parentKeyList;
}
*/
/* DEPRECATED
public function parentKeyExists($key)
{
return isset( $this->parentKeyList[$key] );
}
*/
/* DEPRECATED
public function addParentKey($key)
{
$this->parentKeyList[$key] = $key;
}
*/
// Returns the database
public function getDB()
{

View File

@ -328,11 +328,11 @@ function createPage($args) {
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'new-page-created',
'dictionaryKey'=>'new-content-created',
'notes'=>$args['title']
));
Alert::set( $Language->g('new-page-created') );
Alert::set( $Language->g('new-content-created') );
return $key;
}
@ -391,7 +391,7 @@ function editPage($args) {
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'page-edited',
'dictionaryKey'=>'content-edited',
'notes'=>$args['title']
));
@ -418,7 +418,7 @@ function deletePage($key) {
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'page-deleted',
'dictionaryKey'=>'content-deleted',
'notes'=>$key
));

View File

@ -43,7 +43,7 @@
"new-category": "New category",
"you-do-not-have-sufficient-permissions": "You do not have sufficient permissions",
"add-a-new-user": "Add a new user",
"url-associated-with-the-page": "URL associated with the page.",
"url-associated-with-the-content": "URL associated with the content.",
"language-and-timezone": "Language and timezone",
"change-your-language-and-region-settings": "Change your language and region settings.",
"notifications": "Notifications",
@ -93,7 +93,7 @@
"username": "Username",
"first-name": "First name",
"last-name": "Last name",
"to-schedule-the-page-select-the-date-and-time": "To schedule the page select the date and time.",
"to-schedule-the-content-select-the-date-and-time": "To schedule the content select the date and time, the status has to be set to \"Published\".",
"email": "Email",
"role": "Role",
"registered": "Registered",
@ -149,16 +149,16 @@
"number-of-items-to-show-per-page": "Number of items to show per page.",
"website-or-blog": "Website or Blog",
"scheduled-pages": "Scheduled pages",
"there-are-no-scheduled-pages": "There are no scheduled pages",
"there-are-no-draft-pages": "There are no draft pages",
"order-content-by": "Order content By",
"there-are-no-scheduled-pages": "There are no scheduled pages.",
"there-are-no-draft-pages": "There are no draft pages.",
"order-content-by": "Order content by",
"edit-or-delete-content-from-your-site": "Edit or delete content from your site",
"order-the-content-by-position-to-build-a-website": "Order the content by position to build a Website or order the content by date to build a Blog.",
"order-the-content-by-date-to-build-a-blog": "Order the content by date to build a Blog or order the content by position to build a Website.",
"page-not-found-content": "Hey! looks like the page doesn't exist.",
"page-not-found": "Page not found",
"predefined-pages": "Predefined pages",
"returning-page-when-the-page-doesnt-exist": "Returning page when the page doesn't exist, leave it blank if you want to returns a default message.",
"returning-page-for-the-main-page": "Returning page for the main page, leave it blank if you want to show all the pages on the main page.",
"returning-page-when-the-page-doesnt-exist": "Returning page when the page doesn't exist, by default returns a default message.",
"returning-page-for-the-main-page": "Returning page for the main page, by default shows the latest content order by date or position.",
"full-url-of-your-site": "Full URL of your site. Complete with the protocol HTTP or HTTPS (only if you have enabled SSL on your server).",
"with-the-locales-you-can-set-the-regional-user-interface": "With the locales, you can set the regional user interface, such as the dates in your language. The locales need to be installed on your system.",
"bludit-installer": "Bludit Installer",
@ -211,7 +211,6 @@
"create-a-new-category-to-organize-your-pages": "Create a new category to organize your pages",
"edit-or-delete-pages-from-your-site": "Edit or delete pages from your site",
"add-new-page": "Add new page",
"this-field-is-used-when-you-order-the-pages-by-position": "This field is used when you order the pages by position.",
"about-your-site-or-yourself": "About your site or yourself",
"homepage": "Homepage",
"disabled": "Disabled",
@ -223,11 +222,24 @@
"page-edited": "Page edited",
"the-password-and-confirmation-password-do-not-match": "The password and confirmation password do not match",
"scheduled-content": "Scheduled content",
"there-are-no-scheduled-content": "There are no scheduled content",
"there-are-no-scheduled-content": "There are no scheduled content.",
"new-content-created": "New content created",
"content-edited": "Content edited",
"content-deleted": "Contente deleted",
"undefined": "Undefined",
"create-new-content-for-your-site": "Create new content for your site",
"there-are-no-draft-content": "There are no draft content"
"there-are-no-draft-content": "There are no draft content.",
"order-the-pages-by-date-to-build-a-blog": "Order the pages by date to build a Blog or order the pages by position to build a Website.",
"order-items-by": "Order items by",
"all-pages": "All pages",
"dynamic": "Dynamic",
"type": "Type",
"draft-content": "Draft content",
"post": "Post",
"page": "Page",
"default": "Default",
"latest-content": "Latest content",
"default-message": "Default message",
"no-parent": "No parent",
"have-you-seen-my-ball": "Have you seen my ball?"
}

View File

@ -2,6 +2,6 @@
"plugin-data":
{
"name": "Menu",
"description": "Shows a menu on the sidebar, organized by categories and pages."
"description": "Shows a menu on the sidebar and the content organized by categories."
}
}

View File

@ -3,8 +3,8 @@
class pluginsimpleMDE extends Plugin {
private $loadOnController = array(
'new-page',
'edit-page'
'new-content',
'edit-content'
);
public function init()

View File

@ -2,6 +2,6 @@
"plugin-data":
{
"name": "TinyMCE",
"description": "HTML Editor for formatting content. This plugin needs a license, there are free and paid. <br> Read more about on <a href=\"https://www.tinymce.com\">Tinymce</a>."
"description": "HTML Editor for formatting content. This plugin needs a license, there are free and paid. <br> Read more about it on <a href=\"https://www.tinymce.com\">Tinymce</a>."
}
}

View File

@ -3,8 +3,8 @@
class pluginTinymce extends Plugin {
private $loadOnController = array(
'new-page',
'edit-page'
'new-content',
'edit-content'
);
public function adminHead()