Example #1
3
File: Rss.php Project: hisaboh/w2t
 /**
  * xmlをRssに変換する
  *
  * @param string $src
  * @return Rss
  */
 public static function parse($src)
 {
     if (Tag::setof($rss, $src, "rss")) {
         $result = new self();
         $result->version($rss->inParam("version", "2.0"));
         if (Tag::setof($channel, $rss->value(), "channel")) {
             $result->title($channel->f("title.value()"));
             $result->link($channel->f("link.value()"));
             $result->description($channel->f("description.value()"));
             $result->language($channel->f("language.value()"));
             $result->copyright($channel->f("copyright.value()"));
             $result->docs($channel->f("docs.value()"));
             $result->managingEditor($channel->f("managingEditor.value()"));
             $result->webMaster($channel->f("webMaster.value()"));
             $result->lastBuildDate($channel->f("lastBuildDate.value()"));
             $result->pubDate($channel->f("pubDate.value()"));
             $value = $channel->value();
             $result->item = RssItem::parse($value);
             return $result;
         }
     }
     throw new Exception("no rss");
     /***
     			 $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()));
     			*/
 }
Example #2
0
 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;
 }
Example #3
0
 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;
 }
Example #4
0
 static function pageForwardLink($page)
 {
     $me = new self($page);
     $me->raw = array('websiteTitle' => $me->websiteTitle, 'websiteSubtitle' => $me->page, 'moderator' => $me->moderatorName(), 'moderatorInstitution' => $me->moderatorBusinessName(), 'moderatorProfession' => $me->moderatorProfession(), 'hash' => '', 'author' => $me->authorName(), 'authorInstitution' => $me->authorBusinessName(), 'authorProfession' => $me->authorProfession(), 'href' => $me->href, 'answers' => $me->answers(), 'dateLastUpdated' => $me->lastModif, 'dateOriginated' => $me->findDatePageOriginated(), 'language' => $me->language(), 'count' => $me->countAll(), 'keywords' => $me->keywords(), 'categories' => $me->categories(), 'scientificField' => $me->scientificField(), 'minimumMathNeeded' => $me->minimumMathNeeded(), 'minimumStatisticsNeeded' => $me->minimumStatisticsNeeded(), 'text' => '');
     return $me;
 }