✨ Handle post kinds from content type
This commit is contained in:
parent
ebd7297008
commit
09ea4e647b
6 changed files with 50 additions and 15 deletions
|
@ -92,7 +92,7 @@ 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
|
// Post Kinds
|
||||||
echo ContentPage::formSelectBlock($contentType, array(
|
echo ContentPage::formSelectBlock($contentType, array(
|
||||||
'name' => 'kind',
|
'name' => 'kind',
|
||||||
|
@ -100,7 +100,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
|
||||||
'selected' => $page->kind(),
|
'selected' => $page->kind(),
|
||||||
'class' => '',
|
'class' => '',
|
||||||
'emptyOption' => '- ' . $L->g('None') . ' -',
|
'emptyOption' => '- ' . $L->g('None') . ' -',
|
||||||
'options' => $kinds->getKeyNameArray(),
|
'options' => $contentType->kinds(),
|
||||||
'mt' => 'mt-0',
|
'mt' => 'mt-0',
|
||||||
'type'=> 'Post kinds allow themes to use different formating and microformat for this kind of posts'
|
'type'=> 'Post kinds allow themes to use different formating and microformat for this kind of posts'
|
||||||
));
|
));
|
||||||
|
@ -194,7 +194,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
|
||||||
'selected' => $page->kind(),
|
'selected' => $page->kind(),
|
||||||
'class' => '',
|
'class' => '',
|
||||||
'emptyOption' => '- ' . $L->g('None') . ' -',
|
'emptyOption' => '- ' . $L->g('None') . ' -',
|
||||||
'options' => $kinds->getKeyNameArray(),
|
'options' => $contentType->kinds(),
|
||||||
'mt' => 'mt-0',
|
'mt' => 'mt-0',
|
||||||
'type'=> 'Post kinds allow themes to use different formating and microformat for this kind of posts'
|
'type'=> 'Post kinds allow themes to use different formating and microformat for this kind of posts'
|
||||||
));
|
));
|
||||||
|
|
|
@ -85,15 +85,15 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$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
|
// Post Kinds
|
||||||
echo ContentPage::formSelectBlock($contentType, array(
|
echo ContentPage::formSelectBlock($contentType, array(
|
||||||
'name' => 'kind',
|
'name' => 'kind',
|
||||||
'label' => $L->g('Post Kinds'),
|
'label' => $L->g('Post Kinds'),
|
||||||
'selected' => 'article',
|
'selected' => $contentType->defaultKind(),
|
||||||
'class' => '',
|
'class' => '',
|
||||||
'emptyOption' => '- ' . $L->g('None') . ' -',
|
'emptyOption' => '- ' . $L->g('None') . ' -',
|
||||||
'options' => $kinds->getKeyNameArray(),
|
'options' => $contentType->kinds(),
|
||||||
'mt' => 'mt-0',
|
'mt' => 'mt-0',
|
||||||
'type'=> 'Post kinds allow themes to use different formating and microformat for this kind of posts'
|
'type'=> 'Post kinds allow themes to use different formating and microformat for this kind of posts'
|
||||||
));
|
));
|
||||||
|
@ -183,10 +183,10 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural(
|
||||||
echo ContentPage::formSelectBlock($contentType, array(
|
echo ContentPage::formSelectBlock($contentType, array(
|
||||||
'name' => 'kind',
|
'name' => 'kind',
|
||||||
'label' => $L->g('Post Kinds'),
|
'label' => $L->g('Post Kinds'),
|
||||||
'selected' => 'article',
|
'selected' => $contentType->defaultKind(),
|
||||||
'class' => '',
|
'class' => '',
|
||||||
'emptyOption' => '- ' . $L->g('None') . ' -',
|
'emptyOption' => '- ' . $L->g('None') . ' -',
|
||||||
'options' => $kinds->getKeyNameArray(),
|
'options' => $contentType->kinds(),
|
||||||
'mt' => 'mt-0',
|
'mt' => 'mt-0',
|
||||||
'type'=> 'Post kinds allow themes to use different formating and microformat for this kind of posts'
|
'type'=> 'Post kinds allow themes to use different formating and microformat for this kind of posts'
|
||||||
));
|
));
|
||||||
|
|
|
@ -11,6 +11,10 @@ class KoblogUpdater {
|
||||||
global $L;
|
global $L;
|
||||||
|
|
||||||
foreach ($pages->db as $key => $fields) {
|
foreach ($pages->db as $key => $fields) {
|
||||||
|
if ($fields['kind'] === '') {
|
||||||
|
$pages->db[$key]['kind'] = 'article';
|
||||||
|
}
|
||||||
|
|
||||||
if ($fields['type'] === "published") {
|
if ($fields['type'] === "published") {
|
||||||
$pages->db[$key]['type'] = "article";
|
$pages->db[$key]['type'] = "article";
|
||||||
$pages->db[$key]['state'] = "published";
|
$pages->db[$key]['state'] = "published";
|
||||||
|
@ -43,9 +47,9 @@ class KoblogUpdater {
|
||||||
//
|
//
|
||||||
if (!file_exists(PATH_DATABASES . 'pagetypes.php')) {
|
if (!file_exists(PATH_DATABASES . 'pagetypes.php')) {
|
||||||
$data = array(
|
$data = array(
|
||||||
'article' => array('name' => $L->g("Article"), 'plural' => $L->g("Articles"), 'icon'=>'file-text'),
|
'article' => array('name' => $L->g("Article"), 'plural' => $L->g("Articles"), 'icon'=>'file-text', 'hideFields'=>'', 'kinds'=>'article reply note photo video audio repost review', 'defaultKind'=>'article'),
|
||||||
'static' => array('name' => $L->g("Static page"), 'plural' => $L->g("Static pages"), 'icon'=>'file'),
|
'static' => array('name' => $L->g("Static page"), 'plural' => $L->g("Static pages"), 'icon'=>'file', 'hideFields'=>'category tags sticky sourceLink kind', 'kinds'=>'', 'defaultKind'=>''),
|
||||||
'share'=> array('name' => $L->g("Share"), 'plural' => $L->g("Shares"), 'icon'=>'retweet')
|
'share' => array('name' => $L->g("Share"), 'plural' => $L->g("Shares"), 'icon'=>'retweet', 'hideFields'=>'content category cover position parent template externalCoverImage custom noindex nofollow noarchive', 'kinds'=>'like bookmark', 'defaultKind'=>'bookmark'),
|
||||||
);
|
);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,4 +71,33 @@ class PageType
|
||||||
return !$this->canShow($field);
|
return !$this->canShow($field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function haveKind($var)
|
||||||
|
{
|
||||||
|
$kinds = $this->getValue("kinds");
|
||||||
|
if ($kinds === '' || !isset($kinds))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return !str_contains($kinds, $var);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function kinds()
|
||||||
|
{
|
||||||
|
global $kinds;
|
||||||
|
return array_filter($kinds->getKeyNameArray(), function ($var)
|
||||||
|
{
|
||||||
|
$kinds = $this->getValue("kinds");
|
||||||
|
if ($kinds === '' || !isset($kinds))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return str_contains($kinds, $var);
|
||||||
|
}, ARRAY_FILTER_USE_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defaultKind()
|
||||||
|
{
|
||||||
|
return $this->getValue('defaultKind');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,7 +6,9 @@ class PageTypes extends dbJSON {
|
||||||
'name'=>'',
|
'name'=>'',
|
||||||
'plural'=>'',
|
'plural'=>'',
|
||||||
'icon'=>'fa-file',
|
'icon'=>'fa-file',
|
||||||
'hideField'=>''
|
'hideField'=>'',
|
||||||
|
'kinds'=>'article',
|
||||||
|
'defaultKind'=>'article'
|
||||||
);
|
);
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
|
|
|
@ -469,9 +469,9 @@ function install($adminPassword, $timezone)
|
||||||
file_put_contents(PATH_DATABASES . 'categories.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
file_put_contents(PATH_DATABASES . 'categories.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'article' => array('name' => $L->g("Article"), 'plural' => $L->g("Articles"), 'icon'=>'file-text', 'hideFields'=>''),
|
'article' => array('name' => $L->g("Article"), 'plural' => $L->g("Articles"), 'icon'=>'file-text', 'hideFields'=>'', 'kinds'=>'article reply note photo video audio repost review', 'defaultKind'=>'article'),
|
||||||
'static' => array('name' => $L->g("Static page"), 'plural' => $L->g("Static pages"), 'icon'=>'file', 'hideFields'=>'category tags sticky sourceLink'),
|
'static' => array('name' => $L->g("Static page"), 'plural' => $L->g("Static pages"), 'icon'=>'file', 'hideFields'=>'category tags sticky sourceLink kind', 'kinds'=>'', 'defaultKind'=>''),
|
||||||
'share' => array('name' => $L->g("Share"), 'plural' => $L->g("Shares"), 'icon'=>'retweet', 'hideFields'=>'content category cover position parent template externalCoverImage custom noindex nofollow noarchive'),
|
'share' => array('name' => $L->g("Share"), 'plural' => $L->g("Shares"), 'icon'=>'retweet', 'hideFields'=>'content category cover position parent template externalCoverImage custom noindex nofollow noarchive', 'kinds'=>'like bookmark', 'defaultKind'=>'bookmark'),
|
||||||
);
|
);
|
||||||
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);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue