diff --git a/content/sitemap.xml b/content/sitemap.xml new file mode 100644 index 00000000..e69de29b diff --git a/install.php b/install.php index 8bd84b0a..de1644aa 100644 --- a/install.php +++ b/install.php @@ -61,7 +61,7 @@ if(!defined('JSON_PRETTY_PRINT')) { define('JSON', function_exists('json_encode')); // Database format date -define('DB_DATE_FORMAT', 'Y-m-d H:i'); +define('DB_DATE_FORMAT', 'Y-m-d H:i:s'); // Charset, default UTF-8. define('CHARSET', 'UTF-8'); diff --git a/kernel/admin/controllers/edit-page.php b/kernel/admin/controllers/edit-page.php index 504517bc..594b418c 100644 --- a/kernel/admin/controllers/edit-page.php +++ b/kernel/admin/controllers/edit-page.php @@ -1,5 +1,9 @@ edit($args) ) + // Add the page, if the $key is FALSE the creation of the post failure. + $key = $dbPages->edit($args); + + if($key) { $dbPages->regenerateCli(); + // Call the plugins after page created. + Theme::plugins('afterPageModify'); + + // Alert the user Alert::set($Language->g('The changes have been saved')); Redirect::page('admin', 'edit-page/'.$args['slug']); } @@ -34,6 +44,9 @@ function deletePage($key) if( $dbPages->delete($key) ) { + // Call the plugins after post created. + Theme::plugins('afterPageDelete'); + Alert::set($Language->g('The page has been deleted successfully')); Redirect::page('admin', 'manage-pages'); } diff --git a/kernel/admin/controllers/edit-post.php b/kernel/admin/controllers/edit-post.php index 8bfb274b..d4f4b9b3 100644 --- a/kernel/admin/controllers/edit-post.php +++ b/kernel/admin/controllers/edit-post.php @@ -13,12 +13,18 @@ function editPost($args) global $dbPosts; global $Language; - // Edit the post. - if( $dbPosts->edit($args) ) + // Add the page, if the $key is FALSE the creation of the post failure. + $key = $dbPosts->edit($args); + + if($key) { // Reindex tags, this function is in 70.posts.php reIndexTagsPosts(); + // Call the plugins after post created. + Theme::plugins('afterPostModify'); + + // Alert the user Alert::set($Language->g('The changes have been saved')); Redirect::page('admin', 'edit-post/'.$args['slug']); } @@ -40,6 +46,9 @@ function deletePost($key) // Reindex tags, this function is in 70.posts.php reIndexTagsPosts(); + // Call the plugins after post created. + Theme::plugins('afterPostDelete'); + Alert::set($Language->g('The post has been deleted successfully')); Redirect::page('admin', 'manage-posts'); } diff --git a/kernel/admin/controllers/new-page.php b/kernel/admin/controllers/new-page.php index c7540305..5846f975 100644 --- a/kernel/admin/controllers/new-page.php +++ b/kernel/admin/controllers/new-page.php @@ -13,9 +13,15 @@ function addPage($args) global $dbPages; global $Language; - // Add the page. - if( $dbPages->add($args) ) + // Add the page, if the $key is FALSE the creation of the post failure. + $key = $dbPages->add($args); + + if($key) { + // Call the plugins after page created. + Theme::plugins('afterPageCreate'); + + // Alert the user Alert::set($Language->g('Page added successfully')); Redirect::page('admin', 'manage-pages'); } diff --git a/kernel/admin/controllers/new-post.php b/kernel/admin/controllers/new-post.php index 48e40f4e..53b19667 100644 --- a/kernel/admin/controllers/new-post.php +++ b/kernel/admin/controllers/new-post.php @@ -13,12 +13,18 @@ function addPost($args) global $dbPosts; global $Language; - // Add the page. - if( $dbPosts->add($args) ) + // Add the page, if the $key is FALSE the creation of the post failure. + $key = $dbPosts->add($args); + + if($key) { // Reindex tags, this function is in 70.posts.php reIndexTagsPosts(); + // Call the plugins after post created. + Theme::plugins('afterPostCreate'); + + // Alert for the user Alert::set($Language->g('Post added successfully')); Redirect::page('admin', 'manage-posts'); } diff --git a/kernel/boot/admin.php b/kernel/boot/admin.php index 8a9706f8..42a7e988 100644 --- a/kernel/boot/admin.php +++ b/kernel/boot/admin.php @@ -40,9 +40,9 @@ if( $layout['slug']==='ajax' ) else { // Boot rules + include(PATH_RULES.'60.plugins.php'); include(PATH_RULES.'70.posts.php'); include(PATH_RULES.'70.pages.php'); - include(PATH_RULES.'80.plugins.php'); include(PATH_RULES.'99.header.php'); include(PATH_RULES.'99.paginator.php'); include(PATH_RULES.'99.themes.php'); diff --git a/kernel/boot/init.php b/kernel/boot/init.php index b9faa5a1..7b1731f4 100644 --- a/kernel/boot/init.php +++ b/kernel/boot/init.php @@ -61,7 +61,6 @@ define('ALERT_STATUS_FAIL', 1); // Salt length define('THUMBNAILS_WIDTH', 400); define('THUMBNAILS_HEIGHT', 400); - define('THUMBNAILS_AMOUNT', 6); // Salt length @@ -82,9 +81,12 @@ define('JSON', function_exists('json_encode')); // TRUE if new posts hand-made set published, or FALSE for draft. define('CLI_STATUS', 'published'); -// Database format date +// Database date format define('DB_DATE_FORMAT', 'Y-m-d H:i:s'); +// Sitemap date format +define('SITEMAP_DATE_FORMAT', 'Y-m-d'); + // Date format for Dashboard schedule posts define('SCHEDULED_DATE_FORMAT', 'd M - h:i a'); diff --git a/kernel/boot/rules/80.plugins.php b/kernel/boot/rules/60.plugins.php similarity index 93% rename from kernel/boot/rules/80.plugins.php rename to kernel/boot/rules/60.plugins.php index f178af3a..25c4d3bc 100644 --- a/kernel/boot/rules/80.plugins.php +++ b/kernel/boot/rules/60.plugins.php @@ -24,6 +24,15 @@ $plugins = array( 'beforeAdminLoad'=>array(), 'afterAdminLoad'=>array(), + 'beforeRulesLoad'=>array(), + + 'afterPostCreate'=>array(), + 'afterPostModify'=>array(), + 'afterPostDelete'=>array(), + 'afterPageCreate'=>array(), + 'afterPageModify'=>array(), + 'afterPageDelete'=>array(), + 'loginHead'=>array(), 'loginBodyBegin'=>array(), 'loginBodyEnd'=>array(), diff --git a/kernel/boot/rules/70.pages.php b/kernel/boot/rules/70.pages.php index f9c2ae55..eb11212d 100644 --- a/kernel/boot/rules/70.pages.php +++ b/kernel/boot/rules/70.pages.php @@ -23,7 +23,7 @@ function sortPages($a, $b) return ($a->position() < $b->position()) ? -1 : 1; } -function build_page($key) +function buildPage($key) { global $dbPages; global $dbUsers; @@ -38,7 +38,7 @@ function build_page($key) } // Page database, content from DATABASE JSON. - $db = $dbPages->getDb($key); + $db = $dbPages->getPageDB($key); if( !$db ) { Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the page from database with key: '.$key); return false; @@ -73,19 +73,22 @@ function build_page($key) return $Page; } -function build_all_pages() +function buildAllPages() { global $pages; global $pagesParents; global $dbPages; - $list = $dbPages->getAll(); + $list = $dbPages->getDB(); + + // Clean pages array. + $pages = array(); unset($list['error']); foreach($list as $key=>$db) { - $Page = build_page($key); + $Page = buildPage($key); if($Page!==false) { @@ -144,7 +147,7 @@ if( $Site->cliMode() ) { // Filter by page, then build it if( ($Url->whereAmI()==='page') && ($Url->notFound()===false) ) { - $Page = build_page( $Url->slug() ); + $Page = buildPage( $Url->slug() ); if($Page===false) { @@ -165,7 +168,7 @@ if($Url->notFound()===false) { $Url->setWhereAmI('page'); - $Page = build_page( $Site->homepage() ); + $Page = buildPage( $Site->homepage() ); if($Page===false) { $Url->setWhereAmI('home'); @@ -180,4 +183,4 @@ if($Url->notFound()) } // Build all pages -build_all_pages(); +buildAllPages(); diff --git a/kernel/boot/rules/70.posts.php b/kernel/boot/rules/70.posts.php index 7ab169d6..4f776410 100644 --- a/kernel/boot/rules/70.posts.php +++ b/kernel/boot/rules/70.posts.php @@ -42,7 +42,7 @@ function buildPost($key) } // Post database, content from DATABASE JSON. - $db = $dbPosts->getDb($key); + $db = $dbPosts->getPostDB($key); if( !$db ) { Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the post from database with key: '.$key); return false; diff --git a/kernel/boot/site.php b/kernel/boot/site.php index 209b493c..3fc79a89 100644 --- a/kernel/boot/site.php +++ b/kernel/boot/site.php @@ -1,9 +1,14 @@ pageExists($key)) { return $this->db[$key]; @@ -288,8 +288,8 @@ class dbPages extends dbJSON return $newKey; } - // Return an array with all databases. - public function getAll() + // Returns the database + public function getDB() { return $this->db; } diff --git a/kernel/dbposts.class.php b/kernel/dbposts.class.php index 6f5d1f08..a9fdbec8 100644 --- a/kernel/dbposts.class.php +++ b/kernel/dbposts.class.php @@ -35,8 +35,14 @@ class dbPosts extends dbJSON return $this->numberPosts['published']; } + // Returns the database + public function getDB() + { + return $this->db; + } + // Return an array with the post's database, FALSE otherwise. - public function getDb($key) + public function getPostDB($key) { if($this->postExists($key)) { return $this->db[$key]; @@ -45,7 +51,7 @@ class dbPosts extends dbJSON return false; } - public function setDb($key, $field, $value) + public function setPostDb($key, $field, $value) { if($this->postExists($key)) { $this->db[$key][$field] = $value; @@ -176,7 +182,7 @@ class dbPosts extends dbJSON return false; } - return true; + return $key; } public function edit($args) diff --git a/kernel/helpers/theme.class.php b/kernel/helpers/theme.class.php index 4a61984a..e1ecca44 100644 --- a/kernel/helpers/theme.class.php +++ b/kernel/helpers/theme.class.php @@ -131,103 +131,6 @@ class Theme { return $tmp; } - // OLD - - public static function url($relative = true) - { - if($relative) - return HTML_PATH_ROOT; - else - return BLOG_URL; - } - - - - - public static function name() - { - global $settings; - - return $settings['name']; - } - - public static function slogan() - { - global $settings; - - return $settings['slogan']; - } - - public static function footer() - { - global $settings; - - return $settings['footer']; - } - - public static function language() - { - global $settings; - - $lang = explode("_",$settings['locale']); - - return $lang[0]; - } - - public static function locale() - { - global $settings; - - return $settings['locale']; - } - - public static function meta_tags() - { - global $layout; - global $seo; - - // The validator W3C doesn't support??? - //$meta = ''.PHP_EOL; - - $meta = ''.PHP_EOL; - - if(!empty($layout['title'])) - $meta .= '