/**
  * This method import a JSON-based feed (Google Reader format).
  *
  * @param array $origin represents a feed.
  * @param boolean $google_compliant takes care of some specific values if true.
  * @return FreshRSS_Feed if feed is in database at the end of the process,
  *         else null.
  */
 private function addFeedJson($origin, $google_compliant)
 {
     $default_cat = $this->catDAO->getDefault();
     $return = null;
     $key = $google_compliant ? 'htmlUrl' : 'feedUrl';
     $url = $origin[$key];
     $name = $origin['title'];
     $website = $origin['htmlUrl'];
     try {
         // Create a Feed object and add it in database.
         $feed = new FreshRSS_Feed($url);
         $feed->_category($default_cat->id());
         $feed->_name($name);
         $feed->_website($website);
         // Call the extension hook
         $feed = Minz_ExtensionManager::callHook('feed_before_insert', $feed);
         if (!is_null($feed)) {
             // addFeedObject checks if feed is already in DB so nothing else to
             // check here.
             $id = $this->feedDAO->addFeedObject($feed);
             if ($id !== false) {
                 $feed->_id($id);
                 $return = $feed;
             }
         }
     } catch (FreshRSS_Feed_Exception $e) {
         Minz_Log::warning($e->getMessage());
     }
     return $return;
 }
예제 #2
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;
 }
예제 #3
0
function getFeed($outline, $cat_id)
{
    $url = (string) $outline['xmlUrl'];
    $url = htmlspecialchars($url, ENT_COMPAT, 'UTF-8');
    $title = '';
    if (isset($outline['text'])) {
        $title = (string) $outline['text'];
    } elseif (isset($outline['title'])) {
        $title = (string) $outline['title'];
    }
    $title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8');
    $feed = new FreshRSS_Feed($url);
    $feed->_category($cat_id);
    $feed->_name($title);
    if (isset($outline['htmlUrl'])) {
        $feed->_website(htmlspecialchars((string) $outline['htmlUrl'], ENT_COMPAT, 'UTF-8'));
    }
    if (isset($outline['description'])) {
        $feed->_description(sanitizeHTML((string) $outline['description']));
    }
    return $feed;
}