Exemplo n.º 1
0
 /**
  * It gives the rss feed of contents of given ids.
  *
  * @param $content_id array The content ids of the contents for getting RssFeed
  * @return $generated_rss_feed string This string contains the content of RssFeed file
  */
 public static function get_feed_for_content($content_ids)
 {
     Logger::log("Enter: Content::get_feed_for_content()");
     $sql = "SELECT * FROM {contents} WHERE content_id IN (" . $content_ids[0];
     for ($i = 1; $i < count($content_ids); $i++) {
         $sql .= ", " . $content_ids[$i];
     }
     $sql .= ")";
     $data = array();
     $res = Dal::query($sql, $data);
     $new_rss = new RssFeedHelper();
     $generated_rss_feed = $new_rss->get_rss_feed($res);
     Logger::log("Exit: Content::get_feed_for_content()");
     return $generated_rss_feed;
 }
 /**
  *  Add a new item to rss_helper object.
  *
  * @param $content_collection_id string The id of the content collection for which Rssfeed is Generated
  * @param $no_of_items string The No of latest items for which Rssfeed is Generated
  * @return $generated_rss_feed string This string contains the content of RssFeed file
  */
 public static function get_feed_for_content_collection($collection_id, $no_of_items = 10)
 {
     Logger::log("Enter: ContentCollection::get__feed_for_content_collection()");
     if (!$collection_id) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: Required variable not specified", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, "Required variable not specified");
     }
     //Query for selecting all items from table cotents for generation of RssFeed
     $sql = 'SELECT C.content_id AS content_id, C.author_id AS author_id, C.type AS type, C.body AS body, C.created AS created, C.changed AS changed, C.collection_id AS ccid FROM {contents} AS C WHERE C.collection_id = ? ORDER BY C.created DESC LIMIT ?';
     $data = array($collection_id, $no_of_items);
     $res = Dal::query($sql, $data);
     // Collecting all $no_of_items rows in an array $row
     while ($row[] = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
     }
     $new_rss = new RssFeedHelper();
     $generated_rss_feed = $new_rss->generate_rss($row);
     Logger::log("Exit: ContentCollection::get__feed_for_content_collection()");
     return $generated_rss_feed;
 }
Exemplo n.º 3
0
 /**
  *  This method is called by all rss feed generator method (common to all methods) using generate_rss method
  *
  * @param $res string The user id of the user for getting RssFeed of the content. FIXME: from the code, it looks like this has to be a DB result object (returned from Dal::query).
  * @return $result string This string contains the content of RssFeed file
  */
 public function get_rss_feed($res, $user_id = 0)
 {
     // Collecting all $no_of_items rows in an array $row
     while ($row[] = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
     }
     $result = RssFeedHelper::generate_rss($row, (int) $user_id);
     return $result;
 }
Exemplo n.º 4
0
 /**
  *  get rss feed of blogs for a user.
  *
  * @param $user_id string The user id of the user for getting RssFeed of the blogpost
  * @param $no_of_items string The No of latest items for which Rssfeed is Generated
  * @return $generated_rss_feed string This string contains the content of RssFeed file
  */
 public static function get_feed_for_user($user_id, $no_of_items = 10)
 {
     global $TB_CONTENTS;
     Logger::log("Enter: BlogPost::get_feed_for_user()");
     // Check if user id given
     if (!$user_id) {
         Logger::log(" Throwing exception REQUIRED_PARAMETERS_MISSING | Message: Required variable not specified", LOGGER_ERROR);
         throw new PAException(REQUIRED_PARAMETERS_MISSING, "Required variable not specified");
     }
     //Query for selecting all title, description from table cotents for generation of RssFeed
     $sql = "SELECT * FROM {contents} WHERE author_id = ? AND type = 1 AND is_active = 1 ORDER BY changed DESC LIMIT ?";
     $data = array($user_id, $no_of_items);
     $res = Dal::query($sql, $data);
     $new_rss = new RssFeedHelper();
     $generated_rss_feed = $new_rss->get_rss_feed($res, $user_id);
     Logger::log("Exit: BlogPost::get_feed_for_user()");
     return $generated_rss_feed;
 }