From 5f37660496011487b48de80e9208ad6fa173f81d Mon Sep 17 00:00:00 2001 From: dignajar Date: Sat, 7 May 2016 00:10:10 -0300 Subject: [PATCH] updates --- bl-content/README.md | 6 --- bl-kernel/admin/views/settings-advanced.php | 11 ------ bl-kernel/boot/init.php | 3 ++ bl-kernel/boot/rules/60.plugins.php | 6 ++- bl-kernel/boot/rules/70.posts.php | 2 +- bl-kernel/boot/rules/71.pages.php | 2 +- bl-kernel/dbposts.class.php | 44 +++++++++++++-------- bl-kernel/dbsite.class.php | 7 ---- index.php | 4 +- install.php | 1 - 10 files changed, 40 insertions(+), 46 deletions(-) delete mode 100644 bl-content/README.md diff --git a/bl-content/README.md b/bl-content/README.md deleted file mode 100644 index 7e5fdf1c..00000000 --- a/bl-content/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Bludit - -Set the correct permissions on this directory. - -Documentation: -- http://docs.bludit.com/en/troubleshooting/writing-test-failure-err205 \ No newline at end of file diff --git a/bl-kernel/admin/views/settings-advanced.php b/bl-kernel/admin/views/settings-advanced.php index 334db0f3..9c12461c 100644 --- a/bl-kernel/admin/views/settings-advanced.php +++ b/bl-kernel/admin/views/settings-advanced.php @@ -37,17 +37,6 @@ HTML::formOpen(array('class'=>'uk-form-horizontal')); 'tip'=>$L->g('the-url-of-your-site') )); - HTML::legend(array('value'=>$L->g('Command Line Mode'))); - - HTML::formSelect(array( - 'name'=>'cliMode', - 'label'=>$L->g('Cli Mode'), - 'options'=>array('true'=>$L->g('Enabled'), 'false'=>$L->g('Disabled')), - 'selected'=>$Site->cliMode(), - 'class'=>'uk-width-1-3 uk-form-medium', - 'tip'=>$L->g('enable-the-command-line-mode-if-you-add-edit') - )); - HTML::legend(array('value'=>$L->g('Email account settings'))); HTML::formInputText(array( diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 8f40ae4b..e6987193 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -85,6 +85,9 @@ define('POSTS_PER_PAGE_ADMIN', 10); // Check if JSON encode and decode are enabled. // define('JSON', function_exists('json_encode')); +// Cli mode status for new posts/pages +define('CLI_MODE', true); + // Cli mode status for new posts/pages define('CLI_STATUS', 'published'); diff --git a/bl-kernel/boot/rules/60.plugins.php b/bl-kernel/boot/rules/60.plugins.php index 11faad3f..fe970c02 100644 --- a/bl-kernel/boot/rules/60.plugins.php +++ b/bl-kernel/boot/rules/60.plugins.php @@ -62,7 +62,11 @@ function buildPlugins() // Load each plugin clasess foreach($list as $pluginPath) { - include($pluginPath.DS.'plugin.php'); + + // Check if the directory has the plugin.php + if(file_exists($pluginPath.DS.'plugin.php')) { + include($pluginPath.DS.'plugin.php'); + } } // Get plugins clasess loaded diff --git a/bl-kernel/boot/rules/70.posts.php b/bl-kernel/boot/rules/70.posts.php index c9cf812c..f2740863 100644 --- a/bl-kernel/boot/rules/70.posts.php +++ b/bl-kernel/boot/rules/70.posts.php @@ -123,7 +123,7 @@ function buildPostsForPage($pageNumber=0, $amount=POSTS_PER_PAGE_ADMIN, $removeU // ============================================================================ // Search for changes on posts by the user. -if( $Site->cliMode() ) { +if( CLI_MODE ) { if($dbPosts->regenerateCli()) { reIndexTagsPosts(); } diff --git a/bl-kernel/boot/rules/71.pages.php b/bl-kernel/boot/rules/71.pages.php index 0d0c739f..361c4c0c 100644 --- a/bl-kernel/boot/rules/71.pages.php +++ b/bl-kernel/boot/rules/71.pages.php @@ -146,7 +146,7 @@ function buildAllPages() // ============================================================================ // Search for changes on pages by the user. -if( $Site->cliMode() ) { +if( CLI_MODE ) { $dbPages->regenerateCli(); } diff --git a/bl-kernel/dbposts.class.php b/bl-kernel/dbposts.class.php index cc6e1b10..8de3a235 100644 --- a/bl-kernel/dbposts.class.php +++ b/bl-kernel/dbposts.class.php @@ -9,7 +9,7 @@ class dbPosts extends dbJSON 'username'=> array('inFile'=>false, 'value'=>''), 'status'=> array('inFile'=>false, 'value'=>'draft'), // published, draft, scheduled 'tags'=> array('inFile'=>false, 'value'=>array()), - 'allowComments'=> array('inFile'=>false, 'value'=>false), + 'allowComments'=> array('inFile'=>false, 'value'=>0), 'date'=> array('inFile'=>false, 'value'=>''), 'coverImage'=> array('inFile'=>false, 'value'=>''), 'checksum'=> array('inFile'=>false, 'value'=>'') @@ -111,7 +111,7 @@ class dbPosts extends dbJSON return false; } - // If the date not valid, then set the current date. + // If the date is not valid, then set the current date. if(!Valid::date($args['date'], DB_DATE_FORMAT)) { $args['date'] = $currentDate; } @@ -408,32 +408,40 @@ class dbPosts extends dbJSON $currentDate = Date::current(DB_DATE_FORMAT); // Generate default fields and values. + // -------------------------------------------------------------------------- foreach($this->dbFields as $field=>$options) { if(!$options['inFile']) { $fields[$field] = $options['value']; } } - $fields['status'] = CLI_STATUS; - $fields['date'] = $currentDate; - $fields['username'] = CLI_USERNAME; + $fields['status'] = CLI_STATUS; + $fields['username'] = CLI_USERNAME; + $fields['date'] = $currentDate; // Get all posts from the first level of directories. - $tmpPaths = Filesystem::listDirectories(PATH_POSTS); - foreach($tmpPaths as $directory) + $postsDirectories = Filesystem::listDirectories(PATH_POSTS); + foreach($postsDirectories as $directory) { - // Check if the post have the index.txt file. + + // Check if the post has the index.txt file. if(Sanitize::pathFile($directory.DS.'index.txt')) { // The key is the directory name. $key = basename($directory); + Log::set('----------------'); + Log::set('CliMode - Post KEY: '.$key); + + // This post exists $allPosts[$key] = true; // Create the new entry if not exist inside the DATABASE. - if(!isset($this->db[$key])) { + if( !isset($this->db[$key]) ) { // New entry on database with the default fields and values. $this->db[$key] = $fields; + + Log::set('CliMode - New post: '.$key); } // Create the post from FILE. @@ -442,12 +450,14 @@ class dbPosts extends dbJSON // Update all fields from FILE to DATABASE. foreach($fields as $f=>$v) { - // If the field exists on the FILE, update it. - if($Post->getField($f)) - { - $valueFromFile = $Post->getField($f); + // Get the value from FILE. + $valueFromFile = $Post->getField($f); - Log::set(__METHOD__.LOG_SEP.'Field from file: '.$f); + // If the field exists on the FILE, update it. + if( !empty($valueFromFile) ) + { + Log::set('CliMode - Field to replace: '.$f); + Log::set('CliMode - value from file: '.$valueFromFile); if($f=='tags') { // Generate tags array. @@ -475,6 +485,7 @@ class dbPosts extends dbJSON // Remove orphan posts from db, the orphan posts are posts deleted by hand (directory deleted). foreach( array_diff_key($db, $allPosts) as $key=>$data ) { unset($this->db[$key]); + Log::set('CliMode - Delete post: '.$key); } // Sort posts before save. @@ -487,10 +498,11 @@ class dbPosts extends dbJSON } if($this->db!=$db) { - Log::set(__METHOD__.LOG_SEP.'New posts added from Cli Mode'); + Log::set(__METHOD__.LOG_SEP.'There are new or deleted posts.'); + return true; } - return $this->db!=$db; + return false; } } \ No newline at end of file diff --git a/bl-kernel/dbsite.class.php b/bl-kernel/dbsite.class.php index 44604664..26138464 100644 --- a/bl-kernel/dbsite.class.php +++ b/bl-kernel/dbsite.class.php @@ -19,7 +19,6 @@ class dbSite extends dbJSON 'uriTag'=> array('inFile'=>false, 'value'=>'/tag/'), 'uriBlog'=> array('inFile'=>false, 'value'=>'/blog/'), 'url'=> array('inFile'=>false, 'value'=>''), - 'cliMode'=> array('inFile'=>false, 'value'=>true), 'emailFrom'=> array('inFile'=>false, 'value'=>''), 'dateFormat'=> array('inFile'=>false, 'value'=>'F j, Y'), 'timeFormat'=> array('inFile'=>false, 'value'=>'g:i a'), @@ -216,12 +215,6 @@ class dbSite extends dbJSON return $parse['scheme'].'://'.$domain; } - // Returns TRUE if the cli mode is enabled, otherwise FALSE. - public function cliMode() - { - return $this->getField('cliMode'); - } - // Returns the relative home link public function homeLink() { diff --git a/index.php b/index.php index dec231f3..1a6457d2 100644 --- a/index.php +++ b/index.php @@ -2,12 +2,12 @@ /* * Bludit - * http://www.bludit.com + * https://www.bludit.com * Author Diego Najar * Bludit is opensource software licensed under the MIT license. */ -// Check installation +// Check if Bludit is installed if( !file_exists('bl-content/databases/site.php') ) { header('Location:./install.php'); diff --git a/install.php b/install.php index 6eede661..83897eab 100644 --- a/install.php +++ b/install.php @@ -372,7 +372,6 @@ function install($adminPassword, $email, $timezone) 'uriPage'=>'/', 'uriTag'=>'/tag/', 'url'=>PROTOCOL.DOMAIN.HTML_PATH_ROOT, - 'cliMode'=>false, 'emailFrom'=>'no-reply@'.DOMAIN );