Development

Changeset 5066

You must first sign up to be able to contribute.

Changeset 5066

Show
Ignore:
Timestamp:
09/13/07 13:40:22 (6 years ago)
Author:
francois
Message:

sfSimpleForumPlugin Fixed pagination problem when adding a new message

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfSimpleForumPlugin/CHANGELOG

    r5064 r5066  
    11== Trunk == 
    22 
     3 * francois: Fixed page displayed after adding a message doesn't use pagination 
     4 * francois: Added a new getMessage() action 
    35 * francois: Switched icon set to famfamfam as I couldn't find where the sticky one came from 
    46 * francois: Added locked topic feature 
  • plugins/sfSimpleForumPlugin/lib/model/sfSimpleForumPost.php

    r5063 r5066  
    120120  } 
    121121   
     122  public function getPositionInTopic() 
     123  { 
     124    $c = new Criteria(); 
     125    $c->clearSelectColumns(); 
     126    $c->addSelectColumn(sfSimpleForumPostPeer::ID); 
     127    $c->add(sfSimpleForumPostPeer::PARENT_ID, $this->getParentId()); 
     128    $c->addAscendingOrderByColumn(sfSimpleForumPostPeer::CREATED_AT); 
     129    $rs = sfSimpleForumPostPeer::doSelectRS($c); 
     130    $messages = array(); 
     131    while($rs->next()) 
     132    { 
     133      $messages[] = $rs->getInt(1); 
     134    } 
     135 
     136    return array_search($this->getId(), $messages) + 1; 
     137  } 
     138   
    122139  public function incrementViews() 
    123140  { 
  • plugins/sfSimpleForumPlugin/modules/sfSimpleForum/lib/BasesfSimpleForumActions.class.php

    r5064 r5066  
    224224  } 
    225225   
     226  public function executeMessage() 
     227  { 
     228    $post = sfSimpleForumPostPeer::retrieveByPk($this->getRequestParameter('id')); 
     229    $this->forward404Unless($post); 
     230    if($post->isTopic()) 
     231    { 
     232      $this->redirect('sfSimpleForum/topic?id='.$post->getId().'&stripped_title='.$post->getStrippedTitle()); 
     233    } 
     234    else 
     235    { 
     236      $position = $post->getPositionInTopic(); 
     237      $page = ceil(($position + 1) / sfConfig::get('app_sfSimpleForumPlugin_max_per_page', 10)); 
     238      $this->redirect('sfSimpleForum/topic?id='.$post->getParentId().'&stripped_title='.$post->getStrippedTitle().'&page='.$page.'#post'.$post->getId()); 
     239    } 
     240  } 
    226241  // One user 
    227242 
     
    370385    $post->save(); 
    371386     
    372     $this->redirect('sfSimpleForum/topic?id='.$post->getParent()->getId().'&stripped_title='.$post->getParent()->getStrippedTitle()); 
     387    $position = $post->getPositionInTopic(); 
     388    $page = ceil(($position + 1) / sfConfig::get('app_sfSimpleForumPlugin_max_per_page', 10)); 
     389     $this->redirect('sfSimpleForum/topic?id='.$post->getParent()->getId().'&stripped_title='.$post->getParent()->getStrippedTitle().'&page='.$page.'#post'.$post->getId()); 
    373390  } 
    374391   
  • plugins/sfSimpleForumPlugin/modules/sfSimpleForum/templates/_post.php

    r5064 r5066  
    1616      » 
    1717    <?php endif ?> 
    18       <?php echo $post->getTitle() ?
     18      <a name="post<?php echo $post->getId() ?>"><?php echo $post->getTitle() ?></a
    1919    </div> 
    2020    <div class="post_content">