예제 #1
0
파일: Index.php 프로젝트: andrel/selfoss
 /**
  * load items
  *
  * @return html with items
  */
 private function loadItems($options, $tags)
 {
     $tagColors = $this->convertTagsToAssocArray($tags);
     $itemDao = new \daos\Items();
     $itemsHtml = "";
     foreach ($itemDao->get($options) as $item) {
         // parse tags and assign tag colors
         $itemsTags = explode(",", $item['tags']);
         $item['tags'] = array();
         foreach ($itemsTags as $tag) {
             $tag = trim($tag);
             if (strlen($tag) > 0 && isset($tagColors[$tag])) {
                 $item['tags'][$tag] = $tagColors[$tag];
             }
         }
         $this->view->item = $item;
         $itemsHtml .= $this->view->render('templates/item.phtml');
     }
     if (strlen($itemsHtml) == 0) {
         $itemsHtml = '<div class="stream-empty">' . \F3::get('lang_no_entries') . '</div>';
     } else {
         if ($itemDao->hasMore()) {
             $itemsHtml .= '<div class="stream-more"><span>' . \F3::get('lang_more') . '</span></div>';
         }
         $itemsHtml .= '<div class="mark-these-read"><span>' . \F3::get('lang_markread') . '</span></div>';
     }
     return $itemsHtml;
 }
예제 #2
0
 /**
  * returns items as json string
  * json
  *
  * @return void
  */
 public function listItems()
 {
     // parse params
     $options = array();
     if (count($_GET) > 0) {
         $options = $_GET;
     }
     // get items
     $itemDao = new \daos\Items();
     $items = $itemDao->get($options);
     $this->view->jsonSuccess($items);
 }
예제 #3
0
파일: Rss.php 프로젝트: mm999/selfoss
 /**
  * rss feed
  *
  * @return void
  */
 public function rss()
 {
     $this->needsLoggedInOrPublicMode();
     $feedWriter = new \RSS2FeedWriter();
     $feedWriter->setTitle(\F3::get('rss_title'));
     $feedWriter->setLink($this->view->base);
     // get sources
     $sourceDao = new \daos\Sources();
     $lastSourceId = 0;
     $lastSourceName = "";
     // set options
     $options = array();
     if (count($_GET) > 0) {
         $options = $_GET;
     }
     $options['items'] = \F3::get('rss_max_items');
     if (\F3::get('PARAMS["tag"]') != null) {
         $options['tag'] = \F3::get('PARAMS["tag"]');
     }
     if (\F3::get('PARAMS["type"]') != null) {
         $options['type'] = \F3::get('PARAMS["type"]');
     }
     // get items
     $newestEntryDate = false;
     $lastid = -1;
     $itemDao = new \daos\Items();
     foreach ($itemDao->get($options) as $item) {
         if ($newestEntryDate === false) {
             $newestEntryDate = $item['datetime'];
         }
         $newItem = $feedWriter->createNewItem();
         // get Source Name
         if ($item['source'] != $lastSourceId) {
             foreach ($sourceDao->get() as $source) {
                 if ($source['id'] == $item['source']) {
                     $lastSourceId = $source['id'];
                     $lastSourceName = $source['title'];
                     break;
                 }
             }
         }
         $newItem->setTitle(str_replace('&', '&amp;', $this->UTF8entities($item['title'] . " (" . $lastSourceName . ")")));
         @$newItem->setLink($item['link']);
         $newItem->setDate($item['datetime']);
         $newItem->setDescription(str_replace('&#34;', '"', $item['content']));
         // add tags in category node
         $itemsTags = explode(",", $item['tags']);
         foreach ($itemsTags as $tag) {
             $tag = trim($tag);
             if (strlen($tag) > 0) {
                 $newItem->addElement('category', $tag);
             }
         }
         $feedWriter->addItem($newItem);
         $lastid = $item['id'];
         // mark as read
         if (\F3::get('rss_mark_as_read') == 1 && $lastid != -1) {
             $itemDao->mark($lastid);
         }
     }
     if ($newestEntryDate === false) {
         $newestEntryDate = date(\DATE_ATOM, time());
     }
     $feedWriter->setChannelElement('updated', $newestEntryDate);
     $feedWriter->generateFeed();
 }