bug fixes
This commit is contained in:
parent
c2cf10c39b
commit
304a57beca
|
@ -8,83 +8,6 @@
|
|||
// Functions
|
||||
// ============================================================================
|
||||
|
||||
function editPage($args)
|
||||
{
|
||||
global $dbPages;
|
||||
global $Language;
|
||||
global $Syslog;
|
||||
|
||||
if(!isset($args['parent'])) {
|
||||
$args['parent'] = NO_PARENT_CHAR;
|
||||
}
|
||||
|
||||
// Edit the page
|
||||
$key = $dbPages->edit($args);
|
||||
|
||||
if($key) {
|
||||
// Re-index categories
|
||||
reindexCategories();
|
||||
|
||||
// Re-index tags
|
||||
reindextags();
|
||||
|
||||
// Call the plugins after page modified
|
||||
Theme::plugins('afterPageModify');
|
||||
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'page-edited',
|
||||
'notes'=>$args['title']
|
||||
));
|
||||
|
||||
// Create an alert
|
||||
Alert::set( $Language->g('The changes have been saved') );
|
||||
|
||||
// Redirect
|
||||
Redirect::page('edit-page/'.$key);
|
||||
}
|
||||
else {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to edit the page.');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function deletePage($key)
|
||||
{
|
||||
global $dbPages;
|
||||
global $Language;
|
||||
global $Syslog;
|
||||
|
||||
if( $dbPages->delete($key) ) {
|
||||
// Re-index categories
|
||||
reindexCategories();
|
||||
|
||||
// Re-index tags
|
||||
reindextags();
|
||||
|
||||
// Call the plugins after page deleted
|
||||
Theme::plugins('afterPageDelete');
|
||||
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'page-deleted',
|
||||
'notes'=>$key
|
||||
));
|
||||
|
||||
// Create an alert
|
||||
Alert::set( $Language->g('The changes have been saved') );
|
||||
|
||||
// Redirect
|
||||
Redirect::page('pages');
|
||||
}
|
||||
else {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the page.');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main before POST
|
||||
// ============================================================================
|
||||
|
@ -96,11 +19,20 @@ function deletePage($key)
|
|||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
if( isset($_POST['delete-page']) ) {
|
||||
deletePage($_POST['key']);
|
||||
if( deletePage($_POST['key']) ) {
|
||||
Alert::set( $Language->g('The changes have been saved') );
|
||||
Redirect::page('pages');
|
||||
}
|
||||
}
|
||||
else {
|
||||
editPage($_POST);
|
||||
$key = editPage($_POST);
|
||||
if( $key!==false ) {
|
||||
Alert::set( $Language->g('The changes have been saved') );
|
||||
Redirect::page('edit-page/'.$key);
|
||||
}
|
||||
}
|
||||
|
||||
Redirect::page('pages');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
.label-draft,
|
||||
.label-fixed,
|
||||
.label-sticky,
|
||||
.label-scheduled,
|
||||
.label-empty-title,
|
||||
.label-time {
|
||||
background: #A979D1 none repeat scroll 0 0;
|
||||
|
@ -30,6 +31,10 @@
|
|||
background: #7BD179;
|
||||
}
|
||||
|
||||
.label-scheduled {
|
||||
background: #7BD179;
|
||||
}
|
||||
|
||||
.label-empty-title {
|
||||
background: #53D192;
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
|
|||
'class'=>'uk-width-1-1 uk-form-medium',
|
||||
'options'=>array(
|
||||
'published'=>$L->g('Published'),
|
||||
'draft'=>$L->g('Draft'),
|
||||
'drpaft'=>$L->g('Draft'),
|
||||
'fixed'=>$L->g('Fixed'),
|
||||
'sticky'=>$L->g('Sticky')
|
||||
),
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// Array with all published pages
|
||||
$pages = array();
|
||||
|
||||
// Array with all pages (published, draft, scheduled)
|
||||
// Array with all pages (published, fixed, sticky, draft, scheduled)
|
||||
$allPages = array();
|
||||
|
||||
// Object Page for the page filtered bye the user
|
||||
// Object Page for the page filtered by the user
|
||||
$page = false;
|
||||
|
||||
// Array with all page parents published
|
||||
|
@ -30,6 +30,12 @@ if( $dbPages->scheduler() ) {
|
|||
|
||||
// Reindex categories
|
||||
reindexCategories();
|
||||
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'page-published-from-scheduler',
|
||||
'notes'=>''
|
||||
));
|
||||
}
|
||||
|
||||
// Build specific page
|
||||
|
|
|
@ -21,8 +21,9 @@ class dbCategories extends dbList
|
|||
$this->db[$key]['list'] = array();
|
||||
}
|
||||
|
||||
// Foreach post in the database
|
||||
$db = $dbPages->getDB();
|
||||
// Get a database with published pages
|
||||
$db = $dbPages->getPublishedDB();
|
||||
|
||||
foreach($db as $pageKey=>$pageFields) {
|
||||
if( !empty($pageFields['category']) ) {
|
||||
$categoryKey = $pageFields['category'];
|
||||
|
|
|
@ -42,7 +42,7 @@ class dbPages extends dbJSON
|
|||
$key = $this->generateKey($args['slug'], $args['parent']);
|
||||
|
||||
// Generate UUID
|
||||
$args['uuid'] = md5( uniqid() );
|
||||
$args['uuid'] = $this->generateUUID();
|
||||
|
||||
// Date
|
||||
$currentDate = Date::current(DB_DATE_FORMAT);
|
||||
|
@ -314,6 +314,9 @@ class dbPages extends dbJSON
|
|||
$db = $this->getPublishedDB();
|
||||
}
|
||||
|
||||
// Remove Error page from the list
|
||||
unset($db['error']);
|
||||
|
||||
// The first page number is 1, so the real is 0
|
||||
$realPageNumber = $pageNumber - 1;
|
||||
|
||||
|
@ -360,7 +363,7 @@ class dbPages extends dbJSON
|
|||
return $db;
|
||||
}
|
||||
|
||||
// Return TRUE if the page exists, FALSE otherwise.
|
||||
// Return TRUE if the page exists, FALSE otherwise
|
||||
public function exists($key)
|
||||
{
|
||||
return isset( $this->db[$key] );
|
||||
|
@ -413,6 +416,43 @@ class dbPages extends dbJSON
|
|||
return $a['date']<$b['date'];
|
||||
}
|
||||
|
||||
private function generateUUID() {
|
||||
return md5( uniqid().time() );
|
||||
}
|
||||
|
||||
// Returns TRUE if there are new pages published, FALSE otherwise
|
||||
public function scheduler()
|
||||
{
|
||||
// Get current date
|
||||
$currentDate = Date::current(DB_DATE_FORMAT);
|
||||
$saveDatabase = false;
|
||||
|
||||
// The database need to be sorted by date
|
||||
foreach($this->db as $pageKey=>$fields) {
|
||||
if($fields['status']=='scheduled') {
|
||||
if($fields['date']<=$currentDate) {
|
||||
$this->db[$pageKey]['status'] = 'published';
|
||||
$saveDatabase = true;
|
||||
}
|
||||
}
|
||||
elseif( ($fields['status']=='published') && (ORDER_BY=='date') ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($saveDatabase) {
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
}
|
||||
|
||||
Log::set(__METHOD__.LOG_SEP.'New pages published from the scheduler.');
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ----- OLD
|
||||
|
||||
|
||||
|
@ -518,37 +558,6 @@ class dbPages extends dbJSON
|
|||
return $this->save();
|
||||
}
|
||||
|
||||
// Return TRUE if there are new pages published, FALSE otherwise.
|
||||
public function scheduler()
|
||||
{
|
||||
// Get current date
|
||||
$currentDate = Date::current(DB_DATE_FORMAT);
|
||||
$saveDatabase = false;
|
||||
|
||||
// The database need to be sorted by date
|
||||
foreach($this->db as $pageKey=>$fields) {
|
||||
if($fields['status']=='scheduled') {
|
||||
if($fields['date']<=$currentDate) {
|
||||
$this->db[$pageKey]['status'] = 'published';
|
||||
$saveDatabase = true;
|
||||
}
|
||||
}
|
||||
elseif($fields['status']=='published') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($saveDatabase) {
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
}
|
||||
|
||||
Log::set(__METHOD__.LOG_SEP.'New pages published from the scheduler.');
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -16,7 +16,9 @@ class dbTags extends dbList
|
|||
{
|
||||
global $dbPages;
|
||||
|
||||
$db = $dbPages->getDB();
|
||||
// Get a database with published pages
|
||||
$db = $dbPages->getPublishedDB();
|
||||
|
||||
$tagsIndex = array();
|
||||
|
||||
foreach($db as $pageKey=>$pageFields) {
|
||||
|
|
|
@ -59,30 +59,14 @@ function buildPage($key)
|
|||
|
||||
function reindexCategories()
|
||||
{
|
||||
global $dbPages;
|
||||
global $dbCategories;
|
||||
|
||||
// Get a database with published pages
|
||||
$db = $dbPages->getPublishedDB();
|
||||
|
||||
// Regenerate the tags
|
||||
$dbCategories->reindex($db);
|
||||
|
||||
return true;
|
||||
return $dbCategories->reindex();
|
||||
}
|
||||
|
||||
function reindexTags()
|
||||
{
|
||||
global $dbPages;
|
||||
global $dbTags;
|
||||
|
||||
// Get a database with published pages
|
||||
$db = $dbPages->getPublishedDB();
|
||||
|
||||
// Regenerate the tags
|
||||
$dbTags->reindex($db);
|
||||
|
||||
return true;
|
||||
return $dbTags->reindex();
|
||||
}
|
||||
|
||||
function buildPagesForAdmin()
|
||||
|
@ -210,3 +194,60 @@ function createNewPage($args) {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
function editPage($args) {
|
||||
global $dbPages;
|
||||
global $Syslog;
|
||||
|
||||
if(!isset($args['parent'])) {
|
||||
$args['parent'] = NO_PARENT_CHAR;
|
||||
}
|
||||
|
||||
$key = $dbPages->edit($args);
|
||||
if($key) {
|
||||
// Call the plugins after page modified
|
||||
Theme::plugins('afterPageModify');
|
||||
|
||||
// Re-index categories
|
||||
reindexCategories();
|
||||
|
||||
// Re-index tags
|
||||
reindextags();
|
||||
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'page-edited',
|
||||
'notes'=>$args['title']
|
||||
));
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function deletePage($key) {
|
||||
global $dbPages;
|
||||
global $Syslog;
|
||||
|
||||
if( $dbPages->delete($key) ) {
|
||||
// Call the plugins after page deleted
|
||||
Theme::plugins('afterPageDelete');
|
||||
|
||||
// Re-index categories
|
||||
reindexCategories();
|
||||
|
||||
// Re-index tags
|
||||
reindextags();
|
||||
|
||||
// Add to syslog
|
||||
$Syslog->add(array(
|
||||
'dictionaryKey'=>'page-deleted',
|
||||
'notes'=>$key
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -13,3 +13,5 @@
|
|||
<!-- Plugins with the hook pageEnd -->
|
||||
<?php Theme::plugins('pageEnd') ?>
|
||||
</section>
|
||||
|
||||
<?php var_dump($page); ?>
|
Loading…
Reference in New Issue