From f0df4eb0abf7b7f8454d389ea972b3bdd0055564 Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Wed, 11 Jul 2018 23:36:46 +0200 Subject: [PATCH] Autosave bug fixes --- bl-kernel/admin/themes/booty/css/bludit.css | 5 + bl-kernel/admin/themes/booty/init.php | 4 +- bl-kernel/admin/views/new-content.php | 101 ++++++++++---------- bl-kernel/dbpages.class.php | 5 +- bl-kernel/functions.php | 47 +++------ things-to-do | 2 +- 6 files changed, 78 insertions(+), 86 deletions(-) diff --git a/bl-kernel/admin/themes/booty/css/bludit.css b/bl-kernel/admin/themes/booty/css/bludit.css index c3e015dd..967aa879 100644 --- a/bl-kernel/admin/themes/booty/css/bludit.css +++ b/bl-kernel/admin/themes/booty/css/bludit.css @@ -2,6 +2,11 @@ html { height: 100%; font-size: 0.9rem; + background: #fcfcfc; +} + +body { + background: #fcfcfc; } /* diff --git a/bl-kernel/admin/themes/booty/init.php b/bl-kernel/admin/themes/booty/init.php index f8b53056..a7b7518c 100644 --- a/bl-kernel/admin/themes/booty/init.php +++ b/bl-kernel/admin/themes/booty/init.php @@ -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 << +
diff --git a/bl-kernel/admin/views/new-content.php b/bl-kernel/admin/views/new-content.php index 4ce88e51..50b4bea3 100644 --- a/bl-kernel/admin/views/new-content.php +++ b/bl-kernel/admin/views/new-content.php @@ -89,9 +89,7 @@ $L->g('External Cover Image'))); - ?> - 'externalCoverImage', 'placeholder'=>"https://", @@ -105,6 +103,55 @@
'Advanced')); + + // Date + echo Bootstrap::formInputText(array( + 'name'=>'date', + 'label'=>'Date', + 'placeholder'=>'', + 'value'=>Date::current(DB_DATE_FORMAT), + 'tip'=>'Date format: YYYY-MM-DD Hours:Minutes:Seconds' + )); + + // 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 '
'; - echo Bootstrap::formCheckbox(array( 'name'=>'noindex', 'label'=>'Robots', 'labelForCheckbox'=>'Apply noindex 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 '
'; - - 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'=>'' - )); ?>
diff --git a/bl-kernel/dbpages.class.php b/bl-kernel/dbpages.class.php index df14d23d..54f9c88c 100644 --- a/bl-kernel/dbpages.class.php +++ b/bl-kernel/dbpages.class.php @@ -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() diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 79c05cb6..05aeac03 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -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; } diff --git a/things-to-do b/things-to-do index 6923416f..646417a4 100644 --- a/things-to-do +++ b/things-to-do @@ -28,4 +28,4 @@ Things to do: - add to settings -- time for autosave -- time for check user logged --- thumbnails sizes and compression \ No newline at end of file +-- thumbnails sizes and compression