]> 91.132.146.200 Git - insipid.git/commitdiff
dashboard: view sorted by date and grouped by category
authorBanana <banana@optimus.de>
Sun, 25 Dec 2016 19:50:29 +0000 (20:50 +0100)
committerBanana <banana@optimus.de>
Sun, 25 Dec 2016 19:50:29 +0000 (20:50 +0100)
webroot/lib/management.class.php
webroot/view/home.inc.php
webroot/view/home.php

index c805b01d69454fae18cd92e3bdab8ef98a5c9775..b8ba7e5862e4cc88716fe9bd06ff65d9c2dfa4ac 100644 (file)
@@ -93,6 +93,38 @@ class Management {
         return $ret;
     }
 
+    /**
+     * get all the categories ordered by link added date
+     */
+    public function categoriesByDateAdded() {
+        $ret = array();
+        $queryStr = "SELECT category FROM `".DB_PREFIX."_combined`
+                        WHERE `status` = 2
+                        GROUP BY category
+                        ORDER BY created DESC";
+        $query = $this->DB->query($queryStr);
+        if(!empty($query) && $query->num_rows > 0) {
+            $ret = $query->fetch_all(MYSQLI_ASSOC);
+        }
+
+        return $ret;
+    }
+
+    public function linksByCategoryString($string,$limit=5) {
+        $ret = array();
+
+        $queryStr = "SELECT * FROM `".DB_PREFIX."_combined`
+            WHERE `status` = 2
+                AND `category` = '".$this->DB->real_escape_string($string)."'
+            GROUP BY `hash`
+            ORDER BY `created` DESC";
+        $query = $this->DB->query($queryStr);
+        if(!empty($query) && $query->num_rows > 0) {
+            $ret = $query->fetch_all(MYSQLI_ASSOC);
+        }
+
+        return $ret;
+    }
 }
 
 ?>
\ No newline at end of file
index 3bc26f70b63317aab91d23a7cb5c1dcd6e26fb4d..d6036009027bbe4d0efc961389cb4f7608a060ef 100644 (file)
@@ -170,4 +170,5 @@ if(isset($_POST['data']) && !empty($_POST['data']) && isset($_POST['addnewone'])
 
 $existingCategories = $Management->categories();
 $existingTags = $Management->tags();
-$latestLinks = $Management->latest();
\ No newline at end of file
+$latestLinks = $Management->latest();
+$orderedCategories = $Management->categoriesByDateAdded();
\ No newline at end of file
index 38ce572b4811e7970cd886b30b627120b5a21d44..ed6e41e369e1cd16777c2a0d44549f60b2bf45aa 100644 (file)
 </form>
 <?php } ?>
 
-<div class="row expanded small-up-3 medium-up-6">
-       <div class="column">
-               <div class="card">
+<div class="row expanded small-up-2 medium-up-3 large-up-4" data-equalizer data-equalize-by-row="true">
+       <div class="column" >
+               <div class="card" data-equalizer-watch>
                        <div class="card-divider">
                        <h4>Last added</h4>
                        </div>
                        </div>
                </div>
        </div>
-  <div class="column">
-    <div class="card">
-      <img src="assets/img/generic/rectangle-1.jpg">
-      <div class="card-section">
-        <h4>This is a card.</h4>
-        <p>It has an easy to override visual style, and is appropriately subdued.</p>
-      </div>
-    </div>
-  </div>
-  <div class="column">
-    <div class="card">
-      <img src="assets/img/generic/rectangle-1.jpg">
-      <div class="card-section">
-        <h4>This is a card.</h4>
-        <p>It has an easy to override visual style, and is appropriately subdued.</p>
-      </div>
-    </div>
-  </div>
-  <div class="column">
-    <div class="card">
-      <img src="assets/img/generic/rectangle-1.jpg">
-      <div class="card-section">
-        <h4>This is a card.</h4>
-        <p>It has an easy to override visual style, and is appropriately subdued.</p>
-      </div>
-    </div>
-  </div>
-  <div class="column">
-    <div class="card">
-      <img src="assets/img/generic/rectangle-1.jpg">
-      <div class="card-section">
-        <h4>This is a card.</h4>
-        <p>It has an easy to override visual style, and is appropriately subdued.</p>
-      </div>
-    </div>
-  </div>
-  <div class="column">
-    <div class="card">
-      <img src="assets/img/generic/rectangle-1.jpg">
-      <div class="card-section">
-        <h4>This is a card.</h4>
-        <p>It has an easy to override visual style, and is appropriately subdued.</p>
-      </div>
-    </div>
-  </div>
+<?php
+    if(!empty($orderedCategories)) {
+        foreach ($orderedCategories as $cat) {
+            $links = $Management->linksByCategoryString($cat['category']);
+?>
+       <div class="column">
+               <div class="card" data-equalizer-watch>
+                       <div class="card-divider">
+                               <h4><?php echo $cat['category']; ?></h4>
+                       </div>
+                       <img src="assets/img/generic/rectangle-1.jpg">
+                       <div class="card-section">
+                               <ul>
+<?php foreach ($links as $link) { ?>
+                                       <li>
+                                               <a href="<?php echo $link['link']; ?>" target="_blank"><?php echo $link['title']; ?></a>
+                                       </li>
+<?php } ?>
+                               </ul>
+                               <a class="button" href="#">more</a>
+                       </div>
+               </div>
+       </div>
+<?php
+        }
+    }
+?>
 </div>