public static function make($text = null, $language = null) { $handler = new self(); if (!empty($text)) { $handler->text($text); } if (!empty($language)) { $handler->language($language); } return $handler; }
public static function parse($message) { $obj = new self(); $obj->text(Lou::trans_html($message->text())); $obj->screen_name($message->user()->screen_name()); $obj->profile_image_url($message->user()->profile_image_url()); $obj->created_at($message->created_at()); if ($message instanceof WassrMessage) { $obj->type("wassr"); } else { if ($message instanceof TwitterMessage) { $obj->type("twitter"); } } return $obj; }
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; }
public static function parse($src, $tags = "") { $result = null; if (Tag::setof($tag, $src, "outline")) { $result = new self(); $result->text($tag->inParam("text")); $result->type($tag->inParam("type")); $result->comment($tag->inParam("isComment", false)); $result->breakpoint($tag->inParam("isBreakpoint", false)); $result->htmlUrl($tag->inParam("htmlUrl")); $result->xmlUrl($tag->inParam("xmlUrl")); $result->title($tag->inParam("title")); $result->description($tag->inParam("description")); $result->tags($tags); foreach ($tag->in("outline") as $outlinetag) { $result->outline(self::parse($outlinetag->plain(), $tags)); } } return $result; /*** * $src = '<outline title="りあふ の にっき" htmlUrl="http://riaf.g.hatena.ne.jp/riaf/" type="rss" xmlUrl="http://riaf.g.hatena.ne.jp/riaf/rss2" />'; * $xml = OpmlOutline::parse($src); * eq("りあふ の にっき",$xml->title()); * eq("http://riaf.g.hatena.ne.jp/riaf/rss2",$xml->xmlUrl()); * eq("http://riaf.g.hatena.ne.jp/riaf/",$xml->htmlUrl()); * eq("rss",$xml->type()); * */ }