function load_articles($files) { $articles = array(); foreach ($files as $file) { if (file_exists("news/" . $file)) { $articles[] = NewsArticle::from_file("news/" . $file); } } return $articles; }
public function getManagedModels() { $models = parent::getManagedModels(); if (NewsArticle::config()->get('author_mode') != 'object') { unset($models['NewsAuthor']); } if (!NewsArticle::config()->get('enable_tags')) { unset($models['NewsTag']); } return $models; }
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(); }
/** * 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); } }
$this->title = $title; $this->text = $text; echo 'hello from articles'; } public function view() { echo $this->title; } } class NewsArticle extends Article { private $date; //public function __construct($title, $text) { // parent::__construct($title, $text); // echo 'hello from news'; //} public function setDate($date) { $this->date = $date; } public function getDate() { echo $this->text; } } $a = new NewsArticle('Заголовок новости', 'Тестовый текст'); // $a->title = 'title'; //$a->date = 'some date'; $a->setDate('some date'); $a->getDate();
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; }
public function actionOne() { $id = $_GET['id']; var_dump(NewsArticle::findOne($id)); }
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto"> <link rel="stylesheet" type="text/css" href="styles/common.css"> <?php include "includes/lib/newslib.php"; $article = NewsArticle::from_file("news/" . $_GET['a'] . ".xml"); ?> <title><?php echo $article->title; ?> - ND Faltos</title> </head> <body> <?php include "includes/header.php"; ?> <div class="main"> <br> <?php echo $article->get_image_tag(); ?> <h1 class="nospc"><?php echo $article->title; ?> </h1> <span class="small"><b><?php
/** * Delete an article. * * @param NewsArticle $article * @return bool */ public function deleteArticle(NewsArticle $article) { global $sql_prefix, $sessioninfo; $query = sprintf("DELETE FROM %s_news WHERE ID=%s AND ((global='yes' OR eventID=1) OR eventID=%s)", $sql_prefix, $article->getArticleID(), $sessioninfo->eventID); db_query($query); log_add("news", "rmArticle", "0", "0", $sessioninfo->userID, $sessioninfo->eventID); return true; }
/** * 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; }