✨ Add post kinds
This commit is contained in:
parent
d032d004ce
commit
ebd7297008
8 changed files with 124 additions and 1 deletions
|
@ -93,6 +93,18 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$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' => $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(
|
||||
'name' => 'sourceLink',
|
||||
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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'=>'🐔'
|
||||
);
|
|
@ -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();
|
||||
}
|
||||
|
|
45
bl-kernel/kinds.class.php
Normal file
45
bl-kernel/kinds.class.php
Normal 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();
|
||||
}
|
||||
|
||||
}
|
|
@ -11,6 +11,7 @@ class Pages extends dbJSON
|
|||
'tags' => array(),
|
||||
'type' => 'article', // article, static
|
||||
'state' => 'published', // draft, scheduled, autosave
|
||||
'kind'=>'',
|
||||
'sticky' => false,
|
||||
'date' => '',
|
||||
'dateModified' => '',
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue