From 3d4ffd4f7c2948c2a4c885f514a8466dc6b57cbe Mon Sep 17 00:00:00 2001 From: mcherwin Date: Mon, 14 Nov 2016 14:17:19 -0600 Subject: [PATCH 1/2] Add new sortedPostsList array --- .../UnksoLatestPostsDashboardBox.class.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/files/lib/system/dashboard/box/UnksoLatestPostsDashboardBox.class.php b/files/lib/system/dashboard/box/UnksoLatestPostsDashboardBox.class.php index fe0ca6b..228a793 100644 --- a/files/lib/system/dashboard/box/UnksoLatestPostsDashboardBox.class.php +++ b/files/lib/system/dashboard/box/UnksoLatestPostsDashboardBox.class.php @@ -8,10 +8,29 @@ protected function render() { if (!count($this->latestPostsList)) return ''; + $sortedPostsList = array(); + + $today = new DateTime("now"); + $yesterday = new DateTime(); + $yesterday->sub(new DateInterval("P1D")); + + for ($i=0; $ilatestPostsList); $i++) { + $thisPost = $this->latestPostsList[$i]; + + if ($thisPost["date"] > $yesterday) + $sortedPostsList["today"][] = $thisPost; + + else if ($thisPost["date"] == $yesterday) + $sortedPostsList["yesterday"][] = $thisPost; + + else + $sortedPostsList["earlier"][] = $thisPost; + } + WCF::getTPL()->assign(array( - 'latestPostsList' => $this->latestPostsList + 'latestPostsList' => $sortedPostsList )); return WCF::getTPL()->fetch('unksoDashboardBoxLatestPosts', 'wbb'); } -} \ No newline at end of file +} From 2793e2da782311fcee27e70ee69ef84ec392f25d Mon Sep 17 00:00:00 2001 From: mcherwin Date: Mon, 14 Nov 2016 14:20:35 -0600 Subject: [PATCH 2/2] Render new sortedPostsList array --- templates/unksoDashboardBoxLatestPosts.tpl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/templates/unksoDashboardBoxLatestPosts.tpl b/templates/unksoDashboardBoxLatestPosts.tpl index 455d87c..8586f69 100644 --- a/templates/unksoDashboardBoxLatestPosts.tpl +++ b/templates/unksoDashboardBoxLatestPosts.tpl @@ -1,7 +1,17 @@ {hascontent}
    {content} - {include file='threadList' application='wbb' showAnnouncementsSeparately=false objects=$latestPostsList enableEditMode=false} + {include file='threadList' application='wbb' showAnnouncementsSeparately=false objects=$sortedPostsList["today"] enableEditMode=false} {/content}
-{/hascontent} \ No newline at end of file +
    + {content} + {include file='threadList' application='wbb' showAnnouncementsSeparately=false objects=$sortedPostsList["yesterday"] enableEditMode=false} + {/content} +
+
    + {content} + {include file='threadList' application='wbb' showAnnouncementsSeparately=false objects=$sortedPostsList["earlier"] enableEditMode=false} + {/content} +
+{/hascontent}