Пример #1
0
 public static function parse(&$src)
 {
     $result = array();
     foreach (Tag::anyhow($src)->in("source") as $in) {
         $src = str_replace($in->plain(), "", $src);
         $o = new self();
         $o->url($in->inParam("url"));
         $o->value($in->value());
         $result[] = $o;
     }
     return $result;
 }
Пример #2
0
 public static function parse(&$src)
 {
     $result = array();
     foreach (Tag::anyhow($src)->in("enclosure") as $in) {
         $src = str_replace($in->plain(), "", $src);
         $o = new self();
         $o->url($in->inParam("url"));
         $o->type($in->inParam("type"));
         $o->length($in->inParam("length"));
         $result[] = $o;
     }
     return $result;
 }
Пример #3
0
 public static function parse(&$src)
 {
     $result = array();
     foreach (Tag::anyhow($src)->in("author") as $in) {
         $src = str_replace($in->plain(), "", $src);
         $o = new self();
         $o->name($in->f("name.value()"));
         $o->url($in->f("url.value()"));
         $o->email($in->f("email.value()"));
         $result[] = $o;
     }
     return $result;
 }
Пример #4
0
 public static function parse(&$src)
 {
     $result = array();
     foreach (Tag::anyhow($src)->in("link") as $in) {
         $o = new self();
         $o->href($in->inParam("href"));
         $o->rel($in->inParam("rel"));
         $o->type($in->inParam("type"));
         $result[] = $o;
         $src = str_replace($in->plain(), "", $src);
     }
     return $result;
 }
Пример #5
0
 public static function parse($src)
 {
     $result = array();
     foreach (Tag::anyhow($src)->in("item") as $in) {
         $o = new self();
         $o->title($in->f("title.value()"));
         $o->link($in->f("link.value()"));
         $o->description($in->f("description.value()"));
         $o->author($in->f("author.value()"));
         $o->category($in->f("category.value()"));
         $o->comments($in->f("comments.value()"));
         $o->pubDate($in->f("pubDate.value()"));
         $o->guid($in->f("guid.value()"));
         $value = $in->value();
         $o->enclosure = RssEnclosure::parse($value);
         $o->source = RssSource::parse($src);
         $result[] = $o;
     }
     return $result;
 }
Пример #6
0
 /**
  * ページタイトル
  *
  * @return string
  */
 public function title()
 {
     return Tag::anyhow($this->body)->f("title.value()");
 }
Пример #7
0
 /**
  * brタグを改行コードに変換
  * @param $src 変換する文字列
  * @return string
  */
 public function br2nl($src)
 {
     foreach (Tag::anyhow($src)->in("br") as $t) {
         $src = str_replace($t->get(), "\n", $src);
     }
     return $src;
     /***
     			$body = text('hoge<br />hoge<br>hoge<br /><br />hoge');
     			$t = new self();
     			eq("hoge\nhoge<br>hoge\n\nhoge",$t->br2nl($body));
     		 */
 }
Пример #8
0
 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()));
     		*/
 }
Пример #9
0
 protected function __new__($user, $password)
 {
     $this->wsse($user, $password);
     $this->member_id = preg_replace("/^.+\\?id=(\\d+)\$/", "\\1", Tag::anyhow($this->do_post("http://mixi.jp/atom/tracks")->body())->f("atom:author.atom:uri.value()"));
 }
Пример #10
0
 private final function tableTrEvenodd($src, $name, $counter)
 {
     $tag = Tag::anyhow($src);
     foreach ($tag->in($name) as $tr) {
         $class = $tr->inParam("class");
         if ($class == "even" || $class == "odd") {
             $tr->param("class", "{\$t.evenodd(\$" . $counter . ")}");
             $src = str_replace($tr->plain(), $tr->get(), $src);
         }
     }
     return $src;
 }
Пример #11
0
 private function parse_form()
 {
     $tag = Tag::anyhow($this->body);
     foreach ($tag->in("form") as $key => $formtag) {
         $form = new stdClass();
         $form->name = $formtag->in_param("name", $formtag->in_param("id", $key));
         $form->action = File::absolute($this->url, $formtag->in_param("action", $this->url));
         $form->method = strtolower($formtag->in_param("method", "get"));
         $form->multiple = false;
         $form->element = array();
         foreach ($formtag->in("input") as $count => $input) {
             $obj = new stdClass();
             $obj->name = $input->in_param("name", $input->in_param("id", "input_" . $count));
             $obj->type = strtolower($input->in_param("type", "text"));
             $obj->value = Text::htmldecode($input->in_param("value"));
             $obj->selected = "selected" === strtolower($input->in_param("checked", $input->in_attr("checked")));
             $obj->multiple = false;
             $form->element[] = $obj;
         }
         foreach ($formtag->in("textarea") as $count => $input) {
             $obj = new stdClass();
             $obj->name = $input->in_param("name", $input->in_param("id", "textarea_" . $count));
             $obj->type = "textarea";
             $obj->value = Text::htmldecode($input->value());
             $obj->selected = true;
             $obj->multiple = false;
             $form->element[] = $obj;
         }
         foreach ($formtag->in("select") as $count => $input) {
             $obj = new stdClass();
             $obj->name = $input->in_param("name", $input->in_param("id", "select_" . $count));
             $obj->type = "select";
             $obj->value = array();
             $obj->selected = true;
             $obj->multiple = "multiple" == strtolower($input->param("multiple", $input->attr("multiple")));
             foreach ($input->in("option") as $count => $option) {
                 $op = new stdClass();
                 $op->value = Text::htmldecode($option->in_param("value", $option->value()));
                 $op->selected = "selected" == strtolower($option->in_param("selected", $option->in_attr("selected")));
                 $obj->value[] = $op;
             }
             $form->element[] = $obj;
         }
         $this->form[] = $form;
     }
 }
Пример #12
0
 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;
 }
Пример #13
0
 private final function table_tr_even_odd($src, $name, $even_odd)
 {
     $tag = Tag::anyhow($src);
     foreach ($tag->in($name) as $tr) {
         $class = ' ' . $tr->in_param('class') . ' ';
         if (preg_match('/[\\s](even|odd)[\\s]/', $class, $match)) {
             $tr->param('class', trim(str_replace($match[0], ' {$' . $even_odd . '} ', $class)));
             $src = str_replace($tr->plain(), $tr->get(), $src);
         }
     }
     return $src;
 }