Skip to content

Commit

Permalink
replace affcount -> displaycount
Browse files Browse the repository at this point in the history
the Page::setaffcount() method is now deprecated
It redirect to the new setter
  • Loading branch information
vincent-peugnet committed Mar 18, 2023
1 parent 76228ce commit 5a031ab
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 39 deletions.
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Page related api
],
"invites": [],
"readers": [],
"affcount": 1,
"displaycount": 1,
"visitcount": 0,
"editcount": 3,
"editby": [],
Expand Down
12 changes: 6 additions & 6 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<span class="counter affcount">X</span>
<span class="counter displaycount">X</span>



Expand Down Expand Up @@ -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

Expand All @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion app/class/Controllerpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function read($page)


if ($canread) {
$this->page->addaffcount();
$this->page->adddisplaycount();
if ($this->user->isvisitor()) {
$this->page->addvisitcount();
}
Expand Down
2 changes: 1 addition & 1 deletion app/class/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ abstract class Model
'authors',
'linkto',
'visitcount',
'affcount',
'displaycount',
'editcount'
];

Expand Down
32 changes: 20 additions & 12 deletions app/class/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Page extends Item
protected $authors;
protected $invites;
protected $readers;
protected $affcount;
protected $displaycount;
protected $visitcount;
protected $editcount;
protected $editby;
Expand Down Expand Up @@ -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('');
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -774,9 +782,9 @@ public function addeditcount()
$this->editcount++;
}

public function addaffcount()
public function adddisplaycount()
{
$this->affcount++;
$this->displaycount++;
}

public function addvisitcount()
Expand Down
6 changes: 3 additions & 3 deletions app/class/Servicepostprocess.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 => "<span class=\"counter visitcount\">$visitcount</span>",
self::EDIT_COUNT => "<span class=\"counter editcount\">$editcount</span>",
self::AFF_COUNT => "<span class=\"counter affcount\">$affcount</span>",
self::AFF_COUNT => "<span class=\"counter displaycount\">$displaycount</span>",
];
return strtr($text, $replacements);
}
Expand Down
12 changes: 6 additions & 6 deletions app/view/templates/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@
<?= $this->insert('macro_tablesort', ['opt' => $opt, 'th' => 'editcount']) ?>
</th>
<?php }
if ($columns['affcount']) { ?>
<th class="affcount">
<a href="<?= $opt->sortbyorder('affcount') ?>">aff</a>
<?= $this->insert('macro_tablesort', ['opt' => $opt, 'th' => 'affcount']) ?>
if ($columns['displaycount']) { ?>
<th class="displaycount">
<a href="<?= $opt->sortbyorder('displaycount') ?>">display</a>
<?= $this->insert('macro_tablesort', ['opt' => $opt, 'th' => 'displaycount']) ?>
</th>
<?php } ?>
</tr>
Expand Down Expand Up @@ -275,8 +275,8 @@
if ($columns['editcount']) { ?>
<td class="editcount"><?= $item->editcount() ?></td>
<?php }
if ($columns['affcount']) { ?>
<td class="affcount"><?= $item->affcount() ?></td>
if ($columns['displaycount']) { ?>
<td class="displaycount"><?= $item->displaycount() ?></td>
<?php } ?>
</tr>

Expand Down
2 changes: 1 addition & 1 deletion src/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
2 changes: 1 addition & 1 deletion tests/data/ServicerenderTest/body-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
],
"invites": [],
"readers": [],
"affcount": 16,
"displaycount": 16,
"visitcount": 0,
"editcount": 48,
"editby": [],
Expand Down
2 changes: 1 addition & 1 deletion tests/data/ServicerenderTest/date-time-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
],
"invites": [],
"readers": [],
"affcount": 0,
"displaycount": 0,
"visitcount": 0,
"editcount": 0,
"editby": [],
Expand Down
2 changes: 1 addition & 1 deletion tests/data/ServicerenderTest/empty-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
],
"invites": [],
"readers": [],
"affcount": 0,
"displaycount": 0,
"visitcount": 0,
"editcount": 0,
"editby": [],
Expand Down
2 changes: 1 addition & 1 deletion tests/data/ServicerenderTest/external-links-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
],
"invites": [],
"readers": [],
"affcount": 85,
"displaycount": 85,
"visitcount": 0,
"editcount": 24,
"editby": [],
Expand Down
4 changes: 2 additions & 2 deletions tests/data/ServicerenderTest/markdown-test-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
],
"invites": [],
"readers": [],
"affcount": 2,
"displaycount": 2,
"visitcount": 0,
"editcount": 1,
"editby": [],
"sleep": 0,
"redirection": "",
"refresh": 0,
"password": null
}
}
4 changes: 2 additions & 2 deletions tests/data/ServicerenderTest/markdown-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
],
"invites": [],
"readers": [],
"affcount": 9,
"displaycount": 9,
"visitcount": 0,
"editcount": 14,
"editby": [],
"sleep": 0,
"redirection": "",
"refresh": 0,
"password": null
}
}

0 comments on commit 5a031ab

Please sign in to comment.