Example #1
0
File: Opml.php Project: hisaboh/w2t
 /**
  * 文字列からOpmlをセットする
  *
  * @param string $src
  */
 public static function parse($src)
 {
     if (Tag::setof($tag, $src, "opml")) {
         $result = new self();
         $result->title($tag->f("title.value()"));
         $result->dateCreated($tag->f("dateCreated.value()"));
         $result->dateModified($tag->f("dateModified.value()"));
         $result->ownerName($tag->f("ownerName.value()"));
         $result->ownerEmail($tag->f("ownerEmail.value()"));
         $result->expansionState($tag->f("expansionState.value()"));
         $result->vertScrollState($tag->f("vertScrollState.value()"));
         $result->windowTop($tag->f("windowTop.value()"));
         $result->windowLeft($tag->f("windowLeft.value()"));
         $result->windowBottom($tag->f("windowBottom.value()"));
         $result->windowRight($tag->f("windowRight.value()"));
         foreach ($tag->in("outline") as $intag) {
             $opmloutline = new OpmlOutline();
             $result->outline($opmloutline->parse($intag->plain()));
         }
         return $result;
     }
     throw new Exception("no opml");
     /***
     			$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()));
     		*/
 }
Example #2
0
 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());
      * 
      */
 }