itype = "text"; $this->iclass = ""; } function PHPOK_INPUT() { $this->__construct(); } function get_html($array) { if(!array_key_exists($array["input"],$this->InputType())) { return false; } $varname = "_".strtoupper($array["input"]); //判断是否有插件替换 $plugin = load_plugin("phpok_input_lib:".$varname,$array,true); if($plugin) { return $plugin; } return $this->$varname($array); } function _TEXT($array) { $msg = $this->_LEFT_($array); $msg.= "_RIGHT_($array); return $msg; } function _SIMG($array) { $msg = $this->_LEFT_($array); $msg.= "'; $msg.= " "; $msg.= ''; $msg.= " "; $msg.= ''; $msg .= $this->_RIGHT_($array); return $msg; } function _MODULE($array) { $msg = $this->_LEFT_($array); $msg.= ""; $msg.= ""; $msg.= ""; $msg.= " "; $msg.= ''; $msg.= " "; $msg.= ''; $msg .= $this->_RIGHT_($array); return $msg; } function _SELECT($array) { $msg = $this->_LEFT_($array); $msg.= ""; $msg .= $this->_RIGHT_($array); return $msg; } function _RADIO($array) { $msg = $this->_LEFT_($array); $msg.= ""; $array["list_val"] = str_replace("\r","",$array["list_val"]); $tmparray = explode("\n",$array["list_val"]); if(!$tmparray) { $tmparray = array(); } $msg.= ""; foreach($tmparray AS $key=>$value) { $v = explode(",",$value); if(!$v[1]) $v[1] = $v[0]; $msg .= "
"; $msg .= "_RIGHT_($array); return $msg; } function _CHECKBOX($array) { $msg = $this->_LEFT_($array); $msg.= ""; $array["identifier"] = str_replace("[]","",$array["identifier"]);#去除[] $array["list_val"] = str_replace("\r","",$array["list_val"]); $tmparray = explode("\n",$array["list_val"]); if(!$tmparray) { $tmparray = array(); } $tmpvalue = explode(",",$array["default_val"]); if(!$tmpvalue) { $tmpvalue = array(); } $msg.= ""; foreach($tmparray AS $key=>$value) { $v = explode(",",$value); if(!$v[1]) $v[1] = $v[0]; $msg .= ""; $msg.= $this->_RIGHT_($array); return $msg; } function _IMG($array) { $msg = $this->_LEFT_($array); $msg.= ""; $msg.= ""; $msg .= $this->_RIGHT_($array); return $msg; } function _DOWNLOAD($array) { $msg = $this->_LEFT_($array); $msg.= ""; $t_msg = " "; $t_msg .= " "; $t_msg .= ""; $msg.= ""; $msg .= $this->_RIGHT_($array); return $msg; } //影音 function _VIDEO($array) { $msg = $this->_LEFT_($array); $msg.= ""; $t_msg = " "; $t_msg .= " "; $t_msg .= ""; $msg.= ""; $msg .= $this->_RIGHT_($array); return $msg; } //可视化编辑器 function _EDIT($array) { if(!$array["if_html"]) { return $this->_TEXTAREA($array); } $msg = $this->_LEFT_($array); //$toolbar = (intval($array["height"])>0 && intval($array["height"])<300) ? "Basic" : "Default"; $show_html = $array["show_html"] ? true : false; $height = $array["height"] ? $array["height"] : "370px"; $width = $array["width"] ? $array["width"] : "690px"; $array["default_val"] = $this->format_edit_msg($array["default_val"]); $fckeditor = $this->_FckEditor_($array["identifier"],$array["default_val"],$height,$width,$show_html); $msg.= ""; $msg .= $this->_RIGHT_($array); return $msg; } function format_edit_msg($msg) { if(!$msg) { return false; } if(function_exists("base_url")) { $url = base_url(); } else { $app = sys_init(); if($app->config["siteurl"]) { $url = $app->config["siteurl"]; } else { return false; } } $imgArray = array(); preg_match_all("/src=[\"|'| ]((.*)\.(gif|jpg|jpeg|bmp|png|swf))/isU",$msg,$imgArray); $imgArray = array_unique($imgArray[1]); $count = count($imgArray); if($count < 1) { return $msg; } foreach($imgArray AS $key=>$value) { $value = trim($value); if(strpos($value,"http://") === false && $value) { $msg = str_replace($value,$url.$value,$msg); } } return $msg; } function _OPT($array) { if(!$array["link_id"]) { return false; } $msg = $this->_LEFT_($array); $msg.= ""; $msg.= ""; $msg .= $this->_RIGHT_($array); return $msg; } function InputType() { $fields["text"] = "文本框"; $fields["radio"] = "单选框"; $fields["checkbox"] = "复选框"; $fields["textarea"] = "文本区域"; $fields["edit"] = "可视化编辑器"; $fields["select"] = "下拉菜单"; $fields["img"] = "图片选择器"; $fields["video"] = "影音选择器"; $fields["download"] = "下载框选择器"; $fields["opt"] = "联动选择"; $fields["simg"] = "图片选择器(单选)"; $fields["module"] = "内联模块"; return $fields; } function _LEFT_($array) { $msg = "
"; $msg.= "
"; $array["sub_left"] = $array["sub_left"] ? str_replace(":","",$array["sub_left"]) : $array["title"]; $array["sub_left"] = str_replace(":","",$array["sub_left"]); if($array["input"] == "img") { $msg .= "
"; if($array["if_must"]) { $msg .= "* "; } $msg .= $array["sub_left"].":"; $msg .= "
"; $msg .= "
 
"; $msg .= "
 
"; } elseif($array["input"] == "edit") { $msg .= "
"; if($array["if_must"]) { $msg .= "* "; } $msg .= $array["sub_left"].":"; $msg .= "
"; } else { if($array["if_must"]) { $msg .= "* "; } $msg .= $array["sub_left"].":"; } $msg.= "
"; $msg.= "
"; $msg .= "_RIGHT_($array); return $msg; } function _TEXTAREA($array) { $msg = $this->_LEFT_($array); $msg.= ""; $msg.= ""; $msg.= "".$t_msg."".$t_msg."".$fckeditor."
"; return $msg; } function _RIGHT_($array) { if($array["input"] == "edit" && $array["if_html"]) { $msg .= "
"; $msg .= "
".$this->_FckExt($array["identifier"],$array["sub_note"],$array["width"])."
"; } elseif($array["input"] == "textarea" || $array["input"] == "simg" || $array["input"] == "img" ||($array["input"] == "edit" && !$array["if_html"])) { $msg .= "
"; if($array["sub_note"]) { $msg.= "
".$array["sub_note"]."
"; } } else { if($array["sub_note"]) { $msg.= " ".$array["sub_note"].""; } $msg .= ""; } $msg.= ""; $msg.= "
"; $msg.= ""; return $msg; } function _FckEditor_($var="",$defaultvalue="",$toolbar="Default",$height="370px",$width="690px") { return sys_fckeditor($var,$defaultvalue,$toolbar,$height,$width); } function _FckExt($inputname,$subnote="",$width="690px") { $msg = "
"; $msg.= ""; $msg .= ""; $msg.= ""; $msg.= "
 ".$subnote." 
"; return $msg; } } ?>