diff --git a/bl-kernel/admin/views/edit-content.php b/bl-kernel/admin/views/edit-content.php index 79b05342..dcc276b9 100644 --- a/bl-kernel/admin/views/edit-content.php +++ b/bl-kernel/admin/views/edit-content.php @@ -92,6 +92,18 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural 'rows' => 5, 'placeholder' => $L->get('this-field-can-help-describe-the-content') )); + + // Post Kinds + echo ContentPage::formSelectBlock($contentType, array( + 'name' => 'kind', + 'label' => $L->g('Post Kinds'), + 'selected' => $page->kind(), + 'class' => '', + 'emptyOption' => '- ' . $L->g('None') . ' -', + 'options' => $kinds->getKeyNameArray(), + 'mt' => 'mt-0', + 'type'=> 'Post kinds allow themes to use different formating and microformat for this kind of posts' + )); // Source Link echo ContentPage::formInputTextBlock($contentType,array( @@ -175,6 +187,18 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural )); if ($contentType->canShow("content")) { + // Post Kinds + echo ContentPage::formSelectBlock($contentType, array( + 'name' => 'kind', + 'label' => $L->g('Post Kinds'), + 'selected' => $page->kind(), + 'class' => '', + 'emptyOption' => '- ' . $L->g('None') . ' -', + 'options' => $kinds->getKeyNameArray(), + 'mt' => 'mt-0', + 'type'=> 'Post kinds allow themes to use different formating and microformat for this kind of posts' + )); + // Description echo ContentPage::formTextareaBlock($contentType,array( 'name' => 'description', diff --git a/bl-kernel/admin/views/new-content.php b/bl-kernel/admin/views/new-content.php index 960cfc50..df14c487 100644 --- a/bl-kernel/admin/views/new-content.php +++ b/bl-kernel/admin/views/new-content.php @@ -86,6 +86,18 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural( 'placeholder' => $L->get('this-field-can-help-describe-the-content') )); + // Post Kinds + echo ContentPage::formSelectBlock($contentType, array( + 'name' => 'kind', + 'label' => $L->g('Post Kinds'), + 'selected' => 'article', + 'class' => '', + 'emptyOption' => '- ' . $L->g('None') . ' -', + 'options' => $kinds->getKeyNameArray(), + 'mt' => 'mt-0', + 'type'=> 'Post kinds allow themes to use different formating and microformat for this kind of posts' + )); + // Source Link echo ContentPage::formInputTextBlock($contentType,array( 'name' => 'sourceLink', @@ -167,6 +179,18 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural( )); if ($contentType->canShow("content")) { + // Post Kinds + echo ContentPage::formSelectBlock($contentType, array( + 'name' => 'kind', + 'label' => $L->g('Post Kinds'), + 'selected' => 'article', + 'class' => '', + 'emptyOption' => '- ' . $L->g('None') . ' -', + 'options' => $kinds->getKeyNameArray(), + 'mt' => 'mt-0', + 'type'=> 'Post kinds allow themes to use different formating and microformat for this kind of posts' + )); + // Description echo ContentPage::formTextareaBlock($contentType, array( 'name' => 'description', diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index e1e0d433..16bd0d45 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -69,6 +69,7 @@ define('DB_CATEGORIES', PATH_DATABASES . 'categories.php'); define('DB_TAGS', PATH_DATABASES . 'tags.php'); define('DB_AUTHORS', PATH_DATABASES . 'authors.php'); define('DB_ARCHIVES', PATH_DATABASES . 'archives.php'); +define('DB_KINDS', PATH_DATABASES . 'kinds.php'); define('DB_SYSLOG', PATH_DATABASES . 'syslog.php'); define('DB_USERS', PATH_DATABASES . 'users.php'); define('DB_SECURITY', PATH_DATABASES . 'security.php'); @@ -94,6 +95,7 @@ include(PATH_KERNEL . 'users.class.php'); include(PATH_KERNEL . 'tags.class.php'); include(PATH_KERNEL . 'authors.class.php'); include(PATH_KERNEL . 'archives.class.php'); +include(PATH_KERNEL . 'kinds.class.php'); include(PATH_KERNEL . 'language.class.php'); include(PATH_KERNEL . 'site.class.php'); include(PATH_KERNEL . 'categories.class.php'); @@ -139,6 +141,7 @@ $users = new Users(); $tags = new Tags(); $authors = new Authors(); $archives = new Archives(); +$kinds = new Kinds(); $categories = new Categories(); $site = new Site(); $url = new Url(); diff --git a/bl-kernel/boot/variables.php b/bl-kernel/boot/variables.php index e17f7708..a4ff4d6c 100644 --- a/bl-kernel/boot/variables.php +++ b/bl-kernel/boot/variables.php @@ -108,3 +108,19 @@ $GLOBALS['ALLOWED_IMG_EXTENSION'] = array('gif', 'png', 'jpg', 'jpeg', 'svg', 'w // Allowed image mime types $GLOBALS['ALLOWED_IMG_MIMETYPES'] = array('image/gif', 'image/png', 'image/jpeg', 'image/svg+xml', 'image/webp'); + +// Supported post kinds +$GLOBALS['POST_KINDS'] = array('article', 'note', 'photo', 'reply', 'bookmark', 'like', 'review'); + +$GLOBALS['POST_KINDS_EMOJI'] = array( + "article"=>'📄', + 'note'=>'📔', + 'photo'=>'📷', + 'video'=>'🎥', + 'audio'=>'🎤', + 'reply'=>'💬', + 'bookmark'=>'🔖', + 'like'=>'👍', + 'review'=>'⭐️', + 'chicken'=>'🐔' +); \ No newline at end of file diff --git a/bl-kernel/helpers/updater.class.php b/bl-kernel/helpers/updater.class.php index 19858c59..73ce828a 100644 --- a/bl-kernel/helpers/updater.class.php +++ b/bl-kernel/helpers/updater.class.php @@ -49,6 +49,10 @@ class KoblogUpdater { ); file_put_contents(PATH_DATABASES . 'pagetypes.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX); } + if (!file_exists(PATH_DATABASES . 'kinds.php')) { + global $kinds; + $kinds->reindex(); + } return $pages->save(); } diff --git a/bl-kernel/kinds.class.php b/bl-kernel/kinds.class.php new file mode 100644 index 00000000..ea5b9ef3 --- /dev/null +++ b/bl-kernel/kinds.class.php @@ -0,0 +1,45 @@ +countItems($key); + } + + public function reindex() + { + global $pages; + global $L; + + $kindArray = array(); + + foreach ($GLOBALS['POST_KINDS'] as $kind) { + $kindArray[$kind]['name'] = $GLOBALS['POST_KINDS_EMOJI'][$kind]." ".$L->g($kind); + $kindArray[$kind]['list'] = array(); + } + + + $db = $pages->getDB($onlyKeys=false); + foreach ($db as $pageKey=>$pageFields) { + if ($pageFields['state'] == "published" && isset($pageFields['kinds']) && $pageFields !== '') { + $kind = $pageFields['kind']; + + // Index by years + if (isset($kindArray[$kind])) { + array_push($kindArray[$kind]['list'], $pageKey); + } + + } + } + + $this->db = $kindArray; + return $this->save(); + } + +} \ No newline at end of file diff --git a/bl-kernel/pages.class.php b/bl-kernel/pages.class.php index 72f65911..8cadd9b1 100644 --- a/bl-kernel/pages.class.php +++ b/bl-kernel/pages.class.php @@ -11,6 +11,7 @@ class Pages extends dbJSON 'tags' => array(), 'type' => 'article', // article, static 'state' => 'published', // draft, scheduled, autosave + 'kind'=>'', 'sticky' => false, 'date' => '', 'dateModified' => '', diff --git a/bl-kernel/pagex.class.php b/bl-kernel/pagex.class.php index c276090e..6e391249 100644 --- a/bl-kernel/pagex.class.php +++ b/bl-kernel/pagex.class.php @@ -448,10 +448,16 @@ class Page } // retour the source link - public function sourceLink() { + public function sourceLink() + { return $this->getValue('sourceLink'); } + public function kind() + { + return $this->getValue('kind'); + } + // Returns the page slug public function slug() {