Add post kinds

This commit is contained in:
Kazhnuz 2025-03-03 07:53:10 +01:00
parent d032d004ce
commit ebd7297008
8 changed files with 124 additions and 1 deletions

View file

@ -92,6 +92,18 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
'rows' => 5, 'rows' => 5,
'placeholder' => $L->get('this-field-can-help-describe-the-content') '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 // Source Link
echo ContentPage::formInputTextBlock($contentType,array( echo ContentPage::formInputTextBlock($contentType,array(
@ -175,6 +187,18 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
)); ));
if ($contentType->canShow("content")) { 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 // Description
echo ContentPage::formTextareaBlock($contentType,array( echo ContentPage::formTextareaBlock($contentType,array(
'name' => 'description', 'name' => 'description',

View file

@ -86,6 +86,18 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural(
'placeholder' => $L->get('this-field-can-help-describe-the-content') '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 // Source Link
echo ContentPage::formInputTextBlock($contentType,array( echo ContentPage::formInputTextBlock($contentType,array(
'name' => 'sourceLink', 'name' => 'sourceLink',
@ -167,6 +179,18 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural(
)); ));
if ($contentType->canShow("content")) { 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 // Description
echo ContentPage::formTextareaBlock($contentType, array( echo ContentPage::formTextareaBlock($contentType, array(
'name' => 'description', 'name' => 'description',

View file

@ -69,6 +69,7 @@ define('DB_CATEGORIES', PATH_DATABASES . 'categories.php');
define('DB_TAGS', PATH_DATABASES . 'tags.php'); define('DB_TAGS', PATH_DATABASES . 'tags.php');
define('DB_AUTHORS', PATH_DATABASES . 'authors.php'); define('DB_AUTHORS', PATH_DATABASES . 'authors.php');
define('DB_ARCHIVES', PATH_DATABASES . 'archives.php'); define('DB_ARCHIVES', PATH_DATABASES . 'archives.php');
define('DB_KINDS', PATH_DATABASES . 'kinds.php');
define('DB_SYSLOG', PATH_DATABASES . 'syslog.php'); define('DB_SYSLOG', PATH_DATABASES . 'syslog.php');
define('DB_USERS', PATH_DATABASES . 'users.php'); define('DB_USERS', PATH_DATABASES . 'users.php');
define('DB_SECURITY', PATH_DATABASES . 'security.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 . 'tags.class.php');
include(PATH_KERNEL . 'authors.class.php'); include(PATH_KERNEL . 'authors.class.php');
include(PATH_KERNEL . 'archives.class.php'); include(PATH_KERNEL . 'archives.class.php');
include(PATH_KERNEL . 'kinds.class.php');
include(PATH_KERNEL . 'language.class.php'); include(PATH_KERNEL . 'language.class.php');
include(PATH_KERNEL . 'site.class.php'); include(PATH_KERNEL . 'site.class.php');
include(PATH_KERNEL . 'categories.class.php'); include(PATH_KERNEL . 'categories.class.php');
@ -139,6 +141,7 @@ $users = new Users();
$tags = new Tags(); $tags = new Tags();
$authors = new Authors(); $authors = new Authors();
$archives = new Archives(); $archives = new Archives();
$kinds = new Kinds();
$categories = new Categories(); $categories = new Categories();
$site = new Site(); $site = new Site();
$url = new Url(); $url = new Url();

View file

@ -108,3 +108,19 @@ $GLOBALS['ALLOWED_IMG_EXTENSION'] = array('gif', 'png', 'jpg', 'jpeg', 'svg', 'w
// Allowed image mime types // Allowed image mime types
$GLOBALS['ALLOWED_IMG_MIMETYPES'] = array('image/gif', 'image/png', 'image/jpeg', 'image/svg+xml', 'image/webp'); $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'=>'🐔'
);

View file

@ -49,6 +49,10 @@ class KoblogUpdater {
); );
file_put_contents(PATH_DATABASES . 'pagetypes.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX); 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(); return $pages->save();
} }

45
bl-kernel/kinds.class.php Normal file
View file

@ -0,0 +1,45 @@
<?php defined('KOBLOG') or die('Koblog CMS.');
class Kinds extends dbList {
function __construct()
{
parent::__construct(DB_KINDS);
}
function numberOfPages($key)
{
return $this->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();
}
}

View file

@ -11,6 +11,7 @@ class Pages extends dbJSON
'tags' => array(), 'tags' => array(),
'type' => 'article', // article, static 'type' => 'article', // article, static
'state' => 'published', // draft, scheduled, autosave 'state' => 'published', // draft, scheduled, autosave
'kind'=>'',
'sticky' => false, 'sticky' => false,
'date' => '', 'date' => '',
'dateModified' => '', 'dateModified' => '',

View file

@ -448,10 +448,16 @@ class Page
} }
// retour the source link // retour the source link
public function sourceLink() { public function sourceLink()
{
return $this->getValue('sourceLink'); return $this->getValue('sourceLink');
} }
public function kind()
{
return $this->getValue('kind');
}
// Returns the page slug // Returns the page slug
public function slug() public function slug()
{ {