From 5a031ab72590f7361d08d936580464d1f1ccd921 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sat, 18 Mar 2023 22:04:55 +0100 Subject: [PATCH] replace `affcount` -> `displaycount` the Page::setaffcount() method is now deprecated It redirect to the new setter --- API.md | 2 +- MANUAL.md | 12 +++---- app/class/Controllerpage.php | 2 +- app/class/Model.php | 2 +- app/class/Page.php | 32 ++++++++++++------- app/class/Servicepostprocess.php | 6 ++-- app/view/templates/home.php | 12 +++---- src/edit.js | 2 +- tests/data/ServicerenderTest/body-test.json | 2 +- .../ServicerenderTest/date-time-test.json | 2 +- tests/data/ServicerenderTest/empty-test.json | 2 +- .../external-links-test.json | 2 +- .../ServicerenderTest/markdown-test-2.json | 4 +-- .../data/ServicerenderTest/markdown-test.json | 4 +-- 14 files changed, 47 insertions(+), 39 deletions(-) diff --git a/API.md b/API.md index 2b8761fa..5dd6d7fc 100644 --- a/API.md +++ b/API.md @@ -55,7 +55,7 @@ Page related api ], "invites": [], "readers": [], - "affcount": 1, + "displaycount": 1, "visitcount": 0, "editcount": 3, "editby": [], diff --git a/MANUAL.md b/MANUAL.md index a45ef57e..5f6f5f1d 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -476,11 +476,11 @@ Will display the number of [edits](#editcount) of the page. ---- - %AFFCOUNT% + %DISPLAYCOUNT% -Will display the number of [affcount](#affcount) of the page. +Will display the number of [display](#displaycount) of the page. - X + X @@ -949,7 +949,7 @@ Each page have a dedicated stylesheet, that can be called by other pages using [ visitcount -Count the number of visitors that opened the page. Unlike [affcount](#affcount), only un-connected users are counted this way. +Count the number of visitors that opened the page. Unlike [displaycount](#displaycount), only un-connected users are counted this way. ##### Editcount @@ -959,11 +959,11 @@ Count the number of visitors that opened the page. Unlike [affcount](#affcount), Count the number of time the page has been edited. Even empty edits are counted. -##### Affcount +##### Displaycount *readonly* - affcount + displaycount Count the number of time the page is opened is opened. diff --git a/app/class/Controllerpage.php b/app/class/Controllerpage.php index 664d8fd9..0db86d96 100644 --- a/app/class/Controllerpage.php +++ b/app/class/Controllerpage.php @@ -163,7 +163,7 @@ public function read($page) if ($canread) { - $this->page->addaffcount(); + $this->page->adddisplaycount(); if ($this->user->isvisitor()) { $this->page->addvisitcount(); } diff --git a/app/class/Model.php b/app/class/Model.php index 466d2471..89faeacd 100644 --- a/app/class/Model.php +++ b/app/class/Model.php @@ -58,7 +58,7 @@ abstract class Model 'authors', 'linkto', 'visitcount', - 'affcount', + 'displaycount', 'editcount' ]; diff --git a/app/class/Page.php b/app/class/Page.php index 9049ebfa..b14f236f 100644 --- a/app/class/Page.php +++ b/app/class/Page.php @@ -39,7 +39,7 @@ class Page extends Item protected $authors; protected $invites; protected $readers; - protected $affcount; + protected $displaycount; protected $visitcount; protected $editcount; protected $editby; @@ -109,9 +109,9 @@ public function reset() $this->setauthors([]); $this->setinvites([]); $this->setreaders([]); - $this->setaffcount(0); $this->setvisitcount(0); $this->seteditcount(0); + $this->setdisplaycount(0); $this->seteditby([]); $this->setsleep(0); $this->setredirection(''); @@ -354,17 +354,17 @@ public function readers($type = 'array') return $this->invites; } - public function affcount($type = 'int') + public function displaycount($type = 'int'): int { - return $this->affcount; + return $this->displaycount; } - public function visitcount($type = 'int') + public function visitcount($type = 'int'): int { return $this->visitcount; } - public function editcount($type = 'int') + public function editcount($type = 'int'): int { return $this->editcount; } @@ -693,12 +693,20 @@ public function setreaders($readers) } } + /** + * @deprecated 2.4.0 Replaced by displaycount + */ public function setaffcount($affcount) { - if (is_int($affcount)) { - $this->affcount = $affcount; - } elseif (is_numeric($affcount)) { - $this->affcount = intval($affcount); + $this->setdisplaycount($affcount); + } + + public function setdisplaycount($displaycount) + { + if (is_int($displaycount)) { + $this->displaycount = $displaycount; + } elseif (is_numeric($displaycount)) { + $this->displaycount = intval($displaycount); } } @@ -774,9 +782,9 @@ public function addeditcount() $this->editcount++; } - public function addaffcount() + public function adddisplaycount() { - $this->affcount++; + $this->displaycount++; } public function addvisitcount() diff --git a/app/class/Servicepostprocess.php b/app/class/Servicepostprocess.php index 3d0a530c..e8068262 100644 --- a/app/class/Servicepostprocess.php +++ b/app/class/Servicepostprocess.php @@ -20,7 +20,7 @@ class Servicepostprocess public const VISIT_COUNT = '%VISITCOUNT%'; public const EDIT_COUNT = '%EDITCOUNT%'; - public const AFF_COUNT = '%AFFCOUNT%'; + public const AFF_COUNT = '%DISPLAYCOUNT%'; public const COUNTERS = [ self::VISIT_COUNT, @@ -68,12 +68,12 @@ private function replace(string $text): string { $visitcount = $this->page->visitcount(); $editcount = $this->page->editcount(); - $affcount = $this->page->affcount(); + $displaycount = $this->page->displaycount(); $replacements = [ self::VISIT_COUNT => "$visitcount", self::EDIT_COUNT => "$editcount", - self::AFF_COUNT => "$affcount", + self::AFF_COUNT => "$displaycount", ]; return strtr($text, $replacements); } diff --git a/app/view/templates/home.php b/app/view/templates/home.php index efca5aa6..45413313 100644 --- a/app/view/templates/home.php +++ b/app/view/templates/home.php @@ -197,10 +197,10 @@ insert('macro_tablesort', ['opt' => $opt, 'th' => 'editcount']) ?> - - aff - insert('macro_tablesort', ['opt' => $opt, 'th' => 'affcount']) ?> + if ($columns['displaycount']) { ?> + + display + insert('macro_tablesort', ['opt' => $opt, 'th' => 'displaycount']) ?> @@ -275,8 +275,8 @@ if ($columns['editcount']) { ?> editcount() ?> - affcount() ?> + if ($columns['displaycount']) { ?> + displaycount() ?> diff --git a/src/edit.js b/src/edit.js index 666d3a8c..13f87ce0 100644 --- a/src/edit.js +++ b/src/edit.js @@ -17,7 +17,7 @@ CodeMirror.defineSimpleMode('wcms', { // detect a Wcms markup then pass to 'wcms' mode start: [ { - regex: /%(?=(HEADER|NAV|ASIDE|MAIN|FOOTER|SUMMARY|LIST|MEDIA|TITLE|DESCRIPTION|DATE|TIME|THUMBNAIL|RSS|AUTHORS|ID|PATH|URL|VISITCOUNT|EDITCOUNT|AFFCOUNT)(\?[^\s]*)?%)/, + regex: /%(?=(HEADER|NAV|ASIDE|MAIN|FOOTER|SUMMARY|LIST|MEDIA|TITLE|DESCRIPTION|DATE|TIME|THUMBNAIL|RSS|AUTHORS|ID|PATH|URL|VISITCOUNT|EDITCOUNT|DISPLAYCOUNT)(\?[^\s]*)?%)/, token: 'wcms', next: 'wcms', }, diff --git a/tests/data/ServicerenderTest/body-test.json b/tests/data/ServicerenderTest/body-test.json index ede25c01..84573f17 100644 --- a/tests/data/ServicerenderTest/body-test.json +++ b/tests/data/ServicerenderTest/body-test.json @@ -38,7 +38,7 @@ ], "invites": [], "readers": [], - "affcount": 16, + "displaycount": 16, "visitcount": 0, "editcount": 48, "editby": [], diff --git a/tests/data/ServicerenderTest/date-time-test.json b/tests/data/ServicerenderTest/date-time-test.json index 52874b2e..98660ebc 100644 --- a/tests/data/ServicerenderTest/date-time-test.json +++ b/tests/data/ServicerenderTest/date-time-test.json @@ -38,7 +38,7 @@ ], "invites": [], "readers": [], - "affcount": 0, + "displaycount": 0, "visitcount": 0, "editcount": 0, "editby": [], diff --git a/tests/data/ServicerenderTest/empty-test.json b/tests/data/ServicerenderTest/empty-test.json index e7dcfb99..e358d3c5 100644 --- a/tests/data/ServicerenderTest/empty-test.json +++ b/tests/data/ServicerenderTest/empty-test.json @@ -38,7 +38,7 @@ ], "invites": [], "readers": [], - "affcount": 0, + "displaycount": 0, "visitcount": 0, "editcount": 0, "editby": [], diff --git a/tests/data/ServicerenderTest/external-links-test.json b/tests/data/ServicerenderTest/external-links-test.json index a73dd30f..d37abe58 100644 --- a/tests/data/ServicerenderTest/external-links-test.json +++ b/tests/data/ServicerenderTest/external-links-test.json @@ -38,7 +38,7 @@ ], "invites": [], "readers": [], - "affcount": 85, + "displaycount": 85, "visitcount": 0, "editcount": 24, "editby": [], diff --git a/tests/data/ServicerenderTest/markdown-test-2.json b/tests/data/ServicerenderTest/markdown-test-2.json index 29e8b63c..de3f35fd 100644 --- a/tests/data/ServicerenderTest/markdown-test-2.json +++ b/tests/data/ServicerenderTest/markdown-test-2.json @@ -38,7 +38,7 @@ ], "invites": [], "readers": [], - "affcount": 2, + "displaycount": 2, "visitcount": 0, "editcount": 1, "editby": [], @@ -46,4 +46,4 @@ "redirection": "", "refresh": 0, "password": null -} \ No newline at end of file +} diff --git a/tests/data/ServicerenderTest/markdown-test.json b/tests/data/ServicerenderTest/markdown-test.json index 76ba91f1..dbd03849 100644 --- a/tests/data/ServicerenderTest/markdown-test.json +++ b/tests/data/ServicerenderTest/markdown-test.json @@ -38,7 +38,7 @@ ], "invites": [], "readers": [], - "affcount": 9, + "displaycount": 9, "visitcount": 0, "editcount": 14, "editby": [], @@ -46,4 +46,4 @@ "redirection": "", "refresh": 0, "password": null -} \ No newline at end of file +}