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

Changeset 9527


Ignore:
Timestamp:
Dec 9, 2008, 10:59:10 PM (11 years ago)
Author:
ogawa
Message:

#3209:implemented basic actions

Location:
OpenPNE3/plugins/opDiaryPlugin/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/actions/actions.class.php

    r9524 r9527  
    2727  public function executeList($request)
    2828  {
     29    $this->pager = DiaryPeer::retrieveDiaryPager($request->getParameter('page'), 20);
    2930  }
    3031
     
    3637  public function executeShow($request)
    3738  {
     39    $this->diary = DiaryPeer::retrieveByPk($request->getParameter('id'));
     40    $this->forward404Unless($this->diary);
    3841  }
    3942
     
    4548  public function executeEdit($request)
    4649  {
     50    $this->diary = DiaryPeer::retrieveByPk($request->getParameter('id'));
     51    $this->form = new DiaryForm($this->diary);
     52
     53    if ($request->isMethod('post'))
     54    {
     55      $params = $request->getParameter('diary');
     56      $params['member_id'] = $this->getUser()->getMemberId();
     57      $this->form->bind($params);
     58
     59      if ($this->form->isValid())
     60      {
     61        $diary = $this->form->save();
     62        $this->redirect('diary/show?id='.$diary->getId());
     63      }
     64    }
    4765  }
    4866
     
    5472  public function executeDelete($request)
    5573  {
     74    $diary = DiaryPeer::retrieveByPk($request->getParameter('id'));
     75    $this->forward404Unless($diary);
     76    $this->redirectUnless($diary->getMemberId() === $this->getUser()->getMemberId(), '@homepage');
     77
     78    $diary->delete();
    5679    $this->redirect('diary/list');
    5780  }
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/editSuccess.php

    r9524 r9527  
    1 edit diary
     1<?php
     2$options = array('form' => array($form));
     3if ($form->isNew())
     4{
     5  $title = '日記を作成する';
     6  $options['url'] = 'diary/edit';
     7}
     8else
     9{
     10  $title = '日記を編集する';
     11  $options['url'] = 'diary/edit?id='.$diary->getId();
     12}
     13$options['button'] = '確定';
     14include_box('formDiary', $title, '', $options);
     15?>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/listSuccess.php

    r9524 r9527  
    1 list diary
     1<?php use_helper('Pagination', 'Date'); ?>
     2
     3<div class="dparts searchResultList"><div class="parts">
     4<div class="partsHeading"><h3>最新日記</h3></div>
     5<?php if ($pager->getNbResults()): ?>
     6<div class="pagerRelative"><p class="number"><?php echo pager_navigation($pager, 'diary/list?page=%d'); ?></p></div>
     7<div class="block">
     8<?php foreach ($pager->getResults() as $diary): ?>
     9<div class="ditem"><div class="item"><table><tbody><tr>
     10<td rowspan="4" class="photo"></td>
     11<th>ニックネーム</th><td><?php echo $diary->getMember()->getName() ?></td>
     12</tr><tr>
     13<th>タイトル</th><td><?php echo $diary->getTitle() ?></td>
     14</tr><tr>
     15<th>本文</th><td><?php echo $diary->getBody() ?></td>
     16</tr><tr class="operation">
     17<th>作成日時</th><td><span class="text"><?php echo format_datetime($diary->getCreatedAt(), 'f') ?></span> <span class="moreInfo"><?php echo link_to('詳細を見る', 'diary/show?id='.$diary->getId()) ?></span></td>
     18</tr></tbody></table></div></div>
     19<?php endforeach; ?>
     20</div>
     21<div class="pagerRelative"><p class="number"><?php echo pager_navigation($pager, 'diary/list?page=%d'); ?></p></div>
     22<?php else: ?>
     23<div class="body">
     24日記はまだありません
     25</div>
     26<?php endif; ?>
     27</div></div>
     28
     29<?php echo link_to('日記を作成する', 'diary/edit') ?>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/showSuccess.php

    r9524 r9527  
    1 show diary
     1<?php use_helper('Date') ?>
     2
     3<div class="dparts diaryDetailBox"><div class="parts">
     4<div class="partsHeading"><h3><?php echo $diary->getMember()->getName() ?>さんの日記</h3>
     5<p class="public">(全員に公開)</p></div>
     6<dl>
     7<dt><?php echo format_datetime($diary->getCreatedAt(), 'f') ?></dt>
     8<dd>
     9<div class="title">
     10<p class="heading"><?php echo $diary->getTitle(); ?></p>
     11</div>
     12<div class="body">
     13<?php echo nl2br($diary->getBody()) ?>
     14</div>
     15</dd>
     16</dl>
     17</div></div>
     18
     19<?php echo link_to('この日記を削除する', 'diary/delete?id='.$diary->getId()) ?>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/lib/form/DiaryForm.class.php

    r9522 r9527  
    44 * Diary form.
    55 *
    6  * @package    ##PROJECT_NAME##
     6 * @package    OpenPNE
    77 * @subpackage form
    8  * @author     ##AUTHOR_NAME##
    9  * @version    SVN: $Id: sfPropelFormTemplate.php 10377 2008-07-21 07:10:32Z dwhittle $
     8 * @author     Rimpei Ogawa <ogawa@tejimaya.com>
    109 */
    1110class DiaryForm extends BaseDiaryForm
     
    1312  public function configure()
    1413  {
     14    unset($this->widgetSchema['member_id']);
     15    $this->widgetSchema['title'] = new sfWidgetFormInput();
     16
     17    unset($this['created_at']);
     18    unset($this['updated_at']);
    1519  }
    1620}
  • OpenPNE3/plugins/opDiaryPlugin/trunk/lib/model/DiaryPeer.php

    r9522 r9527  
    33class DiaryPeer extends BaseDiaryPeer
    44{
     5  public static function retrieveDiaryPager($page = 1, $size = 20)
     6  {
     7    $c = new Criteria();
     8    $c->addDescendingOrderByColumn(DiaryPeer::CREATED_AT);
     9
     10    $pager = new sfPropelPager('Diary', $size);
     11    $pager->setCriteria($c);
     12    $pager->setPage($page);
     13    $pager->init();
     14
     15    return $pager;
     16  }
    517}
Note: See TracChangeset for help on using the changeset viewer.