diff --git a/bl-kernel/admin/views/edit-content.php b/bl-kernel/admin/views/edit-content.php index a9e3fff7..f805599d 100644 --- a/bl-kernel/admin/views/edit-content.php +++ b/bl-kernel/admin/views/edit-content.php @@ -146,6 +146,18 @@ echo Bootstrap::formInputHidden(array( 'value' => $page->tags() )); + // Post Kinds + echo Bootstrap::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 Bootstrap::formTextareaBlock(array( 'name' => 'description', diff --git a/bl-kernel/admin/views/new-content.php b/bl-kernel/admin/views/new-content.php index 99e94438..e554924e 100644 --- a/bl-kernel/admin/views/new-content.php +++ b/bl-kernel/admin/views/new-content.php @@ -135,6 +135,18 @@ echo Bootstrap::formInputHidden(array( 'tip' => $L->g('Write the tags separated by comma') )); + // Post Kinds + echo Bootstrap::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 Bootstrap::formTextareaBlock(array( 'name' => 'description', diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 1243e0b3..5387a382 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -68,6 +68,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'); @@ -92,6 +93,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'); @@ -132,6 +134,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 3425cd85..f9848b04 100644 --- a/bl-kernel/boot/variables.php +++ b/bl-kernel/boot/variables.php @@ -111,3 +111,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/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 598ca732..001b4339 100644 --- a/bl-kernel/pages.class.php +++ b/bl-kernel/pages.class.php @@ -10,6 +10,7 @@ class Pages extends dbJSON 'username' => '', 'tags' => array(), 'type' => 'published', // published, static, draft, sticky, scheduled, autosave + 'kind'=>'', 'date' => '', 'dateModified' => '', 'position' => 0, diff --git a/bl-kernel/pagex.class.php b/bl-kernel/pagex.class.php index 0575de02..e89bc5e9 100644 --- a/bl-kernel/pagex.class.php +++ b/bl-kernel/pagex.class.php @@ -436,10 +436,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() {