$vObj = CollectionVersion::get($ct, $cvID); $newsList = new PageList(); $newsList->filterByParentID($cat); $newsList->sortBy('cvDatePublic', 'desc'); $newsPage = $newsList->getPage(); //Start creation Loader::library('3rdparty/feedcreator/include/feedcreator.class', $pkgHandle); //define channel $rss = new UniversalFeedCreator(); $rss->useCached(); $rss->title = SITE . ' - ' . $vObj->cvName; $rss->description = $vObj->cvName . ' updates'; $rss->link = SITE_URL; $rss->syndicationURL = EasyNewsController::getRssPagePath() . '?c=' . $cat; //channel items/entries foreach ($newsPage as $page) { $item = new FeedItem(); $item->title = $page->getCollectionName(); $item->link = BASE_URL . Loader::helper('navigation')->getLinkToCollection($page); $item->description = $page->getCollectionDescription(); $item->source = BASE_URL; $user = UserInfo::getByID($page->getCollectionUserID()); $item->author = $user->getUserName(); $item->date = date('r', strtotime($page->getCollectionDatePublic())); $rss->addItem($item); } //Output //Valid parameters are RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated), // MBOX, OPML, ATOM, ATOM1.0, ATOM0.3, HTML, JS $rss->outputFeed("RSS2.0");
$city = DB::LimitQuery('category', array('condition' => array('zone' => 'city', 'ename' => $ename), 'one' => true)); } $rss = new UniversalFeedCreator(); $rss->useCached(); $rss->title = "{$INI['system']['sitename']} 今日团购"; $rss->description = "{$INI['system']['sitename']} 每天团购一次"; $rss->link = "{$INI['system']['wwwprefix']}"; $rss->syndicationURL = $INI['system']['wwwprefix'] . '/' . $PHP_SELF; $image = new FeedImage(); $image->title = $INI['system']['sitename']; $image->url = "{$INI['system']['imgprefix']}/static/css/i/logo.gif"; $image->link = "{$INI['system']['sitename']}"; $image->description = "Feed provided by zuitu.com"; $rss->image = $image; $team = $teams = index_get_team($city['id']); if ($team['id']) { $teams = array(); $teams[] = $team; } foreach ($teams as $team) { $item = new FeedItem(); $item->title = $team['title']; $item->link = $INI['system']['wwwprefix'] . '/team.php?id=' . $team['id']; $item->description = $team['summary'] . "<br /><img src='" . team_image($team['image']) . "'/>" . $team['systemreview']; $item->date = $team['create_time']; $item->source = $INI['system']['wwwprefix']; $item->author = $city['name']; $rss->addItem($item); } $rss->outputFeed("ATOM2.0");
//If needed, trigger content plugins on the row content. //TODO - expand this to allow for individual paramters for the plugin instances $dispatcher->trigger('onPrepareNinjaRSSFeedRow', array(&$item)); $rss->addItem($item); } //If needed, trigger content plugins on the feed as a whole. //TODO - expand this to allow for individual paramters for the plugin instances $dispatcher->trigger('onPrepareNinjaRSSFeed', array(&$rss)); ob_end_clean(); ob_start(); //If we are using the cache and the time out is greater than 0, then generate and use a file. //Otherwise generate the feed on the fly if (intval($docache) == 1 && $this->cache > 0) { $rss->saveFeed($this->type, $filename, true); } else { $rss->outputFeed($this->type); } function noHTML($words) { $words = preg_replace("'<script[^>]*>.*?</script>'si", "", $words); $words = preg_replace('/<a\\s+.*?href="([^"]+)"[^>]*>([^<]+)<\\/a>/is', '\\2 (\\1)', $words); $words = preg_replace('/<!--.+?-->/', '', $words); //$words = preg_replace('/{.+?}/','',$words); $words = strip_tags($words); $words = preg_replace('/ /', ' ', $words); //$words = preg_replace('/&/','&',$words); //$words = preg_replace('/"/','"',$words); return $words; } function addAbsoluteURL($html) {
if (isset($log[$title])) { $item->title = $log[$title]; } else { $item->title = current($log) . ' - ' . sha1(serialize($log)); } if ($format === 'ATOM') { $item->author = 'PmL'; } $item->link = $link . '&' . $log['pmlo']; $item->guid = $link . '&' . $log['pmlo']; $item->descriptionTruncSize = 500; $item->descriptionHtmlSyndicated = true; $rss->addItem($item); } } $rss->outputFeed($tz, $format); break; case 'CSV': header("Content-Transfer-Encoding: binary"); header("Content-Disposition: attachment;filename=PimpMyLog_" . get_slug($file_id) . "_" . date("Y-m-d-His") . '.csv'); header("Content-type: application/vnd.ms-excel; charset=UTF-16LE"); echo chr(255) . chr(254) . mb_convert_encoding(array2csv($logs['logs']), 'UTF-16LE', 'UTF-8'); break; case 'XML': header('Content-type: application/xml', true); $xml = '<?xml version="1.0" encoding="UTF-8" ?>'; $xml .= '<pml>'; $xml .= generate_xml_from_array($logs, 'log'); $xml .= '</pml>'; echo $xml; break;
the required parameter for enclosure is url, length and type (as in MIME-type) */ <?php include "include/feedcreator.class.php"; //define channel $rss = new UniversalFeedCreator(); $rss->useCached(); $rss->title = "Personal News Site"; $rss->description = "daily news from me"; $rss->link = "http://mydomain.net/"; $rss->syndicationURL = "http://mydomain.net/{$PHP_SELF}"; //channel items/entries $item = new FeedItem(); $item->title = "test berita pertama"; $item->link = "http://mydomain.net/news/somelinks.html"; $item->description = "hahaha aku berjaya!"; $item->source = "http://mydomain.net"; $item->author = "*****@*****.**"; //optional enclosure support $item->enclosure = new EnclosureItem(); $item->enclosure->url = 'http://mydomain.net/news/picture.jpg'; $item->enclosure->length = "65905"; $item->enclosure->type = 'image/jpeg'; $rss->addItem($item); //Valid parameters are RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated), // MBOX, OPML, ATOM, ATOM1.0, ATOM0.3, HTML, JS $rss->outputFeed("ATOM1.0"); //$rss->saveFeed("ATOM1.0", "news/feed.xml");
function decks() { $criteria = $_GET['show']; if (!isset($criteria)) { die("error in receiving feed criteria!"); } $feed_type = $_GET['output']; if (!isset($feed_type)) { $feed_type = "RSS1.0"; } $deckList = new DeckList(); switch ($criteria) { case "new": $title = "SlideWiki -- New Presentations"; $description = "list of new presentations"; $link = "http://slidewiki.org/search/order/date"; $syndicationURL = "http://slidewiki.org/feed/decks/new"; $decks = $deckList->getAllDecks(15); break; case "popular": $title = "SlideWiki -- Popular Presentations"; $description = "list of popular presentations"; $link = "http://slidewiki.org/search/order/popularity"; $syndicationURL = "http://slidewiki.org/feed/decks/popular"; $decks = $deckList->getAllPopular(15); break; case "featured": $title = "SlideWiki -- Featured Presentations"; $description = "list of featured presentations"; $link = "http://slidewiki.org/search/order/featured"; $syndicationURL = "http://slidewiki.org/feed/decks/featured"; $decks = $deckList->getAllFeatured(15); break; } //define channel $rss = new UniversalFeedCreator(); $rss->useCached(); $rss->title = $title; $rss->description = $description; $rss->link = $link; $rss->syndicationURL = $syndicationURL; //channel items/entries foreach ($decks as $deck) { $item = new FeedItem(); $item->title = $deck->title; $item->link = "http://slidewiki.org/deck/" . $deck->id . '_' . $deck->slug_title; $item->description = $deck->abstract; $item->source = "http://slidewiki.org/"; $item->date = strtotime($deck->revisionTime); $item->author = $deck->owner->username; $rss->addItem($item); } //Valid parameters are RSS0.91, RSS1.0, RSS2.0, PIE0.1 (deprecated), // MBOX, OPML, ATOM, ATOM1.0, ATOM0.3, HTML, JS $rss->outputFeed($feed_type); }
header('HTTP/1.0 401 Unauthorized'); exit; } $lang = OC_Preferences::getValue($uid, 'core', 'lang', OC_L10N::findLanguage()); $l = OC_L10N::get('notify', $lang); //TODO: use different feed creator library (like Zend_Feed) and switch html flag to true $notifications = OC_Notify::getNotifications($uid, 50, $lang, false); $baseAddress = (isset($_SERVER["HTTPS"]) ? 'https://' : 'http://') . $_SERVER["SERVER_NAME"]; $rssURI = $baseAddress . $baseuri . 'feed.rss'; $atomURI = $baseAddress . $baseuri . 'feed.atom'; $feed = new UniversalFeedCreator(); $feed->title = $l->t('ownCloud notifications'); $feed->description = $l->t('ownCloud notification stream of the user "%s".', array($uid)); $feed->link = $baseAddress . OC::$WEBROOT; $feed->syndicationURL = $baseAddress . $_SERVER["PHP_SELF"]; $feed->image = new FeedImage(); $feed->image->title = 'ownCloud'; $feed->image->url = $baseAddress . OCP\Util::imagePath('core', 'logo-inverted.png'); $feed->image->link = $feed->link; foreach ($notifications as $notification) { $item = new FeedItem(); $item->title = strip_tags($notification["summary"]); $item->date = strtotime($notification["moment"]); $item->link = OCP\Util::linkToAbsolute("notify", "go.php", array("id" => $notification["id"])); $item->description = $notification["content"]; //TODO image $item->author = "ownCloud (" . $notification["app"] . " app)"; $feed->addItem($item); } $feed->outputFeed($type);
// <link rel="x-stanza-cover-image" type="image/jpeg" href="cover.php?filename=$file"/> $coverLink = new LinkItem(); $coverLink->rel = "x-stanza-cover-image"; $coverLink->type = "image/jpeg"; $coverLink->href = "cover.php?filename={$file}"; $item->addLink($coverLink); $thumbnailLink = new LinkItem(); $thumbnailLink->rel = "x-stanza-cover-image-thumbnail"; $thumbnailLink->type = "image/jpeg"; $thumbnailLink->href = "cover.php?filename={$file}&type=thumb"; $item->addLink($thumbnailLink); // <link rel="x-stanza-cover-image" type="image/jpeg" href="/get/cover/3"/> // <link rel="x-stanza-cover-image-thumbnail" type="image/jpeg" href="/get/thumb/3"/> // if there is no description set it to be the same as the titke if ($ebook->getDcDescription() == "") { $item->description = $item->title; } else { $item->description = strip_tags($ebook->getDcDescription()); } // sometimes DcCreator is an array, so make sure we display in both cases if (is_array($ebook->getDcCreator())) { $item->author = implode(', ', $ebook->getDcCreator()); } else { $item->author = $ebook->getDcCreator(); } $atom->addItem($item); } } // can also saveFeed(format, filename) if we want $atom->outputFeed("ATOM1.0"); closedir($dir);
#!/usr/bin/php <?php $config = ['git_urls' => ['https://github.com/yfix/yf_feedcreator.git' => 'yf_feedcreator/'], 'require_once' => ['yf_feedcreator/feedcreator.class.php'], 'example' => function () { $rss = new UniversalFeedCreator(); $rss->title = 'my title'; $rss->description = 'my desc'; $out = $rss->outputFeed('RSS2.0'); echo $out; }]; if ($return_config) { return $config; } require_once __DIR__ . '/_yf_autoloader.php'; new yf_autoloader($config);
function build_rss($context) { if (is_array($context) && count($context) > 0) { $rss = new UniversalFeedCreator(); if (array_key_exists(CLARO_CONTEXT_COURSE, $context)) { // $rssFilePath .= $context[CLARO_CONTEXT_COURSE] . '.'; $_course = claro_get_course_data($context[CLARO_CONTEXT_COURSE]); $rss->title = '[' . get_conf('siteName') . '] ' . $_course['officialCode']; $rss->description = $_course['name']; $rss->editor = $_course['titular'] == '' ? get_conf('administrator_name') : $_course['titular']; $rss->editorEmail = $_course['email'] == '' ? get_conf('administrator_email') : $_course['email']; $rss->link = get_path('rootWeb') . get_path('coursesRepositoryAppend') . claro_get_course_path(); $rss->generator = 'Feedcreator'; if (array_key_exists(CLARO_CONTEXT_GROUP, $context)) { // $rssFilePath .= 'g'.$context[CLARO_CONTEXT_GROUP] . '.'; $rss->title .= '[' . get_lang('Group') . $context[CLARO_CONTEXT_GROUP] . ']'; $rss->description .= get_lang('Group') . $context[CLARO_CONTEXT_GROUP]; } } else { $rss->title = '[' . get_conf('siteName') . '] ' . $_course['officialCode']; $rss->description = $_course['name']; $rss->editor = get_conf('administrator_name'); $rss->editorEmail = get_conf('administrator_email'); $rss->link = get_path('rootWeb'); } $rss->language = get_locale('iso639_1_code'); $rss->docs = 'http://blogs.law.harvard.edu/tech/rss'; $rss->pubDate = date("r", time()); $toolLabelList = rss_get_tool_compatible_list(); //var_dump($toolLabelList); $rssItems = array(); foreach ($toolLabelList as $toolLabel) { /*var_dump(is_tool_activated_in_course( get_tool_id_from_module_label( $toolLabel ), $context[CLARO_CONTEXT_COURSE] ));*/ if (is_tool_activated_in_course(get_tool_id_from_module_label($toolLabel), $context[CLARO_CONTEXT_COURSE])) { if (!is_module_installed_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE])) { install_module_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE]); } $rssToolLibPath = get_module_path($toolLabel) . '/connector/rss.write.cnr.php'; $rssToolFuncName = $toolLabel . '_write_rss'; if (file_exists($rssToolLibPath)) { include_once $rssToolLibPath; if (function_exists($rssToolFuncName)) { $rssItems = array_merge($rssItems, call_user_func($rssToolFuncName, $context)); } } } } $sortDate = array(); foreach ($rssItems as $key => $rssItem) { $sortDate[$key] = $rssItem['pubDate']; } // die(var_export($sortDate, true)); array_multisort($sortDate, SORT_DESC, $rssItems); foreach ($rssItems as $rssItem) { $item = new FeedItem(); $item->title = claro_utf8_encode($rssItem['title'], get_conf('charset')); $item->description = claro_utf8_encode($rssItem['description']); $item->category = $rssItem['category']; $item->guid = $rssItem['guid']; $item->link = $rssItem['link']; $item->date = $rssItem['pubDate']; $rss->addItem($item); } return $rss->outputFeed("RSS2.0"); } return false; }