Beispiel #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;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #2
0
 /**
  *@desc set Data Source
  *@param IteratorInterface $it
  *@return void
  */
 public function setDataSource($it)
 {
     if (is_array($it)) {
         $arrayDS = new ArrayDataset($it);
         $it = $arrayDS->getIterator();
     }
     $this->_it = $it;
 }
Beispiel #3
0
 function test_navigateFromModel2()
 {
     $model = array(new AnyDataSet\Tests\Sample\ModelGetter(1, 'ProdA'), new AnyDataSet\Tests\Sample\ModelGetter(2, 'ProdB'), new AnyDataSet\Tests\Sample\ModelGetter(3, 'ProdC'));
     $arrayDataset = new ArrayDataset($model);
     $arrayIterator = $arrayDataset->getIterator();
     $count = 0;
     if ($arrayIterator->hasNext()) {
         $sr = $arrayIterator->moveNext();
         $this->assertField($sr, $count, "__id", 0);
         $this->assertField($sr, $count, "__key", 0);
         $this->assertField($sr, $count, "__class", "AnyDataSet\\Tests\\Sample\\ModelGetter");
         $this->assertField($sr, $count, "id", 1);
         $this->assertField($sr, $count, "name", 'ProdA');
         $count++;
     }
     if ($arrayIterator->hasNext()) {
         $sr = $arrayIterator->moveNext();
         $this->assertField($sr, $count, "__id", 1);
         $this->assertField($sr, $count, "__key", 1);
         $this->assertField($sr, $count, "__class", "AnyDataSet\\Tests\\Sample\\ModelGetter");
         $this->assertField($sr, $count, "id", 2);
         $this->assertField($sr, $count, "name", 'ProdB');
         $count++;
     }
     if ($arrayIterator->hasNext()) {
         $sr = $arrayIterator->moveNext();
         $this->assertField($sr, $count, "__id", 2);
         $this->assertField($sr, $count, "__key", 2);
         $this->assertField($sr, $count, "__class", "AnyDataSet\\Tests\\Sample\\ModelGetter");
         $this->assertField($sr, $count, "id", 3);
         $this->assertField($sr, $count, "name", 'ProdC');
         $count++;
     }
     $this->assertTrue(!$arrayIterator->hasNext());
     //, 'I did not expected more records');
     $this->assertEquals($count, 3);
     //, "Count records mismatch. Need to process 3 records.");
 }
Beispiel #4
0
 /**
  *
  * @param array $filelist
  * @param FilenameProcessor $proc
  * @return IteratorInterface
  */
 private function getIteratorFromList($filelist, $proc)
 {
     $arResult = array();
     asort($filelist);
     foreach ($filelist as $key => $file) {
         $name = FileUtil::ExtractFileName($file);
         $name = $proc->removeLanguage($name);
         $arResult[$name] = $name;
     }
     $ds = new ArrayDataset($arResult, "singlename");
     return $ds->getIterator();
 }
Beispiel #5
0
 /**
  * Enter description here...
  *
  * @param string $group
  * @return IteratorInterface
  */
 protected function GetAdminGroups($group = "")
 {
     $keys = array_keys($this->GetAdminModulesList());
     if ($group != "") {
         if (in_array($group, $keys)) {
             $keys = array($group);
         } else {
             $keys = array();
         }
     }
     $arr = new ArrayDataset($keys, "name");
     return $arr->getIterator();
 }
Beispiel #6
0
 /**
  * @access public
  * @param string $sql
  * @param array $params
  * @param int $ttl
  * @return IteratorInterface
  * @throws NotAvailableException
  */
 public function getIterator($sql, $params = null, $ttl = null)
 {
     // If there is no TTL query, return the LIVE iterator
     if (empty($ttl)) {
         return $this->getDbDriver()->getIterator($sql, $params);
     }
     // Otherwise try to get from cache
     $key = $this->getQueryKey($sql, $params);
     // Get the CACHE
     $cache = $this->getCacheEngine()->get($key, $ttl);
     if ($cache === false) {
         $cache = array();
         $it = $this->getDbDriver()->getIterator($sql, $params);
         foreach ($it as $value) {
             $cache[] = $value->toArray();
         }
         $this->getCacheEngine()->set($key, $cache, $ttl);
     }
     $arrayDS = new ArrayDataset($cache);
     return $arrayDS->getIterator();
 }
Beispiel #7
0
 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);
 }