예제 #1
0
 public static function daoToFeed($listDAO, $catID = null)
 {
     $list = array();
     if (!is_array($listDAO)) {
         $listDAO = array($listDAO);
     }
     foreach ($listDAO as $key => $dao) {
         if (!isset($dao['name'])) {
             continue;
         }
         if (isset($dao['id'])) {
             $key = $dao['id'];
         }
         if ($catID === null) {
             $category = isset($dao['category']) ? $dao['category'] : 0;
         } else {
             $category = $catID;
         }
         $myFeed = new FreshRSS_Feed(isset($dao['url']) ? $dao['url'] : '', false);
         $myFeed->_category($category);
         $myFeed->_name($dao['name']);
         $myFeed->_website(isset($dao['website']) ? $dao['website'] : '', false);
         $myFeed->_description(isset($dao['description']) ? $dao['description'] : '');
         $myFeed->_lastUpdate(isset($dao['lastupdate']) ? $dao['lastupdate'] : 0);
         $myFeed->_priority(isset($dao['priority']) ? $dao['priority'] : 10);
         $myFeed->_pathEntries(isset($dao['pathentries']) ? $dao['pathentries'] : '');
         $myFeed->_httpAuth(isset($dao['httpauth']) ? base64_decode($dao['httpauth']) : '');
         $myFeed->_error(isset($dao['error']) ? $dao['error'] === 't' ? true : false : 0);
         $myFeed->_keepHistory(isset($dao['keep_history']) ? $dao['keep_history'] : -2);
         $myFeed->_ttl(isset($dao['ttl']) ? $dao['ttl'] : -2);
         $myFeed->_nbNotRead(isset($dao['cache_nbunreads']) ? $dao['cache_nbunreads'] : 0);
         $myFeed->_nbEntries(isset($dao['cache_nbentries']) ? $dao['cache_nbentries'] : 0);
         if (isset($dao['id'])) {
             $myFeed->_id($dao['id']);
         }
         $list[$key] = $myFeed;
     }
     return $list;
 }