]> 91.132.146.200 Git - insipid.git/commitdiff
init of stats
authorBanana <banana@optimus.de>
Tue, 22 Oct 2019 08:36:41 +0000 (10:36 +0200)
committerBanana <banana@optimus.de>
Tue, 22 Oct 2019 08:36:41 +0000 (10:36 +0200)
webroot/lib/management.class.php
webroot/view/stats.inc.php [new file with mode: 0644]
webroot/view/stats.php [new file with mode: 0644]

index 68d5602dfd663c6b9cfe79fe9d35e84bd3c1c432..07ad6c4cf1ef6b327eae093f3ebd10c05ff64880 100644 (file)
@@ -460,6 +460,86 @@ class Management {
                return $ret;
        }
 
+       /**
+        * amount of links in the DB. Status 1 and 2 only
+        * @return int
+        */
+       public function linkAmount() {
+               $ret = 0;
+
+               $queryStr = "SELECT COUNT(*) AS amount FROM `".DB_PREFIX."_link`";
+               if($this->_showPrivate === true) {
+                       $queryStr .= " WHERE `status` IN (2,1)";
+               }
+               else {
+                       $queryStr .= " WHERE `status` = 2";
+               }
+
+               $query = $this->DB->query($queryStr);
+               if(!empty($query) && $query->num_rows > 0) {
+                       $result = $query->fetch_assoc();
+                       $ret = $result['amount'];
+               }
+
+               return $ret;
+       }
+
+
+       /**
+        * amount of tags
+        * @return int
+        */
+       public function tagAmount() {
+               $ret = 0;
+
+               $queryStr = "SELECT COUNT(*) AS amount FROM `".DB_PREFIX."_tag`";
+
+               $query = $this->DB->query($queryStr);
+               if(!empty($query) && $query->num_rows > 0) {
+                       $result = $query->fetch_assoc();
+                       $ret = $result['amount'];
+               }
+
+               return $ret;
+       }
+
+       /**
+        * amount of categories
+        * @return int
+        */
+       public function categoryAmount() {
+               $ret = 0;
+
+               $queryStr = "SELECT COUNT(*) AS amount FROM `".DB_PREFIX."_category`";
+
+               $query = $this->DB->query($queryStr);
+               if(!empty($query) && $query->num_rows > 0) {
+                       $result = $query->fetch_assoc();
+                       $ret = $result['amount'];
+               }
+
+               return $ret;
+       }
+
+       /**
+        * Amount of links need moderation
+        * @return int
+        */
+       public function moderationAmount() {
+               $ret = 0;
+
+               $queryStr = "SELECT COUNT(*) AS amount FROM `".DB_PREFIX."_link`";
+               $queryStr .= " WHERE `status` = 3";
+
+               $query = $this->DB->query($queryStr);
+               if(!empty($query) && $query->num_rows > 0) {
+                       $result = $query->fetch_assoc();
+                       $ret = $result['amount'];
+               }
+
+               return $ret;
+       }
+
        /**
         * for simpler management we have the search data in a separate column
         * it is not fancy or even technical nice but it damn works
diff --git a/webroot/view/stats.inc.php b/webroot/view/stats.inc.php
new file mode 100644 (file)
index 0000000..e72953a
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+/**
+ * Insipid
+ * Personal web-bookmark-system
+ *
+ * Copyright 2016-2019 Johannes Keßler
+ *
+ * Development starting from 2011: Johannes Keßler
+ * https://www.bananas-playground.net/projekt/insipid/
+ *
+ * creator:
+ * Luke Reeves <luke@neuro-tech.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/gpl-3.0.
+ *
+ */
+$_displayEditButton = false;
+if(Summoner::simpleAuthCheck() === true) {
+       $_displayEditButton = true;
+       $moderationAmount = $Management->moderationAmount();
+}
+
+$linkAmount = $Management->linkAmount();
+$tagAmount = $Management->tagAmount();
+$categoryAmount = $Management->categoryAmount();
+
diff --git a/webroot/view/stats.php b/webroot/view/stats.php
new file mode 100644 (file)
index 0000000..dcf7628
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+/**
+ * Insipid
+ * Personal web-bookmark-system
+ *
+ * Copyright 2016-2019 Johannes Keßler
+ *
+ * Development starting from 2011: Johannes Keßler
+ * https://www.bananas-playground.net/projekt/insipid/
+ *
+ * creator:
+ * Luke Reeves <luke@neuro-tech.net>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see http://www.gnu.org/licenses/gpl-3.0.
+ *
+ */
+?>
+<section class="section">
+       <div class="columns">
+               <div class="column">
+                       <p class="has-text-right">
+                               <a href="index.php?p=overview&m=tag" title="all tags" class="button">
+                                       <span class="icon"><i class="ion-md-pricetags"></i></span>
+                               </a>
+                               <a href="index.php?p=overview&m=category" title="all categories" class="button">
+                                       <span class="icon"><i class="ion-md-filing"></i></span>
+                               </a>
+                               <a href="index.php" title="... back to home" class="button">
+                                       <span class="icon"><i class="ion-md-home"></i></span>
+                               </a>
+                       </p>
+               </div>
+       </div>
+
+       <div class="columns">
+               <div class="column">
+                       <h2 class="is-size-2">Stats</h2>
+               </div>
+       </div>
+</section>
+
+<section class="section">
+       <div class="columns">
+               <div class="column">
+                       <h3 class="is-size-3">Links</h3>
+                       <p># of Links: <?php echo $linkAmount; ?></p>
+                       <p><a href="index.php?p=overview&m=all">View all</a></p>
+               </div>
+               <div class="column">
+                       <h3 class="is-size-3">Tags</h3>
+                       <p># of Tags: <?php echo $tagAmount; ?></p>
+                       <p><a href="index.php?p=overview&m=tag">View all</a></p>
+               </div>
+               <div class="column">
+                       <h3 class="is-size-3">Categories</h3>
+                       <p># of Categories: <?php echo $categoryAmount; ?></p>
+                       <p><a href="index.php?p=overview&m=category">View all</a></p>
+               </div>
+               <?php if($_displayEditButton === true) { ?>
+               <div class="column">
+                       <h3 class="is-size-3">Moderation</h3>
+                       <p># Moderation needed: <?php echo $moderationAmount; ?></p>
+               </div>
+               <?php } ?>
+       </div>
+</section>