Example #1
0
 public static function instantiate(User $user, Comment $comment, bool $up = true)
 {
     $instance = new self();
     $instance->user()->associate($user);
     $instance->comment()->associate($comment);
     $instance->post_id = $comment->post_id;
     $instance->up = $up;
     $instance->save();
     if ($up) {
         $comment->increment('ups');
     } else {
         $comment->decrement('ups');
     }
     return $instance;
 }
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());
      * 
      */
 }