Autosave bug fixes
This commit is contained in:
parent
87c3b31b88
commit
f0df4eb0ab
|
@ -2,6 +2,11 @@
|
|||
html {
|
||||
height: 100%;
|
||||
font-size: 0.9rem;
|
||||
background: #fcfcfc;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #fcfcfc;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -247,7 +247,7 @@ EOF;
|
|||
}
|
||||
$disabled = isset($args['disabled'])?'disabled':'';
|
||||
|
||||
$class = 'form-control';
|
||||
$class = 'form-group row';
|
||||
if (isset($args['class'])) {
|
||||
$class = $class.' '.$args['class'];
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ EOF;
|
|||
}
|
||||
|
||||
return <<<EOF
|
||||
<div class="form-group row">
|
||||
<div class="$class">
|
||||
<label for="$id" class="col-sm-2">$label</label>
|
||||
<div class="col-sm-10">
|
||||
<div class="form-check">
|
||||
|
|
|
@ -89,9 +89,7 @@
|
|||
|
||||
<?php
|
||||
echo Bootstrap::formTitle(array('title'=>$L->g('External Cover Image')));
|
||||
?>
|
||||
|
||||
<?php
|
||||
echo Bootstrap::formInputTextBlock(array(
|
||||
'name'=>'externalCoverImage',
|
||||
'placeholder'=>"https://",
|
||||
|
@ -105,6 +103,55 @@
|
|||
<!-- TABS OPTIONS -->
|
||||
<div class="tab-pane" id="options" role="tabpanel" aria-labelledby="options-tab">
|
||||
<?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'));
|
||||
|
||||
// Tags
|
||||
|
@ -120,16 +167,15 @@
|
|||
'name'=>'slug',
|
||||
'tip'=>$L->g('URL associated with the content'),
|
||||
'label'=>$L->g('Friendly URL'),
|
||||
'placeholder'=>'Leave empty for automaticly complete'
|
||||
'placeholder'=>'Leave empty for autocomplete by Bludit.'
|
||||
));
|
||||
|
||||
echo '<hr>';
|
||||
|
||||
echo Bootstrap::formCheckbox(array(
|
||||
'name'=>'noindex',
|
||||
'label'=>'Robots',
|
||||
'labelForCheckbox'=>'Apply <code>noindex</code> to this page',
|
||||
'placeholder'=>'',
|
||||
'class'=>'mt-4',
|
||||
'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.'
|
||||
));
|
||||
|
||||
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>
|
||||
|
|
|
@ -20,7 +20,10 @@ class dbPages extends dbJSON
|
|||
'md5file'=> array('inFile'=>false, 'value'=>''),
|
||||
'uuid'=> array('inFile'=>false, 'value'=>''),
|
||||
'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()
|
||||
|
|
|
@ -395,33 +395,25 @@ function createPage($args) {
|
|||
global $Language;
|
||||
|
||||
// Check if the autosave page exists for this new page and delete it
|
||||
$pageKey = $dbPages->getByUUID('autosave-'.$args['uuid']);
|
||||
if (!empty($pageKey)) {
|
||||
deletePage($pageKey);
|
||||
$autosaveKey = $dbPages->getByUUID('autosave-'.$args['uuid']);
|
||||
if (!empty($autosaveKey)) {
|
||||
Log::set('Function createPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO);
|
||||
deletePage($autosaveKey);
|
||||
}
|
||||
|
||||
// The user is always the one loggued
|
||||
$args['username'] = Session::get('username');
|
||||
if ( empty($args['username']) ) {
|
||||
Log::set('Function createPage()'.LOG_SEP.'Empty username.');
|
||||
if (empty($args['username'])) {
|
||||
Log::set('Function createPage()'.LOG_SEP.'Empty username.', LOG_TYPE_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
// // External Cover Image
|
||||
// if ( !empty($args['externalCoverImage']) ) {
|
||||
// $args['coverImage'] = $args['externalCoverImage'];
|
||||
// unset($args['externalCoverImage']);
|
||||
// }
|
||||
|
||||
$key = $dbPages->add($args);
|
||||
if ($key) {
|
||||
// Call the plugins after page created
|
||||
Theme::plugins('afterPageCreate');
|
||||
|
||||
// Re-index categories
|
||||
reindexCategories();
|
||||
|
||||
// Re-index tags
|
||||
reindextags();
|
||||
|
||||
// Add to syslog
|
||||
|
@ -431,14 +423,13 @@ function createPage($args) {
|
|||
));
|
||||
|
||||
Alert::set( $Language->g('new-content-created') );
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
Log::set('Function createNewPage()'.LOG_SEP.'Error occurred when trying to create the page');
|
||||
Log::set('Function createNewPage()'.LOG_SEP.'Cleaning database...');
|
||||
$dbPages->delete($key);
|
||||
Log::set('Function createNewPage()'.LOG_SEP.'Cleaning finished...');
|
||||
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_TYPE_ERROR);
|
||||
deletePage($key);
|
||||
Log::set('Function createNewPage()'.LOG_SEP.'Cleaning finished...', LOG_TYPE_ERROR);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -450,27 +441,22 @@ function editPage($args) {
|
|||
// Check if the autosave page exists for this new page and delete it
|
||||
$pageKey = $dbPages->getByUUID('autosave-'.$args['uuid']);
|
||||
if (!empty($pageKey)) {
|
||||
Log::set('Function editPage()'.LOG_SEP.'Autosave deleted for '.$args['title'], LOG_TYPE_INFO);
|
||||
deletePage($pageKey);
|
||||
}
|
||||
|
||||
// Check the key is not empty
|
||||
// Check if the key is not empty
|
||||
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;
|
||||
}
|
||||
|
||||
// Check if the page key exist
|
||||
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;
|
||||
}
|
||||
|
||||
// // 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
|
||||
if (empty($args['title']) || empty($args['content'])) {
|
||||
$page = buildPage($args['key']);
|
||||
|
@ -487,10 +473,7 @@ function editPage($args) {
|
|||
// Call the plugins after page modified
|
||||
Theme::plugins('afterPageModify');
|
||||
|
||||
// Re-index categories
|
||||
reindexCategories();
|
||||
|
||||
// Re-index tags
|
||||
reindextags();
|
||||
|
||||
// Add to syslog
|
||||
|
@ -502,7 +485,7 @@ function editPage($args) {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,4 +28,4 @@ Things to do:
|
|||
- add to settings
|
||||
-- time for autosave
|
||||
-- time for check user logged
|
||||
-- thumbnails sizes and compression
|
||||
-- thumbnails sizes and compression
|
||||
|
|
Loading…
Reference in New Issue