[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/dao/customfields/customfieldvalue.class.php" ); 4 5 /** 6 * offers methods for dealing with custom fields that represent dates 7 * 8 * \ingroup DAO 9 */ 10 class CustomFieldDateValue extends CustomFieldValue 11 { 12 var $_timestamp; 13 14 /** 15 * constructor 16 * 17 * @see CustomFieldValue 18 */ 19 function CustomFieldDateValue( $fieldId, $fieldValue, $articleId, $blogId, $id = -1 ) 20 { 21 $this->CustomFieldValue( $fieldId, $fieldValue, $articleId, $blogId, $id ); 22 23 $this->setValue( $fieldValue ); 24 } 25 26 /** 27 * returns a Timestamp object based on what we have in the field. If the string in the 28 * field does not represent a valid date, we might get unexpected results... 29 * 30 * @return a Timestamp object 31 */ 32 function getDateObject() 33 { 34 return( $this->_timestamp ); 35 } 36 37 /** 38 * formats the date accordingly 39 * 40 * @param value 41 */ 42 function setValue( $value ) 43 { 44 lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" ); 45 46 $this->_timestamp = new Timestamp(); 47 $dateTimeParts = explode(" ", $value ); 48 $dateParts = explode( "/", $dateTimeParts[0] ); 49 $timeParts = explode( ":",$dateTimeParts[1] ); 50 $this->_timestamp->setDay( $dateParts[0] ); 51 $this->_timestamp->setMonth( $dateParts[1] ); 52 $this->_timestamp->setYear( $dateParts[2] ); 53 $this->_timestamp->setHour( $timeParts[0] ); 54 $this->_timestamp->setMinutes( $timeParts[1] ); 55 56 parent::setValue( $value ); 57 58 return true; 59 } 60 61 /** 62 * shortuct for formatting the date in the same way that it is expected by 63 * the "date picker" javascript calendar 64 * 65 * @return a string 66 */ 67 function getDateFormatted() 68 { 69 lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" ); 70 $locale = Locales::getLocale( "en_UK" ); 71 72 $dateFormatted = $locale->formatDate( $this->getDateObject(), "%d/%m/%Y %H:%M" ); 73 74 return $dateFormatted; 75 } 76 77 /** 78 * returns the current date 79 * 80 * @param a default value 81 */ 82 function getDefaultValue() 83 { 84 lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" ); 85 86 return( new Timestamp()); 87 } 88 } 89 90 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |