Show
Ignore:
Timestamp:
09/06/08 23:52:41 (4 months ago)
Author:
dmondark
Message:

090508-dom: Porting add_comments and get_comments. Comments feeds are now functional.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/090508-dom/system/classes/atomhandler.php

    r2453 r2454  
    169169    public function add_posts($xml, $posts) 
    170170    { 
    171         //TODO:Is this the best way to retreive the feed element? : 
    172         $elements= $xml->getElementsByTagName( 'feed' ); 
    173         $feed= $elements->item(0); 
    174          
     171        $feed= $xml->getElementsByTagName( 'feed' )->item(0); 
    175172        foreach ( $posts as $post ) { 
    176173            $user= User::get_by_id( $post->user_id ); 
     
    220217    public function add_comments($xml, $comments) 
    221218    { 
     219        $feed= $xml->getElementsByTagName( 'feed' )->item(0); 
    222220        foreach ( $comments as $comment ) { 
    223             $content= ( $this->is_auth() ) ? htmlspecialchars( $comment->content ) : htmlspecialchars( $comment->content_atom ); 
    224  
    225             $item= $xml->addChild( 'entry' ); 
    226             $title= $item->addChild( 'title', htmlspecialchars( sprintf( _t( '%1$s on "%2$s"' ), $comment->name, $comment->post->title ) ) ); 
    227  
    228             $link= $item->addChild( 'link' ); 
    229             $link->addAttribute( 'rel', 'alternate' ); 
    230             $link->addAttribute( 'href', $comment->post->permalink . '#comment-' . $comment->id ); 
    231  
    232             $author= $item->addChild( 'author' ); 
    233             $author_name= $author->addChild( 'name', htmlspecialchars( $comment->name ) ); 
    234  
    235             $id= $item->addChild( 'id', $comment->post->guid . '/' . $comment->id ); 
    236  
    237             $updated= $item->addChild( 'updated', date( 'c', strtotime( $comment->date ) ) ); 
    238  
    239             $content= $item->addChild( 'content', $content ); 
    240             $content->addAttribute( 'type', 'html' ); 
     221            $content= ( $this->is_auth() ) ?  $comment->content : $comment->content_atom; 
     222 
     223            $item= $feed->appendChild( $xml->createElement( 'entry' ) ); 
     224            $title= $item->appendChild( $xml->createElement( 'title' ) ); 
     225            $title->appendChild( $xml->createTextNode( sprintf( _t( '%1$s on "%2$s"' ), $comment->name, $comment->post->title ) ) ); 
     226 
     227            $link= $item->appendChild( $xml->createElement( 'link' ) ); 
     228            $link->setAttribute( 'rel', 'alternate' ); 
     229            $link->setAttribute( 'href', $comment->post->permalink . '#comment-' . $comment->id ); 
     230 
     231            $author= $item->appendChild( $xml->createElement( 'author' ) ); 
     232            $author_name= $author->appendChild( $xml->createElement( 'name' ) ); 
     233            $author_name->appendChild( $xml->createTextNode( $comment->name ) ); 
     234 
     235            $id= $item->appendChild( $xml->createElement('id', $comment->post->guid . '/' . $comment->id ) ); 
     236 
     237            $updated= $item->appendChild( $xml->createElement( 'updated', date( 'c', strtotime( $comment->date ) ) ) ); 
     238 
     239            $comment_content= $item->appendChild( $xml->createElement( 'content' ) ); 
     240            $comment_content->setAttribute( 'type', 'html' ); 
     241            $comment_content->appendChild( $xml->createTextNode( $content ) ); 
    241242            Plugins::act( 'atom_add_comment', $item, $comment ); 
    242243        } 
     
    479480 
    480481        Plugins::act( 'atom_get_comments', $xml, $params, $this->handler_vars ); 
    481         $xml= $xml->asXML(); 
     482        $xml= $xml->saveXML(); 
    482483 
    483484        ob_clean();