Orion PHP  0.11.12
The PHP5.3 framework
date.php
Go to the documentation of this file.
00001 <?php
00002 namespace Orion\Core\Model;
00003 
00004 class Date extends Field
00005 {
00006     protected $current;
00007 
00008     public function __construct($bind='string', $label='String', $current=true, $required=false, $primary=false)
00009     {
00010         $this->type = 'string';
00011         $this->bind = $bind;
00012         $this->label = $label;
00013         $this->current = $current;
00014         $this->required = $required;
00015         $this->primary = $primary;
00016     }
00017 
00018     public function prepare($value)
00019     {
00020         if($this->current || $value == 'NOW()')
00021             return 'NOW()';
00022         else
00023             return "'".$value."'";
00024     }
00025 
00026     public function toHtml($XHTML=true)
00027     {
00028         if($XHTML)
00029             $tag = ' /';
00030         else
00031             $tag = '';
00032 
00033         return ($this->current) ? '' : '<div class="form-row"><label for="'.$this->bind.'">'.$this->label.'</label><div class="form-container"><input name="'.$this->bind.'" type="text" class="form-element form-date" value="'.$this->value.'"'.$tag.'></div></div>';
00034     }
00035 }
00036 
00037 ?>