public function getArticleList($tag = null, $year = null, $month = null)
 {
     $list = NewsArticle::get()->filter('ParentID', $this->ID);
     // filter by tag?
     if ($tag) {
         $list = $list->filter('Tags.ID:exactMatch', $tag);
     }
     // filter buy date range?
     $year = (int) $year;
     $month = (int) $month;
     if ($year && $month) {
         $beginDate = "{$year}-{$month}-01 00:00:00";
         $endDate = date('Y-m-d H:i:s', strtotime("{$year}-{$month}-1 00:00:00 +1 month"));
         $list = $list->where("(\"NewsArticle\".\"PublishDate\">='{$beginDate}' AND \"NewsArticle\".\"PublishDate\"<'{$endDate}')");
     } elseif ($year) {
         $beginDate = "{$year}-01-01 00:00:00";
         $endDate = "{$year}-12-31 23:59:59";
         $list = $list->where("(\"NewsArticle\".\"PublishDate\">='{$beginDate}' AND \"NewsArticle\".\"PublishDate\"<'{$endDate}')");
     }
     return $list;
 }
 public function rss()
 {
     $SiteConfig = SiteConfig::current_site_config();
     $rss = new RSSFeed(NewsArticle::get(), $this->Link(), $SiteConfig->Title);
     return $rss->outputToBrowser();
 }
예제 #3
0
 /**
  * RelatedArticles
  * Returns a list of articles that share the same tags as this one
  * @param Int $limit
  * @return String
  **/
 public function RelatedArticles($limit = null)
 {
     $tagIDs = $this->Tags()->column('ID');
     if (count($tagIDs)) {
         return NewsArticle::get()->filter("Tags.ID:exactMatch", $tagIDs)->exclude('ID', $this->ID);
     }
 }
예제 #4
0
 function Rss()
 {
     $parent = $this->data()->ID;
     $objects = NewsArticle::get()->filter('ParentID', $parent)->sort('LastEdited DESC')->limit(10);
     $rss = new RSSFeed($objects, $this->data()->Link(), _t('News.RSSTITLE', "10 most recent news"), "", "Title", "Content");
     $this->response->addHeader('Content-Type', 'application/rss+xml');
     return $rss->outputToBrowser();
 }
 function PaginatedPages()
 {
     $list = new PaginatedList(NewsArticle::get()->filter("ParentID", $this->ID), $this->request);
     $list->setPageLength(10);
     return $list;
 }
 /**
  * We do not want to use NewsHolder->SubSections because this splits the paginations into
  * the categories the articles are in which means the pagination will not work or will display
  * multiple times
  *
  * @return Array
  */
 public function TotalChildArticles($number = null)
 {
     if (!$number) {
         $number = $this->numberToDisplay;
     }
     $start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
     if ($start < 0) {
         $start = 0;
     }
     $articles = NewsArticle::get('NewsArticle', '', '"OriginalPublishedDate" DESC, "ID" DESC', '', $start . ',' . $number)->filter(array('ID' => $this->getDescendantIDList()));
     $entries = PaginatedList::create($articles);
     $entries->setPaginationFromQuery($articles->dataQuery()->query());
     return $entries;
 }