✨ Add post kinds
This commit is contained in:
parent
d24455c449
commit
b8542b730a
7 changed files with 96 additions and 1 deletions
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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'=>'🐔'
|
||||
);
|
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();
|
||||
}
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@ class Pages extends dbJSON
|
|||
'username' => '',
|
||||
'tags' => array(),
|
||||
'type' => 'published', // published, static, draft, sticky, scheduled, autosave
|
||||
'kind'=>'',
|
||||
'date' => '',
|
||||
'dateModified' => '',
|
||||
'position' => 0,
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue