Example #1
0
 /**
  *  Contains specific instructions to generate all XML informations
  *  This method is processed only one time
  *  Usually is the last method processed
  *
  * @param DOMNode $current
  */
 public function generateObject($current)
 {
     $nodeWorking = null;
     // Criando o objeto que conterĂ¡ a lista
     switch ($this->_easyListType) {
         case EasyListType::CHECKBOX:
             XmlUtil::CreateChild($current, "caption", $this->_caption);
             $nodeWorking = $current;
             $iHid = new XmlInputHidden("qty" . $this->_name, count($this->_values));
             $iHid->generateObject($nodeWorking);
             break;
         case EasyListType::RADIOBOX:
             XmlUtil::CreateChild($current, "caption", $this->_caption);
             $nodeWorking = $current;
             break;
         case EasyListType::SELECTLIST:
         case EasyListType::SELECTIMAGELIST:
             if ($this->_readOnly) {
                 if ($this->_easyListType == EasyListType::SELECTLIST) {
                     $deliLeft = strlen($this->_readOnlyDeli) != 0 ? $this->_readOnlyDeli[0] : "";
                     $deliRight = strlen($this->_readOnlyDeli) != 0 ? $this->_readOnlyDeli[1] : "";
                     //XmlInputHidden $xih
                     //XmlInputLabelField $xlf
                     $xlf = new XmlInputLabelField($this->_caption, $deliLeft . $this->_values[$this->_selected] . $deliRight);
                     $xih = new XmlInputHidden($this->_name, $this->_selected);
                     $xlf->generateObject($current);
                     $xih->generateObject($current);
                 } elseif ($this->_easyListType == EasyListType::SELECTIMAGELIST) {
                     $img = new XmlnukeImage($this->_values[$this->_selected]);
                     $img->generateObject($current);
                 }
                 return;
             } else {
                 $nodeWorking = XmlUtil::CreateChild($current, "select", "");
                 XmlUtil::AddAttribute($nodeWorking, "caption", $this->_caption);
                 XmlUtil::AddAttribute($nodeWorking, "name", $this->_name);
                 if ($this->_required) {
                     XmlUtil::AddAttribute($nodeWorking, "required", "true");
                 }
                 if ($this->_size > 1) {
                     XmlUtil::AddAttribute($nodeWorking, "size", $this->_size);
                 }
                 if ($this->_easyListType == EasyListType::SELECTIMAGELIST) {
                     XmlUtil::AddAttribute($nodeWorking, "imagelist", "true");
                     XmlUtil::AddAttribute($nodeWorking, "thumbnailsize", $this->_thumbnailSize);
                     XmlUtil::AddAttribute($nodeWorking, "notfoundimage", $this->_notFoundImage);
                     XmlUtil::AddAttribute($nodeWorking, "noimage", $this->_noImage);
                 }
             }
             break;
         case EasyListType::UNORDEREDLIST:
             XmlUtil::CreateChild($current, "b", $this->_caption);
             $nodeWorking = XmlUtil::CreateChild($current, "ul", "");
             break;
     }
     $i = 0;
     foreach ($this->_values as $key => $value) {
         switch ($this->_easyListType) {
             case EasyListType::CHECKBOX:
                 //					XmlInputCheck $iCk
                 $iCk = new XmlInputCheck($value, $this->_name . $i++, $key);
                 $iCk->setType(InputCheckType::CHECKBOX);
                 $iCk->setChecked($key == $this->_selected);
                 $iCk->setReadOnly($this->_readOnly);
                 $iCk->generateObject($nodeWorking);
                 break;
             case EasyListType::RADIOBOX:
                 //					XmlInputCheck $iCk
                 $iCk = new XmlInputCheck($value, $this->_name, $key);
                 $iCk->setType(InputCheckType::RADIOBOX);
                 $iCk->setChecked($key == $this->_selected);
                 $iCk->setReadOnly($this->_readOnly);
                 $iCk->generateObject($nodeWorking);
                 break;
             case EasyListType::SELECTLIST:
             case EasyListType::SELECTIMAGELIST:
                 $node = XmlUtil::CreateChild($nodeWorking, "option", "");
                 XmlUtil::AddAttribute($node, "value", $key);
                 if ($key == $this->_selected) {
                     XmlUtil::AddAttribute($node, "selected", "yes");
                 }
                 XmlUtil::AddTextNode($node, $value);
                 break;
             case EasyListType::UNORDEREDLIST:
                 XmlUtil::CreateChild($nodeWorking, "li", $value);
                 break;
         }
     }
 }