♻️ (pages): separate type and state
This commit is contained in:
parent
23de39ece8
commit
a1456f1cc8
10 changed files with 96 additions and 113 deletions
|
@ -36,11 +36,11 @@ function filterContentOwner($list) {
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
$published = $pages->getList($url->pageNumber(), ITEMS_PER_PAGE_ADMIN);
|
$published = $pages->getList($url->pageNumber(), ITEMS_PER_PAGE_ADMIN);
|
||||||
$drafts = $pages->getDraftDB(true);
|
$drafts = $pages->getDraftDB(['article'], true);
|
||||||
$scheduled = $pages->getScheduledDB(true);
|
$scheduled = $pages->getScheduledDB(['article'],true);
|
||||||
$static = $pages->getStaticDB(true);
|
$static = $pages->getStaticDB(['published'],true);
|
||||||
$sticky = $pages->getStickyDB(true);
|
$sticky = $pages->getStickyDB(['published'],true);
|
||||||
$autosave = $pages->getAutosaveDB(true);
|
$autosave = $pages->getAutosaveDB(['article'],true);
|
||||||
|
|
||||||
// If the user is an Author filter the content he/she can edit
|
// If the user is an Author filter the content he/she can edit
|
||||||
if (checkRole(array('author'), false)) {
|
if (checkRole(array('author'), false)) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ if (checkRole(array('author'), false)) {
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
if ($_POST['type']==='delete') {
|
if ($_POST['state']==='delete') {
|
||||||
if (deletePage($_POST['key'])) {
|
if (deletePage($_POST['key'])) {
|
||||||
Alert::set( $L->g('The changes have been saved') );
|
Alert::set( $L->g('The changes have been saved') );
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ echo Bootstrap::formInputHidden(array(
|
||||||
|
|
||||||
// Type = article, draft, sticky, static
|
// Type = article, draft, sticky, static
|
||||||
echo Bootstrap::formInputHidden(array(
|
echo Bootstrap::formInputHidden(array(
|
||||||
'name' => 'type',
|
'name' => 'state',
|
||||||
'value' => $page->type()
|
'value' => $page->state()
|
||||||
));
|
));
|
||||||
|
|
||||||
// Cover image
|
// Cover image
|
||||||
|
@ -206,7 +206,7 @@ echo Bootstrap::formInputHidden(array(
|
||||||
|
|
||||||
// Type
|
// Type
|
||||||
echo Bootstrap::formSelectBlock(array(
|
echo Bootstrap::formSelectBlock(array(
|
||||||
'name' => 'typeSelector',
|
'name' => 'type',
|
||||||
'label' => $L->g('Type'),
|
'label' => $L->g('Type'),
|
||||||
'selected' => $page->type(),
|
'selected' => $page->type(),
|
||||||
'options' => array(
|
'options' => array(
|
||||||
|
@ -450,7 +450,7 @@ foreach ($customFields as $field => $options) {
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#jsbuttonDeleteAccept").on("click", function() {
|
$("#jsbuttonDeleteAccept").on("click", function() {
|
||||||
$("#jstype").val("delete");
|
$("#jsstate").val("delete");
|
||||||
$("#jscontent").val("");
|
$("#jscontent").val("");
|
||||||
$("#jsform").submit();
|
$("#jsform").submit();
|
||||||
});
|
});
|
||||||
|
@ -498,8 +498,7 @@ foreach ($customFields as $field => $options) {
|
||||||
|
|
||||||
// Button Save
|
// Button Save
|
||||||
$("#jsbuttonSave").on("click", function() {
|
$("#jsbuttonSave").on("click", function() {
|
||||||
var value = $("#jstypeSelector option:selected").val();
|
$("#jsstate").val("published");
|
||||||
$("#jstype").val(value);
|
|
||||||
|
|
||||||
// Get the content
|
// Get the content
|
||||||
$("#jscontent").val(editorGetContent());
|
$("#jscontent").val(editorGetContent());
|
||||||
|
@ -511,7 +510,7 @@ foreach ($customFields as $field => $options) {
|
||||||
// Button Save as draft
|
// Button Save as draft
|
||||||
$("#jsbuttonDraft").on("click", function() {
|
$("#jsbuttonDraft").on("click", function() {
|
||||||
// Set the type as draft
|
// Set the type as draft
|
||||||
$("#jstype").val("draft");
|
$("#jsstate").val("draft");
|
||||||
|
|
||||||
// Get the content
|
// Get the content
|
||||||
$("#jscontent").val(editorGetContent());
|
$("#jscontent").val(editorGetContent());
|
||||||
|
|
|
@ -23,8 +23,8 @@ echo Bootstrap::formInputHidden(array(
|
||||||
|
|
||||||
// Type = article, draft, sticky, static
|
// Type = article, draft, sticky, static
|
||||||
echo Bootstrap::formInputHidden(array(
|
echo Bootstrap::formInputHidden(array(
|
||||||
'name' => 'type',
|
'name' => 'state',
|
||||||
'value' => 'article'
|
'value' => 'published'
|
||||||
));
|
));
|
||||||
|
|
||||||
// Cover image
|
// Cover image
|
||||||
|
@ -187,7 +187,7 @@ echo Bootstrap::formInputHidden(array(
|
||||||
|
|
||||||
// Type
|
// Type
|
||||||
echo Bootstrap::formSelectBlock(array(
|
echo Bootstrap::formSelectBlock(array(
|
||||||
'name' => 'typeSelector',
|
'name' => 'type',
|
||||||
'label' => $L->g('Type'),
|
'label' => $L->g('Type'),
|
||||||
'selected' => '',
|
'selected' => '',
|
||||||
'options' => array(
|
'options' => array(
|
||||||
|
@ -454,8 +454,8 @@ foreach ($customFields as $field => $options) {
|
||||||
$("#jsbuttonSave").on("click", function() {
|
$("#jsbuttonSave").on("click", function() {
|
||||||
let actionParameters = '';
|
let actionParameters = '';
|
||||||
|
|
||||||
var value = $("#jstypeSelector option:selected").val();
|
var value = "published"
|
||||||
$("#jstype").val(value);
|
$("#jsstate").val(value);
|
||||||
actionParameters = '#' + value;
|
actionParameters = '#' + value;
|
||||||
|
|
||||||
// Get the content
|
// Get the content
|
||||||
|
@ -470,7 +470,7 @@ foreach ($customFields as $field => $options) {
|
||||||
$("#jsbuttonDraft").on("click", function() {
|
$("#jsbuttonDraft").on("click", function() {
|
||||||
let actionParameters = '';
|
let actionParameters = '';
|
||||||
|
|
||||||
$("#jstype").val("draft");
|
$("#jsstate").val("draft");
|
||||||
actionParameters = '#draft';
|
actionParameters = '#draft';
|
||||||
|
|
||||||
// Get the content
|
// Get the content
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Archives extends dbList {
|
||||||
$db = $pages->getDB($onlyKeys=false);
|
$db = $pages->getDB($onlyKeys=false);
|
||||||
$archiveIndex = array();
|
$archiveIndex = array();
|
||||||
foreach ($db as $pageKey=>$pageFields) {
|
foreach ($db as $pageKey=>$pageFields) {
|
||||||
if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_TYPES'])) {
|
if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_TYPES']) && $pageFields['state'] == "published") {
|
||||||
$date = $pageFields['date'];
|
$date = $pageFields['date'];
|
||||||
$year = mb_substr($date, 0, 4);
|
$year = mb_substr($date, 0, 4);
|
||||||
$month = mb_substr($date, 0, 7);
|
$month = mb_substr($date, 0, 7);
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Authors extends dbList {
|
||||||
$db = $pages->getDB($onlyKeys=false);
|
$db = $pages->getDB($onlyKeys=false);
|
||||||
$authorsIndex = array();
|
$authorsIndex = array();
|
||||||
foreach ($db as $pageKey=>$pageFields) {
|
foreach ($db as $pageKey=>$pageFields) {
|
||||||
if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_TYPES'])) {
|
if (in_array($pageFields['type'], $GLOBALS['DB_TAGS_TYPES']) && $pageFields['state'] == "published") {
|
||||||
$authorName = $pageFields['username'];
|
$authorName = $pageFields['username'];
|
||||||
if (isset($authorsIndex[$authorName])) {
|
if (isset($authorsIndex[$authorName])) {
|
||||||
array_push($authorsIndex[$authorName]['list'], $pageKey);
|
array_push($authorsIndex[$authorName]['list'], $pageKey);
|
||||||
|
|
|
@ -28,9 +28,10 @@ class Categories extends dbList {
|
||||||
$categoryKey = $pageFields['category'];
|
$categoryKey = $pageFields['category'];
|
||||||
if (isset($this->db[$categoryKey]['list'])) {
|
if (isset($this->db[$categoryKey]['list'])) {
|
||||||
if (
|
if (
|
||||||
($db[$pageKey]['type']=='article') ||
|
(($db[$pageKey]['type']=='article') ||
|
||||||
($db[$pageKey]['type']=='sticky') ||
|
($db[$pageKey]['type']=='sticky') ||
|
||||||
($db[$pageKey]['type']=='static')
|
($db[$pageKey]['type']=='static')) &&
|
||||||
|
($db[$pageKey]['state']=='published')
|
||||||
) {
|
) {
|
||||||
array_push($this->db[$categoryKey]['list'], $pageKey);
|
array_push($this->db[$categoryKey]['list'], $pageKey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,21 @@ class KoblogUpdater {
|
||||||
foreach ($pages->db as $key => $fields) {
|
foreach ($pages->db as $key => $fields) {
|
||||||
if ($fields['type'] === "published") {
|
if ($fields['type'] === "published") {
|
||||||
$pages->db[$key]['type'] = "article";
|
$pages->db[$key]['type'] = "article";
|
||||||
} else {
|
$pages->db[$key]['state'] = "published";
|
||||||
//$pages->db[$key]['sticky'] = false; // Not really important for static
|
} elseif ($fields['type'] === "draft") {
|
||||||
|
$pages->db[$key]['type'] = "article";
|
||||||
|
$pages->db[$key]['state'] = "draft";
|
||||||
|
} elseif ($fields['type'] === "autosave") {
|
||||||
|
$pages->db[$key]['type'] = "article";
|
||||||
|
$pages->db[$key]['state'] = "autosave";
|
||||||
|
} elseif ($fields['type'] === "scheduled") {
|
||||||
|
$pages->db[$key]['type'] = "article";
|
||||||
|
$pages->db[$key]['state'] = "scheduled";
|
||||||
|
}
|
||||||
|
|
||||||
|
// S'il n'y a toujours rien, c'est qu'il est publié
|
||||||
|
if ($pages->db[$key]['state'] === null) {
|
||||||
|
$pages->db[$key]['state'] = "published";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,8 @@ class Pages extends dbJSON
|
||||||
'description' => '',
|
'description' => '',
|
||||||
'username' => '',
|
'username' => '',
|
||||||
'tags' => array(),
|
'tags' => array(),
|
||||||
'type' => 'article', // article, static, draft, sticky, scheduled, autosave
|
'type' => 'article', // article, static, sticky
|
||||||
|
'state' => 'published', // draft, scheduled, autosave
|
||||||
'date' => '',
|
'date' => '',
|
||||||
'dateModified' => '',
|
'dateModified' => '',
|
||||||
'position' => 0,
|
'position' => 0,
|
||||||
|
@ -129,8 +130,8 @@ class Pages extends dbJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
// Schedule page
|
// Schedule page
|
||||||
if (($row['date'] > Date::current(DB_DATE_FORMAT)) && ($row['type'] == 'article')) {
|
if (($row['date'] > Date::current(DB_DATE_FORMAT)) && ($row['state'] == 'published')) {
|
||||||
$row['type'] = 'scheduled';
|
$row['state'] = 'scheduled';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the directory
|
// Create the directory
|
||||||
|
@ -244,9 +245,8 @@ class Pages extends dbJSON
|
||||||
$row['dateModified'] = Date::current(DB_DATE_FORMAT);
|
$row['dateModified'] = Date::current(DB_DATE_FORMAT);
|
||||||
|
|
||||||
// Schedule page
|
// Schedule page
|
||||||
// TODO: will use the state then
|
|
||||||
if (($row['date'] > Date::current(DB_DATE_FORMAT)) && ($row['type'] == 'article')) {
|
if (($row['date'] > Date::current(DB_DATE_FORMAT)) && ($row['type'] == 'article')) {
|
||||||
$row['type'] = 'scheduled';
|
$row['state'] = 'scheduled';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move the directory from old key to new key only if the keys are different
|
// Move the directory from old key to new key only if the keys are different
|
||||||
|
@ -396,14 +396,14 @@ class Pages extends dbJSON
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a database with published articles
|
public function getFilteredDB($types = [], $states = [], $onlyKeys)
|
||||||
// $onlyKeys = true; Returns only the pages keys
|
|
||||||
// $onlyKeys = false; Returns part of the database, I do not recommend use this
|
|
||||||
public function getPublishedDB($onlyKeys = true)
|
|
||||||
{
|
{
|
||||||
$tmp = $this->db;
|
$tmp = $this->db;
|
||||||
foreach ($tmp as $key => $fields) {
|
foreach ($tmp as $key => $fields) {
|
||||||
if ($fields['type'] != 'article') {
|
if (!empty($types) && !in_array($fields['type'], $types)) {
|
||||||
|
unset($tmp[$key]);
|
||||||
|
}
|
||||||
|
if (!empty($states) && !in_array($fields['state'], $states)) {
|
||||||
unset($tmp[$key]);
|
unset($tmp[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -413,16 +413,37 @@ class Pages extends dbJSON
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns a database with published articles
|
||||||
|
// $onlyKeys = true; Returns only the pages keys
|
||||||
|
// $onlyKeys = false; Returns part of the database, I do not recommend use this
|
||||||
|
public function getPublishedDB($types = ['article'], $onlyKeys = true)
|
||||||
|
{
|
||||||
|
return $this->getFilteredDB($types, ['published'], $onlyKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns an array with a list of keys/database of draft pages
|
||||||
|
public function getDraftDB($types = ['article'], $onlyKeys = true)
|
||||||
|
{
|
||||||
|
return $this->getFilteredDB($types, ['draft'], $onlyKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns an array with a list of keys/database of autosave pages
|
||||||
|
public function getAutosaveDB($types = ['article'], $onlyKeys = true)
|
||||||
|
{
|
||||||
|
return $this->getFilteredDB($types, ['autosave'], $onlyKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns an array with a list of keys/database of scheduled pages
|
||||||
|
public function getScheduledDB($types = ['article'], $onlyKeys = true)
|
||||||
|
{
|
||||||
|
return $this->getFilteredDB($types, ['scheduled'], $onlyKeys);
|
||||||
|
}
|
||||||
|
|
||||||
// Returns an array with a list of keys/database of static pages
|
// Returns an array with a list of keys/database of static pages
|
||||||
// By default the static pages are sort by position
|
// By default the static pages are sort by position
|
||||||
public function getStaticDB($onlyKeys = true)
|
public function getStaticDB($states = ['published'], $onlyKeys = true)
|
||||||
{
|
{
|
||||||
$tmp = $this->db;
|
$tmp = $this->getFilteredDB(['static'], $states, false);
|
||||||
foreach ($tmp as $key => $fields) {
|
|
||||||
if ($fields['type'] != 'static') {
|
|
||||||
unset($tmp[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
uasort($tmp, array($this, 'sortByPositionLowToHigh'));
|
uasort($tmp, array($this, 'sortByPositionLowToHigh'));
|
||||||
if ($onlyKeys) {
|
if ($onlyKeys) {
|
||||||
return array_keys($tmp);
|
return array_keys($tmp);
|
||||||
|
@ -430,64 +451,10 @@ class Pages extends dbJSON
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns an array with a list of keys/database of draft pages
|
|
||||||
public function getDraftDB($onlyKeys = true)
|
|
||||||
{
|
|
||||||
$tmp = $this->db;
|
|
||||||
foreach ($tmp as $key => $fields) {
|
|
||||||
if ($fields['type'] != 'draft') {
|
|
||||||
unset($tmp[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($onlyKeys) {
|
|
||||||
return array_keys($tmp);
|
|
||||||
}
|
|
||||||
return $tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns an array with a list of keys/database of autosave pages
|
|
||||||
public function getAutosaveDB($onlyKeys = true)
|
|
||||||
{
|
|
||||||
$tmp = $this->db;
|
|
||||||
foreach ($tmp as $key => $fields) {
|
|
||||||
if ($fields['type'] != 'autosave') {
|
|
||||||
unset($tmp[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($onlyKeys) {
|
|
||||||
return array_keys($tmp);
|
|
||||||
}
|
|
||||||
return $tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns an array with a list of keys/database of scheduled pages
|
|
||||||
public function getScheduledDB($onlyKeys = true)
|
|
||||||
{
|
|
||||||
$tmp = $this->db;
|
|
||||||
foreach ($tmp as $key => $fields) {
|
|
||||||
if ($fields['type'] != 'scheduled') {
|
|
||||||
unset($tmp[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($onlyKeys) {
|
|
||||||
return array_keys($tmp);
|
|
||||||
}
|
|
||||||
return $tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns an array with a list of keys of sticky pages
|
// Returns an array with a list of keys of sticky pages
|
||||||
public function getStickyDB($onlyKeys = true)
|
public function getStickyDB($states = ['published'], $onlyKeys = true)
|
||||||
{
|
{
|
||||||
$tmp = $this->db;
|
return $this->getFilteredDB(['sticky'], $states, $onlyKeys);
|
||||||
foreach ($tmp as $key => $fields) {
|
|
||||||
if ($fields['type'] != 'sticky') {
|
|
||||||
unset($tmp[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($onlyKeys) {
|
|
||||||
return array_keys($tmp);
|
|
||||||
}
|
|
||||||
return $tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the next number of the bigger position
|
// Returns the next number of the bigger position
|
||||||
|
@ -505,13 +472,12 @@ class Pages extends dbJSON
|
||||||
// Returns the next page key of the current page key
|
// Returns the next page key of the current page key
|
||||||
public function nextPageKey($currentKey)
|
public function nextPageKey($currentKey)
|
||||||
{
|
{
|
||||||
if ($this->db[$currentKey]['type'] == 'article') {
|
if ($this->db[$currentKey]['state'] == 'published') {
|
||||||
$keys = array_keys($this->db);
|
$keys = array_keys($this->db);
|
||||||
$position = array_search($currentKey, $keys) - 1;
|
$position = array_search($currentKey, $keys) - 1;
|
||||||
if (isset($keys[$position])) {
|
if (isset($keys[$position])) {
|
||||||
$nextKey = $keys[$position];
|
$nextKey = $keys[$position];
|
||||||
// TODO: make it check pages from the same type instead
|
if ($this->db[$nextKey]['type'] == $this->db[$currentKey]['type']) {
|
||||||
if ($this->db[$nextKey]['type'] == 'article') {
|
|
||||||
return $nextKey;
|
return $nextKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -522,13 +488,12 @@ class Pages extends dbJSON
|
||||||
// Returns the previous page key of the current page key
|
// Returns the previous page key of the current page key
|
||||||
public function previousPageKey($currentKey)
|
public function previousPageKey($currentKey)
|
||||||
{
|
{
|
||||||
if ($this->db[$currentKey]['type'] == 'article') {
|
if ($this->db[$currentKey]['state'] == 'published') {
|
||||||
$keys = array_keys($this->db);
|
$keys = array_keys($this->db);
|
||||||
$position = array_search($currentKey, $keys) + 1;
|
$position = array_search($currentKey, $keys) + 1;
|
||||||
if (isset($keys[$position])) {
|
if (isset($keys[$position])) {
|
||||||
$prevKey = $keys[$position];
|
$prevKey = $keys[$position];
|
||||||
// TODO: make it check pages from the same type instead
|
if ($this->db[$prevKey]['type'] == $this->db[$currentKey]['type']) {
|
||||||
if ($this->db[$prevKey]['type'] == 'article') {
|
|
||||||
return $prevKey;
|
return $prevKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -545,15 +510,15 @@ class Pages extends dbJSON
|
||||||
{
|
{
|
||||||
$list = array();
|
$list = array();
|
||||||
foreach ($this->db as $key => $fields) {
|
foreach ($this->db as $key => $fields) {
|
||||||
if ($published && $fields['type'] == 'article') {
|
if ($published && $fields['type'] == 'article' && $fields['state'] == 'published') {
|
||||||
array_push($list, $key);
|
array_push($list, $key);
|
||||||
} elseif ($static && $fields['type'] == 'static') {
|
} elseif ($static && $fields['type'] == 'static') {
|
||||||
array_push($list, $key);
|
array_push($list, $key);
|
||||||
} elseif ($sticky && $fields['type'] == 'sticky') {
|
} elseif ($sticky && $fields['type'] == 'sticky') {
|
||||||
array_push($list, $key);
|
array_push($list, $key);
|
||||||
} elseif ($draft && $fields['type'] == 'draft') {
|
} elseif ($draft && $fields['state'] == 'draft') {
|
||||||
array_push($list, $key);
|
array_push($list, $key);
|
||||||
} elseif ($scheduled && $fields['type'] == 'scheduled') {
|
} elseif ($scheduled && $fields['state'] == 'scheduled') {
|
||||||
array_push($list, $key);
|
array_push($list, $key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -582,7 +547,7 @@ class Pages extends dbJSON
|
||||||
public function count($onlyPublished = true)
|
public function count($onlyPublished = true)
|
||||||
{
|
{
|
||||||
if ($onlyPublished) {
|
if ($onlyPublished) {
|
||||||
$db = $this->getPublishedDB(false);
|
$db = $this->getPublishedDB(['article'], false);
|
||||||
return count($db);
|
return count($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -360,8 +360,7 @@ class Page
|
||||||
// (boolean) Returns TRUE if the page is published, FALSE otherwise
|
// (boolean) Returns TRUE if the page is published, FALSE otherwise
|
||||||
public function published()
|
public function published()
|
||||||
{
|
{
|
||||||
// TODO: will use then the state
|
return ($this->getValue('state') === 'published');
|
||||||
return ($this->getValue('type') === 'article');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// (boolean) Returns TRUE if the page is an article, FALSE otherwise
|
// (boolean) Returns TRUE if the page is an article, FALSE otherwise
|
||||||
|
@ -373,19 +372,19 @@ class Page
|
||||||
// (boolean) Returns TRUE if the page is scheduled, FALSE otherwise
|
// (boolean) Returns TRUE if the page is scheduled, FALSE otherwise
|
||||||
public function scheduled()
|
public function scheduled()
|
||||||
{
|
{
|
||||||
return ($this->getValue('type') === 'scheduled');
|
return ($this->getValue('state') === 'scheduled');
|
||||||
}
|
}
|
||||||
|
|
||||||
// (boolean) Returns TRUE if the page is draft, FALSE otherwise
|
// (boolean) Returns TRUE if the page is draft, FALSE otherwise
|
||||||
public function draft()
|
public function draft()
|
||||||
{
|
{
|
||||||
return ($this->getValue('type') == 'draft');
|
return ($this->getValue('state') == 'draft');
|
||||||
}
|
}
|
||||||
|
|
||||||
// (boolean) Returns TRUE if the page is autosave, FALSE otherwise
|
// (boolean) Returns TRUE if the page is autosave, FALSE otherwise
|
||||||
public function autosave()
|
public function autosave()
|
||||||
{
|
{
|
||||||
return ($this->getValue('type') == 'autosave');
|
return ($this->getValue('state') == 'autosave');
|
||||||
}
|
}
|
||||||
|
|
||||||
// (boolean) Returns TRUE if the page is sticky, FALSE otherwise
|
// (boolean) Returns TRUE if the page is sticky, FALSE otherwise
|
||||||
|
@ -406,6 +405,12 @@ class Page
|
||||||
return $this->getValue('type');
|
return $this->getValue('type');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// (string) Returns state of the page
|
||||||
|
public function state()
|
||||||
|
{
|
||||||
|
return $this->getValue('state');
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the title field
|
// Returns the title field
|
||||||
public function title()
|
public function title()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue