コード例 #1
0
ファイル: Comments.php プロジェクト: bharatm/NDL-VuFind
 /**
  * Get a list of all comments associated with this record.
  *
  * @param string $recordId Record ID
  *
  * @return array
  * @access public
  */
 public function getComments($recordId)
 {
     $recordId = $this->escape($recordId);
     $sql = "SELECT comments.*, user.firstname || user.lastname as fullname, " . "user.email " . "FROM comments " . "RIGHT OUTER JOIN user ON comments.user_id = user.id " . "JOIN comments_record ON comments.id = comments_record.comment_id " . "WHERE comments_record.record_id = '{$recordId}' " . "AND comments.visible = 1 " . "ORDER BY comments.created ";
     $commentList = array();
     $result = $this->query($sql);
     $date = new VuFindDate();
     if ($this->N) {
         while ($this->fetch()) {
             $comment = clone $this;
             $comment->created = $date->convertToDisplayDate('Y-m-d H:i:s', $comment->created) . ' ' . $date->convertToDisplayTime('Y-m-d H:i:s', $comment->created);
             $commentList[] = $comment;
         }
     }
     return $commentList;
 }
コード例 #2
0
ファイル: VuFindDateTest.php プロジェクト: bharatm/NDL-VuFind
 /**
  * Test citation generation
  *
  * @return void
  * @access public
  */
 public function testDates()
 {
     global $configArray;
     // Clear out config array date settings to ensure we always test defaults
     // in code:
     unset($configArray['Site']['displayDateFormat']);
     unset($configArray['Site']['displayTimeFormat']);
     // Build an object to test with:
     $date = new VuFindDate();
     // Try some conversions:
     $this->_checkDate('11-29-1973', $date->convertToDisplayDate('U', 123456879));
     $this->_checkDate('11-29-1973', $date->convertToDisplayDate('m-d-y', '11-29-73'));
     $this->_checkDate('11-29-1973', $date->convertToDisplayDate('m-d-y', '11-29-1973'));
     $this->_checkDate('11-29-1973', $date->convertToDisplayDate('m-d-y H:i', '11-29-73 23:01'));
     $this->_checkDate('23:01', $date->convertToDisplayTime('m-d-y H:i', '11-29-73 23:01'));
     $this->_checkDate('01-02-2001', $date->convertToDisplayDate('m-d-y', '01-02-01'));
     $this->_checkDate('01-02-2001', $date->convertToDisplayDate('m-d-y', '01-02-2001'));
     $this->_checkDate('01-02-2001', $date->convertToDisplayDate('m-d-y H:i', '01-02-01 05:11'));
     $this->_checkDate('05:11', $date->convertToDisplayTime('m-d-y H:i', '01-02-01 05:11'));
     $this->_checkDate('01-02-2001', $date->convertToDisplayDate('Y-m-d', '2001-01-02'));
     $this->_checkDate('01-02-2001', $date->convertToDisplayDate('Y-m-d H:i', '2001-01-02 05:11'));
     $this->_checkDate('05:11', $date->convertToDisplayTime('Y-m-d H:i', '2001-01-02 05:11'));
     $this->_checkDate('01-2001', $date->convertFromDisplayDate('m-Y', '01-02-2001'));
     // Check for proper handling of known problems:
     $bad = $date->convertToDisplayDate('U', 'invalid');
     $this->assertTrue(PEAR::isError($bad));
     $this->assertTrue((bool) stristr($bad->getMessage(), 'failed to parse time string'));
     $bad = $date->convertToDisplayDate('d-m-Y', '31-02-2001');
     $this->assertTrue(PEAR::isError($bad));
     $this->assertTrue((bool) stristr($bad->getMessage(), 'parsed date was invalid'));
 }