function generate_inner_html() { $inner_template = NULL; switch ($this->mode) { default: $inner_template = PA::$blockmodule_path . '/' . get_class($this) . '/center_inner_html.tpl'; } if (!empty($this->profile_feeds)) { $counter = 0; foreach ($this->profile_feeds as $data) { $params = array('feed_id' => $data['feed_id']); $ExternalFeed = new ExternalFeed(); try { //Getting the feed data corresponding to the feed id $this->profile_feeds[$counter]['links'] = $ExternalFeed->get_feed_data($params); } catch (PAException $e) { //TODO: pending error handling if function fails. //$error = $e->message; } $counter++; } } $inner_html_gen = new Template($inner_template); $inner_html_gen->set('profile_feeds', @$this->profile_feeds); $inner_html_gen->set('feed_id', $this->feed_id); $inner_html = $inner_html_gen->fetch(); return $inner_html; }
/** * Function : render() * Purpose : Setting vars required for the tpl and return html generated by generate_inner_html() function * @return type string * returns rendered html code */ function render() { // global var $_base_url has been removed - please, use PA::$url static variable $links = array(); if (!empty($this->profile_feeds)) { $counter = 0; foreach ($this->profile_feeds as $data) { $params = array('feed_id' => @$data['feed_id']); $ExternalFeed = new ExternalFeed(); try { //Getting the feed data corresponding to the feed id $this->profile_feeds[$counter]['links'] = $ExternalFeed->get_feed_data($params); } catch (CNException $e) { //TODO: pending error handling if function fails. //$error = $e->message; $this->profile_feeds[$counter]['links'][] = $e->message; // insert error message instead Feed object } $counter++; } } $this->inner_HTML = $this->generate_inner_html(); $content = parent::render(); return $content; }
/** * Internal function to return ExternalFeed object from a row. * @param $row array * @return ExternalFeed */ function &_returnExternalFeedFromRow($row) { $externalFeedPlugin =& PluginRegistry::getPlugin('generic', $this->parentPluginName); $externalFeedPlugin->import('ExternalFeed'); $externalFeed = new ExternalFeed(); $externalFeed->setId($row['feed_id']); $externalFeed->setJournalId($row['journal_id']); $externalFeed->setUrl($row['url']); $externalFeed->setSequence($row['seq']); $externalFeed->setDisplayHomepage($row['display_homepage']); $externalFeed->setDisplayBlock($row['display_block']); $externalFeed->setLimitItems($row['limit_items']); $externalFeed->setRecentItems($row['recent_items']); $this->getDataObjectSettings('external_feed_settings', 'feed_id', $row['feed_id'], $externalFeed); return $externalFeed; }
function render() { global $base_url; $ExternalFeed = new ExternalFeed(); //$user = get_login_user(); //$ExternalFeed->user_id = $user->user_id; //Temporarily displaying the feeds of SUPER USER for all users for demoing //To get the user feed data uncomment the above written two line and comment the line below written line $ExternalFeed->user_id = SUPER_USER_ID; $links = array(); try { $links = $ExternalFeed->get_user_feed_data(); } catch (PAException $e) { //TODO: pending error handling if function fails. //$error = $e->message; } $this->inner_HTML = $this->generate_inner_html($links); $content = parent::render(); return $content; }
/** * Function : render() * Purpose : Setting vars required for the tpl and return html generated by generate_inner_html() function * @return type string * returns rendered html code */ function render() { global $base_url; $links = array(); if (!empty($this->profile_feeds)) { $counter = 0; foreach ($this->profile_feeds as $data) { $params = array('feed_id' => $data['feed_id']); $ExternalFeed = new ExternalFeed(); try { //Getting the feed data corresponding to the feed id $this->profile_feeds[$counter]['links'] = $ExternalFeed->get_feed_data($params); } catch (PAException $e) { //TODO: pending error handling if function fails. //$error = $e->message; } $counter++; } } $this->inner_HTML = $this->generate_inner_html(); $content = parent::render(); return $content; }
/** * Public function to create a new feed for a user. * @param import_url, user_id * @return true on success, on failure will throw an exception */ public function save() { Logger::log("Enter: ExternalFeed::save"); //check for feed, whether it exists in the system or not $sql = 'SELECT feed_id FROM {external_feed} WHERE import_url = ?'; $res = Dal::query($sql, array($this->import_url)); if ($res->numRows()) { //feed url already exists in the system $row = $res->fetchRow(DB_FETCHMODE_OBJECT); $this->feed_id = $row->feed_id; $sql = 'SELECT * FROM {user_feed} WHERE user_id = ? AND feed_id = ?'; $res = Dal::query($sql, array($this->user_id, $this->feed_id)); if ($res->numRows()) { // Import url already exists for given user. Logger::log("Feed url = {$this->import_url} already exists for user_id = {$this->user_id}"); throw new CNException(IMPORT_URL_ALREADY_EXISTS, 'Import URL exists already for user.'); } else { //saving feed for the user $this->save_user_feed(); //refreshing the data for the feed $this->do_refresh = true; $this->refresh_feed_data(); } } else { //This is a new feed and will be added to the existing feeds in the system $this->feed_id = Dal::next_id('ExternalFeed'); $sql = 'INSERT INTO {external_feed} ( feed_id, import_url, max_posts, is_active, feed_type, last_build_date ) VALUES ( ?, ?, ?, ?, ?, ? )'; $data = array($this->feed_id, $this->import_url, $this->max_posts, $this->is_active, $this->feed_type, time()); try { //Inserting the feed to external_feed table $res = Dal::query($sql, $data); } catch (CNException $e) { Logger::log("ExternalFeed::save failed for user_id = {$this->user_id}. Associated sql = {$sql}"); throw $e; } //saving feed for the user $this->save_user_feed(); try { $this->import_posts(); //importing the posts for given feed } catch (CNException $e) { Logger::log("{$e->message}"); ExternalFeed::delete_user_feed($this->feed_id, $this->user_id); // deleting the inserted feed if import_posts fails. throw $e; } } Logger::log("Exit: ExternalFeed::save"); return true; }
if (!empty($item['media_thumbnail'])) { echo $item['media_thumbnail'] . "\n"; //prints xml as well } ?> <pubDate><?php echo $item['pubdate']; ?> </pubDate> </item> <?php } // foreach ?> </channel> </external> <?php } } } // feed calls before anything else if (!OFFSET_PATH && isset($_GET['external'])) { if (!$_GET['external']) { $_GET['external'] = 'gallery'; } // load the theme plugins just incase $_zp_gallery_page = 'rss.php'; $e = new ExternalFeed(sanitize($_GET)); $e->printFeed(); exitZP(); }
/** * Save settings. */ function execute() { $plugin =& $this->plugin; $externalFeedDao = DAORegistry::getDAO('ExternalFeedDAO'); $plugin->import('ExternalFeed'); if (isset($this->feedId)) { $feed =& $externalFeedDao->getExternalFeed($this->feedId); } if (!isset($feed)) { $feed = new ExternalFeed(); } $feed->setJournalId($this->journalId); $feed->setUrl($this->getData('feedUrl')); $feed->setTitle($this->getData('title'), null); $feed->setDisplayHomepage($this->getData('displayHomepage') ? 1 : 0); $feed->setDisplayBlock($this->getData('displayBlock') ? $this->getData('displayBlock') : EXTERNAL_FEED_DISPLAY_BLOCK_NONE); $feed->setLimitItems($this->getData('limitItems') ? 1 : 0); $feed->setRecentItems($this->getData('recentItems') ? $this->getData('recentItems') : 0); // Update or insert external feed if ($feed->getId() != null) { $externalFeedDao->updateExternalFeed($feed); } else { $feed->setSequence(REALLY_BIG_NUMBER); $externalFeedDao->insertExternalFeed($feed); // Re-order the feeds so the new one is at the end of the list. $externalFeedDao->resequenceExternalFeeds($feed->getJournalId()); } }
include_once "web/includes/page.php"; require_once "api/UserProfileFeed/UserProfileFeed.php"; if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { $msg = __("Blog Feed sucessfully deleted."); if (!empty($_REQUEST['feed_url']) && is_object(PA::$login_user)) { try { PA::$login_user->delete_profile_field('blogs_rss', 'blog_feed', (int) $_REQUEST['section_id']); PA::$login_user->delete_profile_field('blogs_rss', 'blog_title', (int) $_REQUEST['section_id']); PA::$login_user->delete_profile_field('blogs_rss', 'blog_url', (int) $_REQUEST['section_id']); $feeds = new UserProfileFeed(); $feeds->user_id = PA::$login_uid; $feeds->set_feed_type(USER_PROFILE_FEED); $feed_data = $feeds->get_user_feeds(); $feed_id = null; foreach ($feed_data as $user_feed) { if ($user_feed->import_url == $_REQUEST['feed_url']) { $feed_id = $user_feed->feed_id; } } if ($feed_id) { $feeds->set_feed_id((int) $feed_id); $feeds->delete_user_feed_data(); ExternalFeed::delete_user_feed($feed_id, PA::$login_uid); ExternalFeed::deleteByID($feed_id); } } catch (Exception $e) { $msg = "Error deleting feed: <pre>" . $e->getMessge() . "</pre>"; } } } echo $msg;
<?php $login_required = true; include '../includes/page.php'; include $path_prefix . '/ext/ExternalFeed/ExternalFeed.php'; $ExternalFeed = new ExternalFeed(); $import_url = 'http://blog.broadbandmechanics.com/feed/'; try { $user = get_login_user(); $ExternalFeed->user_id = SUPER_USER_ID; //$feed_data = $ExternalFeed->get_feed_data(); $ExternalFeed->set_import_url($import_url); $ExternalFeed->save(); //$ExternalFeed->set_feed_id(1); //$ExternalFeed->set_do_refresh(false); //$ExternalFeed->refresh_feed_data(); } catch (PAException $e) { echo $e->message; }