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

Changeset 10108


Ignore:
Timestamp:
Jan 13, 2009, 2:00:25 AM (11 years ago)
Author:
ogawa
Message:

#3413:added a diary calendar to sidemenu

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

Legend:

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

    r10011 r10108  
    2020  public function executeSidemenu()
    2121  {
     22    // Calendar
     23    if (!($this->year && $this->month))
     24    {
     25      $this->year = (int)date('Y');
     26      $this->month = (int)date('m');;
     27    }
     28
     29    $this->calendar = new Calendar_Month_Weekdays($this->year, $this->month, 0);
     30    $this->calendar->build();
     31
     32    $this->calendarDiaryDays = DiaryPeer::getMemberDiaryDays($this->member->getId(), $this->getUser()->getMemberId(), $this->year, $this->month);
    2233  }
    2334}
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/_sidemenu.php

    r9870 r10108  
    1 <?php echo __('Diary of %1%', array('%1%' => $member->getName())) ?>
     1<?php use_helper('opDiary') ?>
     2
     3<div class="parts item calendar">
     4<div class="partsHeading"><h3>
     5<?php if ($_m = $calendar->prevMonth('array')): ?>
     6  <?php echo link_to('&lt;&lt;', '@diary_list_member_year_month?id='.$member->getId().'&year='.$_m['year'].'&month='.$_m['month']) ?>
     7<?php endif; ?>
     8  <?php $_m = $calendar->thisMonth('array'); echo op_diary_format_date(sprintf('%04d-%02d-01', $_m['year'], $_m['month']), 'XCalendarMonth') ?>
     9<?php if ($_m = $calendar->nextMonth('array')): ?>
     10  <?php echo link_to('&gt;&gt;', '@diary_list_member_year_month?id='.$member->getId().'&year='.$_m['year'].'&month='.$_m['month']) ?>
     11<?php endif; ?>
     12</h3></div>
     13<table class="calendar"><tbody>
     14<tr>
     15<th class="sun"><?php echo format_date('Sun', 'EE') ?></th>
     16<th class="mon"><?php echo format_date('Mon', 'EE') ?></th>
     17<th class="tue"><?php echo format_date('Tue', 'EE') ?></th>
     18<th class="wed"><?php echo format_date('Wed', 'EE') ?></th>
     19<th class="thu"><?php echo format_date('Thu', 'EE') ?></th>
     20<th class="fri"><?php echo format_date('Fri', 'EE') ?></th>
     21<th class="sat"><?php echo format_date('Sat', 'EE') ?></th>
     22</tr>
     23<?php
     24while ($day = $calendar->fetch())
     25{
     26  if ($day->isFirst())
     27  {
     28    echo '<tr>';
     29  }
     30
     31  echo '<td>';
     32  if (!$day->isEmpty())
     33  {
     34    if (!empty($calendarDiaryDays[$day->thisDay()]))
     35    {
     36      echo link_to($day->thisDay(), '@diary_list_member_year_month_day?id='.$member->getId().'&year='.$year.'&month='.$month.'&day='.$day->thisDay());
     37    }
     38    else
     39    {
     40      echo $day->thisDay();
     41    }
     42  }
     43  echo '</td>';
     44
     45  if ($day->isLast())
     46  {
     47    echo '</tr>';
     48  }
     49}
     50?>
     51</tbody></table>
     52</div>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/listMemberSuccess.php

    r10102 r10108  
    22
    33<?php decorate_with('layoutB') ?>
    4 <?php slot('op_sidemenu', get_component('diary', 'sidemenu', array('member' => $member))) ?>
     4<?php slot('op_sidemenu', get_component('diary', 'sidemenu', array('member' => $member, 'year' => $year, 'month' => $month))) ?>
    55
    66<div class="dparts recentList"><div class="parts">
    7 <div class="partsHeading"><h3><?php echo __('Diaries of %1%', array('%1%' => $member->getName())) ?></h3></div>
     7<div class="partsHeading"><h3><?php echo __('Diaries of %1%', array('%1%' => $member->getName())) ?><?php if ($year && $month): ?> (<?php echo op_diary_format_date(sprintf('%04d-%02d-%02d', $year, $month, ($day) ? $day : 1), ($day) ? 'D' : 'XCalendarMonth') ?>)<?php endif; ?></h3></div>
    88<?php if ($pager->getNbResults()): ?>
    99<div class="pagerRelative"><p class="number"><?php echo pager_navigation($pager, 'diary/listMember?page=%d&id='.$member->getId()); ?></p></div>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/apps/pc_frontend/modules/diary/templates/showSuccess.php

    r10097 r10108  
    22
    33<?php decorate_with('layoutB') ?>
    4 <?php slot('op_sidemenu', get_component('diary', 'sidemenu', array('member' => $member))) ?>
     4<?php slot('op_sidemenu', get_component('diary', 'sidemenu', array('member' => $member, 'year' => $diary->getCreatedAt('Y'), 'month' => $diary->getCreatedAt('n')))) ?>
    55
    66<?php /* {{{ diaryDetailBox */ ?>
  • OpenPNE3/plugins/opDiaryPlugin/trunk/lib/action/opDiaryPluginActions.class.php

    r10063 r10108  
    4949  {
    5050    $this->setNavigation($this->member);
     51
     52    if ($this->pager instanceof sfPager)
     53    {
     54      $this->pager->init();
     55    }
    5156  }
    5257
  • OpenPNE3/plugins/opDiaryPlugin/trunk/lib/action/opDiaryPluginDiaryActions.class.php

    r10068 r10108  
    3030  public function executeListMember(sfWebRequest $request)
    3131  {
    32     $this->pager = DiaryPeer::getMemberDiaryPager($this->member->getId(), $request->getParameter('page'), 20, $this->getUser()->getMemberId());
     32    $this->year  = (int)$request->getParameter('year');
     33    $this->month = (int)$request->getParameter('month');
     34    $this->day   = (int)$request->getParameter('day');
     35
     36    if ($this->year && $this->month)
     37    {
     38      $this->forward404Unless(checkdate($this->month, ($this->day) ? $this->day : 1, $this->year), 'Invalid date format');
     39    }
     40
     41    $this->pager = DiaryPeer::getMemberDiaryPager($this->member->getId(), $request->getParameter('page'), 20, $this->getUser()->getMemberId(), $this->year, $this->month, $this->day);
    3342  }
    3443
  • OpenPNE3/plugins/opDiaryPlugin/trunk/lib/helper/opDiaryHelper.php

    r10075 r10108  
    4646      {
    4747        case 'ja_JP':
    48           $format = "yyyy/MM/dd HH:mm";
     48          $format = 'yyyy/MM/dd HH:mm';
    4949          break;
    5050        default:
     
    5757      {
    5858        case 'ja_JP':
    59           $format = "yyyy年MM月dd日 HH:mm";
     59          $format = 'yyyy年MM月dd日 HH:mm';
    6060          break;
    6161        default:
     
    7272        default:
    7373          $format = 'f';
     74          break;
     75      }
     76      break;
     77    case 'XCalendarMonth':
     78      switch ($culture)
     79      {
     80        case 'ja_JP':
     81          $format = 'yyyy年M月';
     82          break;
     83        default:
     84          $format = 'MMMM yyyy';
    7485          break;
    7586      }
  • OpenPNE3/plugins/opDiaryPlugin/trunk/lib/model/DiaryPeer.php

    r10076 r10108  
    5050  }
    5151
    52   public static function getMemberDiaryList($memberId, $limit = 5, $myMemberId = null, $publicFlag = null)
    53   {
    54     $criteria = self::getOrderdCriteria();
    55     $criteria->add(self::MEMBER_ID, $memberId);
    56     self::addPublicFlagCriteria($criteria, self::getPublicFlagByMemberId($memberId, $myMemberId, $publicFlag));
     52  public static function getMemberDiaryList($memberId, $limit = 5, $myMemberId = null)
     53  {
     54    $criteria = self::getOrderdCriteria();
     55    self::addMemberCriteria($criteria, $memberId, $myMemberId);
    5756    $criteria->setLimit($limit);
    5857
     
    6059  }
    6160
    62   public static function getMemberDiaryPager($memberId, $page = 1, $size = 20, $myMemberId = null, $publicFlag = null)
    63   {
    64     $criteria = self::getOrderdCriteria();
    65     $criteria->add(self::MEMBER_ID, $memberId);
    66     self::addPublicFlagCriteria($criteria, self::getPublicFlagByMemberId($memberId, $myMemberId, $publicFlag));
     61  public static function getMemberDiaryPager($memberId, $page = 1, $size = 20, $myMemberId = null, $year = null, $month = null, $day = null)
     62  {
     63    $criteria = self::getOrderdCriteria();
     64    self::addMemberCriteria($criteria, $memberId, $myMemberId);
     65
     66    if ($year && $month)
     67    {
     68      self::addDateCriteria($criteria, $year, $month, $day);
     69    }
    6770
    6871    return self::getPager($criteria, $page, $size);
     72  }
     73
     74  public static function getMemberDiaryDays($memberId, $myMemberId, $year, $month)
     75  {
     76    $days = array();
     77
     78    $criteria = new Criteria();
     79    self::addMemberCriteria($criteria, $memberId, $myMemberId);
     80    self::addDateCriteria($criteria, $year, $month);
     81    $criteria->clearSelectColumns()->addSelectColumn(self::CREATED_AT);
     82
     83    $stmt = self::doSelectStmt($criteria);
     84    while ($row = $stmt->fetch(PDO::FETCH_NUM))
     85    {
     86      $day = date('j', strtotime($row[0]));
     87      $days[$day] = true;
     88    }
     89    return $days;
    6990  }
    7091
     
    91112    $pager->setCriteria($criteria);
    92113    $pager->setPage($page);
    93     $pager->init();
    94114
    95115    return $pager;
     
    100120    $criteria = new Criteria();
    101121    $criteria->addDescendingOrderByColumn(self::CREATED_AT);
    102    
     122
    103123    return $criteria;
     124  }
     125
     126  protected static function addMemberCriteria(Criteria $criteria, $memberId, $myMemberId)
     127  {
     128    $criteria->add(self::MEMBER_ID, $memberId);
     129    self::addPublicFlagCriteria($criteria, self::getPublicFlagByMemberId($memberId, $myMemberId));
    104130  }
    105131
     
    110136    $criteria->add(self::MEMBER_ID, $friendIds, Criteria::IN);
    111137    self::addPublicFlagCriteria($criteria, self::PUBLIC_FLAG_FRIEND);
    112 
    113     return $criteria;
    114138  }
    115139
     
    118142    if ($flag === self::PUBLIC_FLAG_PRIVATE)
    119143    {
    120       return $criteria;
     144      return;
    121145    }
    122146
     
    130154      $criteria->add(self::PUBLIC_FLAG, $flags, Criteria::IN);
    131155    }
    132 
    133     return $criteria;
     156  }
     157
     158  protected static function addDateCriteria(Criteria $criteria, $year, $month, $day = null)
     159  {
     160    if ($day)
     161    {
     162      $begin = mktime(0, 0, 0, $month, $day, $year);
     163      $end   = mktime(0, 0, 0, $month, $day+1, $year);
     164    }
     165    else
     166    {
     167      $begin = mktime(0, 0, 0, $month, 1, $year);
     168      $end   = mktime(0, 0, 0, $month+1, 1, $year);
     169    }
     170
     171    $criteria->add(self::CREATED_AT, $begin, Criteria::GREATER_EQUAL);
     172    $criteria->addAnd(self::CREATED_AT, $end, Criteria::LESS_THAN);
    134173  }
    135174
  • OpenPNE3/plugins/opDiaryPlugin/trunk/lib/opDiaryPluginRouting.class.php

    r10063 r10108  
    3535        array('module' => 'diary', 'action' => 'listMember'),
    3636        array('id' => '\d+'),
     37        array('model' => 'Member', 'type' => 'object')
     38      ),
     39      'diary_list_member_year_month' => new sfPropelRoute(
     40        '/diary/listMember/:id/:year/:month',
     41        array('module' => 'diary', 'action' => 'listMember'),
     42        array('id' => '\d+', 'year' => '[12][0-9]{3}', 'month' => '(0?[1-9])|(1[0-2])'),
     43        array('model' => 'Member', 'type' => 'object')
     44      ),
     45      'diary_list_member_year_month_day' => new sfPropelRoute(
     46        '/diary/listMember/:id/:year/:month/:day',
     47        array('module' => 'diary', 'action' => 'listMember'),
     48        array('id' => '\d+', 'year' => '[12][0-9]{3}', 'month' => '(0?[1-9])|(1[0-2])', 'day' => '(0?[1-9])|([12][0-9])|(3[01])'),
    3749        array('model' => 'Member', 'type' => 'object')
    3850      ),
Note: See TracChangeset for help on using the changeset viewer.