diff --git a/bl-kernel/admin/views/edit-content.php b/bl-kernel/admin/views/edit-content.php index b0715c04..2055eb70 100644 --- a/bl-kernel/admin/views/edit-content.php +++ b/bl-kernel/admin/views/edit-content.php @@ -21,7 +21,7 @@ echo Bootstrap::formInputHidden(array( 'value' => $page->uuid() )); -// Type = published, draft, sticky, static +// Type = article, draft, sticky, static echo Bootstrap::formInputHidden(array( 'name' => 'type', 'value' => $page->type() @@ -210,7 +210,7 @@ echo Bootstrap::formInputHidden(array( 'label' => $L->g('Type'), 'selected' => $page->type(), 'options' => array( - 'published' => '- ' . $L->g('Default') . ' -', + 'article' => '- ' . $L->g('Default') . ' -', 'sticky' => $L->g('Sticky'), 'static' => $L->g('Static') ), diff --git a/bl-kernel/admin/views/new-content.php b/bl-kernel/admin/views/new-content.php index 7aa4b2f2..42b23158 100644 --- a/bl-kernel/admin/views/new-content.php +++ b/bl-kernel/admin/views/new-content.php @@ -21,10 +21,10 @@ echo Bootstrap::formInputHidden(array( 'value' => $uuid )); -// Type = published, draft, sticky, static +// Type = article, draft, sticky, static echo Bootstrap::formInputHidden(array( 'name' => 'type', - 'value' => 'published' + 'value' => 'article' )); // Cover image @@ -191,7 +191,7 @@ echo Bootstrap::formInputHidden(array( 'label' => $L->g('Type'), 'selected' => '', 'options' => array( - 'published' => '- ' . $L->g('Default') . ' -', + 'article' => '- ' . $L->g('Default') . ' -', 'sticky' => $L->g('Sticky'), 'static' => $L->g('Static') ), diff --git a/bl-kernel/ajax/get-published.php b/bl-kernel/ajax/get-published.php index 881c6738..3608ee05 100644 --- a/bl-kernel/ajax/get-published.php +++ b/bl-kernel/ajax/get-published.php @@ -28,7 +28,7 @@ foreach ($pagesKey as $pageKey) { $page = new Page($pageKey); if ($page->isParent() || !$checkIsParent) { // Check page status - if ($page->published() || $page->sticky() || $page->isStatic()) { + if ($page->article() || $page->sticky() || $page->isStatic()) { // Check if the query contains in the title $lowerTitle = Text::lowercase($page->title()); if (Text::stringContains($lowerTitle, $query)) { diff --git a/bl-kernel/boot/admin.php b/bl-kernel/boot/admin.php index 81768cc9..faf1b965 100644 --- a/bl-kernel/boot/admin.php +++ b/bl-kernel/boot/admin.php @@ -57,6 +57,7 @@ if ($layout['slug']==='ajax') { else { // Boot rules + include(PATH_RULES.'50.updaters.php'); include(PATH_RULES.'69.pages.php'); include(PATH_RULES.'99.header.php'); include(PATH_RULES.'99.paginator.php'); diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 1243e0b3..0f35b018 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -126,6 +126,9 @@ include(PATH_HELPERS . 'tcp.class.php'); include(PATH_HELPERS . 'dom.class.php'); include(PATH_HELPERS . 'cookie.class.php'); +// Updaters +include(PATH_HELPERS . 'updater.class.php'); + // Objects $pages = new Pages(); $users = new Users(); diff --git a/bl-kernel/boot/rules/50.updaters.php b/bl-kernel/boot/rules/50.updaters.php new file mode 100644 index 00000000..f53026e7 --- /dev/null +++ b/bl-kernel/boot/rules/50.updaters.php @@ -0,0 +1,15 @@ +databaseVersion() < 2) { + KoblogUpdater::upgradeArticlesToPageTypes(); +} \ No newline at end of file diff --git a/bl-kernel/boot/site.php b/bl-kernel/boot/site.php index 34046523..b63e6c88 100644 --- a/bl-kernel/boot/site.php +++ b/bl-kernel/boot/site.php @@ -7,6 +7,7 @@ include(PATH_RULES.'60.plugins.php'); Theme::plugins('beforeAll'); // Load rules +include(PATH_RULES.'50.updaters.php'); include(PATH_RULES.'60.router.php'); include(PATH_RULES.'69.pages.php'); include(PATH_RULES.'99.header.php'); diff --git a/bl-kernel/boot/variables.php b/bl-kernel/boot/variables.php index 3425cd85..fbc3c915 100644 --- a/bl-kernel/boot/variables.php +++ b/bl-kernel/boot/variables.php @@ -104,7 +104,7 @@ define('MEDIA_MANAGER_SORT_BY_DATE', true); // Constant arrays using define are not allowed in PHP 5.6 or earlier // Type of pages included in the tag database -$GLOBALS['DB_TAGS_TYPES'] = array('published','static','sticky'); +$GLOBALS['DB_TAGS_TYPES'] = array('article','static','sticky'); // Allowed image extensions $GLOBALS['ALLOWED_IMG_EXTENSION'] = array('gif', 'png', 'jpg', 'jpeg', 'svg', 'webp'); diff --git a/bl-kernel/categories.class.php b/bl-kernel/categories.class.php index 17b8c87b..b0c1178b 100644 --- a/bl-kernel/categories.class.php +++ b/bl-kernel/categories.class.php @@ -28,7 +28,7 @@ class Categories extends dbList { $categoryKey = $pageFields['category']; if (isset($this->db[$categoryKey]['list'])) { if ( - ($db[$pageKey]['type']=='published') || + ($db[$pageKey]['type']=='article') || ($db[$pageKey]['type']=='sticky') || ($db[$pageKey]['type']=='static') ) { diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index 0547985d..d4825c47 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -168,7 +168,7 @@ function buildPagesFor($for, $categoryKey = false, $tagKey = false, $authorKey = foreach ($list as $pageKey) { try { $page = new Page($pageKey); - if (($page->type() == 'published') || + if (($page->type() == 'article') || ($page->type() == 'sticky') || ($page->type() == 'static') ) { diff --git a/bl-kernel/helpers/updater.class.php b/bl-kernel/helpers/updater.class.php new file mode 100644 index 00000000..65ff80b9 --- /dev/null +++ b/bl-kernel/helpers/updater.class.php @@ -0,0 +1,20 @@ + +db as $key => $fields) { + if ($fields['type'] === "published") { + $pages->db[$key]['type'] = "article"; + } else { + //$pages->db[$key]['sticky'] = false; // Not really important for static + } + } + + return $pages->save(); + } + +} \ No newline at end of file diff --git a/bl-kernel/pages.class.php b/bl-kernel/pages.class.php index bac2e2fb..5bf0a8f3 100644 --- a/bl-kernel/pages.class.php +++ b/bl-kernel/pages.class.php @@ -9,7 +9,7 @@ class Pages extends dbJSON 'description' => '', 'username' => '', 'tags' => array(), - 'type' => 'published', // published, static, draft, sticky, scheduled, autosave + 'type' => 'article', // article, static, draft, sticky, scheduled, autosave 'date' => '', 'dateModified' => '', 'position' => 0, @@ -129,7 +129,7 @@ class Pages extends dbJSON } // Schedule page - if (($row['date'] > Date::current(DB_DATE_FORMAT)) && ($row['type'] == 'published')) { + if (($row['date'] > Date::current(DB_DATE_FORMAT)) && ($row['type'] == 'article')) { $row['type'] = 'scheduled'; } @@ -244,7 +244,8 @@ class Pages extends dbJSON $row['dateModified'] = Date::current(DB_DATE_FORMAT); // Schedule page - if (($row['date'] > Date::current(DB_DATE_FORMAT)) && ($row['type'] == 'published')) { + // TODO: will use the state then + if (($row['date'] > Date::current(DB_DATE_FORMAT)) && ($row['type'] == 'article')) { $row['type'] = 'scheduled'; } @@ -395,14 +396,14 @@ class Pages extends dbJSON return $tmp; } - // Returns a database with published pages + // Returns a database with published articles // $onlyKeys = true; Returns only the pages keys // $onlyKeys = false; Returns part of the database, I do not recommend use this public function getPublishedDB($onlyKeys = true) { $tmp = $this->db; foreach ($tmp as $key => $fields) { - if ($fields['type'] != 'published') { + if ($fields['type'] != 'article') { unset($tmp[$key]); } } @@ -504,12 +505,13 @@ class Pages extends dbJSON // Returns the next page key of the current page key public function nextPageKey($currentKey) { - if ($this->db[$currentKey]['type'] == 'published') { + if ($this->db[$currentKey]['type'] == 'article') { $keys = array_keys($this->db); $position = array_search($currentKey, $keys) - 1; if (isset($keys[$position])) { $nextKey = $keys[$position]; - if ($this->db[$nextKey]['type'] == 'published') { + // TODO: make it check pages from the same type instead + if ($this->db[$nextKey]['type'] == 'article') { return $nextKey; } } @@ -520,12 +522,13 @@ class Pages extends dbJSON // Returns the previous page key of the current page key public function previousPageKey($currentKey) { - if ($this->db[$currentKey]['type'] == 'published') { + if ($this->db[$currentKey]['type'] == 'article') { $keys = array_keys($this->db); $position = array_search($currentKey, $keys) + 1; if (isset($keys[$position])) { $prevKey = $keys[$position]; - if ($this->db[$prevKey]['type'] == 'published') { + // TODO: make it check pages from the same type instead + if ($this->db[$prevKey]['type'] == 'article') { return $prevKey; } } @@ -542,7 +545,7 @@ class Pages extends dbJSON { $list = array(); foreach ($this->db as $key => $fields) { - if ($published && $fields['type'] == 'published') { + if ($published && $fields['type'] == 'article') { array_push($list, $key); } elseif ($static && $fields['type'] == 'static') { array_push($list, $key); @@ -719,10 +722,10 @@ class Pages extends dbJSON foreach ($this->db as $pageKey => $fields) { if ($fields['type'] == 'scheduled') { if ($fields['date'] <= $currentDate) { - $this->db[$pageKey]['type'] = 'published'; + $this->db[$pageKey]['type'] = 'article'; $saveDatabase = true; } - } elseif (($fields['type'] == 'published') && (ORDER_BY == 'date')) { + } elseif (($fields['type'] == 'article') && (ORDER_BY == 'date')) { break; } } diff --git a/bl-kernel/pagex.class.php b/bl-kernel/pagex.class.php index 81bee954..7c127658 100644 --- a/bl-kernel/pagex.class.php +++ b/bl-kernel/pagex.class.php @@ -360,7 +360,14 @@ class Page // (boolean) Returns TRUE if the page is published, FALSE otherwise public function published() { - return ($this->getValue('type') === 'published'); + // TODO: will use then the state + return ($this->getValue('type') === 'article'); + } + + // (boolean) Returns TRUE if the page is an article, FALSE otherwise + public function article() + { + return ($this->getValue('type') === 'article'); } // (boolean) Returns TRUE if the page is scheduled, FALSE otherwise diff --git a/bl-kernel/site.class.php b/bl-kernel/site.class.php index a62c69aa..c33eefb7 100644 --- a/bl-kernel/site.class.php +++ b/bl-kernel/site.class.php @@ -477,4 +477,10 @@ class Site extends dbJSON $customFields = Sanitize::htmlDecode($this->getField('customFields')); return json_decode($customFields, true); } + + // Returns the custom fields as array + public function databaseVersion() + { + return 1; + } } diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php index 2e175cdc..4d33bc46 100644 --- a/bl-plugins/api/plugin.php +++ b/bl-plugins/api/plugin.php @@ -352,7 +352,7 @@ class pluginAPI extends Plugin global $pages; // Parameters and the default values - $published = (isset($args['published']) ? $args['published'] == 'true' : true); + $published = (isset($args['article']) ? $args['article'] == 'true' : true); $static = (isset($args['static']) ? $args['static'] == 'true' : false); $draft = (isset($args['draft']) ? $args['draft'] == 'true' : false); $sticky = (isset($args['sticky']) ? $args['sticky'] == 'true' : false); diff --git a/bl-plugins/disqus/plugin.php b/bl-plugins/disqus/plugin.php index 9045eb75..71e825f8 100644 --- a/bl-plugins/disqus/plugin.php +++ b/bl-plugins/disqus/plugin.php @@ -62,7 +62,7 @@ class pluginDisqus extends Plugin if ($WHERE_AM_I === 'page') { global $page; - if ($page->published() && $this->getValue('enablePages')) { + if ($page->article() && $this->getValue('enablePages')) { return $this->javascript(); } if ($page->isStatic() && $this->getValue('enableStatic')) { diff --git a/install.php b/install.php index cc9a2a86..ced49f0b 100644 --- a/install.php +++ b/install.php @@ -334,7 +334,7 @@ function install($adminPassword, $timezone) 'description' => '', 'username' => 'admin', 'tags' => array(), - 'type' => (($slug == 'example-page-4-slug') ? 'static' : 'published'), + 'type' => (($slug == 'example-page-4-slug') ? 'static' : 'article'), 'date' => $nextDate, 'dateModified' => '', 'allowComments' => true,