ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 9671


Ignore:
Timestamp:
Dec 25, 2008, 5:16:31 AM (11 years ago)
Author:
masabon
Message:

#3187:トピック詳細ページでPagerを使用するように変更、トピック一覧表示ページを追加

Location:
OpenPNE3/plugins/opCommunityTopicPlugin/trunk
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opCommunityTopicPlugin/trunk/apps/pc_frontend/modules/communityTopic/actions/actions.class.php

    r9656 r9671  
    4646
    4747 /**
     48  * Executes index action
     49  *
     50  * @param sfRequest $request A request object
     51  */
     52  public function executeList($request)
     53  {
     54    $this->communityConfigPublicFlag = CommunityConfigPeer::retrieveByNameAndCommunityId('public_flag', $this->communityId);
     55    if ($this->communityConfigPublicFlag && $this->communityConfigPublicFlag->getValue() === 'auth_commu_member')
     56    {
     57      $this->community->checkPrivilegeBelong($this->getUser()->getMemberId());
     58    }
     59
     60    $this->pager = CommunityTopicPeer::getCommunityTopicListPager($this->communityId, $request->getParameter('page'), 20);
     61  }
     62
     63 /**
    4864  * Executes edit action
    4965  *
     
    84100    }
    85101
    86     $this->comments = CommunityTopicCommentPeer::retrieveByCommunityTopicId($this->communityTopicId);
    87102    $this->comment = CommunityTopicCommentPeer::retrieveByPk($request->getParameter('comment_id'));
     103    $this->commentPager = CommunityTopicCommentPeer::getCommunityTopicCommentListPager($this->communityTopicId, $request->getParameter('page'), 20);
    88104
    89105    $this->form = new CommunityTopicCommentForm($this->comment, array('community_topic_id' => $this->communityTopicId));
  • OpenPNE3/plugins/opCommunityTopicPlugin/trunk/apps/pc_frontend/modules/communityTopic/templates/_communityTopicList.php

    r9656 r9671  
     1<?php use_helper('Pagination', 'Date'); ?>
     2
    13<?php
    24$communityConfigPublicFlag = CommunityConfigPeer::retrieveByNameAndCommunityId('public_flag', $community->getId());
     
    810<ul>
    911<?php
    10 $list = CommunityTopicPeer::retrieveByCommunityId($community->getId());
    11 foreach ($list as $value):
     12$communityTopics = CommunityTopicPeer::getTopics($community->getId());
     13if ($communityTopics) :
     14for ($i = 0; $i < 7; $i++) :
    1215?>
    1316<li>
    1417<?php
    15 echo $value->getCreatedAt();
     18echo format_datetime($communityTopics[$i]->getUpdatedAt(), 'f');
    1619echo ' ';
    17 echo link_to($value->getName(), 'communityTopic/detail?id='.$value->getId());
    18 echo ' ';
    19 echo link_to('編集', 'communityTopic/edit?id='.$value->getId());
    20 echo ' ';
    21 echo link_to('削除', 'communityTopic/delete?id='.$value->getId())
     20echo link_to($communityTopics[$i]->getName().'('.$communityTopics[$i]->countCommunityTopicComments().')', 'communityTopic/detail?id='.$communityTopics[$i]->getId());
    2221?>
    2322</li>
    24 <?php endforeach; ?>
    25 <li>もっと読む</li>
    26 <li><?php echo link_to('トピック追加', 'communityTopic/edit?community_id='.$community->getId()) ?></li>
     23<?php endfor; ?>
     24<li><?php echo link_to('もっと読む', 'communityTopic/list?community_id='.$community->getId()); ?></li>
     25<?php endif; ?>
     26<li><?php echo link_to('トピック作成', 'communityTopic/edit?community_id='.$community->getId()); ?></li>
    2727</ul>
    2828</td>
  • OpenPNE3/plugins/opCommunityTopicPlugin/trunk/apps/pc_frontend/modules/communityTopic/templates/detailSuccess.php

    r9656 r9671  
    1 <ul>
    2 <li><?php echo 'community_topic_name = '.$communityTopic->getName(); ?></li>
    3 <li><?php echo 'id = '.$communityTopic->getId(); ?></li>
     1<?php use_helper('Pagination', 'Date'); ?>
    42
    5 <?php foreach ($comments as $comment): ?>
    6 <li>
    7 <?php
    8 echo 'コメント '.$comment->getBody().' 書き込んだ人'.$comment->getMemberId();
    9 echo link_to('編集', 'communityTopic/detail?id='.$communityTopic->getId().'&comment_id='.$comment->getId());
    10 echo ' ';
    11 echo link_to('削除', 'comment/delete?id='.$communityTopic->getId().'&comment_id='.$comment->getId());
    12 ?></li>
     3<div class="dparts topicTitle"><div class="parts">
     4<div class="partsHeading">
     5<h3><?php echo '['.$community->getName().'] '.'トピック' ?></h3>
     6</div>
     7
     8<table><tbody>
     9<tr>
     10<th rowspan=2><?php echo format_datetime($communityTopic->getUpdatedAt(), 'f'); ?></th>
     11<td><?php echo $communityTopic->getName(); ?></td>
     12</tr>
     13<tr>
     14<td class="border-left"><?php echo $communityTopic->getMember()->getName(); ?></td>
     15</tr>
     16<tr>
     17<td class="align-center" colspan=2><?php echo link_to('トピック編集', 'communityTopic/edit?id='.$communityTopic->getId()); ?></td>
     18</tr>
     19</tbody>
     20</table>
     21
     22</div>
     23</div>
     24
     25<?php if ($communityTopic->countCommunityTopicComments()) : ?>
     26<div class="dparts commentList"><div class="parts">
     27<div class="partsHeading">
     28<h3><?php echo '書き込み' ?></h3>
     29</div>
     30
     31<div class="pagerRelative"><p class="number"><?php echo pager_navigation($commentPager, 'communityTopic/detail?page=%d&id='.$communityTopic->getId()); ?></p></div>
     32
     33<table><tbody>
     34<?php foreach ($commentPager->getResults() as $comment): ?>
     35<tr>
     36<th rowspan=2><?php echo format_datetime($comment->getUpdatedAt(), 'f'); ?></th>
     37<td><?php echo $comment->getMember()->getName().' '.link_to('削除', 'comment/delete?id='.$communityTopic->getId().'&comment_id='.$comment->getId()) ?></td>
     38</tr>
     39<tr>
     40<td class="border-left"><?php echo $comment->getBody() ?></td>
     41</tr>
    1342<?php endforeach; ?>
     43</tbody>
     44</table>
    1445
    15 </ul>
     46<div class="pagerRelative"><p class="number"><?php echo pager_navigation($commentPager, 'communityTopic/detail?page=%d&id='.$communityTopic->getId()); ?></p></div>
     47
     48</div>
     49</div>
     50<?php endif; ?>
    1651
    1752<?php
    18 $options = array('form' => array($form));
    19 if ($form->isNew()) {
    20   $title = 'コメント書き込み';
    21   $options['url'] = 'communityTopic/detail?id='.$communityTopic->getId();
    22 } else {
    23   $title = 'コメント編集';
    24   $options['url'] = 'communityTopic/detail?id='.$communityTopic->getId().'&comment_id='.$comment->getId();
    25 }
     53$options = array(
     54  'form' => array($form),
     55  'button' => __('書き込み'),
     56);
     57$title = 'コメント書き込み';
     58$options['url'] = 'communityTopic/detail?id='.$communityTopic->getId();
    2659include_box('formCommunityTopicComment', $title, '', $options);
    2760?>
     61
     62<ul>
     63<li class="align-center"><?php echo link_to('['.$community->getName().']'.'コミュニティトップへ', 'community/home?id='.$community->getId());?></li>
     64</ul>
  • OpenPNE3/plugins/opCommunityTopicPlugin/trunk/lib/model/CommunityTopicCommentPeer.php

    r9548 r9671  
    99    return $list;
    1010  }
     11
     12  public static function getCommunityTopicCommentListPager($communityTopicId, $page = 1, $size = 20) {
     13    $c = new Criteria();
     14    $c->add(self::COMMUNITY_TOPIC_ID, $communityTopicId);
     15
     16    $pager = new sfPropelPager('CommunityTopicComment', $size);
     17    $pager->setCriteria($c);
     18    $pager->setPage($page);
     19    $pager->init();
     20
     21    return $pager;
     22  }
    1123}
  • OpenPNE3/plugins/opCommunityTopicPlugin/trunk/lib/model/CommunityTopicPeer.php

    r9512 r9671  
    33class CommunityTopicPeer extends BaseCommunityTopicPeer
    44{
    5   public static function retrieveByCommunityId($community_id) {
     5  public static function retrieveByCommunityId($communityId) {
    66    $c = new Criteria();
    7     $c->add(self::COMMUNITY_ID, $community_id);
     7    $c->add(self::COMMUNITY_ID, $communityId);
    88    $list = self::doSelect($c);
    99    return $list;
    1010  }
     11
     12  public static function getTopics($communityId) {
     13    $c = new Criteria();
     14    $c->add(self::COMMUNITY_ID, $communityId);
     15    $c->addDescendingOrderByColumn(self::UPDATED_AT);
     16    $list = self::doSelect($c);
     17    return $list;
     18  }
     19
     20  public static function getCommunityTopicListPager($communityId, $page = 1, $size = 20) {
     21    $c = new Criteria();
     22    $c->add(self::COMMUNITY_ID, $communityId);
     23    $c->addDescendingOrderByColumn(self::UPDATED_AT);
     24
     25    $pager = new sfPropelPager('CommunityTopic', $size);
     26    $pager->setCriteria($c);
     27    $pager->setPage($page);
     28    $pager->init();
     29
     30    return $pager;
     31  }
    1132}
Note: See TracChangeset for help on using the changeset viewer.