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

Changeset 9853


Ignore:
Timestamp:
Jan 3, 2009, 11:11:46 AM (13 years ago)
Author:
ogawa
Message:

#3209:added routing rules

Location:
OpenPNE3/plugins/opDiaryPlugin/trunk
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/mobile_frontend/modules/diary/templates/_friendDiaryList.php

    r9645 r9853  
    66foreach ($diaryList as $diary)
    77{
    8   $list[] = format_date($diary->getCreatedAt()).' '.link_to($diary->getTitle(), '@diary_by_id?id='.$diary->getId());
     8  $list[] = format_date($diary->getCreatedAt()).' '.link_to($diary->getTitle(), 'diary_show', $diary);
    99}
    1010$moreInfo = array();
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/mobile_frontend/modules/diary/templates/_memberDiaryList.php

    r9645 r9853  
    66foreach ($diaryList as $diary)
    77{
    8   $list[] = format_date($diary->getCreatedAt()).' '.link_to($diary->getTitle(), '@diary_by_id?id='.$diary->getId());
     8  $list[] = format_date($diary->getCreatedAt()).' '.link_to($diary->getTitle(), 'diary_show', $diary);
    99}
    1010$moreInfo = array();
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/mobile_frontend/modules/diary/templates/_myDiaryList.php

    r9645 r9853  
    55foreach ($diaryList as $diary)
    66{
    7   $list[] = format_date($diary->getCreatedAt()).' '.link_to($diary->getTitle(), '@diary_by_id?id='.$diary->getId());
     7  $list[] = format_date($diary->getCreatedAt()).' '.link_to($diary->getTitle(), 'diary_show', $diary);
    88}
    99$moreInfo = array();
    1010if (count($diaryList))
    1111{
    12   $moreInfo[] = link_to(__('More'), 'diary/listMember');
     12  $moreInfo[] = link_to(__('More'), 'diary/listMember?id='.$sf_user->getMemberId());
    1313}
    14 $moreInfo[] = link_to(__('Post a diary'), 'diary/edit');
     14$moreInfo[] = link_to(__('Post a diary'), 'diary_new');
    1515$options = array(
    1616  'title'  => __('Recently Posted Diaries'),
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/mobile_frontend/modules/diary/templates/editSuccess.php

    r9645 r9853  
    11<?php
    2 if ($form->isNew())
    3 {
    4   $title = __('Post a diary');
    5 }
    6 else
    7 {
    8   $title = __('Edit the diary');
    9 }
    10 include_page_title($title);
     2include_page_title(__('Edit the diary'));
    113?>
    124
    135<?php
    146$options = array('form' => array($form));
    15 if ($form->isNew())
    16 {
    17   $options['url'] = 'diary/edit';
    18 }
    19 else
    20 {
    21   $options['url'] = 'diary/edit?id='.$diary->getId();
    22 }
     7$options['url'] = 'diary/update?id='.$diary->getId();
    238$options['button'] = __('Save');
    24 $options['isMultipart'] = true;
    259include_box('formDiary', '', '', $options);
    2610?>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/mobile_frontend/modules/diary/templates/listFriendSuccess.php

    r9752 r9853  
    1212{
    1313  $list[] = format_datetime($diary->getCreatedAt(), 'f').'<br>'
    14            .link_to($diary->getTitle(), '@diary_by_id?id='.$diary->getId())
     14           .link_to($diary->getTitle(), 'diary_show', $diary)
    1515           .'('.$diary->getMember()->getName().')';
    1616}
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/mobile_frontend/modules/diary/templates/listMemberSuccess.php

    r9752 r9853  
    1212{
    1313  $list[] = format_datetime($diary->getCreatedAt(), 'f').'<br>'
    14            .link_to($diary->getTitle(), '@diary_by_id?id='.$diary->getId());
     14           .link_to($diary->getTitle(), 'diary_show', $diary);
    1515}
    1616$options = array(
     
    2828
    2929<?php if ($sf_user->getMemberId() === $member->getId()): ?>
    30 <?php echo link_to(__('Post a diary'), 'diary/edit') ?>
     30<?php echo link_to(__('Post a diary'), 'diary_new') ?>
    3131<?php endif; ?>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/mobile_frontend/modules/diary/templates/listSuccess.php

    r9752 r9853  
    1212{
    1313  $list[] = format_datetime($diary->getCreatedAt(), 'f').'<br>'
    14            .link_to($diary->getTitle(), '@diary_by_id?id='.$diary->getId())
     14           .link_to($diary->getTitle(), 'diary_show', $diary)
    1515           .'('.$diary->getMember()->getName().')';
    1616}
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/mobile_frontend/modules/diary/templates/showSuccess.php

    r9852 r9853  
    44▼<?php echo format_datetime($diary->getCreatedAt(), 'f') ?>
    55<?php if ($diary->getMemberId() === $sf_user->getMemberId()): ?>
    6 [<?php echo link_to(__('Edit'), 'diary/edit?id='.$diary->getId()) ?>][<?php echo link_to(__('Delete'), 'diary/delete?id='.$diary->getId()) ?>]
     6[<?php echo link_to(__('Edit'), 'diary_edit', $diary) ?>][<?php echo link_to(__('Delete'), 'diary/delete?id='.$diary->getId()) ?>]
    77<?php endif; ?><br>
    88
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/_friendDiaryList.php

    r9612 r9853  
    77<ul>
    88<?php foreach ($diaryList as $diary): ?>
    9 <li><?php echo format_date($diary->getCreatedAt()) ?> <?php echo link_to($diary->getTitle(), '@diary_by_id?id='.$diary->getId()) ?></li>
     9<li><?php echo format_date($diary->getCreatedAt()) ?> <?php echo link_to($diary->getTitle(), 'diary_show', $diary) ?></li>
    1010<?php endforeach; ?>
    1111</ul>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/_memberDiaryList.php

    r9612 r9853  
    77<ul>
    88<?php foreach ($diaryList as $diary): ?>
    9 <li><?php echo format_date($diary->getCreatedAt()) ?> <?php echo link_to($diary->getTitle(), '@diary_by_id?id='.$diary->getId()) ?></li>
     9<li><?php echo format_date($diary->getCreatedAt()) ?> <?php echo link_to($diary->getTitle(), 'diary_show', $diary) ?></li>
    1010<?php endforeach; ?>
    1111</ul>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/_myDiaryList.php

    r9612 r9853  
    77<ul>
    88<?php foreach ($diaryList as $diary): ?>
    9 <li><?php echo format_date($diary->getCreatedAt()) ?> <?php echo link_to($diary->getTitle(), '@diary_by_id?id='.$diary->getId()) ?></li>
     9<li><?php echo format_date($diary->getCreatedAt()) ?> <?php echo link_to($diary->getTitle(), 'diary_show', $diary) ?></li>
    1010<?php endforeach; ?>
    1111</ul>
    12 <p><?php echo link_to(__('More'), 'diary/listMember') ?></p>
     12<p><?php echo link_to(__('More'), 'diary/listMember?id='.$sf_user->getMemberId()) ?></p>
    1313<?php endif; ?>
    14 <p><?php echo link_to(__('Post a diary'), 'diary/edit') ?></p>
     14<p><?php echo link_to(__('Post a diary'), 'diary_new') ?></p>
    1515</div></div>
    1616</div></div>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/editSuccess.php

    r9612 r9853  
    11<?php
    22$options = array('form' => array($form));
    3 if ($form->isNew())
    4 {
    5   $title = __('Post a diary');
    6   $options['url'] = 'diary/edit';
    7 }
    8 else
    9 {
    10   $title = __('Edit the diary');
    11   $options['url'] = 'diary/edit?id='.$diary->getId();
    12 }
     3$title = __('Edit the diary');
     4$options['url'] = 'diary/update?id='.$diary->getId();
    135$options['button'] = __('Save');
    146$options['isMultipart'] = true;
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/listFriendSuccess.php

    r9752 r9853  
    88<dl>
    99<dt><?php echo format_datetime($diary->getCreatedAt(), 'f') ?></dt>
    10 <dd><?php echo link_to($diary->getTitle(), '@diary_by_id?id='.$diary->getId()) ?> (<?php echo $diary->getMember()->getName() ?>)</dd>
     10<dd><?php echo link_to($diary->getTitle(), 'diary_show', $diary) ?> (<?php echo $diary->getMember()->getName() ?>)</dd>
    1111</dl>
    1212<?php endforeach; ?>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/listMemberSuccess.php

    r9752 r9853  
    44<div class="partsHeading"><h3><?php echo __('Diaries of %1%', array('%1%' => $member->getName())) ?></h3></div>
    55<?php if ($pager->getNbResults()): ?>
    6 <div class="pagerRelative"><p class="number"><?php echo pager_navigation($pager, 'diary/list?page=%d'); ?></p></div>
     6<div class="pagerRelative"><p class="number"><?php echo pager_navigation($pager, 'diary/listMember?page=%d&id='.$member->getId()); ?></p></div>
    77<?php foreach ($pager->getResults() as $diary): ?>
    88<dl>
    99<dt><?php echo format_datetime($diary->getCreatedAt(), 'f') ?></dt>
    10 <dd><?php echo link_to($diary->getTitle(), '@diary_by_id?id='.$diary->getId()) ?></dd>
     10<dd><?php echo link_to($diary->getTitle(), 'diary_show', $diary) ?></dd>
    1111</dl>
    1212<?php endforeach; ?>
    13 <div class="pagerRelative"><p class="number"><?php echo pager_navigation($pager, 'diary/list?page=%d'); ?></p></div>
     13<div class="pagerRelative"><p class="number"><?php echo pager_navigation($pager, 'diary/listMember?page=%d&id='.$member->getId()); ?></p></div>
    1414<?php else: ?>
    1515<div class="body">
     
    2020
    2121<?php if ($sf_user->getMemberId() === $member->getId()): ?>
    22 <?php echo link_to(__('Post a diary'), 'diary/edit') ?>
     22<?php echo link_to(__('Post a diary'), 'diary_new') ?>
    2323<?php endif; ?>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/listSuccess.php

    r9824 r9853  
    1515<th><?php echo __('Body') ?></th><td><?php echo $diary->getBody() ?></td>
    1616</tr><tr class="operation">
    17 <th><?php echo __('Created at') ?></th><td><span class="text"><?php echo format_datetime($diary->getCreatedAt(), 'f') ?></span> <span class="moreInfo"><?php echo link_to(__('View this diary'), '@diary_by_id?id='.$diary->getId()) ?></span></td>
     17<th><?php echo __('Created at') ?></th><td><span class="text"><?php echo format_datetime($diary->getCreatedAt(), 'f') ?></span> <span class="moreInfo"><?php echo link_to(__('View this diary'), 'diary_show', $diary) ?></span></td>
    1818</tr></tbody></table></div></div>
    1919<?php endforeach; ?>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/showSuccess.php

    r9852 r9853  
    2828<?php if ($diary->getMemberId() === $sf_user->getMemberId()): ?>
    2929<ul>
    30 <li><?php echo link_to(__('Edit this diary'), 'diary/edit?id='.$diary->getId()) ?></li>
    31 <li><?php echo link_to(__('Delete this diary'), 'diary/delete?id='.$diary->getId()) ?></li>
     30<li><?php echo link_to(__('Edit this diary'), 'diary_edit', $diary) ?></li>
     31<li><form action="<?php echo url_for('diary_delete', $diary) ?>" method="post"><input type="submit" value="<?php echo __('Delete this diary') ?>" /></form></li>
    3232</ul>
    3333<?php endif; ?>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/lib/action/opDiaryPluginDiaryActions.class.php

    r9852 r9853  
    1010class opDiaryPluginDiaryActions extends sfActions
    1111{
    12   public function postExecute()
     12  public function preExecute()
    1313  {
    14     if ($this->member instanceof Member)
     14    if (is_callable(array($this->getRoute(), 'getObject')))
    1515    {
    16       $this->setNavigation($this->member->getId());
    17     }
    18     elseif ($this->diary instanceof Diary)
    19     {
    20       $this->setNavigation($this->diary->getMemberId());
     16      $object = $this->getRoute()->getObject();
     17      if ($object instanceof Diary)
     18      {
     19        $this->diary = $object;
     20        $this->setNavigation($this->diary->getMemberId());
     21      }
     22      elseif ($object instanceof Member)
     23      {
     24        $this->member = $object;
     25        $this->setNavigation($this->member->getId());
     26      }
    2127    }
    2228  }
     
    3137  }
    3238
    33  /**
    34   * Executes index action
    35   *
    36   * @param sfRequest $request A request object
    37   */
    38   public function executeIndex($request)
     39  public function executeIndex(sfWebRequest $request)
    3940  {
    4041    $this->forward('diary', 'list');
    4142  }
    4243
    43  /**
    44   * Executes list action
    45   *
    46   * @param sfRequest $request A request object
    47   */
    48   public function executeList($request)
     44  public function executeList(sfWebRequest $request)
    4945  {
    5046    $this->pager = DiaryPeer::getDiaryPager($request->getParameter('page'), 20);
    5147  }
    5248
    53  /**
    54   * Executes listMember action
    55   *
    56   * @param sfRequest $request A request object
    57   */
    58   public function executeListMember($request)
     49  public function executeListMember(sfWebRequest $request)
    5950  {
    6051    $memberId = $request->getParameter('id', $this->getUser()->getMemberId());
     
    6455  }
    6556
    66  /**
    67   * Executes listFriend action
    68   *
    69   * @param sfRequest $request A request object
    70   */
    71   public function executeListFriend($request)
     57  public function executeListFriend(sfWebRequest $request)
    7258  {
    7359    $this->pager = DiaryPeer::getFriendDiaryPager($this->getUser()->getMemberId(), $request->getParameter('page'), 20);
    7460  }
    7561
    76  /**
    77   * Executes show action
    78   *
    79   * @param sfRequest $request A request object
    80   */
    81   public function executeShow($request)
     62  public function executeShow(sfWebRequest $request)
    8263  {
    83     $this->diary = DiaryPeer::retrieveByPk($request->getParameter('id'));
    84     $this->forward404unless($this->diary);
    8564    $this->form = new DiaryCommentForm();
    8665  }
    8766
    88  /**
    89   * Executes edit action
    90   *
    91   * @param sfRequest $request A request object
    92   */
    93   public function executeEdit($request)
     67  public function executeNew(sfWebRequest $request)
    9468  {
    95     $this->diary = DiaryPeer::retrieveByPk($request->getParameter('id'));
    96     if ($this->diary)
     69    $this->form = new DiaryForm();
     70  }
     71
     72  public function executeCreate(sfWebRequest $request)
     73  {
     74    $this->form = new DiaryForm();
     75    $this->processForm($request, $this->form);
     76    $this->setTemplate('new');
     77  }
     78
     79  public function executeEdit(sfWebRequest $request)
     80  {
     81    $this->forward404Unless($this->diary->getMemberId() === $this->getUser()->getMemberId());
     82    $this->form = new DiaryForm($this->diary);
     83  }
     84
     85  public function executeUpdate(sfWebRequest $request)
     86  {
     87    $this->forward404Unless($this->diary->getMemberId() === $this->getUser()->getMemberId());
     88    $this->form = new DiaryForm($this->diary);
     89    $this->processForm($request, $this->form);
     90    $this->setTemplate('edit');
     91  }
     92
     93  protected function processForm(sfWebRequest $request, sfForm $form)
     94  {
     95    $params = $request->getParameter('diary');
     96    $params['member_id'] = $this->getUser()->getMemberId();
     97    $this->form->bind($params, $request->getFiles('diary'));
     98
     99    if ($this->form->isValid())
    97100    {
    98       $this->forward404Unless($this->diary->getMemberId() === $this->getUser()->getMemberId());
    99     }
    100     $this->form = new DiaryForm($this->diary);
     101      $diary = $this->form->save();
    101102
    102     if ($request->isMethod('post'))
    103     {
    104       $params = $request->getParameter('diary');
    105       $params['member_id'] = $this->getUser()->getMemberId();
    106       $this->form->bind($params, $request->getFiles('diary'));
    107 
    108       if ($this->form->isValid())
    109       {
    110         $diary = $this->form->save();
    111 
    112         $this->redirect('diary/show?id='.$diary->getId());
    113       }
     103      $this->redirect($this->generateUrl('diary_show', $diary));
    114104    }
    115105  }
    116106
    117  /**
    118   * Executes delete action
    119   *
    120   * @param sfRequest $request A request object
    121   */
    122   public function executeDelete($request)
     107  public function executeDelete(sfWebRequest $request)
    123108  {
    124109    $diary = DiaryPeer::retrieveByPk($request->getParameter('id'));
     
    130115  }
    131116
    132  /**
    133   * Executes postComment action
    134   *
    135   * @param sfRequest $request A request object
    136   */
    137   public function executePostComment($request)
     117  public function executePostComment(sfWebRequest $request)
    138118  {
    139     $this->forward404Unless($request->isMethod('post'));
    140 
    141     $this->diary = DiaryPeer::retrieveByPk($request->getParameter('id'));
    142     $this->forward404Unless($this->diary);
    143 
    144119    $comment = new DiaryComment();
    145120    $comment->setDiary($this->diary);
     
    152127      $this->form->save();
    153128
    154       $this->redirect('diary/show?id='.$this->diary->getId());
     129      $this->redirect($this->generateUrl('diary_show', $this->diary));
    155130    }
    156131
     
    158133  }
    159134
    160  /**
    161   * Executes deleteComment action
    162   *
    163   * @param sfRequest $request A request object
    164   */
    165   public function executeDeleteComment($request)
     135  public function executeDeleteComment(sfWebRequest $request)
    166136  {
    167137    $diaryComment = DiaryCommentPeer::retrieveByPk($request->getParameter('id'));
    168138    $this->forward404Unless($diaryComment);
    169139    $this->forward404Unless(
    170          $diaryComment->getDiary()->getMemberId() === $this->getUser()->getMemberId()
    171       || $diaryComment->getMemberId() === $this->getUser()->getMemberId());
     140        $diaryComment->getDiary()->getMemberId() === $this->getUser()->getMemberId()
     141        || $diaryComment->getMemberId() === $this->getUser()->getMemberId());
    172142    $diaryComment->delete();
    173143
    174     $this->redirect('diary/show?id='.$diaryComment->getDiaryId());
     144    $this->redirect($this->generateUrl('diary_show', $diaryComment->getDiary()));
    175145  }
    176146}
  • OpenPNE3/plugins/opDiaryPlugin/trunk/lib/opDiaryPluginRouting.class.php

    r9550 r9853  
    1212  {
    1313    $routing = $event->getSubject();
    14     $routing->prependRoute('diary_by_id',
     14    $routing->prependRoute('diary_delete_default',
    1515      new sfRoute(
     16        '/diary/*',
     17        array('module' => 'default', 'action' => 'error')
     18      )
     19    );
     20    $routing->prependRoute('diary_index',
     21      new sfRoute(
     22        '/diary',
     23        array('module' => 'diary', 'action' => 'index')
     24      )
     25    );
     26    $routing->prependRoute('diary_list',
     27      new sfRoute(
     28        '/diary/list',
     29        array('module' => 'diary', 'action' => 'list')
     30      )
     31    );
     32    $routing->prependRoute('diary_list_member',
     33      new sfPropelRoute(
     34        '/diary/listMember/:id',
     35        array('module' => 'diary', 'action' => 'listMember'),
     36        array('id' => '\d+'),
     37        array('model' => 'Member', 'type' => 'object')
     38      )
     39    );
     40    $routing->prependRoute('diary_list_friend',
     41      new sfRoute(
     42        '/diary/listFriend',
     43        array('module' => 'diary', 'action' => 'listFriend')
     44      )
     45    );
     46    $routing->prependRoute('diary_show',
     47      new sfPropelRoute(
    1648        '/diary/:id',
    1749        array('module' => 'diary', 'action' => 'show'),
    18         array('id' => '\d+')
     50        array('id' => '\d+'),
     51        array('model' => 'Diary', 'type' => 'object')
     52      )
     53    );
     54    $routing->prependRoute('diary_new',
     55      new sfRoute(
     56        '/diary/new',
     57        array('module' => 'diary', 'action' => 'new')
     58      )
     59    );
     60    $routing->prependRoute('diary_create',
     61      new sfRoute(
     62        '/diary/create',
     63        array('module' => 'diary', 'action' => 'create'),
     64        array('sf_method' => array('post'))
     65      )
     66    );
     67    $routing->prependRoute('diary_edit',
     68      new sfPropelRoute(
     69        '/diary/edit/:id',
     70        array('module' => 'diary', 'action' => 'edit'),
     71        array('id' => '\d+'),
     72        array('model' => 'Diary', 'type' => 'object')
     73      )
     74    );
     75    $routing->prependRoute('diary_update',
     76      new sfPropelRoute(
     77        '/diary/update/:id',
     78        array('module' => 'diary', 'action' => 'update'),
     79        array('id' => '\d+', 'sf_method' => array('post')),
     80        array('model' => 'Diary', 'type' => 'object')
     81      )
     82    );
     83    // TODO: remove GET method
     84    $routing->prependRoute('diary_delete',
     85      new sfPropelRoute(
     86        '/diary/delete/:id',
     87        array('module' => 'diary', 'action' => 'delete'),
     88        array('id' => '\d+', 'sf_method' => array('get', 'post')),
     89        array('model' => 'Diary', 'type' => 'object')
     90      )
     91    );
     92    $routing->prependRoute('diary_post_comment',
     93      new sfPropelRoute(
     94        '/diary/postComment/:id',
     95        array('module' => 'diary', 'action' => 'postComment'),
     96        array('id' => '\d+', 'sf_method' => array('post')),
     97        array('model' => 'Diary', 'type' => 'object')
     98      )
     99    );
     100    // TODO: remove GET method
     101    $routing->prependRoute('diary_delete_comment',
     102      new sfPropelRoute(
     103        '/diary/deleteComment/:id',
     104        array('module' => 'diary', 'action' => 'deleteComment'),
     105        array('id' => '\d+', 'sf_method' => array('get', 'post')),
     106        array('model' => 'DiaryComment', 'type' => 'object')
    19107      )
    20108    );
Note: See TracChangeset for help on using the changeset viewer.