Example #1
0
 public function generateFeed()
 {
     $articles = $this->getArticles();
     $feed = Feed::make();
     // set your feed's title, description, link, pubdate and language
     $feed->title = 'cnBeta1';
     $feed->description = '一个干净、现代、开放的cnBeta';
     $feed->logo = 'http://cnbeta1.com/assets/img/cnbeta1.png';
     $feed->link = URL::to('feed');
     $feed->pubdate = $articles[0]['date'];
     $feed->lang = 'zh-cn';
     foreach ($articles as $article) {
         $articleModel = new Article($article['article_id']);
         try {
             $articleModel->load();
         } catch (Exception $ex) {
             Log::error('feed: fail to fetch article: ' . $article['article_id'] . ', error: ' . $ex->getMessage());
         }
         $content = $article['intro'];
         $content .= $articleModel->data['content'] ? $articleModel->data['content'] : '';
         // set item's title, author, url, pubdate, description and content
         $feed->add($article['title'], 'cnBeta1', URL::to($article['article_id']), $article['date'], $content, $content);
     }
     $this->data = $feed->render('atom', -1);
     $this->saveToCache();
 }
Example #2
0
 public function toTimeline()
 {
     $article = new Article($this->article_id);
     $article->load();
     $hot_comment = isset($article->data['hotlist']) && !empty($article->data['hotlist']) ? ' ——“' . $article->data['hotlist'][0]['content'] . '”' : '';
     return '【' . $this->title . '】' . $hot_comment . ' http://cnbeta1.com/' . $this->article_id;
 }
Example #3
0
 public function showArticle($id)
 {
     Debugbar::startMeasure('load data', '载入文章数据');
     $article = new Article($id);
     try {
         $article->load();
     } catch (Exception $ex) {
         return View::make('error/custom', array('error' => $ex->getMessage()));
     }
     Debugbar::stopMeasure('load data');
     Debugbar::startMeasure('render article', '渲染');
     $view = View::make('site/article/view', array('article' => $article->data, 'needRefresh' => $article->needRefresh()));
     Debugbar::stopMeasure('render article');
     return $view;
 }
Example #4
0
<?php

require "/class/class_article.php";
$bdd = new Article();
$bdd->load();
Example #5
0
<?php

require '../class/class_disaster.php';
$article = new Article();
$article->load();
exit;
Example #6
0
 public function getArticleDetail($id)
 {
     $article = new Article($id);
     $article->load();
     return $this->jsonResponse($article->data);
 }
Example #7
0
 public function no_testLoadRelationManyMany()
 {
     $users = array(new User(), new User());
     $qb = $this->getMock('\\SimpleAR\\Orm\\Builder', array('all'));
     $qb->expects($this->once())->method('all')->will($this->returnValue($users));
     Article::setQueryBuilder($qb);
     $article = new Article();
     $article->populate(array('id' => 12));
     // In order to be concrete.
     $article->load('readers');
     $attributes = $article->attributes();
     $this->assertArrayHasKey('readers', $attributes);
     $this->assertEquals($users, $attributes['readers']);
     $relation = Article::relation('readers');
     $reversed = User::relation('readers_r');
     $this->assertInstanceOf('SimpleAR\\Orm\\Relation\\ManyMany', $reversed);
     $this->assertEquals($relation->reverse(), $reversed);
 }