diff --git a/bl-kernel/admin/controllers/new-page.php b/bl-kernel/admin/controllers/new-page.php index 92c7b43b..31e85d29 100644 --- a/bl-kernel/admin/controllers/new-page.php +++ b/bl-kernel/admin/controllers/new-page.php @@ -8,48 +8,6 @@ // Functions // ============================================================================ -function addPage($args) -{ - global $dbPages; - global $Language; - global $Syslog; - - // Add the page, if the $key is FALSE the creation of the page failure - $key = $dbPages->add($args); - - if($key) { - // Re-index categories - reindexCategories(); - - // Re-index tags - reindextags(); - - // Call the plugins after page created - Theme::plugins('afterPageCreate'); - - // Add to syslog - $Syslog->add(array( - 'dictionaryKey'=>'new-page-created', - 'notes'=>$args['title'] - )); - - // Create an alert - Alert::set( $Language->g('Page added successfully') ); - - // Redirect - Redirect::page('pages'); - - return true; - } - else { - Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the page'); - Log::set(__METHOD__.LOG_SEP.'Cleaning database...'); - $dbPages->delete($key); - } - - return false; -} - // ============================================================================ // Main before POST // ============================================================================ @@ -60,7 +18,11 @@ function addPage($args) if( $_SERVER['REQUEST_METHOD'] == 'POST' ) { - addPage($_POST); + if( createNewPage($_POST)!==false ) { + Alert::set( $Language->g('Page added successfully') ); + } + + Redirect::page('pages'); } // ============================================================================ diff --git a/bl-kernel/boot/rules/69.pages.php b/bl-kernel/boot/rules/69.pages.php index 56a786b9..bc94890e 100644 --- a/bl-kernel/boot/rules/69.pages.php +++ b/bl-kernel/boot/rules/69.pages.php @@ -42,8 +42,8 @@ if( $Url->whereAmI()==='page' ) { if($page===false) { $Url->setNotFound(true); } - // The page is not published - elseif( !$page->published() ) { + // The page is not published, still scheduled or draft + elseif( $page->scheduled() || $page->draft() ) { $Url->setNotFound(true); } else { diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 4de24bed..09f7f387 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -178,4 +178,35 @@ function printDebug($array) { echo '
'; var_dump($array); echo ''; +} + +function createNewPage($args) { + global $dbPages; + global $Syslog; + + $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 + $Syslog->add(array( + 'dictionaryKey'=>'new-page-created', + 'notes'=>$args['title'] + )); + + 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); + + return false; } \ No newline at end of file diff --git a/bl-kernel/page.class.php b/bl-kernel/page.class.php index 82c717b4..712e20fc 100644 --- a/bl-kernel/page.class.php +++ b/bl-kernel/page.class.php @@ -335,29 +335,31 @@ class Page { return $this->getValue('key'); } - // Returns TRUE if the post/page is published, FALSE otherwise. + // (boolean) Returns TRUE if the page is published, FALSE otherwise public function published() { return ($this->getValue('status')==='published'); } - // Returns TRUE if the post/page is scheduled, FALSE otherwise. + // (boolean) Returns TRUE if the page is scheduled, FALSE otherwise public function scheduled() { return ($this->getValue('status')==='scheduled'); } - // Returns TRUE if the post/page is draft, FALSE otherwise. + // (boolean) Returns TRUE if the page is draft, FALSE otherwise public function draft() { return ($this->getValue('status')=='draft'); } + // (boolean) Returns TRUE if the page is sticky, FALSE otherwise public function sticky() { return ($this->getValue('status')=='sticky'); } + // (boolean) Returns TRUE if the page is fixed, FALSE otherwise public function fixed() { return ($this->getValue('status')=='fixed'); diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php index d0235e41..4ed3b348 100644 --- a/bl-plugins/api/plugin.php +++ b/bl-plugins/api/plugin.php @@ -8,40 +8,23 @@ class pluginAPI extends Plugin { $token = md5( uniqid().time().DOMAIN ); $this->dbFields = array( - 'ping'=>0, // 0 = false, 1 = true 'token'=>$token, // API Token - 'showAllAmount'=>15, // Amount of posts and pages for return - 'authentication'=>1 // Authentication required + 'amountOfItems'=>15 // Amount of items to return ); } public function form() { - $html = ''; - - $html .= '
Authorization Key: '.$this->getDbField('token').'
'; - $html .= 'Show all posts: '.DOMAIN_BASE.'api/show/all/posts/'.$this->getDbField('token').'
'; - $html .= 'Show all pages: '.DOMAIN_BASE.'api/show/all/pages/'.$this->getDbField('token').'
'; - $html .= 'Show post: '.DOMAIN_BASE.'api/show/post/{POST-NAME}
'; - $html .= 'Show page: '.DOMAIN_BASE.'api/show/page/{PAGE-NAME}
'; - $html .= '