/** * Get all the events between the sync period. * * @param string $google_calendar The name of the google calendar to be used. * @param date $start The start date of sync period. * @param date $end The end date of sync period. * @return object Returns an array with Google_Event objects that belong on the given * sync period (start, end). */ public function get_sync_events($google_calendar, $start, $end) { $this->CI->load->helper('general'); $params = array('timeMin' => date3339($start), 'timeMax' => date3339($end)); return $this->service->events->listEvents($google_calendar, $params); }
/** * Outputs data as a Feed. * * @param int|array $blog_ids The id's of blogs that are going to get outputted, * @param string $feed_type The type of feed we are outputting */ function feed_output($ids, $feed_type) { global $template, $phpbb_root_path, $phpEx, $page, $mode, $limit, $config, $user, $blog_data, $user_id, $blog_id; // Feed explanation page if ($feed_type == 'explain') { $available_feeds = array('RSS 0.91' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'RSS_0.91'))), 'RSS 1.0' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'RSS_1.0'))), 'RSS 2.0' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'RSS_2.0'))), 'ATOM' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'ATOM'))), 'JAVASCRIPT' => array('url' => blog_url(false, false, false, array_merge($_GET, array('feed' => 'JAVASCRIPT'))), 'text' => htmlspecialchars('<script type="text/javascript" src="' . blog_url(false, false, false, array_merge($_GET, array('feed' => 'JAVASCRIPT', 'output' => 'true'))) . '"></script>'), 'demo' => '<script type="text/javascript" src="' . blog_url(false, false, false, array_merge($_GET, array('feed' => 'JAVASCRIPT', 'output' => 'true'))) . '"></script>')); blog_plugins::plugin_do_ref('available_feeds', $available_feeds); $message = '<strong>' . $user->lang['AVAILABLE_FEEDS'] . '</strong><br /><br />'; foreach ($available_feeds as $feed_name => $data) { if (!is_array($data)) { $message .= '<br /><h2><a href="' . $data . '">' . $feed_name . '</a></h2><div><a href="' . $data . '">' . $data . '</a></div><br />'; } else { $message .= '<br /><h2><a href="' . $data['url'] . '">' . $feed_name . '</a></h2><div><dl class="codebox"><dt>' . $user->lang['CODE'] . ': <a href="#" onclick="selectCode(this); return false;">Select all</a></dt><dd><code style="font-size: 12px;">' . $data['text'] . '</code></dd></dl></div><br />'; if (isset($data['demo'])) { $message .= $data['demo']; } } } trigger_error($message); } $title = $feed_type == 'JAVASCRIPT' ? str_replace("'", "\\'", $template->_tpldata['navlinks'][sizeof($template->_tpldata['navlinks']) - 1]['FORUM_NAME']) : $template->_tpldata['navlinks'][sizeof($template->_tpldata['navlinks']) - 1]['FORUM_NAME']; $template->assign_vars(array('FEED' => $feed_type, 'SELF_URL' => blog_url(false, false, false, array('page' => $page, 'mode' => $mode)), 'SELF_FULL_URL' => blog_url(false, false, false, array('page' => $page, 'mode' => $mode, 'feed' => $feed_type, 'limit' => $limit)), 'TITLE' => $config['sitename'] . ' ' . $title . ' ' . $user->lang['FEED'], 'SITE_URL' => generate_board_url(), 'SITE_DESC' => $config['site_desc'], 'SITE_LANG' => $config['default_lang'], 'CURRENT_TIME' => $feed_type == 'ATOM' ? date3339() : date('r'), 'IMG_MIN' => generate_board_url() . '/styles/' . $user->theme['theme_path'] . '/theme/images/blog/min_dark_blue.gif', 'IMG_MAX' => generate_board_url() . '/styles/' . $user->theme['theme_path'] . '/theme/images/blog/max_dark_blue.gif', 'S_OUTPUT' => isset($_GET['output']) ? true : false)); if ($ids !== false) { if (!is_array($ids)) { $ids = array(intval($ids)); } // the items section is only used in RSS 1.0 if ($feed_type == 'RSS_1.0') { if (strpos($mode, 'comments') === false) { // output the URLS for the items section foreach ($ids as $id) { $template->assign_block_vars('items', array('URL' => blog_url(blog_data::$blog[$id]['user_id'], $id))); } } else { // output the URLS for the items section foreach ($ids as $id) { $template->assign_block_vars('items', array('URL' => blog_url(blog_data::$reply[$id]['user_id'], $id))); } } } if (strpos($mode, 'comments') === false) { // Output the main data foreach ($ids as $id) { $blog_row = $blog_data->handle_blog_data($id, true); $row = array('URL' => blog_url(blog_data::$blog[$id]['user_id'], $id), 'USERNAME' => blog_data::$user[blog_data::$blog[$id]['user_id']]['username'], 'MESSAGE' => str_replace("'", ''', $blog_row['MESSAGE']), 'PUB_DATE' => date('r', blog_data::$blog[$id]['blog_time']), 'DATE_3339' => $feed_type == 'ATOM' ? date3339(blog_data::$blog[$id]['blog_time']) : ''); $template->assign_block_vars('item', array_merge($blog_row, $row)); } } else { // Output the main data foreach ($ids as $id) { $reply_row = $blog_data->handle_reply_data($id, true); $row = array('URL' => blog_url(blog_data::$reply[$id]['user_id'], blog_data::$reply[$id]['blog_id'], $id), 'USERNAME' => blog_data::$user[blog_data::$reply[$id]['user_id']]['username'], 'MESSAGE' => str_replace("'", ''', $reply_row['MESSAGE']), 'PUB_DATE' => date('r', blog_data::$reply[$id]['reply_time']), 'DATE_3339' => $feed_type == 'ATOM' ? date3339(blog_data::$reply[$id]['reply_time']) : ''); $template->assign_block_vars('item', array_merge($reply_row, $row)); } } blog_plugins::plugin_do_arg('function_feed_output', compact('ids', 'feed_type', 'mode')); } // Output time if ($feed_type == 'JAVASCRIPT') { header('Content-type: text/html; charset=UTF-8'); } else { header('Content-type: application/xml; charset=UTF-8'); } header('Cache-Control: private, no-cache="set-cookie"'); header('Expires: 0'); header('Pragma: no-cache'); $template->set_template(); $template->set_filenames(array('body' => 'blog/blog_feed.xml')); $template->display('body'); garbage_collection(); exit_handler(); }
function write_atom($data) { $domain = 'robotpony.ca'; $uri = "http://{$domain}/"; $feed = 'feed.xml'; $now = date3339(); $author = 'Bruce Alderson'; $target = './'; $output = <<<XML <feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom"> \t <title>{$domain}</title> \t <subtitle>Latest graphs, charts, diagrams, and other funnies.</subtitle> \t <link href="{$uri}{$feed}" rel="self"/> \t <updated>{$now}</updated> \t <author> \t\t <name>Bruce Alderson</name> \t\t <email>bruce@robotpony.ca</email> \t </author> \t <id>tag:{$domain},2012:{$uri}{$feed}</id> XML; foreach ($data as $row) { // TODO need to fix date (or put into records above) $d = date3339($row->date); $summary = htmlentities(preg_replace("/ src='/", "src='{$uri}", $row->html)); $as = str_replace('//comics', '/comics', "{$uri}{$row->uri}"); $output .= <<<XML \t\t<entry> \t\t\t<title>{$row->title}</title> \t\t\t<updated>{$d}</updated> \t\t\t<id>tag:{$domain},2012:{$as}</id> \t\t\t<link rel="alternate" type="text/html" href="{$as}"/> \t\t\t<link rel="enclosure" type="image/{$row->type}" href="{$as}" /> \t\t\t<link rel="license" type="text/html" href="http://creativecommons.org/licenses/by-nc-sa/2.0/deed.en" /> \t\t\t<author><name>{$author}</name></author> \t\t\t<content type="html">{$summary}</content> \t\t</entry> XML; } $output .= <<<XML </feed> XML; if (!file_put_contents("{$target}/{$feed}", $output)) { throw new Exception("Failed to write RSS to {$target}/{$feed}", 500); } print "Wrote RSS to '{$target}'\n"; }
$date .= 'Z'; } return $date; } # Blank PHP $sourcescraper = 'tmp_dependspace'; $item = scraperwiki::select("* from swdata"); // ATOM published scraperwiki::httpresponseheader("Content-Type", "application/atom+xml"); echo '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL; echo '<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">' . PHP_EOL; echo ' <title>DependSpace v.9 メーカーサイト更新情報、発売日情報サイト</title>' . PHP_EOL; echo ' <subtitle type="text">DependSpace v.9 メーカーサイト更新情報、発売日情報サイト</subtitle>' . PHP_EOL; echo ' <link rel="alternate" type="text/html" href="http://www.nona.dti.ne.jp/d-space/" />' . PHP_EOL; echo ' <link rel="self" type="application/atom+xml" href="https://views.scraperwiki.com/run/dependspace_to_atom_feed_view/" />' . PHP_EOL; echo ' <updated>' . date3339() . '</updated>' . PHP_EOL; echo ' <id>tag:dependspace.net,' . date("Y") . ':' . date("m") . ':' . date("d") . '</id>' . PHP_EOL; echo ' <link rel="start" href="https://views.scraperwiki.com/run/dependspace_to_atom_feed_view/" type="application/rss+xml"/>' . PHP_EOL; foreach ($item as $key => $val) { $val['text'] = htmlspecialchars($val['text'], ENT_QUOTES); echo ' <entry>' . PHP_EOL; echo ' <title>' . $val['text'] . '</title>' . PHP_EOL; echo ' <link rel="alternate" type="text/html" href="' . $val['href'] . '" />' . PHP_EOL; echo ' <id>tag:dependppace.net,' . date("Y") . ':feed/' . $val['id'] . '</id>' . PHP_EOL; echo ' <published>' . $val['date'] . '</published>' . PHP_EOL; echo ' <updated>' . $val['date'] . '</updated>' . PHP_EOL; //echo ' <author><name>hoge</name><email>foo@example.net</email></author>'.PHP_L; echo ' <summary>' . $val['text'] . '</summary>' . PHP_EOL; echo ' <content type="html"><![CDATA[<a href="' . $val['href'] . '">' . $val['text'] . '</a>]]></content>' . PHP_EOL; echo ' </entry>' . PHP_EOL; }
$o[$pl] = $stat[9]; } } } arsort($o); $latest = array_slice($o, 0, 10, true); $mydir = preg_replace('/(.*)\\/.*/', '$1/', $_SERVER['PHP_SELF']); $self = $prot . $_SERVER['HTTP_HOST'] . $mydir; //var_dump( $latest ); try { include 'feed/FeedGenerator.php'; $feeds = new FeedGenerator(); $feeds->setGenerator(new AtomGenerator()); $feeds->setAuthor('Jart'); $feeds->setTitle('New and Updated Jart Playlists'); $feeds->setChanneLink($self); $feeds->setLink($self); $feeds->setDescription('New and Updated Jart Playlists'); $feeds->setID($self); foreach ($latest as $playlist => $pldate) { $shortpl = preg_replace('/.pspl$/', '', $playlist); $name = preg_replace('/.*\\/(.*)/', '$1', $shortpl); $author = preg_replace('|([^/]*)/.*|', '$1', $playlist); $item = new FeedItem("{$self}?pl={$shortpl}", $name, "{$self}?pl={$shortpl}", "<a href=\"{$self}?pl={$shortpl}\">{$name}</a>", date3339($pldate)); $item->author = $author; $feeds->addItem($item); } $feeds->display(); } catch (FeedGeneratorException $e) { echo 'Error: ' . $e->getMessage(); }
/** * Generates XML code * * @param Channel $channel * @return string */ public function generate(Channel $channel) { $this->_channel = $channel; foreach ($this->_channel as $nodeName => $nodeValue) { if (in_array($nodeName, $this->channelDeleted)) { continue; } if ($nodeName == 'link') { if (empty($nodeValue)) { continue; } $tmp = $this->_atomNode->appendChild($this->_dom->createElement($nodeName)); $tmp->setAttribute('href', $nodeValue); continue; } if ($nodeName == 'author') { $tmp = $this->_atomNode->appendChild($this->_dom->createElement('author')); $tmp->appendChild($this->_dom->createElement('name', $nodeValue)); continue; } if (in_array($nodeName, array_keys($this->channelChanged))) { $nodeName = $this->channelChanged[$nodeName]; } if (!empty($nodeValue) or in_array($nodeName, $this->channelRequired)) { $this->_atomNode->appendChild($this->_dom->createElement($nodeName, $nodeValue)); } } $tmp = $this->_atomNode->appendChild($this->_dom->createElement('link')); $tmp->setAttribute('rel', 'self'); $tmp->setAttribute('href', empty($this->_channel->channelLink) ? $this->_channel->id : $this->_channel->channelLink); $tmp->setAttribute('type', 'application/atom+xml'); if (empty($this->_channel->lastBuildDate)) { $this->_atomNode->appendChild($this->_dom->createElement('updated', date3339(time()))); } foreach ($this->_channel->getItems() as $item) { $i = $this->_atomNode->appendChild($this->_dom->createElement('entry')); foreach ($item as $nodeName => $nodeValue) { if ($nodeName == 'link') { if (empty($nodeValue)) { continue; } $tmp = $i->appendChild($this->_dom->createElement($nodeName)); $tmp->setAttribute('href', $nodeValue); continue; } if ($nodeName == 'description') { $tmp = $i->appendChild($this->_dom->createElement('content', htmlspecialchars($nodeValue))); $tmp->setAttribute('type', 'html'); continue; } if (in_array($nodeName, array_keys($this->itemChanged))) { $nodeName = $this->itemChanged[$nodeName]; } if (!empty($nodeValue) or in_array($nodeName, $this->itemRequired)) { $i->appendChild($this->_dom->createElement($nodeName, $nodeValue)); } } if (empty($item->updated)) { $i->appendChild($this->_dom->createElement('updated', date3339(time()))); } } return $this->_dom->saveXML(); }