⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forms.php

📁 基于PHP的一套网络管理系统代码,对接口流量等可以进行详细的统计分析,很不错.
💻 PHP
📖 第 1 页 / 共 5 页
字号:
			case "relation":
			case "droplist":
			case "countries":

				switch ($field["type"]) {
					case "USstates":
					case "states":
						$field["options"] = $form_US_states;
					break;

					case "countries":
						$field["options"] = $form_countries;
					break;

					case "relation":
						$field["editable"] = "false";
					break;
				}
				
				//clearign vals
				$temp_options = "";

				//check if the options are generated dinamic
				if (is_array($field["dynamic"])) {
					for ($i = $field["dynamic"]["from"]; $i<=$field["dynamic"]["to"]; $i++ ) {
						$field["options"][$i] = $field["dynamic"]["width"] ? sprintf("%0" . $field["dynamic"]["width"] . "d", $i) : $i;						
					}					
				}

				if (is_array($field["options"])) {

					//add the enpty option
					if ($field["empty"] == "true") {
						$temp_options = $this->templates->blocks["SelectOption"]->Replace(array(
																								"LABEL" => $field["empty_text"] ? $field["empty_text"] : "[ select ]",
																								"VALUE" => "",
																								"DISABLED" => "",
																								"CHECKED" => $field["value"] == "" ? " selected " : ""
																							));
					}

					//building the select from options
					foreach ($field["options"] as $key => $val) {

						//hm ... support for noeditable fields, will apear as text
						if ($field["editable"] == "false") {
							foreach ($field["options"] as $key => $val) {
								if ($key == $values["values"][$field["name"]]) {
									$found = 1;

									$field["value"] = $val;

									$this->templates->blocks["text"]->Replace($field , false);
									$current_field = $this->templates->blocks["text"]->EmptyVars();	
								}							
							}						

						} else {					

							//checking if is a complex option or a simple one
							if (is_array($val)) {
								$label = $val["value"];
								$disabled = $val["disabled"] == "true" ? " disabled " : "";
							} else {
								$label = $val;
								$disabled = "";
							}
							
							$temp_options .= $this->templates->blocks["SelectOption"]->Replace(
												array(	
													"value" => $key,
													"label" => $label,
													"checked" => ($key == $field["value"]  ? " selected=\"selected\" " : ""),
													"disabled" => $disabled
												)
											  );
						}
					}														
				} else
					if (is_array($field["relation"])) {
						//reading from database

						if (is_array($field["relation"]["sql"])) {
							$form_sql_vars = array();

							if (is_array($field["relation"]["sql"]["vars"])) {
								foreach ($field["relation"]["sql"]["vars"] as $key => $val) {
									//echeking if the default must be evaluated
									if ($val["action"] == "eval") {
										eval("\$val[\"import\"] = " . $val["default"] .";");
									}

									switch ($val["type"]) {
										case "eval":
											eval("\$form_sql_vars[\"$key\"] = " . $val["import"] . ";");
										break;

										case "var":
											$form_sql_vars[$key] = $val["import"];
										break;

										case "page":
											$form_sql_vars[$key] = ($_GET[($val["code"] ? $val["code"] : 'page')] -1 )* $form['items'];
										break;

										case "form":
											eval("\$form_sql_vars[\"$key\"] = " . $form[$val["var"]] . ";");
										break;
									}													
								}

								foreach ($form_sql_vars as $key => $val) {							
									$this->templates->blocks["Temp"]->input = $val;							
									$form_sql_vars[$key] = $this->templates->blocks["Temp"]->Replace($form_sql_vars);
								}	

								//doing a double replace, in case there are unreplaced variable sfom "vars" type
								$this->templates->blocks["Temp"]->input = $field["relation"]["sql"]["query"];
								$sql = $this->templates->blocks["Temp"]->Replace($form_sql_vars);

								//do a precheck for [] elements to be replaced with <>
								$sql = str_replace("]" , ">" , str_replace("[" , "<" , $sql));

								$records = $this->db->QFetchRowArray($sql);								
							}							
						} else {

							//check to eval the condition if requred
							if (is_array($field["relation"]["condition"]) && ($field["relation"]["condition"]["eval"] == "true")) {
								echo "\$field[\"relation\"][\"condition\"] = " . $field["relation"]["condition"]["import"];
								eval("\$field[\"relation\"][\"condition\"] = " . $field["relation"]["condition"]["import"]);
							}
							
							$sql =	"SELECT * FROM `" . $this->tables[$field["relation"]["table"]] . "`" . 
									($field["relation"]["condition"] ? " WHERE (" . $field["relation"]["condition"] . ") " : "" ) . 
									($field["relation"]["order"] ? " ORDER BY `" . $field["relation"]["order"] . "` " . 
									($field["relation"]["ordermode"] ? $field["relation"]["ordermode"] : "") : "" );

							$records =$this->db->QFetchRowArray( $sql );
						}

						//ckech and replace the label field with multi fields array
						if (is_array($tmp_fields = @explode($field["tree"]["db_separator"] , $values["values"][$field["name"]]))) {
							foreach ($tmp_fields as $_val) {
								$_tmp_fields[$_val] = $_val;
							}							
						}
							
						
						if (is_array($records)) {
							if ($field["subtype"] == "multiple") {
											
								foreach ($records as $_k => $_v) {
									if ($_tmp_fields[$_v[$field["tree"]["id"]]] == $_v[$field["tree"]["id"]])
										$values["values"][$field["name"]."_option_" . $_v[$field["tree"]["id"]]] = true;
								}

								$temp_options = $this->privateDrawTree($field, $records , $values);

								//check if the overflow div settings are enabled
								if (is_array($field["tree"]["div"])) {
									$temp_options = $this->templates->blocks["SelectDiv"]->Replace(array(
																										"WIDTH" => $field["tree"]["div"]["width"],
																										"HEIGHT" => $field["tree"]["div"]["height"],
																										"SELECT_DATA" =>$temp_options 
																									));
								}
								
								
								
							} else {

								//add the enpty option
								if ($field["empty"] == "true") {
									$temp_options = $this->templates->blocks["SelectOption"]->Replace(array(
																											"LABEL" => $field["empty_text"] ? $field["empty_text"] : "[ select ]",
																											"VALUE" => "",
																											"DISABLED" => "",
																											"CHECKED" => ""
																										));
								}
								
								//echo "`" . $field["relation"]["id"] . "`"	;

								foreach ($records as $key => $val) {
									//preparing the data to send to template
									$send = array();
									$_tmp_text = "";

									$send["value"] = $val[$field["relation"]["id"]];
									$send["checked"] = $val[$field["relation"]["id"]] == $field["value"] ? " selected=\"selected\" " : "";
									$send["disabled"] = "";
									
									//build the label for multiple fields 
									if (is_array($field["relation"]["text"])) {

										foreach ($field["relation"]["text"] as $kkey => $vval)
											if (is_array($vval))
												$_tmp_text[] = $vval["preffix"] . $val[$vval["field"]] . $vval["suffix"];
											else
												$_tmp_text[] = $val[$vval];
										
										$send["label"] = implode($field["relation"]["separator"] ? $field["relation"]["separator"] : " " , $_tmp_text);
									} else
										//else return the single field
										$send["label"] = $val[$field["relation"]["text"]];

									// if the type is relation of editable false, then search for the selected element.
									if (($val[$field["relation"]["id"]] == $field["value"]) && ($field["editable"] == "false")) {
										//control variblae for the cases when i found a relation value
										$found = 1;

										$field["value"] = $send["label"];
										//format the text
										switch ($field["font"]) {

											case "normal":
											break;

											default:
												$field["value"] = "<b>" . $field["value"] . "</b>";
											break;
										}

										$this->templates->blocks["text"]->Replace($field , false);
										$current_field = $this->templates->blocks["text"]->EmptyVars();	

										//quit the for 
										break;

									}								
									
									$temp_options .= $this->templates->blocks["SelectOption"]->Replace($send);
								}
							}
						} else {
						}
					}
				if ($field["editable"] != "false") {
					if ($temp_options != "") {
							if ($field["subtype"] == "multiple") {

								$current_field = $temp_options;

							} else {
								//if there are options, build the select
								$current_field = $this->templates->blocks["Select"]->Replace(array(
														"name" => $field["name"] , 
														"options" => $temp_options ,
														"width" => $field["width"],
														"onchange" => $field["onchange"]
													));
							}
					} else 
						//else return a message, customizable from xml
						$current_field = $field["emptymsg"] ? $field["emptymsg"] : $this->templates->blocks["selectempty"]->output;
				} else {

					if (($current_field != "")&& $found) {
//							if ($field["subtype"] == "multiple") {
//								$current_field = $temp_options;
//							}
					} else {
						//else return a message, customizable from xml
						$current_field = $field["emptymsg"] ? $field["emptymsg"] : $this->templates->blocks["selectempty"]->output;
					}
				}
				
				//if the field hs description then i add the valign code
				$current_field_extra = $field["description"] || $field["subtype"] ? $this->templates->blocks["TopAlign"]->output : ""; 

			break;

			case "upload":
				$file = true;
			case "image":
				if ($field["editable"] != "false") {

					//adding the editable area to form
					$field["web_checked"] = $values["values"][$field["name"] . "_radio_type"] ? "checked" : "";
					$field["client_checked"] = $values["values"][$field["name"] . "_radio_type"] ? "" : "checked";
					$field["web_link"] = $values["values"][$field["name"] . "_upload_web"] ? $values["values"][$field["name"] . "_upload_web"] : "http://";
					$field["file_name"] = $values["values"][$field["name"] . "_file"];
					$field["target"] == "self" ? "" : "target=\"_new\"" ;

					$field["rem_disabled"] = $values["values"][$field["name"] . "_temp"] || $values["values"][$field["name"] . "_temp"] || $values["values"][$field["name"]] ? "" : "disabled";

					$image["editable"] = $this->templates->blocks[$file ? "uploadedit" : "imageedit"]->Replace($field);
				}	

				if ($file) {
					if (is_file($_CONF["path"] . $_CONF["upload"] . "tmp/" . $values["values"][$field["name"] . "_temp"])) {

						//show the  ing image
						$image["preview"] = $this->templates->blocks["fileshow"]->Replace(
												array(
													"name" => $_CONF["url"] . $_CONF["upload"] . "tmp/" . $values["values"][$field["name"] . "_file"],
													"src" => $_CONF["url"] . $_CONF["upload"] . "tmp/" . $values["values"][$field["name"] . "_temp"] ,
													"target" => $field["target"] == "self" ? "" : "target=\"_new\"" 
												)
											);

					} else {
						$file_name = $_CONF["path"] . $_CONF["upload"] . ($field["path"] ? $field["path"] : $field["file"]["path"]) . $field["file"]["default"] . $values["values"][$field["file"]["field"]] . $field["file"]["ext"];
						$file_url = $_CONF["url"] . $_CONF["upload"] . ($field["path"] ? $field["path"] : $field["file"]["path"]) . $field["file"]["default"] . $values["values"][$field["file"]["field"]] . $field["file"]["ext"];

						if (/*$values["values"][$field["name"]] && */file_exists($file_name)) {
							$image["preview"] = $this->templates->blocks["fileshow"]->Replace(
													array(
														"name" => $values["values"][$field["name"] . "_file"] ? $values["values"][$field["name"] . "_file"]  : $field["file"]["default"] . $values["values"][$field["file"]["field"]] . $field["file"]["ext"],
														"src" => $file_url,
														"target" => $field["target"] == "self" ? "" : "target=\"_new\"" 
													)
												);
						} else 
							$image["preview"] = $field["error"] ? $field["error"] : "No file uploaded.";
					}

				} else {
				
					if (is_file($_CONF["path"] . $_CONF["upload"] . "tmp/" . $values["values"][$field["name"] . "_temp"])) {

						//show the  ing image
						$image["preview"] = $this->templates->blocks["imageshow"]->Replace(
												array(
													"width" => $field["adminwidth"],
													"height" => $field["adminheight"],
													"src" => $_CONF["url"] . $_CONF["upload"] . "tmp/" . $values["values"][$field["name"] . "_temp"] 
												)
											);

					} else {
						//hm ... making a small trick to keep the image even if that was an failed adding,
						//this sux becouse if the add process is not completed then i get   in the temp folder.					
						if ($values["values"][$field["name"]] && file_exists($_CONF["path"] . $_CONF["upload"] . $field["path"] . $field["file"]["default"] . $values["values"][$field["file"]["field"]] . $field["file"]["ext"])) {
							$image["preview"] = $this->templates->blocks["imageshow"]->Replace(
													array(
														"width" => $field["adminwidth"],
														"height" => $field["adminheight"],
														"src" => $_CONF["url"] . $_CONF["upload"] . $field["path"] . $field["file"]["default"] . $values["values"][$field["file"]["field"]] . $field["file"]["ext"]
													)
												);

						} else {

							//checking if there exists a default image
							if ($field["default"]) {
								$image["preview"] = $this->templates->blocks["imageshownolink"]->Replace(
														array(
															"width" => $field["adminwidth"],
															"height" => $field["adminheight"],
															"src" => $_CONF["url"] . $_CONF["upload"] . $field["path"] . $field["default"]
														)
													);
							} else
								//return an error from xml
								$image["preview"] = $field["error"] ? $field["error"] : "No image curently available.";
						}
					}
				}

				$image["temp"] = $values["values"][$field["name"] . "_temp"];
										
				$this->templates->blocks["image"]->Replace($image , false);
				$current_field = $this->templates->blocks["image"]->EmptyVars();							

				//if the field hs description then i add the valign code
				$current_field_extra = $field["description"] ? $this->templates->blocks["TopAlign"]->output : ""; 
			break;

			case "comment":
				if ($field["subtype"] == "extern") {
					$field["description"] = GetFileContents(dirname($form["xmlfile"]) . "/" . $field["file"]);
				} else {
				
					$field["description"] = preg_replace( 
									array( '(\[)' , '(\])' ),
									array( "<" , ">" ),
									$field["description"]
								);
				}
				//save the input 
				$old

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -