public static function get_parser($data, $url = false, $debug = false) { libxml_use_internal_errors(true); $data = trim($data); $xml = @simplexml_load_string($data, null, LIBXML_DTDLOAD); if (!$xml) { if ($debug) { echo "******** RSS PARSING ERROR: XML could not be loaded ********\n"; foreach (libxml_get_errors() as $error) { printf("Error %d on line %d, column %d, level %d\n %s", $error->code, $error->line, $error->column, $error->level, $error->message); } } return false; } if ($xml->getName() == "feed") { $rss = new Atom($xml, $debug); $rss->set_url($url); return $rss; } if ($xml->getName() == "rss") { if ($xml['version'] == "2.0") { $rss = new Rss20($xml, $debug); $rss->set_url($url); return $rss; } } if ($debug) { printf("******** RSS PARSING ERROR: %s/%s ********\n", $xml->getName(), $xml['version']); } return false; }
public static function getAllAtomObjects($concept) { foreach (Concept::getAllAtomIds($concept) as $tgtAtomId) { $tgtAtom = new Atom($tgtAtomId, $concept); $arr[] = $tgtAtom->getAtom(); } return $arr; }
public static function getAllSessionRoles() { $sessionRoleLabels = array(); $sessionRoles = array(); $interface = new InterfaceObject('SessionRoles'); $session = new Atom(session_id(), 'SESSION'); $sessionRoleLabels = array_keys((array) $session->getContent($interface, true)); foreach (Role::getAllRoleObjects() as $role) { if (in_array($role->label, $sessionRoleLabels) || $role->id == 0) { $sessionRoles[] = $role; } } return $sessionRoles; }
public static function parse_list($response) { $result = array(); try { $atom = Atom::parse($response, new YouTubeDataMedia()); } catch (Exception $e) { throw new Exception($response); } foreach ($atom->arEntry() as $entry) { $obj = new self(); $links = $entry->link(); if (isset($links[0])) { $obj->url($links[0]->href()); } if (isset($links[3])) { $obj->mobile_url($links[3]->href()); } if ($entry->content() instanceof AtomContent) { $obj->content($entry->content()->value()); } $obj->title($entry->title()); $obj->published($entry->published()); $obj->updated($entry->updated()); $obj->keyword($entry->extra()->keyword()); $obj->duration($entry->extra()->duration()); $obj->player($entry->extra()->player()); $obj->category($entry->extra()->category()); $obj->thumbnail($entry->extra()->thumbnail()); $result[] = $obj; } return $result; }
public function __construct($data = array()) { parent::__construct($data); if (!isset($data['name'])) { $this->name = 'eventlist'; } if (!isset($data['posts'])) { $event_args = array(); // Get the active plugins. $active_plugins = get_option('active_plugins'); // We do some guessing here for Tzolkin if (in_array('tzolkin/tzolkin.php', $active_plugins)) { $event_args = ['post_type' => 'tz_events']; } // Some more guessing for The Events Calendar if (in_array('the-events-calendar/the-events-calendar.php', $active_plugins)) { $event_args = ['post_type' => \Tribe__Events__Main::POSTTYPE, 'orderby' => 'event_date', 'order' => 'ASC', 'posts_per_page' => tribe_get_option('postsPerPage', 10), 'tribe_render_context' => 'default']; } $eventlist_event_args_filter = $this->name . '_event_args'; $event_args = apply_filters($eventlist_event_args_filter, $event_args); Atom::add_debug_entry('Filter', $eventlist_event_args_filter); $this->posts = new \WP_Query($event_args); } if (!isset($data['posts-structure'])) { $posts_structure = ['PostClass' => ['children' => ['image', 'text']], 'image' => ['parts' => ['PostThumbnail']], 'text' => ['parts' => ['EventBadge', 'PostTitleLink', 'EventDate', 'ForceExcerpt', 'PostLink' => 'Read More']]]; $postlist_posts_structure_filter = $this->name . '_posts_structure'; $this->posts_structure = apply_filters($postlist_posts_structure_filter, $posts_structure); Atom::add_debug_entry('Filter', $postlist_posts_structure_filter); } }
public function __construct($config) { $config['link'] = 'http://www.google.com/profiles/' . $config['username'] . '#buzz'; $config['url'] = 'http://buzz.googleapis.com/feeds/' . $config['username'] . '/public/posted'; parent::__construct($config); $this->setItemTemplate('<li><div>{{{content}}}</div><div style="text-align:right"><small><a href="{{{link}}}"> {{{date}}}</a></small></div></li>' . "\n"); }
/** * @return array */ public function populateItemTemplate(&$item) { $media = $item->children('http://search.yahoo.com/mrss/'); $attrs = $media->group->thumbnail[0]->attributes(); $title = (string) $media->group->title; $description = (string) $media->group->description; $url_attrs = $media->group->player->attributes(); $url = $url_attrs['url']; return parent::populateItemTemplate($item) + array('title' => $title, 'description' => $description, 'image' => $attrs['url'], 'size' => $item->size); }
public function __construct($data = array()) { parent::__construct($data); if (!isset($data['name'])) { $this->name = 'postheader'; } if (!isset($data['structure'])) { $structure = ['title' => ['atom' => 'PostTitleLink', 'sibling' => 'date'], 'date' => ['atom' => 'PostDate', 'sibling' => 'author'], 'author' => ['atom' => 'PostAuthor', 'sibling' => 'categories'], 'categories' => ['atom' => 'CategoryList', 'sibling' => 'excerpt'], 'excerpt' => ['atom' => 'ExcerptForce']]; if (is_search()) { $structure['excerpt']['atom'] = 'ExcerptSearch'; } $postheader_structure_filter = $this->name . '_archive_structure'; $this->structure = apply_filters($postheader_structure_filter, $structure); Atom::add_debug_entry('Filter', $postheader_structure_filter); } }
public function __construct($data = array()) { parent::__construct($data); if (!isset($data['name'])) { $this->name = 'section'; } if (!isset($data['tag'])) { $this->name = 'header'; } if (!isset($data['structure'])) { $ancestor = get_highest_ancestor(); $section_title_filter = $this->name . '_title'; $title = apply_filters($section_title_filter, $ancestor['title']); Atom::add_debug_entry('Filter,', $section_title_filter); $this->structure = ['row' => ['children' => ['column']], 'column' => ['parts' => ['title' => ['tag' => 'h2', 'content' => $title]]]]; } }
public function __construct($data) { parent::__construct($data); if ('' === $this->name) { $this->name = 'list-pages'; } $this->tag = isset($data['tag']) ? $data['tag'] : 'ul'; // Set up default list args. $list_args_defaults_arr = ['post_type' => 'page', 'echo' => 0, 'title_li' => '']; // Parse supplied args from the organism setup. if (isset($data['list_args'])) { $list_args_arr = wp_parse_args($data['list_args'], $list_args_defaults_arr); } else { $list_args_arr = $list_args_defaults_arr; } /** * list_pages_list_args. * * A generic filter for site-wide use. * * @since 0.5.0 * * @param array $list_args_arr An array of list arguments. */ $list_args_arr = apply_filters('list_pages_list_args', $list_args_arr); Atom::add_debug_entry('Filter', 'list_pages_list_args'); /** * $this->name_list_pages_list_args. * * An atom-specific wp_list_categories args filter. * * @since 0.5.0 * * @param array $list_args_arr An array of list arguments. */ $list_args_arr_filter = $this->name . '_list_pages_list_args'; $list_args_arr = apply_filters($list_args_arr_filter, $list_args_arr); Atom::add_debug_entry('Filter', $list_args_arr_filter); // Assign the resolved args to the object. $this->list_args = $list_args_arr; $this->content = wp_list_pages($this->list_args); }
public function __construct($data) { parent::__construct($data); if (!isset($data['name'])) { $this->name = 'eventbadge'; } $this->tag = 'p'; if (isset($data['badge_pieces'])) { $badge_pieces_arr = $data['badge_pieces']; } else { $badge_pieces_arr = ['month' => date('F', $this->event_start_date), 'day' => date('d', $this->event_start_date)]; } $badge_pieces_arr_filter = $this->name . '_badge_pieces_arr'; $badge_pieces_arr = apply_filters($badge_pieces_arr_filter, $badge_pieces_arr); Atom::add_debug_entry('Filter', $badge_pieces_arr_filter); $badge_pieces_markup_arr = array(); foreach ($badge_pieces_arr as $badge_label => $badge_piece) { $format = '<span class="' . $this->name . '__%1$s">%2$s</span>'; $badge_pieces_markup_arr[$badge_label] = sprintf($format, $badge_label, $badge_piece); } $this->badge_pieces = $badge_pieces_markup_arr; $this->content = implode('', $this->badge_pieces); }
/** * @url GET resource/{concept}/{atomId} * @param string $concept * @param string $atomId * @param array $roleIds */ public function getConceptAtom($concept, $atomId, $roleIds = null) { try { $session = Session::singleton(); $session->activateRoles($roleIds); if (!in_array($concept, $session->getEditableConcepts())) { throw new Exception("You do not have access for this call", 403); } $atom = new Atom($atomId, $concept); if (!$atom->atomExists()) { throw new Exception("Resource '{$atomId}' not found", 404); } return $atom->getAtom(); } catch (Exception $e) { throw new RestException($e->getCode(), $e->getMessage()); } }
public function testWriteRecord() { $record = new WriterTestRecord(); $record->setId(1); $record->setAuthor('foo'); $record->setTitle('bar'); $record->setContent('foobar'); $writer = new Atom(); $actual = $writer->write($record); $expect = <<<XML <?xml version="1.0" encoding="UTF-8"?> <entry xmlns="http://www.w3.org/2005/Atom"> <content type="application/xml"> <record> <id>1</id> <author>foo</author> <title>bar</title> <content>foobar</content> </record> </content> </entry> XML; $this->assertXmlStringEqualsXmlString($expect, $actual); }
public static function getSessionVars() { if (!Config::get('loginEnabled')) { return false; } else { try { $ifc = new InterfaceObject('SessionVars'); $session = new Atom(session_id(), 'SESSION'); return $session->getContent($ifc, false, null, false, 'num', false); // $rootElement = false => this will return a single object instead of array. } catch (Exception $e) { return false; } } }
public function get_markup() { $this->markup = Atom::assemble($this->name, $this); }
public function atom() { Rhaco::import("net.feed.atom.Atom"); $atom = new Atom(); $atom->title($this->title()); $atom->subtitle($this->description()); $atom->generator($this->webMaster()); $atom->updated($this->lastBuildDate()); $link = new AtomLink(); $link->href($this->link()); $atom->link($link); foreach ($this->arItem() as $item) { $entry = new AtomEntry(); $entry->title($item->title()); $entry->published($item->pubDate()); $author = new AtomAuthor(); $author->name($item->author()); $entry->author($author); $link = new AtomLink(); $link->href($item->link()); $entry->link($link); $content = new AtomContent(); $content->value($item->description()); $entry->content($content); $summary = new AtomSummary(); $summary->value($item->comments()); $entry->summary($summary); $atom->add($entry); } return $atom; /*** $src = text(' <rss version="2.0"> <channel> <title>rhaco</title> <link>http://rhaco.org</link> <description>php</description> <language>ja</language> <copyright>rhaco.org</copyright> <docs>hogehoge</docs> <lastBuildDate>2007-10-10T10:10:10+09:00</lastBuildDate> <managingEditor>tokushima</managingEditor> <pubDate>2007-10-10T10:10:10+09:00</pubDate> <webMaster>kazutaka</webMaster> <item> <title>rhaco</title> <link>http://rhaco.org</link> <description>rhaco desc</description> </item> <item> <title>everes</title> <link>http://www.everes.net</link> <description>everes desc</description> </item> </channel> </rss> '); $xml = Rss::parse($src); eq("2.0",$xml->version()); eq("rhaco",$xml->title()); eq("http://rhaco.org",$xml->link()); eq("php",$xml->description()); eq("ja",$xml->language()); eq("rhaco.org",$xml->copyright()); eq("hogehoge",$xml->docs()); eq(1191978610,$xml->lastBuildDate()); eq("Wed, 10 Oct 2007 10:10:10 +0900",$xml->fmLastBuildDate()); eq("tokushima",$xml->managingEditor()); eq(1191978610,$xml->pubDate()); eq("Wed, 10 Oct 2007 10:10:10 +0900",$xml->fmPubDate()); eq("kazutaka",$xml->webMaster()); eq(2,sizeof($xml->item())); $atom = $xml->atom(); eq(true,$atom instanceof Atom); eq("rhaco",$atom->title()); eq("php",$atom->subtitle()); eq(1191978610,$atom->updated()); eq("kazutaka",$atom->generator()); eq(2,sizeof($atom->entry())); */ }
#$log->logf(" done!"); $microstop = explode(' ', microtime()); $stop_time = $microstop[0] + $microstop[1]; #$log->logf("Expired time: ".($stop_time - $start_time)); #foreach($chars as $cid) { #STEP 1: load and register atoms $log->logf("Processing char '" . $cdata['cid'] . "' (" . $cdata['race'] . "," . $cdata['cult'] . "," . $cdata['civ'] . ") ... "); #$log->logi("Loading and registering Atoms... ",false); $atom_list = array(); $tmps = 0; #$res = $DBc->sendSQL("SELECT at_id FROM ach_task WHERE NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_player='".$cdata['cid']."' AND apt_task=at_id) AND at_dev='0' AND (NOT EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id) OR EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id AND atta_alignment LIKE '".$cdata['cult'].'|'.$cdata['civ']."'))","ARRAY"); #foreach($res as $task) { //get unfinished atoms belonging to unfinished objectives $res2 = $DBc->sendSQL("SELECT ach_atom.* FROM ach_atom,ach_objective,ach_task WHERE ao_task=at_id AND ao_id=atom_objective AND NOT EXISTS (SELECT * FROM ach_player_objective WHERE apo_player='" . $cdata['cid'] . "' AND apo_objective=ao_id) AND NOT EXISTS (SELECT * FROM ach_player_task WHERE apt_player='" . $cdata['cid'] . "' AND apt_task=at_id) AND at_dev='0' AND (NOT EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id) OR EXISTS (SELECT * FROM ach_task_tie_align WHERE atta_task=at_id AND atta_alignment LIKE '" . $cdata['cult'] . '|' . $cdata['civ'] . "'))", "ARRAY"); foreach ($res2 as $atom) { $a = new Atom($atom, $cdata); $atom_list[] = $a; $atom_list[] = $a; $a->register(); } $tmps += sizeof($res2); #} $log->logf("loaded atoms: " . $tmps); $statsdb = new Stats(); $statsdb->register(); #$log->logf("done!"); #$log->logf("Memory load: ".memory_get_usage()." bytes"); $microstop = explode(' ', microtime()); $stop_time = $microstop[0] + $microstop[1]; #$log->logf("Expired time: ".($stop_time - $start_time)); #$log->logi("Driving data... ",false);
/** * factory for creating atom object instances * * factory for creating atom object instances * * @param integer $offset The offset of the atom (in bytes) * @param integer $size The size of the atom (in bytes) * @param string $type The type of the atom * * @return object An instance of the Atom-class * @author Benjamin Carl <*****@*****.**> * @version 0.1 * @since Method available since Release 0.1 * @access public */ public static function factory($offset, $size, $type) { // instanciate a new atom-object $atom = new Atom(); // setup ... $atom->setOffset($offset); $atom->setSize($size); $atom->setType($type); // and give back ... return $atom; }
private function determine_fallback_subnav_type() { global $post; $behavior = ''; if (is_home()) { $behavior = 'archive-home'; } if (is_post_type_archive()) { $behavior = 'archive-post_type'; } if (is_tax() || is_category()) { $behavior = 'archive-taxonomy'; } if (is_singular()) { if (is_post_type_hierarchical($post->post_type)) { $behavior = 'single-hierarchical'; } else { $behavior = 'single-nonhierarchical'; } } $behavior = apply_filters('subnav_location', $behavior); Atom::add_debug_entry('Filter,', 'subnav_location'); $subnav_location_filter = $this->name . '_subnav_location'; $behavior = apply_filters($subnav_location_filter, $behavior); Atom::add_debug_entry('Filter,', $subnav_location_filter); if ('' === $behavior) { return false; } else { $this->behavior = $behavior; } }
public function getContent($interface, $rootElement = true, $tgtAtom = null, $inclLinktoData = false, $arrayType = "assoc", $metaData = true, $recursionAtomArr = array()) { $session = Session::singleton(); if (is_null($tgtAtom)) { $idEsc = $this->database->escape($this->id); $query = "SELECT DISTINCT `tgt` FROM ({$interface->expressionSQL}) AS `results` WHERE `src` = '{$idEsc}' AND `tgt` IS NOT NULL"; $tgtAtoms = array_column($this->database->Exe($query), 'tgt'); } else { // Make sure that atom is in db (not necessarily the case: e.g. new atom) $this->database->addAtomToConcept($this->id, $this->concept); $tgtAtoms[] = $tgtAtom; } foreach ($tgtAtoms as $tgtAtomId) { $tgtAtom = new Atom($tgtAtomId, $interface->tgtConcept, $interface->viewId); // Add @context for JSON-LD to rootElement if ($rootElement) { $content['@context'] = Config::get('serverURL') . Config::get('apiPath') . '/interface/' . $interface->id; } // Leaf if (empty($interface->subInterfaces) && empty($interface->refInterfaceId)) { // Property if ($interface->isProperty && !$interface->isIdent) { $content = !is_null($tgtAtom->id); // convert NULL into false and everything else in true // Object } elseif ($interface->tgtConceptIsObject) { $content = array(); // Add meta data if ($metaData) { // Define interface(s) to navigate to for this tgtAtom $atomInterfaces = array(); if ($interface->isLinkTo && !$inclLinktoData && $session->role->isInterfaceForRole($interface->refInterfaceId)) { $atomInterfaces[] = array('id' => $interface->refInterfaceId, 'label' => $interface->refInterfaceId); } elseif (isset($session->role)) { $atomInterfaces = array_map(function ($o) { return array('id' => $o->id, 'label' => $o->label); }, $session->role->getInterfacesToReadConcept($interface->tgtConcept)); } // Add meta data elements $content = array_merge($content, array('@id' => $tgtAtom->jsonld_id, '@label' => $tgtAtom->label, '@view' => $tgtAtom->view, '@type' => $tgtAtom->jsonld_type, '@interfaces' => $atomInterfaces, '_sortValues_' => array())); } // Add id TODO:can be removed when angular templates use @id instead of id $content = array_merge($content, array('id' => $tgtAtom->id)); // Scalar } else { $content = $this->typeConversion($tgtAtom->id, $interface->tgtConcept); // TODO: now same conversion as to database is used, maybe this must be changed to JSON types (or the json_encode/decode does this automaticaly?) } // Tree } else { $content = array(); // Add meta data if ($metaData) { // Define interface(s) to navigate to for this tgtAtom $atomInterfaces = array(); if ($interface->isLinkTo && !$inclLinktoData && $session->role->isInterfaceForRole($interface->refInterfaceId)) { $atomInterfaces[] = array('id' => $interface->refInterfaceId, 'label' => $interface->refInterfaceId); } elseif (isset($session->role)) { $atomInterfaces = array_map(function ($o) { return array('id' => $o->id, 'label' => $o->label); }, $session->role->getInterfacesToReadConcept($interface->tgtConcept)); } // Add meta data elements $content = array_merge($content, array('@id' => $tgtAtom->jsonld_id, '@label' => $tgtAtom->label, '@view' => $tgtAtom->view, '@type' => $tgtAtom->jsonld_type, '@interfaces' => $atomInterfaces, '_sortValues_' => array())); } // Add id TODO:can be removed when angular templates use @id instead of id $content = array_merge($content, array('id' => $tgtAtom->id)); // Subinterfaces if (!empty($interface->subInterfaces)) { if (!$interface->tgtConceptIsObject) { throw new Exception("TgtConcept of interface: '" . $interface->label . "' is scalar and can not have subinterfaces", 501); } foreach ($interface->subInterfaces as $subinterface) { $otherAtom = $tgtAtom->getContent($subinterface, false, null, $inclLinktoData, $arrayType, $metaData); $content[$subinterface->id] = $otherAtom; // _sortValues_ (if subInterface is uni) if ($subinterface->univalent && $metaData) { // property if (is_bool($otherAtom)) { $content['_sortValues_'][$subinterface->id] = $otherAtom; } elseif ($subinterface->tgtConceptIsObject) { $content['_sortValues_'][$subinterface->id] = current((array) $otherAtom)['@label']; } else { $content['_sortValues_'][$subinterface->id] = $otherAtom; } } } } // Ref subinterfaces (for LINKTO interfaces only when $inclLinktoData = true) if (!empty($interface->refInterfaceId) && (!$interface->isLinkTo || $inclLinktoData) && $recursionAtomArr[$tgtAtom->id] < 2) { if (!$interface->tgtConceptIsObject) { throw new Exception("TgtConcept of interface: '" . $interface->label . "' is scalar and can not have a ref interface defined", 501); } if ($inclLinktoData) { $recursionAtomArr[$tgtAtom->id]++; } $refInterface = new InterfaceObject($interface->refInterfaceId, null); foreach ($refInterface->subInterfaces as $subinterface) { $otherAtom = $tgtAtom->getContent($subinterface, false, null, $inclLinktoData, $arrayType, $metaData, $recursionAtomArr); $content[$subinterface->id] = $otherAtom; // _sortValues_ (if subInterface is uni) if ($subinterface->univalent && $metaData) { // property if (is_bool($otherAtom)) { $content['_sortValues_'][$subinterface->id] = $otherAtom; } elseif ($subinterface->tgtConceptIsObject) { $content['_sortValues_'][$subinterface->id] = current((array) $otherAtom)['@label']; } else { $content['_sortValues_'][$subinterface->id] = $otherAtom; } } } } } // Determine whether value of atom must be inserted as list or as single value // Properties are represented as single value if ($interface->isProperty && !$interface->isIdent && empty($interface->subInterfaces) && empty($interface->refInterfaceId)) { $arr = $content; // Object are always inserted as array } elseif ($interface->tgtConceptIsObject) { switch ($arrayType) { case "num": if ($interface->univalent && !$rootElement) { $arr = $content; } else { $arr[] = $content; } break; case "assoc": default: $arr[$content['id']] = $content; break; } // Non-object UNI results are inserted as single value } elseif ($interface->univalent) { $arr = $content; // Non-object Non-UNI results are inserted as array } else { $arr[] = $content; } unset($content); } return $arr; }
public function atom() { Rhaco::import("net.feed.atom.Atom"); $atom = new Atom(); $atom->title($this->title()); foreach ($this->outlines() as $outline) { $entry = new AtomEntry(); $entry->title($outline->title()); $entry->published(time()); if ($outline->isHtmlUrl()) { $entry->link(new AtomLink("type=html,href=" . $outline->htmlUrl())); } if ($outline->isXmlUrl()) { $entry->link(new AtomLink("type=xml,href=" . $outline->xmlUrl())); } $entry->content(new AtomContent("value=" . $outline->description())); $entry->summary(new AtomSummary("value=" . $outline->tags())); $atom->add($entry); } return $atom; /*** $text = text(' <?xml version="1.0" encoding="utf-8"?> <opml version="1.0"> <head> <title>Subscriptions</title> <dateCreated>Mon, 19 May 2008 04:51:05 UTC</dateCreated> <ownerName>rhaco</ownerName> </head> <body> <outline title="Subscriptions"> <outline title="スパムとか" htmlUrl="http://www.everes.net/" type="rss" xmlUrl="http://www.everes.net/blog/atom/" /> <outline title="tokushimakazutaka.com" htmlUrl="http://tokushimakazutaka.com" type="rss" xmlUrl="tokushimakazutaka.com/rss" /> <outline title="rhaco"> </outline> <outline title="php"> <outline title="riaf-ja blog" htmlUrl="http://blog.riaf.jp/" type="rss" xmlUrl="http://blog.riaf.jp/rss" /> </outline> <outline title="お知らせ"> </outline> </outline> </body></opml> '); $feed = Opml::parse($text); eq("Subscriptions",$feed->title()); eq("1.0",$feed->version()); eq(1211172665,$feed->dateCreated()); eq("rhaco",$feed->ownerName()); eq(null,$feed->ownerEmail()); eq(1,sizeof($feed->outline())); $opml = $feed->outline(); eq("Subscriptions",$opml[0]->title()); eq(3,sizeof($opml[0]->xml())); eq(3,sizeof($opml[0]->html())); $atom = $feed->atom(); eq(true,$atom instanceof Atom); eq("Subscriptions",$atom->title()); eq(null,$atom->subtitle()); eq(time(),$atom->updated()); eq(null,$atom->generator()); eq(5,sizeof($atom->entry())); */ }
/** * フィードを取得 * * @param string $src * @return Atom */ public static function parse($src) { try { return Atom::parse($src); } catch (Exception $e) { try { return Rss::parse($src)->atom(); } catch (Exception $e) { try { return Opml::parse($src)->atom(); } catch (Exception $e) { throw new Exception("no feed"); } } } /*** $src = text(' <feed xmlns="http://www.w3.org/2005/Atom"> <title>atom10 feed</title> <subtitle>atom10 sub title</subtitle> <updated>2007-07-18T16:16:31+00:00</updated> <generator>tokushima</generator> <link href="http://tokushimakazutaka.com" rel="abc" type="xyz" /> <author> <url>http://tokushimakazutaka.com</url> <name>tokushima</name> <email>tokushima@hoge.hoge</email> </author> <entry> <title>rhaco</title> <summary type="xml" xml:lang="ja">summary test</summary> <content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content> <link href="http://rhaco.org" rel="abc" type="xyz" /> <link href="http://conveyor.rhaco.org" rel="abc" type="conveyor" /> <link href="http://lib.rhaco.org" rel="abc" type="lib" /> <updated>2007-07-18T16:16:31+00:00</updated> <issued>2007-07-18T16:16:31+00:00</issued> <published>2007-07-18T16:16:31+00:00</published> <id>rhaco</id> <author> <url>http://rhaco.org</url> <name>rhaco</name> <email>rhaco@rhaco.org</email> </author> </entry> <entry> <title>django</title> <summary type="xml" xml:lang="ja">summary test</summary> <content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content> <link href="http://djangoproject.jp" rel="abc" type="xyz" /> <updated>2007-07-18T16:16:31+00:00</updated> <issued>2007-07-18T16:16:31+00:00</issued> <published>2007-07-18T16:16:31+00:00</published> <id>django</id> <author> <url>http://www.everes.net</url> <name>everes</name> <email>everes@hoge.hoge</email> </author> </entry> </feed> '); $xml = Feed::parse($src); $result = text(' <feed xmlns="http://www.w3.org/2005/Atom"> <title>atom10 feed</title> <subtitle>atom10 sub title</subtitle> <id>rhaco</id> <generator>tokushima</generator> <updated>2007-07-18T16:16:31Z</updated> <link rel="abc" type="xyz" href="http://tokushimakazutaka.com" /> <entry> <id>rhaco</id> <title>rhaco</title> <published>2007-07-18T16:16:31Z</published> <updated>2007-07-18T16:16:31Z</updated> <issued>2007-07-18T16:16:31Z</issued> <content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content> <summary type="xml" xml:lang="ja">summary test</summary> <link rel="abc" type="xyz" href="http://rhaco.org" /> <link rel="abc" type="conveyor" href="http://conveyor.rhaco.org" /> <link rel="abc" type="lib" href="http://lib.rhaco.org" /> <author> <name>rhaco</name> <url>http://rhaco.org</url> <email>rhaco@rhaco.org</email> </author> </entry> <entry> <id>django</id> <title>django</title> <published>2007-07-18T16:16:31Z</published> <updated>2007-07-18T16:16:31Z</updated> <issued>2007-07-18T16:16:31Z</issued> <content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content> <summary type="xml" xml:lang="ja">summary test</summary> <link rel="abc" type="xyz" href="http://djangoproject.jp" /> <author> <name>everes</name> <url>http://www.everes.net</url> <email>everes@hoge.hoge</email> </author> </entry> <author> <name>tokushima</name> <url>http://tokushimakazutaka.com</url> <email>tokushima@hoge.hoge</email> </author> </feed> '); $result = str_replace(array("\n","\t"),"",$result); eq($result,(string)$xml); */ }
// add sitemap $context->sitemap['/index.html'] = 1; le_do_workflow('build', $template, $target, ['index' => $index]); }); // generate feeds le_add_workflow('generate_feeds', function () use($context) { if (!isset($context->config['feeds'])) { return; } $config = $context->config['feeds']; if (!isset($config['source']) || !isset($context->index[$config['source']])) { return; } $config = array_merge(['title' => isset($context->data['title']) ? $context->data['title'] : 'My Feeds', 'description' => isset($context->data['description']) ? $context->data['description'] : 'My Feeds Description', 'recent' => 20, 'target' => 'feeds.xml', 'url' => isset($context->data['url']) ? $context->data['url'] : '/'], $config); $feedsUrl = rtrim($config['url'], '/') . '/' . ltrim($config['target'], '/'); $feeds = new \Atom(); $feeds->setBaseUrl($config['url']); $feeds->setFeedUrl($feedsUrl); $feeds->setTitle($config['title']); $feeds->setSubTitle($config['description']); $posts = array_slice($context->index[$config['source']], 0, $config['recent']); foreach ($posts as $post) { $post = le_do_workflow('get_post', $config['source'], $post); $item = ['title' => $post['title'], 'link' => $post['permalink'], 'updated' => $post['date'], 'published' => $post['date'], 'author' => isset($config['author']) ? ['name' => $config['author'], 'url' => $config['url']] : NULL, 'content' => $post['content']]; foreach ($context->config['blocks'] as $type => $val) { if (isset($val['source']) && is_string($val['source'])) { continue; } if ('archive' != $type && !empty($post[$type])) { foreach ($post[$type] as $meta) { $item['category'][] = ['feeds_url' => $meta['url'], 'name' => $meta['name']];
private function setDateFormat() { switch ($this->event_date_type) { case 'now': // Now - 1:45 PM $event_date_formatted = sprintf('Now - %s', date('g:i A', $this->event_end_date)); break; case 'allday-single': // Jan 1, 2016 - All Day $event_date_formatted = date('M j, Y', $this->event_start_date) . ' - All Day'; break; case 'allday-multiple': // Mon, Jan 13 - Fri, Jan 18 $event_date_formatted = sprintf('%s - %s', date('D, M j, Y', $this->event_start_date), date('D, M j, Y', $this->event_end_date)); break; case 'single-day': // 11:05 AM - 1:45 PM $event_date_formatted = sprintf('%s - %s', date('g:i A', $this->event_start_date), date('g:i A', $this->event_end_date)); break; default: // Mon, Jan 13 @ 11:05 AM - Fri, Jan 18 @ 1:45 PM $event_date_formatted = sprintf('%s - %s', date('D, M j, Y @ g:i A', $this->event_start_date), date('D, M j, Y @ g:i A', $this->event_end_date)); break; } /** * event_date_format. * * A site-wide filter for adjusting the event date format. * * @since 0.5.0 * * @param string $var The formatted event date. * @param string $this ->event_date_type Include the event date type so that making an intelligent adjustment is easier. */ $event_date_formatted = apply_filters('event_date_format', $event_date_formatted, $this); Atom::add_debug_entry('Filter', 'event_date_format'); /** * $this->name_event_date_format. * * An atom-specific event date format filter. * * @since 0.5.0 * * @param string $var The formatted event date. * @param string $this ->event_date_type Include the event date type so that making an intelligent adjustment is easier. */ $event_date_format_filter = $this->name . '_event_date_format'; $this->event_date_formatted = apply_filters($event_date_format_filter, $event_date_formatted, $this); Atom::add_debug_entry('Filter', $event_date_format_filter); }
/** * get_structure_part * * Get a part of the structure: returns either a plain atom or a named atom based on the args. * * @since 0.1.0 * @see CNP/Atom * * @param string $atom_name The base atom name, modified to be namespaced by the organism name. * @param array $atom_args The atom args * @param WP_Post $post_obj Post object * * @return mixed */ protected function get_structure_part($atom_name, $atom_args, $post_obj) { // First, namespace the atom based on the organism name. if (isset($atom_args['name'])) { $namespaced_atom_name = $this->name . $this->separator . $atom_args['name']; } if (!isset($atom_args['name'])) { $namespaced_atom_name = $this->name . $this->separator . $atom_name; } $class_atom_suffix = $atom_name; if (isset($atom_args['atom'])) { $class_atom_suffix = $atom_args['atom']; } // Set up the class to check against $class_atom_name = 'CNP\\' . $class_atom_suffix; // If class isn't set already, then it defaults to an array. if (!isset($atom_args['attributes']['class'])) { $atom_args['attributes']['class'] = array(); } // Shorthand for class if (isset($atom_args['class'])) { // The utility function takes either a string or array, and returns an array. $classes_arr = Utility::parse_classes_as_array($atom_args['class']); if (!empty($classes_arr)) { // $atom_args['attributes']['class'] has been pre-set as an array, so the merge here is safe. $atom_args['attributes']['class'] = array_merge($atom_args['attributes']['class'], $classes_arr); } } // Add the $post to $atom_args, if it is present. if (isset($post_obj)) { $atom_args['post'] = $post_obj; } // Set up the atom class. $atom_args['attributes']['class'][] = $namespaced_atom_name; // Set up atom filter suppression, or not $atom_args['suppress_filters'] = $this->suppress_filters; // If the class exists, then it's a named atom, and we need to // run the get_markup method based on the namespaced atom name. if (class_exists($class_atom_name)) { $atom_args['name'] = $namespaced_atom_name; $atom_object = new $class_atom_name($atom_args); $atom_object->get_markup(); return $atom_object->markup; } // If the class does not exist, then it's a generic atom. // Run it through the Atom class to assemble it if (!class_exists($class_atom_name)) { $atom = Atom::assemble($namespaced_atom_name, $atom_args); return $atom; } return true; }
public function atom() { Atom::convert(module_const('sitename', 'Planet'), url(), C(PlanetEntry)->find_all(new Paginator(20), Q::order('-updated')))->output(); }
<?php require dirname(__FILE__) . '/main.php'; $db = new DB(); $result = $db->query("SELECT * FROM playlists ORDER BY id DESC LIMIT 10"); $now = time(); $feed = new Atom('Playr: New Playlists', array('name' => 'Playr'), array('link' => array('text/html' => 'http://playr.hubmed.org/new.php'))); while ($item = mysql_fetch_object($result)) { $flash_params['playlistfile'] = play_url('xspf', $item->url); $entry = $feed->addEntry('tag:playr.hubmed.org,2005:atom,' . $item->id, $item->title, $now, NULL, array('link' => array('text/html' => $item->url))); $content = $feed->addContent($entry); $p = $feed->addTextChild($content, 'p', 'Play '); $a = $feed->addTextChild($p, 'a', 'Flash'); $a->setAttribute('href', url(FLASH_PLAYER, $flash_params)); $p = $feed->dom->createElement('p'); $content->appendChild($p); $a = $feed->addTextChild($p, 'a', 'Original page'); $a->setAttribute('href', $item->url); } $feed->output(); ?> <feed xmlns="http://www.w3.org/2005/Atom"> <title>Playr: New Playlists</title> <subtitle>New Playlists</subtitle> <id>tag:playr.hubmed.org,2005:new</id> <link rel="alternate" type="text/html" href="http://playr.hubmed.org/new.php" /> <link rel="self" type="application/atom+xml" href="http://projects.hubmed.org/playr/atom.php"/> <author> <name>Playr</name> <email>alf@hubmed.org</email> </author>
/** * @return array */ public function populateItemTemplate(&$item) { return parent::populateItemTemplate($item) + array(); }
public function log($_channel = "", $_title = "", $_author = "", $_content = "", $_level = ATOM_LEVEL_DEBUG, $_module = "SYSTEM") { //el canal y título por defecto. if (empty($_channel)) { $_channel = ATOM_DEFAULT_CHANNEL; } if (empty($_title)) { $_title = ATOM_GENERAL_TITLE; } if (empty($_author)) { $_author = ATOM_SYSTEM_AUTHOR; } //crea manejador del AtomHopper. $atom = new Atom($this->_url, $_channel); //Crea mensaje. $categories = array($_level, $_module, $this->_instance); $atommsg = new AtomMsg($_title, $_author, $_content, $categories); //envía mensaje. $res = $atom->postMessage($atommsg); if ($res == FALSE) { error_log("error ATOMLOGGER: ERROR ENVIANDO MENSAJE AL ATOM HOOPER " . $this->_url); error_log("error ATOMLOGGER: " . $atommsg->xml); error_log("error ATOMLOGGER: " . $atom->resultmsg); } return $res; }
/** * Adds "github" to the box HTML class attribute * @return array */ public function populateBoxTemplate($data) { return parent::populateBoxTemplate($data) + array('class' => $data['class'] . ' github'); }