/** * @plugin ebi.Session * @param string $id * @param string $sess_data */ public function session_write($id, $sess_data) { try { $obj = new self(); $obj->id($id); $obj->data($sess_data); $obj->save(); } catch (\Exception $e) { } }
public static function parse_list($response, $paginator) { $result = array(); $res = Text::parse_json($response); if (isset($res["error"])) { throw new Exception($res["error"]); } if (!empty($res["pager"])) { $paginator = new Paginator($res["pager"]["clips_in_page"], $res["pager"]["current_page"], $res["pager"]["total_entries"]); } if (!empty($res["entries"])) { foreach ($res["entries"] as $re) { $obj = new self(); $obj->id($re["id"]); $obj->title($re["title"]); $obj->url($re["permalink"]); $obj->author(new FlipClipAuthor($re["author"]["id"], $re["author"]["name"], $re["author"]["uri"])); $obj->summary($re["summary"]); $obj->updated($re["updated"]); if (isset($re["category"])) { $obj->category(new FlipClipCategory($re["category"]["term"], $re["category"]["scheme"], $re["category"]["label"])); } if (isset($re["subcategory"])) { $obj->category(new FlipClipCategory($re["subcategory"]["term"], $re["subcategory"]["scheme"], $re["subcategory"]["label"])); } if (isset($re["tags"])) { foreach ($re["tags"] as $tag) { $obj->tags(new FlipClipTag($tag["term"], $tag["scheme"], $tag["label"])); } } $obj->embed_script($re["embed_script"]); $obj->latitude($re["latitude"]); $obj->longitude($re["longitude"]); $obj->privacy($re["privacy"]); $obj->duration($re["duration"]); $obj->image($re["image"]); $obj->image_medium($re["imageMedium"]); $obj->image_small($re["imageSmall"]); $obj->thumbnail($re["thumbnail"]); $result[] = $obj; } } return $result; }
public static function parse_search_list($response) { $results = array(); if (Tag::setof($atom, $response, "feed")) { foreach ($atom->in("entry") as $entry) { $self = new self(); $self->id(preg_replace("/^.+\\:([\\d]+)\$/", "\\1", $entry->f("id.value()"))); $self->text($entry->f("title.value()")); $self->source(Text::htmldecode($entry->f("twitter:source.value()"))); $self->created_at($atom->f("published.value()")); $user = new TwitterUser(); $user->name(str_replace("http://twitter.com/", "", Text::htmldecode($entry->f("author.uri.value()")))); $user->screen_name(Text::htmldecode($entry->f("author.name.value()"))); $user->profile_image_url(Text::htmldecode($entry->f("link[1].param(href)"))); $self->user($user); $results[] = $self; } } return $results; }
/** * 文字列からAtomフィードを取得する * @param string $src * @return self */ public static function parse($src) { $args = func_get_args(); array_shift($args); if (\org\rhaco\Xml::set($tag, $src, 'feed') && $tag->in_attr('xmlns') == self::XMLNS) { $result = new self(); $value = $tag->value(); \org\rhaco\Xml::set($tag, '<:>' . $value . '</:>'); $result->id($tag->f('id.value()')); $result->title($tag->f('title.value()')); $result->subtitle($tag->f('subtitle.value()')); $result->updated($tag->f('updated.value()')); $result->generator($tag->f('generator.value()')); $value = $tag->value(); $result->entry = \org\rhaco\net\xml\atom\Entry::parse($value); $result->link = \org\rhaco\net\xml\atom\Link::parse($value); $result->author = \org\rhaco\net\xml\atom\Author::parse($value); return $result; } throw new \InvalidArgumentException('no atom'); }
public function parse_list($response) { if ($response === "N;") { throw new Exception("Invalid data"); } $result = array(); foreach (unserialize($response) as $re) { $obj = new self(); $obj->language($re["language"]); $obj->id($re["id"]); $obj->url($re["url"]); $obj->title($re["title"]); $obj->body($re["body"]); $obj->length($re["length"]); $obj->redirect($re["redirect"]); $obj->strict($re["strict"]); $obj->datetime($re["datetime"]); $result[] = $obj; } return $result; }
public static function instance($nameOrData = null, $data = null) { if (!self::$namespace) { self::$namespace = array(); } $obj = null; if (is_string($nameOrData) && trim($nameOrData)) { self::$namespace[trim($nameOrData)] = new self($data); self::$namespace[trim($nameOrData)]->id($nameOrData); return self::$namespace[trim($nameOrData)]; } elseif ($nameOrData === null) { $obj = new self($data); } else { $obj = new self($nameOrData); } $obj->id(); return $obj; }
public static function parse($src) { $args = func_get_args(); array_shift($args); if (Tag::setof($tag, $src, "feed") && $tag->inParam("xmlns") == self::$XMLNS) { $result = new self(); $value = $tag->value(); $tag = Tag::anyhow($value); $result->id($tag->f("id.value()")); $result->title($tag->f("title.value()")); $result->subtitle($tag->f("subtitle.value()")); $result->updated($tag->f("updated.value()")); $result->generator($tag->f("generator.value()")); $value = $tag->value(); $result->entry = call_user_func_array(array("AtomEntry", "parse"), array_merge(array(&$value), $args)); $result->link = AtomLink::parse($value); $result->author = AtomAuthor::parse($value); return $result; } throw new Exception("no atom"); /*** $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 = Atom::parse($src); eq("atom10 feed",$xml->title()); eq("atom10 sub title",$xml->subtitle()); eq(1184775391,$xml->updated()); eq("2007-07-18T16:16:31Z",$xml->fmUpdated()); eq("tokushima",$xml->generator()); eq(2,sizeof($xml->entry())); */ }
public static function parse(&$src) { $args = func_get_args(); array_shift($args); $result = array(); foreach (Tag::anyhow($src)->in("entry") as $in) { $o = new self(); foreach ($args as $module) { $o->add_modules($module); } $o->id($in->f("id.value()")); $o->title($in->f("title.value()")); $o->published($in->f("published.value()")); $o->updated($in->f("updated.value()")); $o->issued($in->f("issued.value()")); $value = $in->value(); $o->content = AtomContent::parse($value); $o->summary = AtomSummary::parse($value); $o->link = AtomLink::parse($value); $o->author = AtomAuthor::parse($value); $o->parse_extra($value); $result[] = $o; $src = str_replace($in->plain(), "", $src); } return $result; }
public static function parse(&$src) { $args = func_get_args(); array_shift($args); $result = array(); \org\rhaco\Xml::set($x, '<:>' . $src . '</:>'); foreach ($x->in('entry') as $in) { $o = new self(); $o->id($in->f('id.value()')); $o->title($in->f('title.value()')); $o->published($in->f('published.value()')); $o->updated($in->f('updated.value()')); $o->issued($in->f('issued.value()')); $value = $in->value(); $o->content = Content::parse($value); $o->summary = Summary::parse($value); $o->link = Link::parse($value); $o->author = Author::parse($value); $result[] = $o; $src = str_replace($in->plain(), '', $src); } return $result; }