if( $inlineedit == EDIT_INLINE ) //#9069 $pageObject->removeHiddenColumnsFromInlineFields( $controlFields, postvalue("screenWidth"), postvalue("screenHeight"), postvalue("orientation") ); foreach($controlFields as $fName) { $gfName = GoodFieldName($fName); $controls = array('controls'=>array()); if (!$detailKeys || !in_array($fName, $detailKeys)) { $control[$gfName] = array(); $parameters = array(); $parameters["id"] = $id; $parameters["ptype"] = PAGE_EDIT; $parameters["field"] = $fName; $parameters["data"] = $data; if( IsFloatType( $pageObject->pSet->getFieldType($fName) ) && !is_null( @$data[$fName] ) ) { if( $pageObject->pSet->getHTML5InputType( $fName ) == "number" ) { // no thousand delimiters, only dot as decimal delimiter $parameters["value"] = formatNumberForHTML5(@$data[$fName]); } else { $parameters["value"] = str_replace(".", $locale_info["LOCALE_SDECIMAL"], @$data[$fName]); } } else { $parameters["value"] = @$data[$fName]; }
/** * @param String field * @param Mixed value * @param String controltype * @param String postfilename * @param String table The datasource table name * @intellisense */ function prepare_for_db($field, $value, $controltype = "", $postfilename = "", $table = "") { global $strTableName, $cman; if ($table == "") { $table = $strTableName; } $pSet = new ProjectSettings($table); $connection = $cman->byTable($table); $filename = ""; $type = $pSet->getFieldType($field); if ((!$controltype || $controltype == "multiselect") && !IsTimeType($type)) { if (is_array($value)) { $value = combinevalues($value); } if (($value === "" || $value === FALSE) && !IsCharType($type)) { return ""; } if (IsGuid($type)) { if (!IsGuidString($value)) { return ""; } } if (IsFloatType($type)) { return makeFloat($value); } if (IsNumberType($type) && !is_int($value)) { $value = trim($value); if (!is_numeric(str_replace(",", ".", $value))) { $value = ""; } } return $value; } else { if ($controltype == "time" || IsTimeType($type)) { if (!strlen($value)) { return ""; } $time = localtime2db($value); if ($connection->dbType == nDATABASE_PostgreSQL) { $timeArr = explode(":", $time); if ($timeArr[0] > 24 || $timeArr[1] > 59 || $timeArr[2] > 59) { return ""; } } if (IsDateFieldType($type)) { $time = "2000-01-01 " . $time; } return $time; } else { if (substr($controltype, 0, 4) == "date") { $dformat = substr($controltype, 4); if ($dformat == EDIT_DATE_SIMPLE || $dformat == EDIT_DATE_SIMPLE_INLINE || $dformat == EDIT_DATE_SIMPLE_DP) { $time = localdatetime2db($value); if ($time == "null") { return ""; } return $time; } else { if ($dformat == EDIT_DATE_DD || $dformat == EDIT_DATE_DD_INLINE || $dformat == EDIT_DATE_DD_DP) { $a = explode("-", $value); if (count($a) < 3) { return ""; } else { $y = $a[0]; $m = $a[1]; $d = $a[2]; } if ($y < 100) { if ($y < 70) { $y += 2000; } else { $y += 1900; } } return mysprintf("%04d-%02d-%02d", array($y, $m, $d)); } else { return ""; } } } else { if (substr($controltype, 0, 8) == "checkbox") { if ($value == "on") { $ret = 1; } else { if ($value == "none") { return ""; } else { $ret = 0; } } return $ret; } else { return false; } } } } }
/** * Prepare edit controls */ public function prepareEditControls() { global $locale_info; if ($this->mode == EDIT_INLINE) { $fields = $this->editFields; $this->removeHiddenColumnsFromInlineFields($fields, $this->screenWidth, $this->screenHeight, $this->orientation); $this->editFields = $fields; } // prepare values $data = $this->getCurrentRecordInternal(); if ($this->readEditValues) { foreach ($this->editFields as $f) { if (!isset($this->newRecordData[$f])) { continue; } $editFormat = $this->pSet->getEditFormat($f); if ($editFormat != EDIT_FORMAT_DATABASE_FILE && $editFormat != EDIT_FORMAT_DATABASE_IMAGE && $editFormat != EDIT_FORMAT_READONLY) { $data[$f] = $this->newRecordData[$f]; } } } $control = array(); foreach ($this->editFields as $fName) { $gfName = GoodFieldName($fName); $isDetKeyField = in_array($fName, $this->detailKeysByM); $control[$gfName] = array(); $controls = array(); $controls["controls"] = array(); $controls["controls"]['ctrlInd'] = 0; $controls["controls"]['id'] = $this->id; $controls["controls"]['fieldName'] = $fName; $parameters = array(); $parameters["id"] = $this->id; $parameters["ptype"] = PAGE_EDIT; $parameters["field"] = $fName; $parameters["pageObj"] = $this; $parameters["value"] = @$data[$fName]; if (!$isDetKeyField) { if (IsFloatType($this->pSet->getFieldType($fName)) && !is_null(@$data[$fName])) { if ($this->pSet->getHTML5InputType($fName) == "number") { // no thousand delimiters, only dot as decimal delimiter $parameters["value"] = formatNumberForHTML5(@$data[$fName]); } else { $parameters["value"] = str_replace(".", $locale_info["LOCALE_SDECIMAL"], @$data[$fName]); } } $parameters["validate"] = $this->pSet->getValidation($fName); $additionalCtrlParams = array(); $additionalCtrlParams["disabled"] = $this->controlsDisabled; $parameters["additionalCtrlParams"] = $additionalCtrlParams; } $controlMode = $this->mode == EDIT_INLINE ? "inline_edit" : "edit"; $parameters["mode"] = $controlMode; $controls["controls"]['mode'] = $controlMode; if ($this->pSet->isUseRTE($fName) && $this->pSet->isAutoUpdatable($fName)) { $_SESSION[$this->sessionPrefix . "_" . $fName . "_rte"] = GetAutoUpdateValue($fName, PAGE_EDIT); $control[$gfName]["params"]["mode"] = "add"; } if ($isDetKeyField) { $controls["controls"]['value'] = @$data[$fName]; $parameters["extraParams"] = array(); $parameters["extraParams"]["getDetKeyReadOnlyCtrl"] = true; // to the ReadOnly control show the detail key cotnrol's value $this->readOnlyFields[$fName] = $this->showDBValue($fName, $data); } AssignFunction($control[$gfName], "xt_buildeditcontrol", $parameters); $this->xt->assignbyref($gfName . "_editcontrol", $control[$gfName]); // category control field $strCategoryControl = $this->getMainLookupFieldNameForDependant($fName); if (strlen($strCategoryControl) && in_array($strCategoryControl, $this->editFields)) { $vals = array($fName => @$data[$fName], $strCategoryControl => @$data[$strCategoryControl]); } else { $vals = array($fName => @$data[$fName]); } $preload = $this->fillPreload($fName, $vals); if ($preload !== false) { $controls["controls"]['preloadData'] = $preload; } $this->fillControlsMap($controls); $this->fillFieldToolTips($fName); // fill special settings for timepicker if ($this->pSet->getEditFormat($fName) == 'Time') { $this->fillTimePickSettings($fName, $data[$fName]); } if ($this->pSet->getViewFormat($fName) == FORMAT_MAP) { $this->googleMapCfg['isUseGoogleMap'] = true; } } }