Add repost link functionalities #53

Open
kazhnuz wants to merge 11 commits from feat/shaarli-like into koblog
15 changed files with 431 additions and 102 deletions

View file

@ -74,10 +74,15 @@
<span class="visually-hidden">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu dropdown-menu-end">
<?php foreach ($pagetypes->getDB() as $contentPageKey => $fields) {
$pageType = new PageType($contentPageKey);
?>
<li>
<a class="dropdown-item" href="<?php echo HTML_PATH_ADMIN_ROOT.'new-content/static' ?>">
<?php $L->p('New') ?> (<?php $L->p(string: 'Static page') ?>)</a>
<a class="dropdown-item" href="<?php echo HTML_PATH_ADMIN_ROOT.'new-content/'.$pageType->type(); ?>">
<?php $L->p('New') ?> (<?php echo $pageType->name(); ?>)</a>
</li>
<?php
} ?>
<li>
<a class="dropdown-item" href="<?php echo HTML_PATH_ADMIN_ROOT.'new-category' ?>">
<?php $L->p('New category') ?></a>

View file

@ -1,5 +1,67 @@
<?php
class ContentPage
{
private static function canShow($contentType, $args)
{
return $contentType->canShow($args['name']);
}
public static function formInputTextBlock($contentType, $args) {
if (ContentPage::canShow($contentType, $args)) {
return Bootstrap::formInputTextBlock($args);
}
return '';
}
public static function formInputFile($contentType, $args) {
if (ContentPage::canShow($contentType, $args)) {
return Bootstrap::formInputFile($args);
}
return '';
}
public static function formTextarea($contentType, $args) {
if (ContentPage::canShow($contentType, $args)) {
return Bootstrap::formTextarea($args);
}
return '';
}
public static function formTextareaBlock($contentType, $args) {
if (ContentPage::canShow($contentType, $args)) {
return Bootstrap::formTextareaBlock($args);
}
return '';
}
public static function formInputText($contentType, $args) {
if (ContentPage::canShow($contentType, $args)) {
return Bootstrap::formInputText($args);
}
return '';
}
public static function formCheckbox($contentType, $args) {
if (ContentPage::canShow($contentType, $args)) {
return Bootstrap::formCheckbox($args);
}
return '';
}
public static function formSelect($contentType, $args) {
if (ContentPage::canShow($contentType, $args)) {
return Bootstrap::formSelect($args);
}
return '';
}
public static function formSelectBlock($contentType, $args) {
if (ContentPage::canShow($contentType, $args)) {
return Bootstrap::formSelectBlock($args);
}
return '';
}
public static function formInputHidden($contentType, $args) {
if (ContentPage::canShow($contentType, $args)) {
return Bootstrap::formInputHidden($args);
}
return '';
}
}
class Bootstrap
{

View file

@ -1,7 +1,18 @@
<?php
echo "<div class='d-flex justify-content-between align-content-center'>";
echo Bootstrap::pageTitle(array('title'=>$contentType->plural(), 'icon'=>$contentType->icon()));
echo "<div>";
echo Bootstrap::link(array(
'title'=>$L->g('New'),
'href'=>HTML_PATH_ADMIN_ROOT.'new-content/'.$contentType->type(),
'icon'=>'plus',
'class'=>'btn btn-outline-success'
));
echo "</div></div>";
function table($type) {
global $url;
global $L;

View file

@ -78,7 +78,42 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
</div>
<!-- Editor -->
<textarea id="jseditor" class="editable h-100" style=""><?php echo $page->contentRaw(true) ?></textarea>
<div class="<?php echo $contentType->mustHide("content")?"d-none":"" ?>">
<textarea id="jseditor" class="editable h-100" style=""><?php echo $page->contentRaw(true) ?></textarea>
</div>
<?php if ($contentType->mustHide("content")) {
// Description
echo ContentPage::formTextareaBlock($contentType, array(
'name' => 'description',
'label' => $L->g('Description'),
'selected' => '',
'class' => '',
'value' => $page->description(),
'rows' => 5,
'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' => $contentType->kinds(),
'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',
'label' => $L->g('Source Link'),
'placeholder' => '',
'tip' => $L->g('The external link you refer to in the post'),
'value' => $page->sourceLink()
));
} ?>
<!-- Custom fields: BOTTOM -->
<?php
@ -131,52 +166,74 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
<div class="tab-content pr-3 pl-3 pb-3 card-body">
<div id="nav-general" class="tab-pane fade show active" role="tabpanel" aria-labelledby="general-tab">
<?php
if ($contentTypeKey == "article") {
// Category
echo Bootstrap::formSelectBlock(array(
'name' => 'category',
'label' => $L->g('Category'),
'selected' => $page->categoryKey(),
'class' => '',
'emptyOption' => '- ' . $L->g('Uncategorized') . ' -',
'options' => $categories->getKeyNameArray(),
'mt'=>'mt-0'
));
// Tags
echo Bootstrap::formInputTextBlock(array(
'name' => 'tags',
'label' => $L->g('Tags'),
'placeholder' => '',
'tip' => $L->g('Write the tags separated by comma'),
'value' => $page->tags()
));
}
// Description
echo Bootstrap::formTextareaBlock(array(
'name' => 'description',
'label' => $L->g('Description'),
'selected' => '',
// Category
echo ContentPage::formSelectBlock($contentType,array(
'name' => 'category',
'label' => $L->g('Category'),
'selected' => $page->categoryKey(),
'class' => '',
'value' => $page->description(),
'rows' => 5,
'placeholder' => $L->get('this-field-can-help-describe-the-content')
'emptyOption' => '- ' . $L->g('Uncategorized') . ' -',
'options' => $categories->getKeyNameArray(),
'mt'=>'mt-0'
));
if ($contentTypeKey == "article") {
// Sticky
echo Bootstrap::formCheckbox(array(
'name' => 'sticky',
'label' => $L->g('Sticky'),
'labelForCheckbox' => $L->g('Put this article in first position in the article list.'),
// Tags
echo ContentPage::formInputTextBlock($contentType,array(
'name' => 'tags',
'label' => $L->g('Tags'),
'placeholder' => '',
'tip' => $L->g('Write the tags separated by comma'),
'value' => $page->tags()
));
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' => $contentType->kinds(),
'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',
'label' => $L->g('Description'),
'selected' => '',
'class' => '',
'value' => $page->description(),
'rows' => 5,
'placeholder' => $L->get('this-field-can-help-describe-the-content')
));
// Source Link
echo ContentPage::formInputTextBlock($contentType,array(
'name' => 'sourceLink',
'label' => $L->g('Source Link'),
'placeholder' => '',
'checked' => $page->sticky(),
'tip' => ""
'tip' => $L->g('The external link you refer to in the post'),
'value' => $page->sourceLink()
));
}
// Sticky
echo ContentPage::formCheckbox($contentType,array(
'name' => 'sticky',
'label' => $L->g('Sticky'),
'labelForCheckbox' => $L->g('Put this article in first position in the article list.'),
'placeholder' => '',
'checked' => $page->sticky(),
'tip' => ""
));
?>
<?php if ($contentType->canShow('cover')): ?>
<!-- Cover Image -->
<?php
$coverImage = $page->coverImage(false);
@ -210,11 +267,12 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
});
});
</script>
<?php endif; ?>
</div>
<div id="nav-advanced" class="tab-pane fade" role="tabpanel" aria-labelledby="advanced-tab">
<?php
// Date
echo Bootstrap::formInputTextBlock(array(
echo ContentPage::formInputTextBlock($contentType, array(
'name' => 'date',
'label' => $L->g('Date'),
'placeholder' => '',
@ -224,7 +282,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
));
// Position
echo Bootstrap::formInputTextBlock(array(
echo ContentPage::formInputTextBlock($contentType, array(
'name' => 'position',
'label' => $L->g('Position'),
'tip' => $L->g('Field used when ordering content by position'),
@ -242,7 +300,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
} catch (Exception $e) {
// continue
}
echo Bootstrap::formSelectBlock(array(
echo ContentPage::formSelectBlock($contentType,array(
'name' => 'parent',
'label' => $L->g('Parent'),
'options' => $options,
@ -290,7 +348,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
<?php
// Template
echo Bootstrap::formInputTextBlock(array(
echo ContentPage::formInputTextBlock($contentType, array(
'name' => 'template',
'label' => $L->g('Template'),
'placeholder' => '',
@ -298,7 +356,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
'tip' => $L->g('Write a template name to filter the page in the theme and change the style of the page.')
));
echo Bootstrap::formInputTextBlock(array(
echo ContentPage::formInputTextBlock($contentType, array(
'name' => 'externalCoverImage',
'label' => $L->g('External cover image'),
'placeholder' => "https://",
@ -364,7 +422,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
<div id="nav-seo" class="tab-pane fade" role="tabpanel" aria-labelledby="seo-tab">
<?php
// Friendly URL
echo Bootstrap::formInputTextBlock(array(
echo ContentPage::formInputTextBlock($contentType, array(
'name' => 'slug',
'tip' => $L->g('URL associated with the content'),
'label' => $L->g('Friendly URL'),
@ -374,7 +432,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
));
// Robots
echo Bootstrap::formCheckbox(array(
echo ContentPage::formCheckbox($contentType, array(
'name' => 'noindex',
'label' => 'Robots',
'labelForCheckbox' => $L->g('apply-code-noindex-code-to-this-page'),
@ -384,7 +442,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
));
// Robots
echo Bootstrap::formCheckbox(array(
echo ContentPage::formCheckbox($contentType, array(
'name' => 'nofollow',
'label' => '',
'labelForCheckbox' => $L->g('apply-code-nofollow-code-to-this-page'),
@ -394,7 +452,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("Edit")." (".$contentType->plural
));
// Robots
echo Bootstrap::formCheckbox(array(
echo ContentPage::formCheckbox($contentType, array(
'name' => 'noarchive',
'label' => '',
'labelForCheckbox' => $L->g('apply-code-noarchive-code-to-this-page'),

View file

@ -71,7 +71,42 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural(
</div>
<!-- Editor -->
<textarea id="jseditor" class="editable h-100 mb-1"></textarea>
<div class="<?php echo $contentType->mustHide("content")?"d-none":"" ?>">
<textarea id="jseditor" class="editable h-100 mb-1"></textarea>
</div>
<?php if ($contentType->mustHide("content")) {
// Description
echo ContentPage::formTextareaBlock($contentType, array(
'name' => 'description',
'label' => $L->g('Description'),
'selected' => '',
'class' => '',
'value' => '',
'rows' => 5,
'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' => $contentType->defaultKind(),
'class' => '',
'emptyOption' => '- ' . $L->g('None') . ' -',
'options' => $contentType->kinds(),
'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',
'label' => $L->g('Source Link'),
'placeholder' => '',
'tip' => $L->g('The external link you refer to in the post'),
'value' => ''
));
} ?>
<!-- Custom fields: BOTTOM -->
<?php
@ -124,51 +159,71 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural(
<div class="tab-content pr-3 pl-3 pb-3">
<div id="nav-general" class="tab-pane fade show active" role="tabpanel" aria-labelledby="general-tab">
<?php
if ($contentTypeKey == "article") {
// Category
echo Bootstrap::formSelectBlock(array(
'name' => 'category',
'label' => $L->g('Category'),
'selected' => '',
'class' => '',
'emptyOption' => '- ' . $L->g('Uncategorized') . ' -',
'options' => $categories->getKeyNameArray(),
'mt' => 'mt-0'
));
// Tags
echo Bootstrap::formInputTextBlock(array(
'name' => 'tags',
'label' => $L->g('Tags'),
'placeholder' => '',
'tip' => $L->g('Write the tags separated by comma')
));
}
// Description
echo Bootstrap::formTextareaBlock(array(
'name' => 'description',
'label' => $L->g('Description'),
// Category
echo ContentPage::formSelectBlock($contentType, array(
'name' => 'category',
'label' => $L->g('Category'),
'selected' => '',
'class' => '',
'value' => '',
'rows' => 5,
'placeholder' => $L->get('this-field-can-help-describe-the-content')
'emptyOption' => '- ' . $L->g('Uncategorized') . ' -',
'options' => $categories->getKeyNameArray(),
'mt' => 'mt-0'
));
if ($contentTypeKey == "article") {
// Sticky
echo Bootstrap::formCheckbox(array(
'name' => 'sticky',
'label' => $L->g('Sticky'),
'labelForCheckbox' => $L->g('Put this article in first position in the article list.'),
// Tags
echo ContentPage::formInputTextBlock($contentType, array(
'name' => 'tags',
'label' => $L->g('Tags'),
'placeholder' => '',
'tip' => $L->g('Write the tags separated by comma')
));
if ($contentType->canShow("content")) {
// Post Kinds
echo ContentPage::formSelectBlock($contentType, array(
'name' => 'kind',
'label' => $L->g('Post Kinds'),
'selected' => $contentType->defaultKind(),
'class' => '',
'emptyOption' => '- ' . $L->g('None') . ' -',
'options' => $contentType->kinds(),
'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',
'label' => $L->g('Description'),
'selected' => '',
'class' => '',
'value' => '',
'rows' => 5,
'placeholder' => $L->get('this-field-can-help-describe-the-content')
));
// Source Link
echo ContentPage::formInputTextBlock($contentType,array(
'name' => 'sourceLink',
'label' => $L->g('Source Link'),
'placeholder' => '',
'checked' => false,
'tip' => ""
'tip' => $L->g('The external link you refer to in the post'),
'value' => ''
));
}
// Sticky
echo ContentPage::formCheckbox($contentType, array(
'name' => 'sticky',
'label' => $L->g('Sticky'),
'labelForCheckbox' => $L->g('Put this article in first position in the article list.'),
'placeholder' => '',
'checked' => false,
'tip' => ""
));
?>
<?php if ($contentType->canShow('cover')): ?>
<!-- Cover Image -->
<label class="mt-2 mb-0 pb-1 text-uppercase w-100"><?php $L->p('Cover Image') ?></label>
<div>
@ -194,11 +249,12 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural(
});
});
</script>
<?php endif; ?>
</div>
<div id="nav-advanced" class="tab-pane fade" role="tabpanel" aria-labelledby="advanced-tab">
<?php
// Date
echo Bootstrap::formInputTextBlock(array(
echo ContentPage::formInputTextBlock($contentType, array(
'name' => 'date',
'label' => $L->g('Date'),
'placeholder' => '',
@ -208,7 +264,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural(
));
// Position
echo Bootstrap::formInputTextBlock(array(
echo ContentPage::formInputTextBlock($contentType, array(
'name' => 'position',
'label' => $L->g('Position'),
'tip' => $L->g('Field used when ordering content by position'),
@ -216,7 +272,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural(
));
// Parent
echo Bootstrap::formSelectBlock(array(
echo ContentPage::formSelectBlock($contentType, array(
'name' => 'parent',
'label' => $L->g('Parent'),
'options' => array(),
@ -263,7 +319,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural(
<?php
// Template
echo Bootstrap::formInputTextBlock(array(
echo ContentPage::formInputTextBlock($contentType, array(
'name' => 'template',
'label' => $L->g('Template'),
'placeholder' => '',
@ -271,7 +327,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural(
'tip' => $L->g('Write a template name to filter the page in the theme and change the style of the page.')
));
echo Bootstrap::formInputTextBlock(array(
echo ContentPage::formInputTextBlock($contentType, array(
'name' => 'externalCoverImage',
'label' => $L->g('External cover image'),
'placeholder' => "https://",
@ -348,7 +404,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural(
<div id="nav-seo" class="tab-pane fade" role="tabpanel" aria-labelledby="seo-tab">
<?php
// Friendly URL
echo Bootstrap::formInputTextBlock(array(
echo ContentPage::formInputTextBlock($contentType, array(
'name' => 'slug',
'tip' => $L->g('URL associated with the content'),
'label' => $L->g('Friendly URL'),
@ -357,7 +413,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural(
));
// Robots
echo Bootstrap::formCheckbox(array(
echo ContentPage::formCheckbox($contentType, array(
'name' => 'noindex',
'label' => 'Robots',
'labelForCheckbox' => $L->g('apply-code-noindex-code-to-this-page'),
@ -367,7 +423,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural(
));
// Robots
echo Bootstrap::formCheckbox(array(
echo ContentPage::formCheckbox($contentType, array(
'name' => 'nofollow',
'label' => '',
'labelForCheckbox' => $L->g('apply-code-nofollow-code-to-this-page'),
@ -377,7 +433,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g("New")." (".$contentType->plural(
));
// Robots
echo Bootstrap::formCheckbox(array(
echo ContentPage::formCheckbox($contentType, array(
'name' => 'noarchive',
'label' => '',
'labelForCheckbox' => $L->g('apply-code-noarchive-code-to-this-page'),
@ -462,6 +518,7 @@ foreach ($customFields as $field => $options) {
// Button Save
$("#jsbuttonSave").on("click", function() {
console.log("uwu")
let actionParameters = '';
var value = "published"

View file

@ -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();

View file

@ -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'=>'🐔'
);

View file

@ -11,6 +11,10 @@ class KoblogUpdater {
global $L;
foreach ($pages->db as $key => $fields) {
if ($fields['kind'] === '') {
$pages->db[$key]['kind'] = 'article';
}
if ($fields['type'] === "published") {
$pages->db[$key]['type'] = "article";
$pages->db[$key]['state'] = "published";
@ -43,11 +47,16 @@ class KoblogUpdater {
//
if (!file_exists(PATH_DATABASES . 'pagetypes.php')) {
$data = array(
'article' => array('name' => $L->g("Article"), 'plural' => $L->g("Articles"), 'icon'=>'file-text'),
'static' => array('name' => $L->g("Static page"), 'plural' => $L->g("Static pages"), 'icon'=>'file'),
'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 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', 'kinds'=>'like bookmark', 'defaultKind'=>'bookmark'),
);
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
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(),
'type' => 'article', // article, static
'state' => 'published', // draft, scheduled, autosave
'kind'=>'',
'sticky' => false,
'date' => '',
'dateModified' => '',
@ -24,6 +25,7 @@ class Pages extends dbJSON
'noindex' => false,
'nofollow' => false,
'noarchive' => false,
'sourceLink'=>'',
'custom' => array()
);

View file

@ -57,5 +57,47 @@ class PageType
{
return $this->getValue("plural");
}
public function canShow($field)
{
$hideFields = $this->getValue("hideFields");
if ($hideFields === '' || !isset($hideFields))
{
return true;
}
return !str_contains($hideFields, $field);
}
public function mustHide($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');
}
}

View file

@ -5,7 +5,10 @@ class PageTypes extends dbJSON {
protected $dbFields = array(
'name'=>'',
'plural'=>'',
'icon'=>'fa-file'
'icon'=>'fa-file',
'hideField'=>'',
'kinds'=>'article',
'defaultKind'=>'article'
);
function __construct()

View file

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

View file

@ -265,6 +265,8 @@
"post": "Article",
"article": "Article",
"articles": "Articles",
"share": "Partage",
"shares": "Partages",
"static-page": "Page statique",
"static-pages": "Pages statiques",
"default": "Défaut",
@ -411,5 +413,7 @@
"insert-thumbnail": "Insérer une miniature",
"insert-linked-thumbnail": "Insérer une miniature liée",
"more-infos": "Infos supplémentaires",
"base-infos": "Infos de bases"
"base-infos": "Infos de bases",
"source-link": "Lien source",
"the-external-link-you-refer-to-in-the-post":"Le lien externe auquel vous vous referrez dans le contenu"
}

View file

@ -469,8 +469,9 @@ function install($adminPassword, $timezone)
file_put_contents(PATH_DATABASES . 'categories.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
$data = array(
'article' => array('name' => $L->g("Article"), 'plural' => $L->g("Articles"), 'icon'=>'fa-file-text'),
'static' => array('name' => $L->g("Static page"), 'plural' => $L->g("Static pages"), 'icon'=>'fa-file'),
'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 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', 'kinds'=>'like bookmark', 'defaultKind'=>'bookmark'),
);
file_put_contents(PATH_DATABASES . 'pagetypes.php', $dataHead . json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);