Go to the documentation of this file.00001 <?php
00010 class form_date extends form_abstract {
00011
00017 protected $date;
00018
00019 protected function afterInit() {
00020 parent::afterInit();
00021 $this->date = factory::getHelper('date', array(
00022 'timestamp'=>$this->cfg->value ? strtotime($this->cfg->value) : time(),
00023 'defaultFormat'=>array(
00024 'type'=>'date',
00025 'len'=>'mysql'
00026 )
00027 ));
00028 }
00029
00030 public function getValue() {
00031 return $this->date->format();
00032 }
00033
00034 public function setValue($value, $refill=false) {
00035 parent::setValue($value);
00036 if ($refill)
00037 $this->date->set($value, 'formatDate', 'short2');
00038 else
00039 $this->date->set($value);
00040 }
00041
00042 public function toHtml() {
00043 if ($this->cfg->mode == 'view')
00044 return $this->date->format('date', 'short2');
00045
00046 if ($this->cfg->useJs) {
00047 $resp = response::getInstance();
00048 $resp->addJs('jqueryui');
00049
00050 $resp->blockJquery('$("#'.$this->id.'").datepicker('.json_encode($this->jsPrm).');');
00051 }
00052
00053 return utils::htmlTag($this->htmlTagName,
00054 array_merge($this->html, array(
00055 'name'=>$this->name,
00056 'id'=>$this->id,
00057 'value'=>$this->date->format('date', 'short2'),
00058 )));
00059 }
00060
00061 public function toXul() {
00062 return utils::htmlTag($this->xulTagName,
00063 array_merge($this->xul, array(
00064 'id'=>$this->id,
00065 'value'=>$this->date->format('date', 'short2'),
00066 )));
00067 }
00068
00069 }