00001 <?php
00016 class CampoFecha extends Campo{
00017 const FORMATODEFECTO = 'd/m/Y';
00018 protected $atributos = array('id','valor','clase','tabindex','formato');
00019
00029 public function __construct($nodo){
00030 parent::__construct($nodo);
00031
00032 if (!isset($this->id)) throw new ExcepcionCampoAtributoObligatorioNoDefinido('id',get_class($this));
00033 if (!isset($this->formato)) $this->formato = self::FORMATODEFECTO;
00034 if ($this->valor == 'hoy')
00035 $this->valor = date($this->formato);
00036 }
00040 public function verNodo(){
00041 $xml = new DOMDocument();
00042
00043 $input = $xml->createElement("input");
00044 $input->setAttribute("type", "text");
00045 $input->setAttribute("size", "10");
00046 $input->setAttribute("maxlength", "10");
00047 $input->setAttribute("id", $this->id);
00048 $input->setAttribute("name", $this->id);
00049 $input->setAttribute("value", $this->valor);
00050 if (isset($this->clase))
00051 $input->setAttribute("class", $this->clase);
00052 if (isset($this->tabindex))
00053 $input->setAttribute("tabindex", $this->tabindex);
00054
00055
00056 $script = $xml->createElement("script");
00057 $script->setAttribute("type", "text/JavaScript");
00058 $codigo = ' Calendar.setup({';
00059 $codigo .= ' inputField : "'.$this->id.'",';
00060
00061 $codigo .= ' ifFormat : "%d/%m/%Y",';
00062 $codigo .= ' button : "'.$id.'"})';
00063 $script->appendChild($xml->createTextNode($codigo));
00064
00065
00066 $span = $xml->createElement("span");
00067 $span->appendChild($input);
00068 $span->appendChild($script);
00069
00070 return $span;
00071 }
00072 }
00073
00075
00076 return true;
00077 ?>