Ejemplo n.º 1
0
 /**
  * Action to get only single feed html
  * @param int feed_id
  * will be used in ajax requests to get the recently added field
  */
 public function action_feed()
 {
     $feed_id = $this->request->param('feed_id');
     $feed = ORM::factory('feed', $feed_id);
     $feeds = array();
     $feeds[$feed->id] = Feed::factory($feed->type, $feed->id)->render();
     $view = View::factory('feed/feeds')->bind('feeds', $feeds);
     $this->content = $view;
 }
Ejemplo n.º 2
0
 protected function countFeeds()
 {
     return Feed::factory()->count();
 }
Ejemplo n.º 3
0
 /**
  * Search linked entries
  * @route /discussion
  * @args url={url}
  */
 public function discussion($arguments)
 {
     if (isset($arguments['url']) && !empty($arguments['url'])) {
         $search_method = 'strict';
         $url = trim($arguments['url']);
         $entries = Feed::factory()->select_expr('feeds.id AS feed_id, feeds.url AS feed_url, feeds.link AS feed_link, feeds.title AS feed_title')->select_expr('entries.id, date, permalink, entries.title, content, categories')->join('entries', array('entries.feed_id', '=', 'feeds.id'))->order_by_desc('date');
         if ($search_method == 'strict') {
             $entries->where('entries.permalink', $url);
         } else {
             if ($search_method == 'large') {
                 // TODO: à réfléchir...
                 $url = trim($url, '/') . '%';
                 $entries->where_like('entries.permalink', $url);
             }
         }
         $entries = $entries->findArray();
         if ($entries != null) {
             foreach ($entries as &$entry) {
                 $entry['feed']['id'] = $entry['feed_id'];
                 $entry['feed']['url'] = $entry['feed_url'];
                 $entry['feed']['link'] = $entry['feed_link'];
                 $entry['feed']['title'] = $entry['feed_title'];
                 unset($entry['feed_id'], $entry['feed_url'], $entry['feed_link'], $entry['feed_title']);
             }
         }
         return $entries;
     } else {
         throw new ShaarliApiException('Need url (?url=url)');
     }
 }