Created
November 4, 2013 10:37
-
-
Save wtajak/7300835 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/composition/templater/compositionItemTemplater.class.php b/lib/composition/templater/compositionItemTemplater.class.php | |
index bf2d73e..e371435 100755 | |
--- a/lib/composition/templater/compositionItemTemplater.class.php | |
+++ b/lib/composition/templater/compositionItemTemplater.class.php | |
@@ -11,6 +11,7 @@ class CompositionItemTemplater | |
'type' => 'review', | |
'model' => 'Review', | |
'id' => $item['id'], | |
+ 'date' => $item['reviewed_at'], | |
'product_id' => $item['Product']['id'], | |
'slug' => $item['Product']['slug'], | |
'title' => $item['Product']['name'], | |
@@ -101,6 +102,7 @@ class CompositionItemTemplater | |
'type' => strtolower($item['type']), | |
'model' => 'News', | |
'id' => $item['id'], | |
+ 'date' => $item['display_date'], | |
'slug' => $item['slug'], | |
'title' => $item['title'], | |
'teaser' => $item['teaser_web'], | |
@@ -127,6 +129,7 @@ class CompositionItemTemplater | |
'type' => strtolower($item['type']), | |
'model' => 'News', | |
'id' => $item['id'], | |
+ 'date' => $item['display_date'], | |
'slug' => $item['slug'], | |
'title' => $item['title'], | |
'display_date' => $item['display_date'], | |
@@ -195,6 +198,7 @@ class CompositionItemTemplater | |
'type' => 'round_up', | |
'model' => 'RoundUp', | |
'id' => $item['id'], | |
+ 'date' => $item['display_date'], | |
'slug' => $item['slug'], | |
'title' => $item['headline'], | |
'teaser' => $item['teaser_web'], | |
diff --git a/lib/composition/trIndexPageBroker.php b/lib/composition/trIndexPageBroker.php | |
index e99d2ce..a417c8f 100755 | |
--- a/lib/composition/trIndexPageBroker.php | |
+++ b/lib/composition/trIndexPageBroker.php | |
@@ -95,6 +95,59 @@ class trIndexPageBroker implements IndexPageBrokerInterface | |
return $list; | |
} | |
+ private function getReviews_roundupsListItems(){ | |
+ | |
+ $reviews = $this->getReviewListItems(array(), 5); | |
+ $roundups = $this->getRoundUpListItems(array(), 5); | |
+ | |
+ $items = array_merge($reviews, $roundups); | |
+ | |
+ usort($items, array($this, 'usortByPositionAndDate')); | |
+ | |
+ return $items; | |
+ } | |
+ | |
+ private function getNews_opinionsListItems(){ | |
+ $news = $this->getNewsListItems(array(), 5); | |
+ $opinions = $this->getOpinionListItems(array(), 5); | |
+ | |
+ $items = array_merge($news, $opinions); | |
+ | |
+ usort($items, array($this, 'usortByPositionAndDate')); | |
+ | |
+ return $items; | |
+ } | |
+ | |
+ | |
+ private static function usortByPositionAndDate($a, $b) { | |
+ | |
if (isset($a['static_position']) && isset($b['static_position'])){ | |
+ if ($a['static_position'] == $b['static_position']) { | |
+ return $a['date'] < $b['date']; | |
+ } | |
+ | |
+ return $a['static_position'] - $b['static_position']; | |
+ } | |
+ return $a['date'] < $b['date']; | |
+ } | |
+ | |
+ private function getMixedListItems(){ | |
+ $reviews = $this->getReviewListItems(array(), 5); | |
+ $roundups = $this->getRoundUpListItems(array(), 5); | |
+ $news = $this->getNewsListItems(array(), 5); | |
+ $opinions = $this->getOpinionListItems(array(), 5); | |
+ | |
+ $items = array_merge($reviews, $roundups, $news, $opinions); | |
+ usort($items, array($this, 'usortByDate')); | |
+ | |
+ return $items; | |
+ } | |
+ | |
+ private static function usortByDate($a, $b) { | |
+ return ($a["date"] > $b["date"]) ? 0 : 1; | |
+ } | |
+ | |
+ | |
private function getReviewListItems(array $excludeSlugs, $limit, $productCategorySlug = null) | |
{ | |
$query = Doctrine_Query::create() | |
@@ -369,6 +422,7 @@ class trIndexPageBroker implements IndexPageBrokerInterface | |
$item = array( | |
'id' => $contentPromo['id'], | |
'type' => $contentPromo['content_type'], | |
+ 'date' => $contentPromo['updated_at'], | |
+ } | |
+ | |
+ return $a['static_position'] - $b['static_position']; | |
+ } | |
+ return $a['date'] < $b['date']; | |
+ } | |
+ | |
+ private function getMixedListItems(){ | |
+ $reviews = $this->getReviewListItems(array(), 5); | |
+ $roundups = $this->getRoundUpListItems(array(), 5); | |
+ $news = $this->getNewsListItems(array(), 5); | |
+ $opinions = $this->getOpinionListItems(array(), 5); | |
+ | |
+ $items = array_merge($reviews, $roundups, $news, $opinions); | |
+ usort($items, array($this, 'usortByDate')); | |
+ | |
+ return $items; | |
+ } | |
+ | |
+ private static function usortByDate($a, $b) { | |
+ return ($a["date"] > $b["date"]) ? 0 : 1; | |
+ } | |
+ | |
+ | |
private function getReviewListItems(array $excludeSlugs, $limit, $productCategorySlug = null) | |
{ | |
$query = Doctrine_Query::create() | |
@@ -369,6 +422,7 @@ class trIndexPageBroker implements IndexPageBrokerInterface | |
$item = array( | |
'id' => $contentPromo['id'], | |
'type' => $contentPromo['content_type'], | |
+ 'date' => $contentPromo['updated_at'], | |
'model' => $this->getModelFromContentType($contentPromo['content_type']), | |
'slug' => $contentPromo['content_slug'], | |
'title' => $contentPromo['title'], |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment