function simpleProcessFeed($feed = NULL, $target = 'newswire') { $importLog = PATH_SERVER_LOGS . 'import.log'; // for bookmarks // process feed with simple pie require_once PATH_CORE . '/utilities/simplepie.inc'; // Create a new instance of the SimplePie object $sp = new SimplePie(); $sp->set_feed_url($feed->rss); $sp->set_cache_location(PATH_CACHE); $success = $sp->init(); $sp->handle_content_type(); if ($success) { echo '<h2>' . $sp->get_title() . '</h2><br />'; // set up a feedTime as a backup for feeds without dates in them $spTime = time(); $cnt = 0; // count headlines in feed foreach ($sp->get_items() as $item) { $spTime = $spTime - 60 * 15; // go fifteen minutes back for each feed item // clean up brand labels $itemTitle = $item->get_title(); $itemDescription = $item->get_content(); if ($author = $item->get_author()) { $authorName = $author->get_name(); } else { $authorName = ''; } // get the date $itemDate = $item->get_date('Y-m-d H:i:s'); if ($itemDate == '') { $itemDate = date('Y-m-d H:i:s', $spTime); } $itemLink = $item->get_permalink(); // skip open threads if (stristr($itemTitle, 'open thread') === FALSE) { switch ($target) { case 'newswire': $feedItem = $this->nwObj->serialize($itemTitle, $itemDescription, $feed->title, $itemLink, $itemDate, $feed->wireid, $feed->feedType, $feed->id); // load into newswire table $id = $this->nwObj->add($feedItem); // returns false on duplicate if ($id !== false) { echo 'insert ' . $itemTitle . '<br>'; if ($enclosure = $item->get_enclosure()) { // look up thumbnail switch ($spNotes) { default: // look for default image url $mediaUrl = $this->db->safe($enclosure->link); $imageUrl = $this->db->safe($enclosure->get_thumbnail()); $embed = $this->db->safe($enclosure->embed()); print_r($mediaUrl); echo '<br />'; print_r($imageUrl); echo '<br />'; var_dump($embed); echo '<br />'; $this->db->update("Newswire", "imageUrl='{$imageUrl}',mediaUrl='{$mediaUrl}',embed='{$embed}'", "id={$id}"); break; case 'inlineImage': // feeds like Countdown that embed the thumbnail incorrectly $embed = $enclosure->native_embed(); $link = $this->parseLink($embed); $this->db->update("Newswire", "imageUrl='{$link}'", "id={$id}"); break; } } // for new items - check for loadOption switch ($feed->loadOptions) { default: // none - do nothing break; case 'all': // add story to content table $this->loadStory($feedItem, $feed); break; case 'matches': // add story to content table if it matches one of our feeds if ($feed->feedType == 'bookmarks' and ($this->checkMatches($feedItem) or $this->checkKeywords($itemTitle, $itemDescription)) !== false) { $this->db->log('IMPORT:' . $itemTitle, $importLog); $this->loadStory($feedItem, $feed); } else { $this->db->log('No match:' . $itemTitle, $importLog); } break; } } break; case 'FeedMedia': // flickr atom is rss where best image is in content // echo 'title '.$itemTitle.'<br>'; // strip img tags for medium pics from itemDescription // echo 'descrip <pre>'.$itemDescription.'</pre><br>'; $imgList = $this->_parsePageImages($itemDescription); // var_dump($imgList); // echo 'link:'.$itemLink.'<br>'; if ($enclosure = $item->get_enclosure()) { // look up thumbnail switch ($spNotes) { default: // look for default image url $mediaUrl = $this->db->safe($enclosure->link); $imageUrl = $this->db->safe($enclosure->get_thumbnail()); $embed = $this->db->safe($enclosure->embed()); // print_r($mediaUrl); // echo '<br />'; // print_r($imageUrl); // echo '<br />'; // var_dump ($embed); // echo '<br />'; break; case 'inlineImage': // feeds like Countdown that embed the thumbnail incorrectly $embed = $enclosure->native_embed(); $link = $this->parseLink($embed); break; } } switch ($feed->specialType) { case 'flickrContent': $fmTable = new FeedMediaTable($this->db); $m = $fmTable->getRowObject(); $m->title = $itemTitle; $m->author = $authorName; $m->caption = nl2br(strip_tags($itemDescription)); $m->previewImageUrl = $imgList[0]['src']; $m->linkUrl = $itemLink; $m->imageUrl = $mediaUrl; $m->numLikes = 0; $m->numComments = 0; $m->fbId = 0; $m->t = $itemDate; $m->mediaType = 'image'; if (!$fmTable->isDup($m->linkUrl, $m->imageUrl) and $m->imageUrl != '') { switch ($feed->loadOptions) { default: if (!array_search($authorName, $this->authorList) or $authorName == '') { // only use each flickr photographer/author once per fetch $m->insert(); $this->authorList[] = $authorName; } break; case 'all': // load every image from this feed $m->insert(); $this->authorList[] = $authorName; break; } } break; } break; } } $cnt += 1; if ($cnt > 25) { break; } // only do this many headlines } } }
function buildMediaView($id = 0, $media = 'image') { $code = ''; require_once PATH_CORE . '/classes/feed.class.php'; if ($id == 0 or $id == '') { $q = $this->db->queryC("SELECT id FROM FeedMedia ORDER BY id DESC LIMIT 1;"); if (!$q) { $code .= '<p>Invalid media request. Please try again or return to the <a href="?p=home">home page</a>.</p>'; return $code; } else { $d = $this->db->readQ($q); $id = $d->id; } } $mTable = new FeedMediaTable($this->db); $m = $mTable->getRowObject(); $m->load($id); $code .= $this->buildMediaSlider(); $code .= '<h1>' . $m->title . '</h1>'; $code .= '<a href="' . $m->linkUrl . '" target="_blank"><img style="border:1px;max-width:480px;height:auto;margin:10px;" src="' . $m->imageUrl . '"></a>'; /* $code.='<div id="ideaShare" class="'.($showShare?'':'hidden').'">'; $temp='<form requirelogin="******" id="idea_share_form" action="?p=ideas&o=view&id='.$id.'" method="post"><p>To:<br /> <fb:multi-friend-input max="20" /></p><p class="bump10"><input class="btn_1" type="button" value="Send now" onclick="ideaShareSubmit('.$id.');return false;"></p></form>'; $temp ='<div class="panelBar clearfix"><h2>Share this idea with your friends</h2></div><br />' . $temp; $temp = '<div class="panel_2 clearfix">'. $temp . '</div>'; $code.=$temp.'</div><br />';*/ // display the comments to this media image $comTemp = '<div id="mediaComments" >'; $comTemp .= $this->buildCommentThread($id, false); $comTemp .= '</div><br />'; $code .= '<div class="panel_2 clearfix"><div class="panelBar clearfix"><h2>Comments</h2><!-- end panelBar--></div><br />' . $comTemp . '<!-- end panel_2 --></div>'; // display the link to this idea box $code .= $this->fetchLinkBox($m); return $code; }
$manageObj->addColumn("FolderLinks", "notes", "VARCHAR(255) default ''"); $manageObj->addColumn('FolderLinks', 'linkType', "enum ('link','product')"); $manageObj->addColumn('FolderLinks', 'imageUrl', "VARCHAR(255) default '';"); // database updates for alpha v.11 // update newswire table $manageObj->addColumn("Newswire", "feedType", "ENUM ('blog','wire','images','miniblog','bookmarks','allowed','localBlog') default 'wire'"); $manageObj->addColumn("Newswire", "mediaUrl", "VARCHAR(255) default ''"); $manageObj->addColumn("Newswire", "imageUrl", "VARCHAR(255) default ''"); $manageObj->addColumn("Newswire", "embed", "TEXT"); echo 'Completed database initialization<br />'; } if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'feed.class.php')) { // create feed tables require_once PATH_CORE . '/classes/feed.class.php'; FeedsTable::createTable($manageObj); FeedMediaTable::createTable($manageObj); } if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'notifications.class.php')) { // create Notifications and NotificationMessages Tables require_once PATH_CORE . '/classes/notifications.class.php'; NotificationsTable::createTable($manageObj); NotificationMessagesTable::createTable($manageObj); } // Set up some default SystemStatus variables require_once PATH_CORE . '/classes/systemStatus.class.php'; $ssObj = new systemStatus($manageObj->db); $ssObj->setState('cloudid', SITE_CLOUDID); //$ssObj->name=$this->getState('name'); //$ssObj->permalink=$this->getState('permalink'); $ssObj->setState('max_sessions', MAX_SESSIONS_ACTIVE); if ($manageObj->modifyLibrary(PATH_CORE . '/classes/', 'userBlogs.class.php')) {