Changeset 7

Show
Ignore:
Timestamp:
06/01/06 12:16:40 (6 years ago)
Author:
francois
Message:

refactored sidebar module and added latest comments in sidebar (+feed)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/apps/snippets/config/app.yml

    r2 r7  
    55  list_size:      100 
    66  feed_size:      10 
     7  sidebar_comments: 5 
  • trunk/apps/snippets/config/routing.yml

    r2 r7  
    22  url:   /snippet/:id 
    33  param: { module: snippet, action: show } 
     4  requirements: { id: ^\d+$ } 
     5 
     6snippet_by_comment: 
     7  url:   /snippet/comment/:id 
     8  param: { module: snippet, action: showByComment } 
    49  requirements: { id: ^\d+$ } 
    510 
  • trunk/apps/snippets/modules/rss/actions/actions.class.php

    r2 r7  
    6868  } 
    6969 
     70  public function executeComments() 
     71  { 
     72    $feed = sfFeed::newInstance('atom1'); 
     73    
     74    $feed->setTitle('Latest comments'); 
     75    $feed->setLink('@homepage'); 
     76    $feed->setAuthorEmail('noreply@symfony-project.com'); 
     77    $feed->setAuthorName('Symfony'); 
     78    
     79    $comments = SnippetCommentPeer::getLatests(sfConfig::get('app_feed_size'));; 
     80    
     81    $feed->setFeedItemsRouteName('@snippet_by_comment'); 
     82    $feed->setItems($comments); 
     83    
     84    $this->feed = $feed; 
     85  } 
     86 
    7087} 
    7188 
  • trunk/apps/snippets/modules/snippet/actions/actions.class.php

    r2 r7  
    7676    $this->comments = $this->snippet->getSnippetComments(); 
    7777  } 
     78   
     79  public function executeShowByComment() 
     80  { 
     81    $this->snippet = SnippetSnippetPeer::retrieveByComment($this->getRequestParameter('id')); 
     82    $this->forward404Unless($this->snippet); 
     83 
     84    $this->comments = $this->snippet->getSnippetComments(); 
     85  }   
    7886 
    7987  public function executeDelete() 
  • trunk/apps/snippets/modules/snippet/config/view.yml

    r2 r7  
    33  javascripts: [/sf/js/prototype/prototype, vote] 
    44 
     5showByCommentSuccess: 
     6  template: show 
     7 
    58listSuccess: 
    69  components: 
    7     sidebar:   [tag, listAll] 
     10    sidebar:   [sidebar, listAll] 
    811 
    912listByTagSuccess: 
    1013  components: 
    11     sidebar:   [tag, listRelated] 
     14    sidebar:   [sidebar, listRelated] 
    1215 
    1316previewSuccess: 
  • trunk/lib/model/SnippetCommentPeer.php

    r2 r7  
    2121class SnippetCommentPeer extends BaseSnippetCommentPeer { 
    2222 
     23  public function getLatests($max) 
     24  { 
     25    $c = new Criteria(); 
     26    $c->addDescendingOrderByColumn(self::CREATED_AT); 
     27    $c->setLimit($max); 
     28    return self::doSelect($c);  
     29  } 
     30 
    2331} // SnippetCommentPeer 
  • trunk/lib/model/SnippetSnippetPeer.php

    r2 r7  
    3636 
    3737    return $pager; 
     38  } 
     39 
     40  public static function retrieveByComment($comment_id) 
     41  { 
     42    $c = new Criteria(); 
     43    $c->add(SnippetCommentPeer::ID, $comment_id); 
     44    $c->addJoin(self::ID, SnippetCommentPeer::SNIPPET_ID); 
     45 
     46    return self::doSelectOne($c); 
    3847  } 
    3948