Development

Changeset 3677

You must first sign up to be able to contribute.

Changeset 3677

Show
Ignore:
Timestamp:
03/27/07 22:59:43 (2 years ago)
Author:
superhaggis
Message:

sfBBPlugin:
* Changed sfBB_lastpost() to use format_datetime().
* Added additional sf_guard_user_profile fixture.
* Dropped divs in favour of tables for the time being.
* Rewrote default.css to accomodate new tabled layout.
* Added getter methods to sfBBPost and sfBBForum model classes.
* Added stripped_title column to sf_bb_post table.
* Added additional rule for @sf_bb_viewforum route.
* Created initial viewForumSuccess template.
* Created basic executeViewForum action.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfBBPlugin/config/config.php

    r3670 r3677  
    3838); 
    3939 
     40sfRouting::getInstance()->prependRoute(   
     41  'sf_bb_viewthread', 
     42  '/sfBB/viewthread/:id/:stripped_title', 
     43  array(   
     44    'module' => 'sfBB', 
     45    'action' => 'viewThread', 
     46  ), 
     47  array() 
     48); 
     49 
    4050sfRouting::getInstance()->prependRoute( 
    4151  'sf_bb_viewpost', 
  • plugins/sfBBPlugin/config/schema.yml

    r3667 r3677  
    2626    id:  
    2727    title: { type: varchar, size: 255 } 
     28    stripped_title: { type: varchar, size: 255 } 
    2829    content: { type: longvarchar } 
    2930    created_at: 
  • plugins/sfBBPlugin/data/fixtures/fixtures.yml

    r3667 r3677  
    3232    nickname: joebloggs 
    3333    date_of_birth: '1976-01-01' 
     34  u2: 
     35    user_id: 2 
     36    nickname: superhaggis 
     37    date_of_birth: '1977-03-23' 
  • plugins/sfBBPlugin/lib/helper/sfBBHelper.php

    r3667 r3677  
    3838  $html .= link_to($user->getNickname(), '@sf_bb_viewuser?username='.$user->getNickname()); 
    3939  $html .= ' on '; 
    40   $html .= format_date($post->getCreatedAt()); 
     40  $html .= format_datetime($post->getCreatedAt()); 
    4141 
    4242  return $html; 
  • plugins/sfBBPlugin/lib/model

    • Property svn:ignore set to
      om/
      map/
  • plugins/sfBBPlugin/lib/model/map/sfBBPostMapBuilder.php

    r3667 r3677  
    3737    $tMap->addColumn('TITLE', 'Title', 'string', CreoleTypes::VARCHAR, false, 255); 
    3838 
     39    $tMap->addColumn('STRIPPED_TITLE', 'StrippedTitle', 'string', CreoleTypes::VARCHAR, false, 255); 
     40 
    3941    $tMap->addColumn('CONTENT', 'Content', 'string', CreoleTypes::LONGVARCHAR, false); 
    4042 
  • plugins/sfBBPlugin/lib/model/om/BasesfBBPost.php

    r3667 r3677  
    1818 
    1919   
     20  protected $stripped_title; 
     21 
     22 
     23   
    2024  protected $content; 
    2125 
     
    7377 
    7478    return $this->title; 
     79  } 
     80 
     81   
     82  public function getStrippedTitle() 
     83  { 
     84 
     85    return $this->stripped_title; 
    7586  } 
    7687 
     
    168179  }  
    169180   
     181  public function setStrippedTitle($v) 
     182  { 
     183 
     184    if ($this->stripped_title !== $v) { 
     185      $this->stripped_title = $v; 
     186      $this->modifiedColumns[] = sfBBPostPeer::STRIPPED_TITLE; 
     187    } 
     188 
     189  }  
     190   
    170191  public function setContent($v) 
    171192  { 
     
    262283      $this->title = $rs->getString($startcol + 1); 
    263284 
    264       $this->content = $rs->getString($startcol + 2); 
    265  
    266       $this->created_at = $rs->getTimestamp($startcol + 3, null); 
    267  
    268       $this->updated_at = $rs->getTimestamp($startcol + 4, null); 
    269  
    270       $this->user_id = $rs->getInt($startcol + 5); 
    271  
    272       $this->forum_id = $rs->getInt($startcol + 6); 
    273  
    274       $this->parent_id = $rs->getInt($startcol + 7); 
     285      $this->stripped_title = $rs->getString($startcol + 2); 
     286 
     287      $this->content = $rs->getString($startcol + 3); 
     288 
     289      $this->created_at = $rs->getTimestamp($startcol + 4, null); 
     290 
     291      $this->updated_at = $rs->getTimestamp($startcol + 5, null); 
     292 
     293      $this->user_id = $rs->getInt($startcol + 6); 
     294 
     295      $this->forum_id = $rs->getInt($startcol + 7); 
     296 
     297      $this->parent_id = $rs->getInt($startcol + 8); 
    275298 
    276299      $this->resetModified(); 
     
    278301      $this->setNew(false); 
    279302 
    280             return $startcol + 8;  
     303            return $startcol + 9;  
    281304    } catch (Exception $e) { 
    282305      throw new PropelException("Error populating sfBBPost object", $e); 
     
    473496        break; 
    474497      case 2: 
     498        return $this->getStrippedTitle(); 
     499        break; 
     500      case 3: 
    475501        return $this->getContent(); 
    476502        break; 
    477       case 3
     503      case 4
    478504        return $this->getCreatedAt(); 
    479505        break; 
    480       case 4
     506      case 5
    481507        return $this->getUpdatedAt(); 
    482508        break; 
    483       case 5
     509      case 6
    484510        return $this->getUserId(); 
    485511        break; 
    486       case 6
     512      case 7
    487513        return $this->getForumId(); 
    488514        break; 
    489       case 7
     515      case 8
    490516        return $this->getParentId(); 
    491517        break; 
     
    502528      $keys[0] => $this->getId(), 
    503529      $keys[1] => $this->getTitle(), 
    504       $keys[2] => $this->getContent(), 
    505       $keys[3] => $this->getCreatedAt(), 
    506       $keys[4] => $this->getUpdatedAt(), 
    507       $keys[5] => $this->getUserId(), 
    508       $keys[6] => $this->getForumId(), 
    509       $keys[7] => $this->getParentId(), 
     530      $keys[2] => $this->getStrippedTitle(), 
     531      $keys[3] => $this->getContent(), 
     532      $keys[4] => $this->getCreatedAt(), 
     533      $keys[5] => $this->getUpdatedAt(), 
     534      $keys[6] => $this->getUserId(), 
     535      $keys[7] => $this->getForumId(), 
     536      $keys[8] => $this->getParentId(), 
    510537    ); 
    511538    return $result; 
     
    530557        break; 
    531558      case 2: 
     559        $this->setStrippedTitle($value); 
     560        break; 
     561      case 3: 
    532562        $this->setContent($value); 
    533563        break; 
    534       case 3
     564      case 4
    535565        $this->setCreatedAt($value); 
    536566        break; 
    537       case 4
     567      case 5
    538568        $this->setUpdatedAt($value); 
    539569        break; 
    540       case 5
     570      case 6
    541571        $this->setUserId($value); 
    542572        break; 
    543       case 6
     573      case 7
    544574        $this->setForumId($value); 
    545575        break; 
    546       case 7
     576      case 8
    547577        $this->setParentId($value); 
    548578        break; 
     
    556586    if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); 
    557587    if (array_key_exists($keys[1], $arr)) $this->setTitle($arr[$keys[1]]); 
    558     if (array_key_exists($keys[2], $arr)) $this->setContent($arr[$keys[2]]); 
    559     if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); 
    560     if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); 
    561     if (array_key_exists($keys[5], $arr)) $this->setUserId($arr[$keys[5]]); 
    562     if (array_key_exists($keys[6], $arr)) $this->setForumId($arr[$keys[6]]); 
    563     if (array_key_exists($keys[7], $arr)) $this->setParentId($arr[$keys[7]]); 
     588    if (array_key_exists($keys[2], $arr)) $this->setStrippedTitle($arr[$keys[2]]); 
     589    if (array_key_exists($keys[3], $arr)) $this->setContent($arr[$keys[3]]); 
     590    if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); 
     591    if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); 
     592    if (array_key_exists($keys[6], $arr)) $this->setUserId($arr[$keys[6]]); 
     593    if (array_key_exists($keys[7], $arr)) $this->setForumId($arr[$keys[7]]); 
     594    if (array_key_exists($keys[8], $arr)) $this->setParentId($arr[$keys[8]]); 
    564595  } 
    565596 
     
    571602    if ($this->isColumnModified(sfBBPostPeer::ID)) $criteria->add(sfBBPostPeer::ID, $this->id); 
    572603    if ($this->isColumnModified(sfBBPostPeer::TITLE)) $criteria->add(sfBBPostPeer::TITLE, $this->title); 
     604    if ($this->isColumnModified(sfBBPostPeer::STRIPPED_TITLE)) $criteria->add(sfBBPostPeer::STRIPPED_TITLE, $this->stripped_title); 
    573605    if ($this->isColumnModified(sfBBPostPeer::CONTENT)) $criteria->add(sfBBPostPeer::CONTENT, $this->content); 
    574606    if ($this->isColumnModified(sfBBPostPeer::CREATED_AT)) $criteria->add(sfBBPostPeer::CREATED_AT, $this->created_at); 
     
    609641    $copyObj->setTitle($this->title); 
    610642 
     643    $copyObj->setStrippedTitle($this->stripped_title); 
     644 
    611645    $copyObj->setContent($this->content); 
    612646 
  • plugins/sfBBPlugin/lib/model/om/BasesfBBPostPeer.php

    r3667 r3677  
    1414 
    1515   
    16   const NUM_COLUMNS = 8
     16  const NUM_COLUMNS = 9
    1717 
    1818   
     
    2727 
    2828   
     29  const STRIPPED_TITLE = 'sf_bb_post.STRIPPED_TITLE'; 
     30 
     31   
    2932  const CONTENT = 'sf_bb_post.CONTENT'; 
    3033 
     
    5053   
    5154  private static $fieldNames = array ( 
    52     BasePeer::TYPE_PHPNAME => array ('Id', 'Title', 'Content', 'CreatedAt', 'UpdatedAt', 'UserId', 'ForumId', 'ParentId', ), 
    53     BasePeer::TYPE_COLNAME => array (sfBBPostPeer::ID, sfBBPostPeer::TITLE, sfBBPostPeer::CONTENT, sfBBPostPeer::CREATED_AT, sfBBPostPeer::UPDATED_AT, sfBBPostPeer::USER_ID, sfBBPostPeer::FORUM_ID, sfBBPostPeer::PARENT_ID, ), 
    54     BasePeer::TYPE_FIELDNAME => array ('id', 'title', 'content', 'created_at', 'updated_at', 'user_id', 'forum_id', 'parent_id', ), 
    55     BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7,
     55    BasePeer::TYPE_PHPNAME => array ('Id', 'Title', 'StrippedTitle', 'Content', 'CreatedAt', 'UpdatedAt', 'UserId', 'ForumId', 'ParentId', ), 
     56    BasePeer::TYPE_COLNAME => array (sfBBPostPeer::ID, sfBBPostPeer::TITLE, sfBBPostPeer::STRIPPED_TITLE, sfBBPostPeer::CONTENT, sfBBPostPeer::CREATED_AT, sfBBPostPeer::UPDATED_AT, sfBBPostPeer::USER_ID, sfBBPostPeer::FORUM_ID, sfBBPostPeer::PARENT_ID, ), 
     57    BasePeer::TYPE_FIELDNAME => array ('id', 'title', 'stripped_title', 'content', 'created_at', 'updated_at', 'user_id', 'forum_id', 'parent_id', ), 
     58    BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8,
    5659  ); 
    5760 
    5861   
    5962  private static $fieldKeys = array ( 
    60     BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Title' => 1, 'Content' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, 'UserId' => 5, 'ForumId' => 6, 'ParentId' => 7, ), 
    61     BasePeer::TYPE_COLNAME => array (sfBBPostPeer::ID => 0, sfBBPostPeer::TITLE => 1, sfBBPostPeer::CONTENT => 2, sfBBPostPeer::CREATED_AT => 3, sfBBPostPeer::UPDATED_AT => 4, sfBBPostPeer::USER_ID => 5, sfBBPostPeer::FORUM_ID => 6, sfBBPostPeer::PARENT_ID => 7, ), 
    62     BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'title' => 1, 'content' => 2, 'created_at' => 3, 'updated_at' => 4, 'user_id' => 5, 'forum_id' => 6, 'parent_id' => 7, ), 
    63     BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7,
     63    BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Title' => 1, 'StrippedTitle' => 2, 'Content' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, 'UserId' => 6, 'ForumId' => 7, 'ParentId' => 8, ), 
     64    BasePeer::TYPE_COLNAME => array (sfBBPostPeer::ID => 0, sfBBPostPeer::TITLE => 1, sfBBPostPeer::STRIPPED_TITLE => 2, sfBBPostPeer::CONTENT => 3, sfBBPostPeer::CREATED_AT => 4, sfBBPostPeer::UPDATED_AT => 5, sfBBPostPeer::USER_ID => 6, sfBBPostPeer::FORUM_ID => 7, sfBBPostPeer::PARENT_ID => 8, ), 
     65    BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'title' => 1, 'stripped_title' => 2, 'content' => 3, 'created_at' => 4, 'updated_at' => 5, 'user_id' => 6, 'forum_id' => 7, 'parent_id' => 8, ), 
     66    BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8,
    6467  ); 
    6568 
     
    118121 
    119122    $criteria->addSelectColumn(sfBBPostPeer::TITLE); 
     123 
     124    $criteria->addSelectColumn(sfBBPostPeer::STRIPPED_TITLE); 
    120125 
    121126    $criteria->addSelectColumn(sfBBPostPeer::CONTENT); 
  • plugins/sfBBPlugin/lib/model/sfBBForum.php

    r3667 r3677  
    1414    parent::setName($name); 
    1515    $this->setStrippedName(sfBBTools::stripText($name)); 
     16  } 
     17 
     18  public function getThreads() 
     19  { 
     20    $c = new Criteria(); 
     21    $c->addDescendingOrderByColumn(sfBBPostPeer::CREATED_AT); 
     22    $c->addJoin(sfGuardUserPeer::ID, sfBBPostPeer::USER_ID, Criteria::LEFT_JOIN); 
     23    $c->add(sfBBPostPeer::PARENT_ID, null); 
     24    return sfBBPostPeer::doSelectJoinsfGuardUser($c); 
    1625  } 
    1726 
  • plugins/sfBBPlugin/lib/model/sfBBPost.php

    r3667 r3677  
    1010class sfBBPost extends BasesfBBPost 
    1111{ 
     12  public function setTitle($title) 
     13  { 
     14    parent::setTitle($title); 
     15    $this->setStrippedTitle(sfBBTools::stripText($title)); 
     16  } 
     17 
     18  public function getNbReplies() 
     19  { 
     20    $c = new Criteria(); 
     21    $c->add(sfBBPostPeer::PARENT_ID, $this->getId()); 
     22    return sfBBPostPeer::doCount($c); 
     23  } 
     24 
     25  public function getNbViews() 
     26  { 
     27 
     28  } 
     29 
     30  public function getLatestReply() 
     31  { 
     32    $c = new Criteria(); 
     33    $c->add(sfBBPostPeer::PARENT_ID, $this->getId()); 
     34    $c->addJoin(sfGuardUserPeer::ID, sfBBPostPeer::USER_ID, Criteria::LEFT_JOIN); 
     35    $c->addDescendingOrderByColumn(sfBBPostPeer::CREATED_AT); 
     36    $c->setLimit(1); 
     37    $post = sfBBPostPeer::doSelectJoinsfGuardUser($c); 
     38    return $post[0]; 
     39  } 
    1240} 
  • plugins/sfBBPlugin/modules/sfBB/actions/actions.class.php

    r3667 r3677  
    3131  public function executeIndex() 
    3232  { 
    33     $this->categories = sfBBCategoryPeer::doSelect(new Criteria()); 
     33    $c = new Criteria(); 
     34    $c->add(sfBBCategoryPeer::IS_LIVE, 1); 
     35    $this->categories = sfBBCategoryPeer::doSelect($c); 
    3436  } 
    3537 
    3638  public function executeViewForum() 
    3739  { 
     40    $c = new Criteria(); 
     41    $c->add(sfBBForumPeer::ID, $this->getRequestParameter('id')); 
     42    $c->add(sfBBForumPeer::IS_LIVE, 1); 
     43    $forum = sfBBForumPeer::doSelectOne($c); 
     44 
     45    $this->forward404Unless($forum instanceof sfBBForum); 
     46 
     47    $this->forum = $forum; 
    3848  } 
    3949 
  • plugins/sfBBPlugin/modules/sfBB/templates/indexSuccess.php

    r3667 r3677  
    55  <div id="category<?php echo $category->getId() ?>" class="category"> 
    66    <p class="category_header"><?php echo $category->getName() ?></p> 
    7     <div id="fora_header"> 
    8       <div id="forum_name">Forum Name</div
    9       <div id="forum_threads">Threads</div
    10       <div id="forum_posts">Posts</div
    11       <div id="forum_recent">Last Post</div
    12     </div
    13     <div id="fora"
     7    <table id="fora"> 
     8      <tr
     9        <td class="forumheader_name">Name</td
     10        <td class="forumheader_threads">Threads</td
     11        <td class="forumheader_posts">Posts</td
     12        <td class="forumheader_recent">Last Post</td
     13      </tr
    1414      <?php foreach ($category->getFora() as $forum): ?> 
    15       <div id="forum<?php echo $forum->getId() ?>" class="forum"
    16         <div class="forum_name"> 
     15      <tr
     16        <td class="forum_name"> 
    1717          <?php echo link_to($forum->getName(), '@sf_bb_viewforum?id='.$forum->getId().'&stripped_name='.$forum->getStrippedName()) ?><br /> 
    18           <?php echo simple_format_text($forum->getDescription()) ?
    19         </div
    20         <div class="forum_threads"><?php echo $forum->getNbThreads() ?></div
    21         <div class="forum_posts"><?php echo $forum->getNbPosts() ?></div
    22         <div class="forum_recent"><?php echo sfBB_lastpost($forum->getNewestPost()) ?></div
    23       </div
     18          <span class="forum_description"><?php echo simple_format_text($forum->getDescription()) ?></span
     19        </td
     20        <td class="forum_threads"><?php echo $forum->getNbThreads() ?></td
     21        <td class="forum_posts"><?php echo $forum->getNbPosts() ?></td
     22        <td class="forum_recent"><?php echo sfBB_lastpost($forum->getNewestPost()) ?></td
     23      </tr
    2424      <?php endforeach ?> 
    25     </div
     25    </table
    2626  </div> 
    2727  <?php endforeach ?> 
  • plugins/sfBBPlugin/modules/sfBB/templates/viewForumSuccess.php

    r3667 r3677  
     1<?php use_helper('sfBB') ?> 
     2<div id="threads"> 
     3  <?php foreach ($forum->getThreads() as $thread): ?> 
     4  <div id="thread<?php echo $thread->getId() ?>" class="thread"> 
     5    <div class="thread_title"> 
     6      <?php echo link_to($thread->getTitle(), '@sf_bb_viewthread?id='.$thread->getId().'&stripped_title='.$thread->getStrippedTitle()) ?><br /> 
     7    </div> 
     8    <div class="thread_replies"><?php echo $thread->getNbReplies() ?></div> 
     9    <div class="thread_recent"><?php echo sfBB_lastpost($thread->getLatestReply()) ?></div> 
     10  </div> 
     11  <?php endforeach ?> 
     12</div> 
  • plugins/sfBBPlugin/web/css/default.css

    r3667 r3677  
    1 div#categories 
     1div#categories, div#threads 
    22{ 
    33  font: 9pt Verdana; 
     
    55  float: left; 
    66  width: 980px; 
    7   background-color: #00ccff
     7  background-color: #bcbcbc
    88} 
    99 
    10 div#categories div.category 
     10div.category 
    1111{ 
    1212  float: left; 
     
    1616} 
    1717 
    18 div#categories div.category p.category_header 
     18p.category_header 
    1919{ 
    2020  padding: 2px; 
    21   background-color: #22eeff
     21  background-color: #cdcdcd
    2222  font-size: 12pt; 
    2323  font-weight: bold; 
    2424} 
    2525 
    26 div#categories div.category div#fora_header 
     26table#fora 
    2727{ 
    28   float: left; 
    29   background-color: #dddddd; 
    3028  padding: 2px; 
    31   width: 970px; 
     29  background-color: #ffffff; 
     30  width: 974px; 
    3231} 
    3332 
    34 div#categories div.category div#fora_header div#forum_name 
     33td.forumheader_name 
    3534{ 
    3635  font-weight: bold; 
    3736  width: 700px; 
    38   float: left
     37  background-color: #dddddd
    3938} 
    4039 
    41 div#categories div.category div#fora_header div#forum_thread
     40td.forumheader_threads, td.forumheader_post
    4241{ 
     42  font-weight: bold; 
     43  text-align: center; 
     44  background-color: #dddddd; 
    4345  width: 50px; 
    44   float: left; 
    45   text-align: center; 
    4646} 
    4747 
    48 div#categories div.category div#fora_header div#forum_posts 
     48td.forumheader_recent 
    4949{ 
    50   width: 50px; 
    51   float: left; 
    52   text-align: center; 
     50  font-weight: bold; 
     51  background-color: #dddddd; 
    5352} 
    5453 
    55 div#categories div.category div#fora_header div#forum_recent 
     54td.forum_name 
    5655{ 
    57   width: 164px
    58   float: left
     56  font-size: 115%
     57  font-weight: bold
    5958} 
    6059 
    61  
    62 div#categories div.category div#fora 
     60td.forum_name span.forum_description 
    6361{ 
    64   padding: 2px; 
    65   float: left; 
    66   background-color: #fafafa; 
    67   width: 970px; 
     62  font-size: 75%; 
     63  font-weight: normal; 
    6864} 
    6965 
    70 div#categories div.category div#fora div.forum 
     66td.forum_threads, td.forum_posts 
    7167{ 
    72   float: left; 
    73   width: 964px; 
    74 } 
    75  
    76 div#categories div.category div#fora div.forum div.forum_name 
    77 { 
    78   float: left; 
    79   background-color: #eeeeee; 
    80   width: 700px; 
    81   height: 32px; 
    82 } 
    83  
    84 div#categories div.category div#fora div.forum div.forum_threads 
    85 { 
    86   float: left; 
    87   width: 50px; 
    8868  font-weight: bold; 
    8969  text-align: center; 
    9070} 
    91  
    92 div#categories div.category div#fora div.forum div.forum_posts 
    93 { 
    94   float: left; 
    95   width: 50px; 
    96   font-weight: bold; 
    97   text-align: center; 
    98 } 
    99  
    100 div#categories div.category div#fora div.forum div.forum_recent 
    101 { 
    102   float: left; 
    103   width: 164px; 
    104 } 
    105  
    106