From 393709dcf84776c760146722560816172167fe98 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sat, 12 Jan 2019 14:53:41 +0100 Subject: visit counter --- app/class/art2.php | 21 +++++++++++++++++++++ app/class/config.php | 1 - app/class/controllerart.php | 7 ++++++- app/class/modelhome.php | 2 +- app/view/templates/home.php | 10 +++++----- app/view/templates/homeopt.php | 32 ++++++++++++++++++++++++++++++-- app/view/templates/user.php | 16 ++++++++++++++-- 7 files changed, 77 insertions(+), 12 deletions(-) (limited to 'app') diff --git a/app/class/art2.php b/app/class/art2.php index a378bd4..2341ff9 100644 --- a/app/class/art2.php +++ b/app/class/art2.php @@ -37,6 +37,7 @@ class Art2 protected $invites; protected $readers; protected $affcount; + protected $visitcount; protected $editcount; @@ -110,6 +111,7 @@ class Art2 $this->setinvites([]); $this->setreaders([]); $this->setaffcount(0); + $this->setvisitcount(0); $this->seteditcount(0); } @@ -432,6 +434,11 @@ class Art2 return $this->affcount; } + public function visitcount($type = 'int') + { + return $this->visitcount; + } + public function editcount($type = 'int') { return $this->editcount; @@ -739,6 +746,15 @@ class Art2 } } + public function setvisitcount($visitcount) + { + if (is_int($visitcount)) { + $this->visitcount = $visitcount; + } elseif (is_numeric($visitcount)) { + $this->visitcount = intval($visitcount); + } + } + public function seteditcount($editcount) { if (is_int($editcount)) { @@ -762,6 +778,11 @@ class Art2 $this->affcount++; } + public function addvisitcount() + { + $this->visitcount++; + } + public function updateedited() { $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); diff --git a/app/class/config.php b/app/class/config.php index d04c602..06251ca 100644 --- a/app/class/config.php +++ b/app/class/config.php @@ -21,7 +21,6 @@ abstract class Config protected static $defaultprivacy = 0; - // _______________________________________ F U N _______________________________________ diff --git a/app/class/controllerart.php b/app/class/controllerart.php index be86660..00b7558 100644 --- a/app/class/controllerart.php +++ b/app/class/controllerart.php @@ -104,7 +104,12 @@ class Controllerart extends Controller } else { $page = ['head' => $this->art->renderhead(), 'body' => $this->art->renderbody()]; } - $this->art->addaffcount(); + if($canread) { + $this->art->addaffcount(); + if($this->user->level() < 2) { + $this->art->addvisitcount(); + } + } $this->artmanager->update($this->art); } $data = array_merge($alerts, $page, ['art' => $this->art, 'artexist' => $artexist, 'canread' => $canread, 'readernav' => Config::showeditmenu(), 'canedit' => $this->canedit()]); diff --git a/app/class/modelhome.php b/app/class/modelhome.php index 4a2da53..2efdef4 100644 --- a/app/class/modelhome.php +++ b/app/class/modelhome.php @@ -11,7 +11,7 @@ class Modelhome extends Modelart { $opt = new Opt(Art2::classvarlist()); - $opt->setcol(['id', 'tag', 'linkfrom', 'linkto', 'description', 'title', 'datemodif', 'datecreation', 'date', 'secure', 'affcount']); + $opt->setcol(['id', 'tag', 'linkfrom', 'linkto', 'description', 'title', 'datemodif', 'datecreation', 'date', 'secure', 'visitcount']); $opt->settaglist($table); $opt->submit(); diff --git a/app/view/templates/home.php b/app/view/templates/home.php index 6fcb0c8..5860975 100644 --- a/app/view/templates/home.php +++ b/app/view/templates/home.php @@ -22,7 +22,7 @@
- insert('homeopt', ['opt' => $opt]) ?> + insert('homeopt', ['opt' => $opt, 'user' => $user]) ?> @@ -63,12 +63,12 @@ date of creation date privacy - affcount + visit - - + + 👁 @@ -80,7 +80,7 @@ datecreation('hrdi') ?> date('dmy') ?> secure('string') ?> - affcount() ?> + visitcount() ?> diff --git a/app/view/templates/homeopt.php b/app/view/templates/homeopt.php index a37e65b..5dab881 100644 --- a/app/view/templates/homeopt.php +++ b/app/view/templates/homeopt.php @@ -51,9 +51,9 @@ foreach ($opt->taglist() as $tagfilter => $count) { if (in_array($tagfilter, $opt->tagfilter())) { - echo '
  • '; + echo '
  • '; } else { - echo '
  • '; + echo '
  • '; } } if ($in = true || $out = true) { @@ -78,5 +78,33 @@ if ($in = true || $out = true) { +isadmin()) { ?> + + +

    Columns

    + +
    + +
      + +col() as $col) { + ?> +
    • + + +
    • + + +
    + +
    + + +
    diff --git a/app/view/templates/user.php b/app/view/templates/user.php index 957f17f..d97cc31 100644 --- a/app/view/templates/user.php +++ b/app/view/templates/user.php @@ -11,12 +11,22 @@
    -

    User : id() ?>

    -
    +
    + +

    Connexion Options

    + + + + + + +
    + +

    Admin panel

    @@ -88,6 +98,8 @@ foreach ($userlist as $user ) {
    + +
    -- cgit v1.2.3