Autosave bug fixes
This commit is contained in:
parent
87c3b31b88
commit
f0df4eb0ab
|
@ -2,6 +2,11 @@
|
||||||
html {
|
html {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
|
background: #fcfcfc;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background: #fcfcfc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -247,7 +247,7 @@ EOF;
|
||||||
}
|
}
|
||||||
$disabled = isset($args['disabled'])?'disabled':'';
|
$disabled = isset($args['disabled'])?'disabled':'';
|
||||||
|
|
||||||
$class = 'form-control';
|
$class = 'form-group row';
|
||||||
if (isset($args['class'])) {
|
if (isset($args['class'])) {
|
||||||
$class = $class.' '.$args['class'];
|
$class = $class.' '.$args['class'];
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <<<EOF
|
return <<<EOF
|
||||||
<div class="form-group row">
|
<div class="$class">
|
||||||
<label for="$id" class="col-sm-2">$label</label>
|
<label for="$id" class="col-sm-2">$label</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
|
|
|
@ -89,9 +89,7 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('External Cover Image')));
|
echo Bootstrap::formTitle(array('title'=>$L->g('External Cover Image')));
|
||||||
?>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
echo Bootstrap::formInputTextBlock(array(
|
echo Bootstrap::formInputTextBlock(array(
|
||||||
'name'=>'externalCoverImage',
|
'name'=>'externalCoverImage',
|
||||||
'placeholder'=>"https://",
|
'placeholder'=>"https://",
|
||||||
|
@ -105,6 +103,55 @@
|
||||||
<!-- TABS OPTIONS -->
|
<!-- TABS OPTIONS -->
|
||||||
<div class="tab-pane" id="options" role="tabpanel" aria-labelledby="options-tab">
|
<div class="tab-pane" id="options" role="tabpanel" aria-labelledby="options-tab">
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
echo Bootstrap::formTitle(array('title'=>'Advanced'));
|
||||||
|
|
||||||
|
// Date
|
||||||
|
echo Bootstrap::formInputText(array(
|
||||||
|
'name'=>'date',
|
||||||
|
'label'=>'Date',
|
||||||
|
'placeholder'=>'',
|
||||||
|
'value'=>Date::current(DB_DATE_FORMAT),
|
||||||
|
'tip'=>'Date format: <code>YYYY-MM-DD Hours:Minutes:Seconds</code>'
|
||||||
|
));
|
||||||
|
|
||||||
|
// Type
|
||||||
|
echo Bootstrap::formSelect(array(
|
||||||
|
'name'=>'type',
|
||||||
|
'label'=>'Type',
|
||||||
|
'selected'=>'',
|
||||||
|
'options'=>array(
|
||||||
|
''=>'- Default -',
|
||||||
|
'sticky'=>'Sticky',
|
||||||
|
'static'=>'Static'
|
||||||
|
),
|
||||||
|
'tip'=>'???'
|
||||||
|
));
|
||||||
|
|
||||||
|
// Parent
|
||||||
|
echo Bootstrap::formInputText(array(
|
||||||
|
'name'=>'parentTMP',
|
||||||
|
'label'=>$L->g('Parent'),
|
||||||
|
'placeholder'=>'Start typing a page title to see a list of suggestions.',
|
||||||
|
'tip'=>'Select a page to arrange your content in hierarchies.'
|
||||||
|
));
|
||||||
|
|
||||||
|
// Position
|
||||||
|
echo Bootstrap::formInputText(array(
|
||||||
|
'name'=>'position',
|
||||||
|
'label'=>$L->g('Position'),
|
||||||
|
'tip'=>'Field used when ordering content by position',
|
||||||
|
'value'=>$dbPages->nextPositionNumber()
|
||||||
|
));
|
||||||
|
|
||||||
|
// Template
|
||||||
|
echo Bootstrap::formInputText(array(
|
||||||
|
'name'=>'template',
|
||||||
|
'label'=>'Template',
|
||||||
|
'placeholder'=>'',
|
||||||
|
'tip'=>'Write a template name to filter the page in the theme and change the style of the page.'
|
||||||
|
));
|
||||||
|
|
||||||
echo Bootstrap::formTitle(array('title'=>'SEO'));
|
echo Bootstrap::formTitle(array('title'=>'SEO'));
|
||||||
|
|
||||||
// Tags
|
// Tags
|
||||||
|
@ -120,16 +167,15 @@
|
||||||
'name'=>'slug',
|
'name'=>'slug',
|
||||||
'tip'=>$L->g('URL associated with the content'),
|
'tip'=>$L->g('URL associated with the content'),
|
||||||
'label'=>$L->g('Friendly URL'),
|
'label'=>$L->g('Friendly URL'),
|
||||||
'placeholder'=>'Leave empty for automaticly complete'
|
'placeholder'=>'Leave empty for autocomplete by Bludit.'
|
||||||
));
|
));
|
||||||
|
|
||||||
echo '<hr>';
|
|
||||||
|
|
||||||
echo Bootstrap::formCheckbox(array(
|
echo Bootstrap::formCheckbox(array(
|
||||||
'name'=>'noindex',
|
'name'=>'noindex',
|
||||||
'label'=>'Robots',
|
'label'=>'Robots',
|
||||||
'labelForCheckbox'=>'Apply <code>noindex</code> to this page',
|
'labelForCheckbox'=>'Apply <code>noindex</code> to this page',
|
||||||
'placeholder'=>'',
|
'placeholder'=>'',
|
||||||
|
'class'=>'mt-4',
|
||||||
'tip'=>'This tells search engines not to show this page in their search results.'
|
'tip'=>'This tells search engines not to show this page in their search results.'
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -149,51 +195,6 @@
|
||||||
'tip'=>'This tells search engines not to save a cached copy of this page.'
|
'tip'=>'This tells search engines not to save a cached copy of this page.'
|
||||||
));
|
));
|
||||||
|
|
||||||
echo '<hr>';
|
|
||||||
|
|
||||||
echo Bootstrap::formTitle(array('title'=>'Advanced'));
|
|
||||||
|
|
||||||
// Date
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'date',
|
|
||||||
'label'=>'Date',
|
|
||||||
'placeholder'=>'YYYY-MM-DD hh:mm:ss',
|
|
||||||
'value'=>Date::current(DB_DATE_FORMAT)
|
|
||||||
));
|
|
||||||
|
|
||||||
// Type
|
|
||||||
echo Bootstrap::formSelect(array(
|
|
||||||
'name'=>'type',
|
|
||||||
'label'=>'Type',
|
|
||||||
'selected'=>'',
|
|
||||||
'options'=>array(
|
|
||||||
''=>'- Default -',
|
|
||||||
'sticky'=>'Sticky',
|
|
||||||
'static'=>'Static'
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
// Parent
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'parentTMP',
|
|
||||||
'label'=>$L->g('Parent'),
|
|
||||||
'tip'=>'Start typing a page title to see a list of suggestions.'
|
|
||||||
));
|
|
||||||
|
|
||||||
// Position
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'position',
|
|
||||||
'label'=>$L->g('Position'),
|
|
||||||
'tip'=>$L->g('This field is used when you order the content by position'),
|
|
||||||
'value'=>$dbPages->nextPositionNumber()
|
|
||||||
));
|
|
||||||
|
|
||||||
// Template
|
|
||||||
echo Bootstrap::formInputText(array(
|
|
||||||
'name'=>'template',
|
|
||||||
'label'=>'Template',
|
|
||||||
'placeholder'=>''
|
|
||||||
));
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -20,7 +20,10 @@ class dbPages extends dbJSON
|
||||||
'md5file'=> array('inFile'=>false, 'value'=>''),
|
'md5file'=> array('inFile'=>false, 'value'=>''),
|
||||||
'uuid'=> array('inFile'=>false, 'value'=>''),
|
'uuid'=> array('inFile'=>false, 'value'=>''),
|
||||||
'allowComments'=> array('inFile'=>false, 'value'=>true),
|
'allowComments'=> array('inFile'=>false, 'value'=>true),
|
||||||
'template'=> array('inFile'=>false, 'value'=>'')
|
'template'=> array('inFile'=>false, 'value'=>''),
|
||||||
|
'noindex'=> array('inFile'=>false, 'value'=>false),
|
||||||
|
'nofollow'=> array('inFile'=>false, 'value'=>false),
|
||||||
|
'noarchive'=> array('inFile'=>false, 'value'=>false)
|
||||||
);
|
);
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
|
|
|
@ -395,33 +395,25 @@ function createPage($args) {
|
||||||
global $Language;
|
global $Language;
|
||||||
|
|
||||||
// Check if the autosave page exists for this new page and delete it
|
// Check if the autosave page exists for this new page and delete it
|
||||||
$pageKey = $dbPages->getByUUID('autosave-'.$args['uuid']);
|
$autosaveKey = $dbPages->getByUUID('autosave-'.$args['uuid']);
|
||||||
if (!empty($pageKey)) {
|
if (!empty($autosaveKey)) {
|
||||||
deletePage($pageKey);
|
Log::set('Function createPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO);
|
||||||
|
deletePage($autosaveKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The user is always the one loggued
|
// The user is always the one loggued
|
||||||
$args['username'] = Session::get('username');
|
$args['username'] = Session::get('username');
|
||||||
if ( empty($args['username']) ) {
|
if (empty($args['username'])) {
|
||||||
Log::set('Function createPage()'.LOG_SEP.'Empty username.');
|
Log::set('Function createPage()'.LOG_SEP.'Empty username.', LOG_TYPE_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // External Cover Image
|
|
||||||
// if ( !empty($args['externalCoverImage']) ) {
|
|
||||||
// $args['coverImage'] = $args['externalCoverImage'];
|
|
||||||
// unset($args['externalCoverImage']);
|
|
||||||
// }
|
|
||||||
|
|
||||||
$key = $dbPages->add($args);
|
$key = $dbPages->add($args);
|
||||||
if ($key) {
|
if ($key) {
|
||||||
// Call the plugins after page created
|
// Call the plugins after page created
|
||||||
Theme::plugins('afterPageCreate');
|
Theme::plugins('afterPageCreate');
|
||||||
|
|
||||||
// Re-index categories
|
|
||||||
reindexCategories();
|
reindexCategories();
|
||||||
|
|
||||||
// Re-index tags
|
|
||||||
reindextags();
|
reindextags();
|
||||||
|
|
||||||
// Add to syslog
|
// Add to syslog
|
||||||
|
@ -431,14 +423,13 @@ function createPage($args) {
|
||||||
));
|
));
|
||||||
|
|
||||||
Alert::set( $Language->g('new-content-created') );
|
Alert::set( $Language->g('new-content-created') );
|
||||||
|
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::set('Function createNewPage()'.LOG_SEP.'Error occurred when trying to create the page');
|
Log::set('Function createNewPage()'.LOG_SEP.'Error occurred when trying to create the page', LOG_TYPE_ERROR);
|
||||||
Log::set('Function createNewPage()'.LOG_SEP.'Cleaning database...');
|
Log::set('Function createNewPage()'.LOG_SEP.'Cleaning database...', LOG_TYPE_ERROR);
|
||||||
$dbPages->delete($key);
|
deletePage($key);
|
||||||
Log::set('Function createNewPage()'.LOG_SEP.'Cleaning finished...');
|
Log::set('Function createNewPage()'.LOG_SEP.'Cleaning finished...', LOG_TYPE_ERROR);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -450,27 +441,22 @@ function editPage($args) {
|
||||||
// Check if the autosave page exists for this new page and delete it
|
// Check if the autosave page exists for this new page and delete it
|
||||||
$pageKey = $dbPages->getByUUID('autosave-'.$args['uuid']);
|
$pageKey = $dbPages->getByUUID('autosave-'.$args['uuid']);
|
||||||
if (!empty($pageKey)) {
|
if (!empty($pageKey)) {
|
||||||
|
Log::set('Function editPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO);
|
||||||
deletePage($pageKey);
|
deletePage($pageKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the key is not empty
|
// Check if the key is not empty
|
||||||
if (empty($args['key'])) {
|
if (empty($args['key'])) {
|
||||||
Log::set('Function editPage()'.LOG_SEP.'Empty key.');
|
Log::set('Function editPage()'.LOG_SEP.'Empty key.', LOG_TYPE_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the page key exist
|
// Check if the page key exist
|
||||||
if (!$dbPages->exists($args['key'])) {
|
if (!$dbPages->exists($args['key'])) {
|
||||||
Log::set('Function editPage()'.LOG_SEP.'Page key does not exist, '.$args['key']);
|
Log::set('Function editPage()'.LOG_SEP.'Page key does not exist, '.$args['key'], LOG_TYPE_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // External Cover Image
|
|
||||||
// if (!empty($args['externalCoverImage'])) {
|
|
||||||
// $args['coverImage'] = $args['externalCoverImage'];
|
|
||||||
// unset($args['externalCoverImage']);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Title and content need to be here because from inside the dbPages is not visible
|
// Title and content need to be here because from inside the dbPages is not visible
|
||||||
if (empty($args['title']) || empty($args['content'])) {
|
if (empty($args['title']) || empty($args['content'])) {
|
||||||
$page = buildPage($args['key']);
|
$page = buildPage($args['key']);
|
||||||
|
@ -487,10 +473,7 @@ function editPage($args) {
|
||||||
// Call the plugins after page modified
|
// Call the plugins after page modified
|
||||||
Theme::plugins('afterPageModify');
|
Theme::plugins('afterPageModify');
|
||||||
|
|
||||||
// Re-index categories
|
|
||||||
reindexCategories();
|
reindexCategories();
|
||||||
|
|
||||||
// Re-index tags
|
|
||||||
reindextags();
|
reindextags();
|
||||||
|
|
||||||
// Add to syslog
|
// Add to syslog
|
||||||
|
@ -502,7 +485,7 @@ function editPage($args) {
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::set('Function editPage()'.LOG_SEP.'ERROR: Something happen when try to edit the page.');
|
Log::set('Function editPage()'.LOG_SEP.'Something happen when try to edit the page.', LOG_TYPE_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue