From 43f5d781cf54d452c8e935feb0a3af8adef5f4c0 Mon Sep 17 00:00:00 2001 From: Banana Date: Sun, 25 Dec 2016 20:50:29 +0100 Subject: [PATCH] dashboard: view sorted by date and grouped by category --- webroot/lib/management.class.php | 32 +++++++++++++ webroot/view/home.inc.php | 3 +- webroot/view/home.php | 78 ++++++++++++-------------------- 3 files changed, 64 insertions(+), 49 deletions(-) diff --git a/webroot/lib/management.class.php b/webroot/lib/management.class.php index c805b01..b8ba7e5 100644 --- a/webroot/lib/management.class.php +++ b/webroot/lib/management.class.php @@ -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 diff --git a/webroot/view/home.inc.php b/webroot/view/home.inc.php index 3bc26f7..d603600 100644 --- a/webroot/view/home.inc.php +++ b/webroot/view/home.inc.php @@ -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 diff --git a/webroot/view/home.php b/webroot/view/home.php index 38ce572..ed6e41e 100644 --- a/webroot/view/home.php +++ b/webroot/view/home.php @@ -179,9 +179,9 @@ -
-
-
+
+
+

Last added

@@ -200,49 +200,31 @@
-
-
- -
-

This is a card.

-

It has an easy to override visual style, and is appropriately subdued.

-
-
-
-
-
- -
-

This is a card.

-

It has an easy to override visual style, and is appropriately subdued.

-
-
-
-
-
- -
-

This is a card.

-

It has an easy to override visual style, and is appropriately subdued.

-
-
-
-
-
- -
-

This is a card.

-

It has an easy to override visual style, and is appropriately subdued.

-
-
-
-
-
- -
-

This is a card.

-

It has an easy to override visual style, and is appropriately subdued.

-
-
-
+linksByCategoryString($cat['category']); +?> +
+
+
+

+
+ +
+
    + +
  • + +
  • + +
+ more +
+
+
+
-- 2.39.5