From 743c562ac9a8d8df7a176a989ebee36ad2acbfb7 Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Sun, 8 Nov 2020 17:13:51 +0100 Subject: Move article status consts into Article class --- ratatoeskr/backend.php | 2 +- ratatoeskr/frontend.php | 2 +- ratatoeskr/setup/setup.php | 2 +- ratatoeskr/sys/models.php | 25 +++++++++++-------------- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/ratatoeskr/backend.php b/ratatoeskr/backend.php index 597e1d5..23568a1 100644 --- a/ratatoeskr/backend.php +++ b/ratatoeskr/backend.php @@ -379,7 +379,7 @@ function build_backend_subactions() $inputs["date"] = time(); } if (!isset($inputs["article_status"])) { - $inputs["article_status"] = ARTICLE_STATUS_LIVE; + $inputs["article_status"] = Article::STATUS_LIVE; } /* Push data back to template */ diff --git a/ratatoeskr/frontend.php b/ratatoeskr/frontend.php index 0bac1e4..56bb231 100644 --- a/ratatoeskr/frontend.php +++ b/ratatoeskr/frontend.php @@ -169,7 +169,7 @@ function comment_transform_ste($comment) * urlname - (optional) Filter by urlname. * section - (optional) Filter by section (section name). * sectionvar - (optional) Filter by section (Name of variable that contains a section). - * status - (optional) Filter by status (numeric, ). + * status - (optional) Filter by status (numeric, ). * tag - (optional) Filter by tag (tag name). * tagvar - (optional) Filter by tag (Name of variable that contains a tag). * sort - (optional) How to sort. Format: "fieldname direction" where fieldname is one of [id, urlname, title, timestamp] and direction is one of [asc, desc]. diff --git a/ratatoeskr/setup/setup.php b/ratatoeskr/setup/setup.php index d096afd..7fc4bb7 100644 --- a/ratatoeskr/setup/setup.php +++ b/ratatoeskr/setup/setup.php @@ -228,7 +228,7 @@ STYLE; $article->title["en"] = new Translation("Congratulations! You have just installed Ratatöskr!", ""); $article->text["en"] = new Translation("Congratulations! You have just installed Ratatöskr!", "Markdown"); $article->excerpt["en"] = new Translation("Congratulations! You have just installed Ratatöskr!", "Markdown"); - $article->status = ARTICLE_STATUS_LIVE; + $article->status = Article::STATUS_LIVE; $article->timestamp = time(); $article->allow_comments = true; $article->set_section($section); diff --git a/ratatoeskr/sys/models.php b/ratatoeskr/sys/models.php index 74d4419..d51bb1f 100644 --- a/ratatoeskr/sys/models.php +++ b/ratatoeskr/sys/models.php @@ -35,18 +35,6 @@ require_once(dirname(__FILE__) . "/pluginpackage.php"); */ $ratatoeskr_settings = null; -/* - * Constants: ARTICLE_STATUS_ - * Possible
::$status values. - * - * ARTICLE_STATUS_HIDDEN - Article is hidden (Numeric: 0) - * ARTICLE_STATUS_LIVE - Article is visible / live (Numeric: 1) - * ARTICLE_STATUS_STICKY - Article is sticky (Numeric: 2) - */ -define("ARTICLE_STATUS_HIDDEN", 0); -define("ARTICLE_STATUS_LIVE", 1); -define("ARTICLE_STATUS_STICKY", 2); - /* * Class: DoesNotExistError * This Exception is thrown by an ::by_*-constructor or any array-like object if the desired object is not present in the database. @@ -2636,6 +2624,15 @@ class Repository extends BySQLRowEnabled */ class Article extends BySQLRowEnabled { + /** @var int Article is hidden (Numeric: 0) */ + public const STATUS_HIDDEN = 0; + + /** @var int Article is visible / live (Numeric: 1) */ + public const STATUS_LIVE = 1; + + /** @var int Article is sticky (Numeric: 2) */ + public const STATUS_STICKY = 2; + /** @var int */ private $id; @@ -2666,7 +2663,7 @@ class Article extends BySQLRowEnabled /** @var Image|null The article image. If none: null */ public $article_image = null; - /** @var int One of the ARTICLE_STATUS_* constants */ + /** @var int One of the self::STATUS_* constants */ public $status; /** @var int Timestamp */ @@ -2750,7 +2747,7 @@ class Article extends BySQLRowEnabled $obj->meta = ""; $obj->custom = []; $obj->article_image = null; - $obj->status = ARTICLE_STATUS_HIDDEN; + $obj->status = self::STATUS_HIDDEN; $obj->section_id = $ratatoeskr_settings["default_section"]; $obj->timestamp = time(); $obj->allow_comments = $ratatoeskr_settings["allow_comments_default"]; -- cgit v1.2.3-54-g00ecf