This commit is contained in:
dignajar 2016-05-07 00:10:10 -03:00
parent 8f8121e360
commit 5f37660496
10 changed files with 40 additions and 46 deletions

View File

@ -1,6 +0,0 @@
# Bludit
Set the correct permissions on this directory.
Documentation:
- http://docs.bludit.com/en/troubleshooting/writing-test-failure-err205

View File

@ -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(

View File

@ -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');

View File

@ -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

View File

@ -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();
}

View File

@ -146,7 +146,7 @@ function buildAllPages()
// ============================================================================
// Search for changes on pages by the user.
if( $Site->cliMode() ) {
if( CLI_MODE ) {
$dbPages->regenerateCli();
}

View File

@ -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;
}
}

View File

@ -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()
{

View File

@ -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');

View File

@ -372,7 +372,6 @@ function install($adminPassword, $email, $timezone)
'uriPage'=>'/',
'uriTag'=>'/tag/',
'url'=>PROTOCOL.DOMAIN.HTML_PATH_ROOT,
'cliMode'=>false,
'emailFrom'=>'no-reply@'.DOMAIN
);