示例#1
0
 /**
  *@desc
  *@param CrudField $field
  *@param string $curValue
  *@return IXmlnukeDocumentObject
  */
 public function renderField($field, $curValue)
 {
     if ($field->fieldXmlInput == XmlInputObjectType::TEXTBOX || $field->fieldXmlInput == XmlInputObjectType::PASSWORD || $field->fieldXmlInput == XmlInputObjectType::TEXTBOX_AUTOCOMPLETE) {
         //			XmlInputTextBox $itb
         $itb = new XmlInputTextBox($field->fieldCaption, $field->fieldName, $curValue, $field->size);
         $itb->setRequired($field->required);
         $itb->setRange($field->rangeMin, $field->rangeMax);
         $itb->setDescription($field->fieldCaption);
         if ($field->fieldXmlInput == XmlInputObjectType::PASSWORD) {
             $itb->setInputTextBoxType(InputTextBoxType::PASSWORD);
         } elseif ($field->fieldXmlInput == XmlInputObjectType::TEXTBOX_AUTOCOMPLETE) {
             if (!is_array($field->arraySelectList) || $field->arraySelectList["URL"] == "" || $field->arraySelectList["PARAMREQ"] == "") {
                 throw new XMLNukeException("You have to pass a array to arraySelectList field parameter with the following keys: URL, PARAMREQ. Optional: ATTRINFO, ATTRID, JSCALLBACK");
             }
             $itb->setInputTextBoxType(InputTextBoxType::TEXT);
             $itb->setAutosuggest($this->_context, $field->arraySelectList["URL"], $field->arraySelectList["PARAMREQ"], $field->arraySelectList["JSCALLBACK"]);
         } else {
             $itb->setInputTextBoxType(InputTextBoxType::TEXT);
         }
         $itb->setReadOnly($this->isReadOnly($field));
         $itb->setMaxLength($field->maxLength);
         $itb->setDataType($field->dataType);
         return $itb;
     } else {
         if ($field->fieldXmlInput == XmlInputObjectType::RADIOBUTTON || $field->fieldXmlInput == XmlInputObjectType::CHECKBOX) {
             //			XmlInputCheck $ic
             $ic = new XmlInputCheck($field->fieldCaption, $field->fieldName, $field->defaultValue);
             if ($field->fieldXmlInput == XmlInputObjectType::TEXTBOX) {
                 $ic->setType(InputCheckType::CHECKBOX);
             } else {
                 $ic->setType(InputCheckType::CHECKBOX);
             }
             $ic->setChecked($field->defaultValue == $curValue);
             $ic->setReadOnly($this->isReadOnly($field));
             return $ic;
         } else {
             if ($field->fieldXmlInput == XmlInputObjectType::MEMO) {
                 //			XmlInputMemo $im
                 $im = new XmlInputMemo($field->fieldCaption, $field->fieldName, $curValue);
                 $im->setWrap("SOFT");
                 $im->setSize(50, 8);
                 $im->setReadOnly($this->isReadOnly($field));
                 return $im;
             } else {
                 if ($field->fieldXmlInput == XmlInputObjectType::HTMLTEXT) {
                     //			XmlInputMemo $im
                     $im = new XmlInputMemo($field->fieldCaption, $field->fieldName, $curValue);
                     //$im->setWrap("SOFT");
                     //$im->setSize(50, 8);
                     $im->setVisualEditor(true);
                     $im->setReadOnly($this->isReadOnly($field));
                     return $im;
                 } else {
                     if ($field->fieldXmlInput == XmlInputObjectType::HIDDEN) {
                         //			XmlInputHidden $ih
                         $ih = new XmlInputHidden($field->fieldName, $curValue);
                         return $ih;
                     } else {
                         if ($field->fieldXmlInput == XmlInputObjectType::SELECTLIST) {
                             //			XmlEasyList $el
                             $el = new XmlEasyList(EasyListType::SELECTLIST, $field->fieldName, $field->fieldCaption, $field->arraySelectList, $curValue);
                             $el->setReadOnly($this->isReadOnly($field));
                             return $el;
                         } else {
                             if ($field->fieldXmlInput == XmlInputObjectType::DUALLIST) {
                                 $ards = new ArrayDataset($field->arraySelectList, "value");
                                 $duallist = new XmlDualList($this->_context, $field->fieldName, $this->_lang->Value("TXT_AVAILABLE", $field->fieldCaption), $this->_lang->Value("TXT_USED", $field->fieldCaption));
                                 $duallist->createDefaultButtons();
                                 $duallist->setDataSourceFieldName("key", "value");
                                 if ($curValue != "") {
                                     $ardt = explode(",", $curValue);
                                     $ardt = array_flip($ardt);
                                     foreach ($ardt as $key => $value) {
                                         $ardt[$key] = $field->arraySelectList[$key];
                                     }
                                 } else {
                                     $ardt = array();
                                 }
                                 $ards2 = new ArrayDataset($ardt, "value");
                                 $duallist->setDataSource($ards->getIterator(), $ards2->getIterator());
                                 $label = new XmlInputLabelObjects("=>");
                                 $label->addXmlnukeObject($duallist);
                                 return $label;
                             } else {
                                 if ($field->fieldXmlInput == XmlInputObjectType::DATE || $field->fieldXmlInput == XmlInputObjectType::DATETIME) {
                                     $cur = explode(" ", $curValue);
                                     if (count($cur) == 0) {
                                         $cur = array('', '');
                                     } else {
                                         if (count($cur) == 1) {
                                             $cur[] = '';
                                         }
                                     }
                                     $idt = new XmlInputDateTime($field->fieldCaption, $field->fieldName, $this->_dateFormat, $field->fieldXmlInput == XmlInputObjectType::DATETIME, $cur[0], $cur[1]);
                                     return $idt;
                                 } else {
                                     if ($field->fieldXmlInput == XmlInputObjectType::FILEUPLOAD) {
                                         $file = new XmlInputFile($field->fieldCaption, $field->fieldName);
                                         return $file;
                                     } else {
                                         //			XmlInputLabelField xlf
                                         $xlf = new XmlInputLabelField($field->fieldCaption, $curValue);
                                         return $xlf;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
示例#2
0
文件: Sample.php 项目: byjg/xmlnuke
 protected function Opcao11()
 {
     $block = new XmlBlockCollection("Exemplo 11: DualList", BlockPosition::Center);
     //XmlnukeBreakLine br = new XmlnukeBreakLine();
     if ($this->isPostBack()) {
         Debug::PrintValue(XmlDualList::Parse($this->_context, "frmdual"));
     }
     $form = new XmlFormCollection($this->_context, $this->_url . "?op=11", "Formulário com Um Dual List");
     // Create DualList Object
     $duallist = new XmlDualList($this->_context, "frmdual", "Não Selecionado", "Selecionado");
     $duallist->setDualListSize(10, 10);
     $duallist->createDefaultButtons();
     // Define DataSet Source
     $arrayLeft = array("A" => "Letra A", "B" => "Letra B", "C" => "Letra C", "D" => "Letra D", "E" => "Letra E", "F" => "Letra F");
     $arrayRight = array("B" => "Letra B", "D" => "Letra D");
     $arrayDBLeft = new ArrayDataset($arrayLeft);
     $itLeft = $arrayDBLeft->getIterator();
     $arrayDBRight = new ArrayDataset($arrayRight);
     $itRight = $arrayDBRight->getIterator();
     $duallist->setDataSourceFieldName("key", "value");
     $duallist->setDataSource($itLeft, $itRight);
     $form->addXmlnukeObject($duallist);
     $button = new XmlInputButtons();
     $button->addSubmit("Enviar Dados");
     $form->addXmlnukeObject($button);
     $block->addXmlnukeObject($form);
     $this->_document->addXmlnukeObject($block);
 }