nyroFwk  0.2
form/date.class.php
Go to the documentation of this file.
1 <?php
10 class form_date extends form_abstract {
11 
17  protected $date;
18 
19  protected function afterInit() {
20  parent::afterInit();
21  $this->date = factory::getHelper('date', array(
22  'timestamp'=>$this->cfg->value ? strtotime($this->cfg->value) : time(),
23  'defaultFormat'=>array(
24  'type'=>'date',
25  'len'=>'mysql'
26  )
27  ));
28  }
29 
30  public function getValue() {
31  return $this->date->format();
32  }
33 
34  public function setValue($value, $refill=false) {
35  parent::setValue($value);
36  if ($refill)
37  $this->date->set($value, 'formatDate', 'short2');
38  else
39  $this->date->set($value);
40  }
41 
42  public function toHtml() {
43  if ($this->cfg->mode == 'view')
44  return $this->date->format('date', 'short2');
45 
46  if ($this->cfg->useJs) {
47  $resp = response::getInstance();
48  $resp->addJs('jqueryui');
49 
50  $resp->blockJquery('$("#'.$this->id.'").datepicker('.utils::jsEncode($this->jsPrm).');');
51  }
52 
53  return utils::htmlTag($this->htmlTagName,
54  array_merge($this->html, array(
55  'name'=>$this->name,
56  'id'=>$this->id,
57  'value'=>$this->date->format('date', 'short2'),
58  )));
59  }
60 
61  public function toXul() {
62  return utils::htmlTag($this->xulTagName,
63  array_merge($this->xul, array(
64  'id'=>$this->id,
65  'value'=>$this->date->format('date', 'short2'),
66  )));
67  }
68 
69 }
static htmlTag($tag, array $attributes, $content=null)
Definition: utils.class.php:46
static jsEncode($vars)
static getHelper($className, array $cfg=array())
static getInstance()
setValue($value, $refill=false)
Generated on Sun Oct 15 2017 22:25:20 for nyroFwk by doxygen 1.8.13