/** * Agrega Control textbox a un Form desde una array * @param array $arrM * @example * Array( Array( * "Control.id", * "Control.Etiqueta", * "Control.Valor", * "Control.Tamanio", * "Control.Clase-CSS", * Array( * "Propiedad" => "Valor" * ) * ) );" */ function addHElementsInArray($arrM) { if (is_array($arrM)) { $iMark = 1; $items = count($arrM) - 1; $mxItem = 0; $aElem = array(); foreach ($arrM as $clave => $arrMen) { if (is_array($arrMen)) { $id = isset($arrMen[0]) ? $arrMen[0] : ""; $id = isset($arrMen["id"]) ? $arrMen["id"] : $id; $label = isset($arrMen[1]) ? $arrMen[1] : ""; $valor = isset($arrMen[2]) ? $arrMen[2] : 0; $size = isset($arrMen[3]) ? $arrMen[3] : 10; $class = isset($arrMen[4]) ? $arrMen[4] : "normalfield"; $aVals = isset($arrMen[5]) ? $arrMen[5] : false; $txt = new cHText($id); $txt->init($id, $size, $class); $txt->set($id, $valor, $label); if (is_array($aVals)) { foreach ($aVals as $mKey => $mValue) { if (strpos($mValue, "=") > 0) { $DProp = explode("=", $mValue); $txt->setProperty($DProp[0], $DProp[1]); } else { $txt->setProperty($mKey, $mValue); } } } $Element = $label == "" ? $id : $txt->get(); // si el marcador es igual al numero de elementos if ($iMark == $this->mEByLine) { $aElem[] = $Element; $this->addHElem($aElem); $iMark = 1; $aElem = array(); } else { $aElem[] = $Element; if ($mxItem == $items) { if ($iMark <= $this->mEByLine - 1) { $this->addHElem($aElem); } } $iMark++; } /* array ( array ( id, label value, size, class, options[]) */ } $mxItem++; } $x = fopen("../images/tmp/test.yaml", "w+"); fwrite($x, Spyc::YAMLDump($arrM)); fclose($x); } }