function GetFormItemValue($ctag, $fvalue) { $fieldname = $ctag->GetName(); $formitem = "\r\n\t\t<table width=\"800\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n <tr>\r\n <td width=\"80\">~name~</td>\r\n <td width=\"720\">~form~</td>\r\n </tr>\r\n </table>\r\n"; $innertext = trim($ctag->GetInnerText()); if ($innertext != "") { if ($ctag->GetAtt("type") == 'select') { $myformItem = ''; $items = explode(',', $innertext); $myformItem = "<select name='{$fieldname}' style='width:150px'>"; foreach ($items as $v) { $v = trim($v); if ($v != '') { if ($fvalue == $v) { $myformItem .= "<option value='{$v}' selected>{$v}</option>\r\n"; } else { $myformItem .= "<option value='{$v}'>{$v}</option>\r\n"; } } } $myformItem .= "</select>\r\n"; $formitem = str_replace("~name~", $ctag->GetAtt('itemname'), $formitem); $formitem = str_replace("~form~", $myformItem, $formitem); return $formitem; } else { if ($ctag->GetAtt("type") == 'radio') { $myformItem = ''; $items = explode(',', $innertext); foreach ($items as $v) { $v = trim($v); if ($v != '') { if ($fvalue == $v) { $myformItem .= "<input type='radio' name='{$fieldname}' class='np' value='{$v}' checked>{$v}\r\n"; } else { $myformItem .= "<input type='radio' name='{$fieldname}' class='np' value='{$v}'>{$v}\r\n"; } } } $formitem = str_replace("~name~", $ctag->GetAtt('itemname'), $formitem); $formitem = str_replace("~form~", $myformItem, $formitem); return $formitem; } else { $formitem = str_replace('~name~', $ctag->GetAtt('itemname'), $formitem); $formitem = str_replace('~form~', $innertext, $formitem); $formitem = str_replace('@value', $fvalue, $formitem); return $formitem; } } } //文本数据的特殊处理 if ($ctag->GetAtt("type") == "textdata") { if (is_file($GLOBALS['cfg_basedir'] . $fvalue)) { $fp = fopen($GLOBALS['cfg_basedir'] . $fvalue, 'r'); $okfvalue = ""; while (!feof($fp)) { $okfvalue .= fgets($fp, 1024); } fclose($fp); } else { $okfvalue = ""; } $formitem = "<table width=\"800\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"80\">" . $ctag->GetAtt('itemname') . "</td>\r\n"; $formitem .= "<td>\r\n" . GetEditor($fieldname, $okfvalue, 350, 'Basic', 'string') . "</td>\r\n"; $formitem .= "</tr></table>\r\n"; $formitem .= "<input type='hidden' name='{$fieldname}_file' value='{$fvalue}'>\r\n"; return $formitem; } else { if ($ctag->GetAtt("type") == "htmltext") { $formitem = "<table width=\"800\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"80\">" . $ctag->GetAtt('itemname') . "</td>\r\n"; $formitem .= "<td>\r\n" . GetEditor($fieldname, $fvalue, 350, 'Basic', 'string') . "</td>\r\n"; $formitem .= "</tr></table>\r\n"; return $formitem; } else { if ($ctag->GetAtt("type") == "multitext") { $innertext = "<textarea name='{$fieldname}' id='{$fieldname}' style='width:100%;height:80'>{$fvalue}</textarea>\r\n"; $formitem = str_replace("~name~", $ctag->GetAtt('itemname'), $formitem); $formitem = str_replace("~form~", $innertext, $formitem); return $formitem; } else { if ($ctag->GetAtt("type") == "datetime") { $nowtime = GetDateTimeMk($fvalue); $innertext = "<input name=\"{$fieldname}\" value=\"{$nowtime}\" type=\"text\" id=\"{$fieldname}\" style=\"width:200\">"; $innertext .= "<input name=\"selPubtime\" type=\"button\" id=\"selkeyword\" value=\"选择\" onClick=\"showCalendar('{$fieldname}', 'Y-m-d H:i:00', '24');\">"; $formitem = str_replace("~name~", $ctag->GetAtt('itemname'), $formitem); $formitem = str_replace("~form~", $innertext, $formitem); return $formitem; } else { if ($ctag->GetAtt("type") == "img") { $ndtp = new DedeTagParse(); $ndtp->LoadSource($fvalue); if (!is_array($ndtp->CTags)) { $ndtp->Clear(); $fvalue = ""; } $ntag = $ndtp->GetTag("img"); $fvalue = trim($ntag->GetInnerText()); $innertext = "<input type='text' name='{$fieldname}' value='{$fvalue}' id='{$fieldname}' style='width:300'><input name='" . $fieldname . "_bt' type='button' value='浏览...' onClick=\"SelectImage('form1.{$fieldname}','big')\">\r\n"; $formitem = str_replace("~name~", $ctag->GetAtt('itemname'), $formitem); $formitem = str_replace("~form~", $innertext, $formitem); return $formitem; } else { if ($ctag->GetAtt("type") == "media") { $innertext = "<input type='text' name='{$fieldname}' value='{$fvalue}' id='{$fieldname}' style='width:300'><input name='" . $fieldname . "_bt' type='button' value='浏览...' onClick=\"SelectMedia('form1.{$fieldname}')\">\r\n"; $formitem = str_replace("~name~", $ctag->GetAtt('itemname'), $formitem); $formitem = str_replace("~form~", $innertext, $formitem); return $formitem; } else { if ($ctag->GetAtt("type") == "addon") { $innertext = "<input type='text' name='{$fieldname}' id='{$fieldname}' value='{$fvalue}' style='width:300'><input name='" . $fieldname . "_bt' type='button' value='浏览...' onClick=\"SelectSoft('form1.{$fieldname}')\">\r\n"; $formitem = str_replace("~name~", $ctag->GetAtt('itemname'), $formitem); $formitem = str_replace("~form~", $innertext, $formitem); return $formitem; } else { $innertext = "<input type='text' name='{$fieldname}' id='{$fieldname}' style='width:200' value='{$fvalue}'>\r\n"; $formitem = str_replace("~name~", $ctag->GetAtt('itemname'), $formitem); $formitem = str_replace("~form~", $innertext, $formitem); return $formitem; } } } } } } } }
function GetFormItemValue($ctag,$fvalue,$admintype='admin') { global $cfg_basedir; $fieldname = $ctag->GetName(); $formitem = $formitem = GetSysTemplets("custom_fields_{$admintype}.htm"); $innertext = trim($ctag->GetInnerText()); $ftype = $ctag->GetAtt("type"); $myformItem = ''; if(eregi("select|radio|checkbox",$ftype)) $items = explode(',',$innertext); if($ftype=='select') { $myformItem = "<select name='$fieldname' style='width:150px'>"; if(is_array($items)) { foreach($items as $v){ $v = trim($v); if($v=='') continue; $myformItem.= ($fvalue==$v ? "<option value='$v' selected>$v</option>\r\n" : "<option value='$v'>$v</option>\r\n"); } } $myformItem .= "</select>\r\n"; $formitem = str_replace("~name~",$ctag->GetAtt('itemname'),$formitem); $formitem = str_replace("~form~",$myformItem,$formitem); return $formitem; }else if($ctag->GetAtt("type")=='radio') { if(is_array($items)) { foreach($items as $v) { $v = trim($v); if($v=='') continue; $myformItem.= ($fvalue==$v ? "<input type='radio' name='$fieldname' class='np' value='$v' checked>$v\r\n" : "<input type='radio' name='$fieldname' class='np' value='$v'>$v\r\n"); } } $formitem = str_replace("~name~",$ctag->GetAtt('itemname'),$formitem); $formitem = str_replace("~form~",$myformItem,$formitem); return $formitem; } //checkbox else if($ctag->GetAtt("type")=='checkbox') { $myformItem = ''; $items = explode(',',$innertext); $fvalues = explode(',',$fvalue); foreach($items as $v){ $v = trim($v); if($v=='') continue; if(in_array($v,$fvalues)){ $myformItem .= "<input type='checkbox' name='{$fieldname}[]' class='np' value='$v' checked='checked' />$v\r\n"; } else{ $myformItem .= "<input type='checkbox' name='{$fieldname}[]' class='np' value='$v' />$v\r\n"; } } $formitem = str_replace("~name~",$ctag->GetAtt('itemname'),$formitem); $formitem = str_replace("~form~",$myformItem,$formitem); return $formitem; } //除了以上类型,如果其它的类型自定义了发布表单,则直接输出发布表单优先 if(!empty($innertext)) { $formitem = str_replace('~name~',$ctag->GetAtt('itemname'),$formitem); $formitem = str_replace('~form~',$innertext,$formitem); $formitem = str_replace('@value',$fvalue,$formitem); return $formitem; } //文本数据的特殊处理 if($ftype=="textdata") { if(is_file($cfg_basedir.$fvalue)){ $fp = fopen($cfg_basedir.$fvalue,'r'); $okfvalue = ""; while(!feof($fp)){ $okfvalue .= fgets($fp,1024); } fclose($fp); }else{ $okfvalue = ''; } if($admintype=='admin') $myformItem = GetEditor($fieldname,$okfvalue,350,'Basic','string')."\r\n <input type='hidden' name='{$fieldname}_file' value='{$fvalue}'>\r\n "; else $myformItem = GetEditor($fieldname,$okfvalue,350,'Member','string')."\r\n <input type='hidden' name='{$fieldname}_file' value='{$fvalue}'>\r\n "; $formitem = str_replace("~name~",$ctag->GetAtt('itemname'),$formitem); $formitem = str_replace("~form~",$myformItem,$formitem); return $formitem; } else if($ftype=="htmltext") { if($admintype=='admin') $myformItem = GetEditor($fieldname,$fvalue,350,'Basic','string')."\r\n "; else $myformItem = GetEditor($fieldname,$fvalue,350,'Member','string')."\r\n "; $formitem = str_replace("~name~",$ctag->GetAtt('itemname'),$formitem); $formitem = str_replace("~form~",$myformItem,$formitem); return $formitem; } else if($ftype=="multitext") { $innertext = "<textarea name='$fieldname' id='$fieldname' style='width:100%;height:80px'>$fvalue</textarea>\r\n"; $formitem = str_replace("~name~",$ctag->GetAtt('itemname'),$formitem); $formitem = str_replace("~form~",$innertext,$formitem); return $formitem; } else if($ftype=="datetime") { $nowtime = GetDateTimeMk($fvalue); $innertext = "<input name=\"$fieldname\" value=\"$nowtime\" type=\"text\" id=\"$fieldname\" style=\"width:250px\">"; $formitem = str_replace("~name~",$ctag->GetAtt('itemname'),$formitem); $formitem = str_replace("~form~",$innertext,$formitem); return $formitem; } else if($ftype=="img") { $ndtp = new DedeTagParse(); $ndtp->LoadSource($fvalue); if(!is_array($ndtp->CTags)){ $ndtp->Clear(); $fvalue = ""; }else { $ntag = $ndtp->GetTag("img"); //$fvalue = trim($ntag->GetInnerText()); $fvalue = trim($ndtp->InnerText); } $innertext = "<input type='text' name='$fieldname' value='$fvalue' id='$fieldname' style='width:300px'> <input name='".$fieldname."_bt' class='inputbut' type='button' value='浏览...' onClick=\"SelectImage('form1.$fieldname','big')\">\r\n"; $formitem = str_replace("~name~",$ctag->GetAtt('itemname'),$formitem); $formitem = str_replace("~form~",$innertext,$formitem); return $formitem; } else if($ftype=="imgfile") { $innertext = "<input type='text' name='$fieldname' value='$fvalue' id='$fieldname' style='width:300px'> <input name='".$fieldname."_bt' class='inputbut' type='button' value='浏览...' onClick=\"SelectImage('form1.$fieldname','big')\">\r\n"; $formitem = str_replace("~name~",$ctag->GetAtt('itemname'),$formitem); $formitem = str_replace("~form~",$innertext,$formitem); return $formitem; } else if($ftype=="media") { $innertext = "<input type='text' name='$fieldname' value='$fvalue' id='$fieldname' style='width:300px'> <input name='".$fieldname."_bt' class='inputbut' type='button' value='浏览...' onClick=\"SelectMedia('form1.$fieldname')\">\r\n"; $formitem = str_replace("~name~",$ctag->GetAtt('itemname'),$formitem); $formitem = str_replace("~form~",$innertext,$formitem); return $formitem; } else if($ftype=="addon") { $innertext = "<input type='text' name='$fieldname' id='$fieldname' value='$fvalue' style='width:300px'> <input name='".$fieldname."_bt' class='inputbut' type='button' value='浏览...' onClick=\"SelectSoft('form1.$fieldname')\">\r\n"; $formitem = str_replace("~name~",$ctag->GetAtt('itemname'),$formitem); $formitem = str_replace("~form~",$innertext,$formitem); return $formitem; } else if($ftype=="int"||$ftype=="float") { $innertext = "<input type='text' name='$fieldname' id='$fieldname' style='width:100px' value='$fvalue'> (填写数值)\r\n"; $formitem = str_replace("~name~",$ctag->GetAtt('itemname'),$formitem); $formitem = str_replace("~form~",$innertext,$formitem); return $formitem; } else { $innertext = "<input type='text' name='$fieldname' id='$fieldname' style='width:250px' value='$fvalue'>\r\n"; $formitem = str_replace("~name~",$ctag->GetAtt('itemname'),$formitem); $formitem = str_replace("~form~",$innertext,$formitem); return $formitem; } }
/** * 获得带值的表单(编辑时用) * * @access public * @param object $ctag 标签 * @param mixed $fvalue 变量值 * @param string $admintype 会员类型 * @param string $fieldname 变量名称 * @return string */ function GetFormItemValue($ctag, $fvalue, $admintype = 'admin', $fieldname = '') { global $cfg_basedir, $dsql; $fieldname = $ctag->GetName(); $formitem = $formitem = GetSysTemplets("custom_fields_{$admintype}.htm"); $innertext = trim($ctag->GetInnerText()); if ($innertext != '') { $formitem = $innertext; } $ftype = $ctag->GetAtt('type'); $myformItem = ''; if (preg_match("/select|radio|checkbox/i", $ftype)) { $items = explode(',', $ctag->GetAtt('default')); } if ($ftype == 'select') { $myformItem = "<select name='{$fieldname}' style='width:150px'>"; if (is_array($items)) { foreach ($items as $v) { $v = trim($v); if ($v == '') { continue; } $myformItem .= $fvalue == $v ? "<option value='{$v}' selected>{$v}</option>\r\n" : "<option value='{$v}'>{$v}</option>\r\n"; } } $myformItem .= "</select>\r\n"; $innertext = $myformItem; } else { if ($ctag->GetAtt("type") == 'stepselect') { global $hasSetEnumJs, $cfg_cmspath; $cmspath = empty($cfg_cmspath) || preg_match('/[/$]/', $cfg_cmspath) ? $cfg_cmspath . '/' : $cfg_cmspath; $myformItem = ''; $myformItem .= "<input type='hidden' id='hidden_{$fieldname}' name='{$fieldname}' value='{$fvalue}' />\r\n"; $myformItem .= "<span id='span_{$fieldname}'></span>\r\n"; $myformItem .= "<span id='span_{$fieldname}_son'></span>\r\n"; $myformItem .= "<span id='span_{$fieldname}_sec'></span>\r\n"; if ($hasSetEnumJs != 'hasset') { $myformItem .= '<script language="javascript" type="text/javascript" src="' . $cmspath . 'images/enums.js"></script>' . "\r\n"; $GLOBALS['hasSetEnumJs'] = 'hasset'; } $myformItem .= "<script language='javascript' type='text/javascript' src='{$cmspath}data/enums/{$fieldname}.js'></script>\r\n"; $myformItem .= "<script language='javascript' type='text/javascript'>MakeTopSelect('{$fieldname}', {$fvalue});</script>\r\n"; $formitem = str_replace('~name~', $ctag->GetAtt('itemname'), $formitem); $formitem = str_replace('~form~', $myformItem, $formitem); return $formitem; } else { if ($ftype == 'radio') { if (is_array($items)) { foreach ($items as $v) { $v = trim($v); if ($v == '') { continue; } $myformItem .= $fvalue == $v ? "<input type='radio' name='{$fieldname}' class='np' value='{$v}' checked='checked' />{$v}\r\n" : "<input type='radio' name='{$fieldname}' class='np' value='{$v}' />{$v}\r\n"; } } $innertext = $myformItem; } else { if ($ftype == 'checkbox') { $myformItem = ''; $fvalues = explode(',', $fvalue); if (is_array($items)) { foreach ($items as $v) { $v = trim($v); if ($v == '') { continue; } if (in_array($v, $fvalues)) { $myformItem .= "<input type='checkbox' name='{$fieldname}[]' class='np' value='{$v}' checked='checked' />{$v}\r\n"; } else { $myformItem .= "<input type='checkbox' name='{$fieldname}[]' class='np' value='{$v}' />{$v}\r\n"; } } } $innertext = $myformItem; } else { if ($ftype == "textdata") { if (is_file($cfg_basedir . $fvalue)) { $fp = fopen($cfg_basedir . $fvalue, 'r'); $okfvalue = ''; while (!feof($fp)) { $okfvalue .= fgets($fp, 1024); } fclose($fp); } else { $okfvalue = ''; } if ($admintype == 'admin') { $myformItem = GetEditor($fieldname, $okfvalue, 350, 'Basic', 'string') . "\r\n <input type='hidden' name='{$fieldname}_file' value='{$fvalue}' />\r\n "; } else { $myformItem = GetEditor($fieldname, $okfvalue, 350, 'Member', 'string') . "\r\n <input type='hidden' name='{$fieldname}_file' value='{$fvalue}' />\r\n "; } $innertext = $myformItem; } else { if ($ftype == "htmltext") { if ($admintype == 'admin') { $myformItem = GetEditor($fieldname, $fvalue, 350, 'Basic', 'string') . "\r\n "; } else { $myformItem = GetEditor($fieldname, $fvalue, 350, 'Member', 'string') . "\r\n "; } $innertext = $myformItem; } else { if ($ftype == "multitext") { $innertext = "<textarea name='{$fieldname}' id='{$fieldname}' style='width:90%;height:80px'>{$fvalue}</textarea>\r\n"; } else { if ($ftype == "datetime") { $nowtime = GetDateTimeMk($fvalue); $innertext = "<input name=\"{$fieldname}\" value=\"{$nowtime}\" type=\"text\" id=\"{$fieldname}\" style=\"width:250px\" class=\"intxt\" />"; $innertext .= " <script language=\"javascript\" type=\"text/javascript\">\r\n Calendar.setup({\r\n inputField : \"{$fieldname}\",\r\n ifFormat : \"%Y-%m-%d %H:%M\",\r\n showsTime : true,\r\n timeFormat : \"24\"\r\n });\r\n </script>"; } else { if ($ftype == "img") { $ndtp = new DedeTagParse(); $ndtp->LoadSource($fvalue); if (!is_array($ndtp->CTags)) { $ndtp->Clear(); $fvalue = ""; } else { $ntag = $ndtp->GetTag("img"); $fvalue = trim($ntag->GetInnerText()); } $innertext = "<input type='text' name='{$fieldname}' value='{$fvalue}' id='{$fieldname}' style='width:300px' class='text' /> <input name='" . $fieldname . "_bt' class='inputbut' type='button' value='浏览...' onClick=\"SelectImage('form1.{$fieldname}','big')\" />\r\n"; } else { if ($ftype == "imgfile") { $innertext = "<input type='text' name='{$fieldname}' value='{$fvalue}' id='{$fieldname}' style='width:300px' class='text' /> <input name='" . $fieldname . "_bt' class='inputbut' type='button' value='浏览...' onClick=\"SelectImage('form1.{$fieldname}','big')\" />\r\n"; } else { if ($ftype == "media") { $innertext = "<input type='text' name='{$fieldname}' value='{$fvalue}' id='{$fieldname}' style='width:300px' class='text' /> <input name='" . $fieldname . "_bt' class='inputbut' type='button' value='浏览...' onClick=\"SelectMedia('form1.{$fieldname}')\" />\r\n"; } else { if ($ftype == "addon") { $innertext = "<input type='text' name='{$fieldname}' id='{$fieldname}' value='{$fvalue}' style='width:300px' class='text' /> <input name='" . $fieldname . "_bt' class='inputbut' type='button' value='浏览...' onClick=\"SelectSoft('form1.{$fieldname}')\" />\r\n"; } else { if ($ftype == "int" || $ftype == "float") { $innertext = "<input type='text' name='{$fieldname}' id='{$fieldname}' style='width:100px' class='intxt' value='{$fvalue}' /> (填写数值)\r\n"; } else { $innertext = "<input type='text' name='{$fieldname}' id='{$fieldname}' style='width:250px' class='intxt' value='{$fvalue}' />\r\n"; } } } } } } } } } } } } } $formitem = str_replace('~name~', $ctag->GetAtt('itemname'), $formitem); $formitem = str_replace('~form~', $innertext, $formitem); return $formitem; }
} //编辑文件,可视化模式 else if($fmdo=="editview") { if(!isset($backurl)) $backurl = ""; if(!isset($ishead)) $ishead = ""; $activepath = str_replace("..","",$activepath); $filename = str_replace("..","",$filename); $file = "$cfg_basedir$activepath/$filename"; $fp = fopen($file,"r"); @$content = fread($fp,filesize($file)); fclose($fp); if((eregi("<html",$content) && eregi("<body",$content)) || $ishead == "yes") { $contentView = GetEditor("str",$content,"500","Default","string","true"); } else { $contentView = GetEditor("str",$content,"500","Default","string","false"); } $GLOBALS['filename'] = $filename; $ctp = new DedeTagParse(); $ctp->LoadTemplate(dirname(__FILE__)."/templets/file_edit_view.htm"); $ctp->display(); } //新建文件 else if($fmdo=="newfile") { $content = ""; $GLOBALS['filename'] = "newfile.txt"; $contentView = "<textarea name='str' style='width:100%;height:400'></textarea>\r\n"; $ctp = new DedeTagParse(); $ctp->LoadTemplate(dirname(__FILE__)."/templets/file_edit.htm"); $ctp->display(); }