123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643 |
- <?php
- /**
- *
- * Form.php (模型表单生成)
- *
- */
- class Form extends Think {
- public $data = array() ,$isadmin=1,$doThumb=1,$doAttach=1,$lang;
- public function __construct($data=array()) {
- $this->data = $data;
- if(APP_LANG)$this->lang = LANG_NAME;
- }
- public function catid($info,$value){
- $validate = getvalidate($info);
- if(APP_LANG){
- $Category = F('Category_'.$this->lang);
- }else{
- $Category = F('Category');
- }
- $id = $field = $info['field'];
- $value = $value ? $value : $this->data[$field];
- $moduleid =$info['moduleid'];
- foreach ($Category as $r){
- $postgroup = explode(',',$r['postgroup']);
- //if( ($this->isadmin && $_SESSION['groupid']!=1 && !in_array($_SESSION['groupid'],$postgroup)) || (empty($this->isadmin) && !in_array( cookie('groupid'),$postgroup)) ) continue;
- //if($r['type']==1) continue;
- $arr= explode(",",$r['arrchildid']);
- $show=0;
- foreach((array)$arr as $rr){
- if($Category[$rr]['moduleid'] ==$moduleid) $show=1;
- }
- if(empty($show))continue;
- $r['disabled'] = $r['child'] ? ' disabled' :'';
- $array[] = $r;
- }
- import ( '@.ORG.Tree' );
- $str = "<option value='\$id' \$disabled \$selected>\$spacer \$catname</option>";
- $tree = new Tree ($array);
- $parseStr .= '<select id="'.$id.'" name="'.$field.'" class=" '.$info['class'].'" '.$validate.'>';
- $parseStr .= '<option value="">'.L('please_chose').'</option>';
- $parseStr .= $tree->get_tree(0, $str, $value);
- $parseStr .= '</select>';
- return $parseStr;
- }
- public function title($info,$value){
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $thumb=$info['setup']['thumb'];
- $style=$info['setup']['style'];
- $id = $field = $info['field'];
- $validate = getvalidate($info);
- $value = $value ? $value : $this->data[$field];
- $title_style = explode(';',$this->data['title_style']);
- $style_color = explode(':',$title_style[0]);
- $style_color = $style_color[1];
- $style_bold = explode(':',$title_style[1]);
- $style_bold = $style_bold[1];
- if(empty($info['setup']['upload_maxsize'])){
- if(APP_LANG){
- $Config = F('Config_'.$this->lang);
- }else{
- $Config = F('Config');
- }
- $info['setup']['upload_maxsize'] = intval(byte_format($Config['attach_maxsize']));
- }
- $yourphp_auth_key = sysmd5(C('ADMIN_ACCESS').$_SERVER['HTTP_USER_AGENT']);
- $yourphp_auth = authcode($this->isadmin.'-1-1-1-jpeg,jpg,png,gif-'.$info['setup']['upload_maxsize'].'-'.$info['moduleid'], 'ENCODE',$yourphp_auth_key);
- $thumb_ico = $this->data['thumb']? $this->data['thumb'] : __ROOT__.'/Public/Images/admin_upload_thumb.png';
- $boldchecked= $style_bold=='bold' ? 'checked' : '';
- $thumbstr ='<div class="thumb_box" id="thumb_box"><div id="thumb_aid_box"></div>
- <a href="javascript:swfupload(\'thumb_uploadfile\',\'thumb\',\''.L('uploadfiles').'\','.$this->isadmin.',1,1,1,\'jpeg,jpg,png,gif\','.$info['setup']['upload_maxsize'].','.$info['moduleid'].',\''.$yourphp_auth.'\',yesdo,nodo)"><img src="'.$thumb_ico.'" id="thumb_pic" ></a><br> <input type="button" value="'.L('clean_thumb').'" onclick="javascript:clean_thumb(\'thumb\');" class="button" />
- <input type="hidden" id="thumb" name="thumb" value="'.$this->data['thumb'].'" /><span class="thumb_tips"></span></div>';
- $parseStr = '<input type="text" class="input-text input-title" name="'.$field.'" id="'.$id.'" value="'.$value.'" size="'.$info['setup']['size'].'" '.$validate.' /> ';
- //gzse7en
- /*
- $stylestr = '<div id="'.$id.'_colorimg" class="colorimg" style="background-color:'.$style_color.'"><img src="__PUBLIC__/Images/admin_color_arrow.gif"></div><input type="hidden" id="'.$id.'_style_color" name="style_color" value="'.$style_color.'" /><input type="checkbox" class="style_bold" id="style_bold" name="style_bold" value="bold" '.$boldchecked.' /><b>'. L('style_bold').'</b><script>$.showcolor("'.$id.'_colorimg","'.$id.'_style_color");</script>';
- */
- if($thumb && $this->doThumb)$parseStr = $thumbstr.$parseStr;
- if($style) $parseStr = $parseStr.$stylestr;
- return $parseStr;
- }
- public function text($info,$value){
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $id = $field = $info['field'];
- $validate = getvalidate($info);
- $info['setup']['ispassword'] ? $inputtext = 'password' : $inputtext = 'text';
- if(ACTION_NAME=='add'){
- $value = $value ? $value : $info['setup']['default'];
- }else{
- $value = $value ? $value : $this->data[$field];
- }
- $parseStr = '<input type="'.$inputtext.'" class="input-text '.$info['class'].'" name="'.$field.'" id="'.$id.'" value="'.stripcslashes($value).'" size="'.$info['setup']['size'].'" '.$validate.'/> ';
- return $parseStr;
- }
- public function verify($info,$value){
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $id = $field = $info['field'];
- $validate = getvalidate($info);
- $parseStr = '<input class="input-text '.$info['class'].'" name="'.$field.'" id="'.$id.'" value="" size="'.$info['setup']['size'].'" '.$validate.' /><img src="'.URL('Home-Index/verify').'" onclick="javascript:resetVerifyCode();" class="checkcode" align="absmiddle" title="点击刷新验证码" id="verifyImage"/>';
- return $parseStr;
- }
- public function number($info,$value){
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $id = $field = $info['field'];
- $validate = getvalidate($info);
- $info['setup']['ispassowrd'] ? $inputtext = 'passowrd' : $inputtext = 'text';
- if(ACTION_NAME=='add'){
- $value = $value ? $value : $info['setup']['default'];
- }else{
- $value = $value ? $value : $this->data[$field];
- }
- $parseStr = '<input type="'.$inputtext.'" class="input-text '.$info['class'].'" name="'.$field.'" id="'.$id.'" value="'.$value.'" size="'.$info['setup']['size'].'" '.$validate.'/> ';
- return $parseStr;
- }
- public function textarea($info,$value){
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $id = $field = $info['field'];
- $validate = getvalidate($info);
- if(ACTION_NAME=='add'){
- $value = $value ? $value : $info['setup']['default'];
- }else{
- $value = $value ? $value : $this->data[$field];
- }
- $parseStr = '<textarea class="'.$info['class'].'" name="'.$field.'" rows="'.$info['setup']['rows'].'" cols="'.$info['setup']['cols'].'" id="'.$id.'" '.$validate.'/>'.stripcslashes($value).'</textarea>';
- return $parseStr;
- }
- public function select($info,$value){
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $id = $field = $info['field'];
- $validate = getvalidate($info);
- if(ACTION_NAME=='add'){
- $value = $value ? $value : $info['setup']['default'];
- }else{
- $value = $value ? $value : $this->data[$field];
- }
- if($value != '') $value = strpos($value, ',') ? explode(',', $value) : $value;
- if(is_array($info['options'])){
- if($info['options_key']){
- $options_key=explode(',',$info['options_key']);
- foreach((array)$info['options'] as $key=>$res){
- if($options_key[0]=='key'){
- $optionsarr[$key]=$res[$options_key[1]];
- }else{
- $optionsarr[$res[$options_key[0]]]=$res[$options_key[1]];
- }
- }
- }else{
- $optionsarr = $info['options'];
- }
- }else{
- $options = $info['setup']['options'];
- $options = explode("\n",$info['setup']['options']);
- foreach($options as $r) {
- $v = explode("|",$r);
- $k = trim($v[1]);
- $optionsarr[$k] = $v[0];
- }
- }
- if(!empty($info['setup']['multiple'])) {
- $parseStr = '<select id="'.$id.'" name="'.$field.'" onchange="'.$info['setup']['onchange'].'" class="'.$info['class'].'" '.$validate.' size="'.$info['setup']['size'].'" multiple="multiple" >';
- }else {
- $parseStr = '<select id="'.$id.'" name="'.$field.'" onchange="'.$info['setup']['onchange'].'" class="'.$info['class'].'" '.$validate.'>';
- }
- if(is_array($optionsarr)) {
- foreach($optionsarr as $key=>$val) {
- if(!empty($value)){
- $selected='';
- if($value==$key || in_array($key,$value)) $selected = ' selected="selected"';
- $parseStr .= '<option '.$selected.' value="'.$key.'">'.$val.'</option>';
- }else{
- $parseStr .= '<option value="'.$key.'">'.$val.'</option>';
- }
- }
- }
- $parseStr .= '</select>';
- return $parseStr;
- }
- public function checkbox($info,$value){
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $id = $field = $info['field'];
- $validate = getvalidate($info);
- if(ACTION_NAME=='add'){
- $value = $value ? $value : $info['setup']['default'];
- }else{
- $value = $value ? $value : $this->data[$field];
- }
- $labelwidth = $info['setup']['labelwidth'];
- if(is_array($info['options'])){
- if($info['options_key']){
- $options_key=explode(',',$info['options_key']);
- foreach((array)$info['options'] as $key=>$res){
- if($options_key[0]=='key'){
- $optionsarr[$key]=$res[$options_key[1]];
- }else{
- $optionsarr[$res[$options_key[0]]]=$res[$options_key[1]];
- }
- }
- }else{
- $optionsarr = $info['options'];
- }
- }else{
- $options = $info['setup']['options'];
- $options = explode("\n",$info['setup']['options']);
- foreach($options as $r) {
- $v = explode("|",$r);
- $k = trim($v[1]);
- $optionsarr[$k] = $v[0];
- }
- }
- if($value != '') $value = (strpos($value, ',') && !is_array($value)) ? explode(',', $value) : $value ;
- $value = is_array($value) ? $value : array($value);
- $i = 1;
- $onclick = $info['setup']['onclick'] ? ' onclick="'.$info['setup']['onclick'].'" ' : '' ;
- foreach($optionsarr as $key=>$r) {
- $key = trim($key);
- if($i>1) $validate='';
- $checked = ($value && in_array($key, $value)) ? 'checked' : '';
- if($labelwidth) $parseStr .= '<label style="float:left;width:'.$labelwidth.'px" class="checkbox_'.$id.'" >';
- $parseStr .= '<input type="checkbox" class="input_checkbox '.$info['class'].'" name="'.$field.'[]" id="'.$id.'_'.$i.'" '.$checked.$onclick.' value="'.htmlspecialchars($key).'" '.$validate.'> '.htmlspecialchars($r);
- if($labelwidth) $parseStr .= '</label>';
- $i++;
- }
- return $parseStr;
- }
- public function radio($info,$value){
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $id = $field = $info['field'];
- $validate = getvalidate($info);
- if(ACTION_NAME=='add'){
- $value = $value ? $value : $info['setup']['default'];
- }else{
- $value = $value ? $value : $this->data[$field];
- }
- $labelwidth = $info['setup']['labelwidth'];
- if(is_array($info['options'])){
- if($info['options_key']){
- $options_key=explode(',',$info['options_key']);
- foreach((array)$info['options'] as $key=>$res){
- if($options_key[0]=='key'){
- $optionsarr[$key]=$res[$options_key[1]];
- }else{
- $optionsarr[$res[$options_key[0]]]=$res[$options_key[1]];
- }
- }
- }else{
- $optionsarr = $info['options'];
- }
- }else{
- $options = $info['setup']['options'];
- $options = explode("\n",$info['setup']['options']);
- foreach($options as $r) {
- $v = explode("|",$r);
- $k = trim($v[1]);
- $optionsarr[$k] = $v[0];
- }
- }
- $onclick = $info['setup']['onclick'] ? ' onclick="'.$info['setup']['onclick'].'" ' : '' ;
- $i = 1;
- foreach($optionsarr as $key=>$r) {
- if($i>1) $validate ='';
- $checked = trim($value)==trim($key) ? 'checked' : '';
- if(empty($value) && empty($key) ) $checked = 'checked';
- if($labelwidth) $parseStr .= '<label style="float:left;width:'.$labelwidth.'px" class="checkbox_'.$id.'" >';
- $parseStr .= '<input type="radio" class="input_radio '.$info['class'].'" name="'.$field.'" id="'.$id.'_'.$i.'" '.$checked.$onclick.' value="'.$key.'" '.$validate.'> '.$r;
- if($labelwidth) $parseStr .= '</label>';
- $i++;
- }
- return $parseStr;
- }
- public function editor($info,$value){
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $id = $field = $info['field'];
- $validate = getvalidate($info);
- if(ACTION_NAME=='add'){
- $value = $value ? $value : $info['setup']['default'];
- }else{
- $value = $value ? $value : $this->data[$field];
- }
- $textareaid = $field;
- $toolbar = $info['setup']['toolbar'];
- $moduleid = $info['moduleid'];
- $height = $info['setup']['height'] ? $info['setup']['height'] : 300;
- $flashupload = $info['setup']['flashupload']==1 ? 1 : '';
- $alowuploadexts = $info['setup']['alowuploadexts'] ? $info['setup']['alowuploadexts'] : 'jpg,gif,png';
- $alowuploadlimit=$info['setup']['alowuploadlimit'] ? $info['setup']['alowuploadlimit'] : 20 ;
- $show_page=$info['setup']['showpage'];
- if(APP_LANG){
- $Config = F('Config_'.$this->lang);
- }else{
- $Config = F('Config');
- }
- $file_size = intval(byte_format($Config['attach_maxsize']));
- $yourphp_auth_key = sysmd5(C('ADMIN_ACCESS').$_SERVER['HTTP_USER_AGENT']);
- $attach_auth = authcode("$this->isadmin-1-0-$alowuploadlimit-$Config[attach_allowext]-$file_size-$moduleid", 'ENCODE',$yourphp_auth_key);
- $yourphp_auth = authcode("$this->isadmin-1-0-$alowuploadlimit-$alowuploadexts-$file_size-$moduleid", 'ENCODE',$yourphp_auth_key);
- $str ='';
- $str .= '<div class="editor_box"><div style="display:none;" id="'.$field.'_aid_box"></div><textarea name="'.$field.'" class="'.$info['class'].'" id="'.$id.'" boxid="'.$id.'" '.$validate.' style="width:99%;height:'.$height.'px;visibility:hidden;">'.$value.'</textarea>';
- $show_page = $show_page ? 1 : 0;
- if ($info['setup']['edittype']=='Xheditor'){
- if($toolbar=='basic'){
- $modtools = 'simple';
- } elseif($toolbar == 'full') {
- $modtools = $this->isadmin ? 'full' : 'mfull';
- } elseif($toolbar == 'desc') {
- $modtools = 'mini';
- } else {
- $modtools = '';
- }
- $str .="<script type=\"text/javascript\" src=\"".__ROOT__."/Public/Xheditor/xheditor-zh-cn.min.js\"></script>";
- $str .="<script type=\"text/javascript\"> \r\n";
- $str .="var editor_".$id."=$('#".$id."').xheditor({ ";
- $str .="plugins:plugins,tools:'".$modtools."',loadCSS:'<style>pre{margin:12px;background:#EFEFEF;border:1px solid #ddd;border-left:3px solid #6CE26C;padding:10px;padding-top: 1px;}</style>',shortcuts:{'ctrl+enter':submitForm},width:\"100%\",height:\"$height\"";
- if($flashupload){
- $str .=",upLinkUrl:\"!".__ROOT__."/index.php?g=Admin&m=Attachment&a=index&isadmin=$this->isadmin&more=1&isthumb=0&file_limit=$alowuploadlimit&file_types=$Config[attach_allowext]&file_size=$file_size&moduleid=$moduleid&auth=$attach_auth&editorid=$id&immediate=1&l=$this->lang\"";
- $str .=",upImgUrl:\"!".__ROOT__."/index.php?g=Admin&m=Attachment&a=index&isadmin=$this->isadmin&more=1&isthumb=0&file_limit=$alowuploadlimit&file_types=$alowuploadexts&file_size=$file_size&moduleid=$moduleid&auth=$yourphp_auth&editorid=$id&immediate=1&l=$this->lang\"";
- $yourphp_auth = authcode("$this->isadmin-1-0-$alowuploadlimit-swf-$file_size-$moduleid", 'ENCODE',$yourphp_auth_key);
- $str .=",upFlashUrl:\"!".__ROOT__."/index.php?g=Admin&m=Attachment&a=index&isadmin=$this->isadmin&more=1&isthumb=0&file_limit=$alowuploadlimit&file_types=swf&file_size=$file_size&moduleid=$moduleid&auth=$yourphp_auth&editorid=$id&immediate=1&l=$this->lang\"";
- $yourphp_auth = authcode("$this->isadmin-1-0-$alowuploadlimit-mpg,wmv,avi,wma,mp3,mid,asf,rm-$file_size-$moduleid", 'ENCODE',$yourphp_auth_key);
- $str .=",upMediaUrl:\"!".__ROOT__."/index.php?g=Admin&m=Attachment&a=index&isadmin=$this->isadmin&more=1&isthumb=0&file_limit=$alowuploadlimit&file_types=mpg,wmv,avi,wma,mp3,mid,asf,rm&file_size=$file_size&moduleid=$moduleid&auth=$yourphp_auth&editorid=$id&immediate=1&l=$this->lang\"";
- $str .=",onUpload:upokis,modalWidth:\"600\",modalHeight:\"455\"";
- }
- $str .= "});</script>";
- $str .='<div class=\'editor_bottom1\'>';
- if($show_page) $str .='<a href="javascript:void(0);" onclick="editor_'.$id.'.pasteText(\'[page]\');return false;">'.L('page_break').'</a>';
- if($info['setup']['show_add_description']) $str .='<input type="checkbox" class="input_radio" name="add_description" value="1" checked /> '.L('add_description').' <input type="text" name="description_length" value="200" style="width:24px;" size="3" />'.L('description_length');
- if($info['setup']['show_auto_thumb']) $str .='<input type="checkbox" class="input_radio" name="auto_thumb" value="1" checked /> '.L('auto_thumb').'<input type="text" name="auto_thumb_no" value="1" size="1" />'.L('auto_thumb_no');
- $str .= '</div></div>';
- }else{
- $upurl= __ROOT__."/index.php?g=Admin&m=Attachment&a=index&isadmin=$this->isadmin&more=1&isthumb=0&file_limit=$alowuploadlimit&file_types=$Config[attach_allowext]&file_size=$file_size&moduleid=$moduleid&auth=$attach_auth&l=$this->lang";
- $yourphp_auth = authcode("$this->isadmin-1-0-1-gif,jpg,jpeg,png,bmp-$file_size-$moduleid", 'ENCODE',$yourphp_auth_key);
- $upImgUrl =__ROOT__."/index.php?g=Admin&m=Attachment&a=index&isadmin=$this->isadmin&more=1&isthumb=0&file_limit=1&file_types=gif,jpg,jpeg,png,bmp&file_size=$file_size&moduleid=$moduleid&auth=$yourphp_auth&l=$this->lang";
- $yourphp_auth = authcode("$this->isadmin-1-0-1-swf,flv-$file_size-$moduleid", 'ENCODE',$yourphp_auth_key);
- $upFlashUrl=__ROOT__."/index.php?g=Admin&m=Attachment&a=index&isadmin=$this->isadmin&more=1&isthumb=0&file_limit=1&file_types=swf,flv&file_size=$file_size&moduleid=$moduleid&auth=$yourphp_auth&l=$this->lang";
- $yourphp_auth = authcode("$this->isadmin-1-0-1-mpg,wmv,avi,wma,mp3,mid,asf,rm,rmvb,wav,wma,mp4-$file_size-$moduleid", 'ENCODE',$yourphp_auth_key);
- $upMediaUrl=__ROOT__."/index.php?g=Admin&m=Attachment&a=index&isadmin=$this->isadmin&more=1&isthumb=0&file_limit=1&file_types=mpg,wmv,avi,wma,mp3,mid,asf,rm,rmvb,wav,wma,mp4&file_size=$file_size&moduleid=$moduleid&auth=$yourphp_auth&l=$this->lang";
- $str .="<script type=\"text/javascript\" src=\"".__ROOT__."/Public/Kindeditor/kindeditor-min.js\"></script>";
- $str .= "<script type=\"text/javascript\">\r\n";
- $str .= "KindEditor.ready(function(K) {\r\n";
- $str .= "K.create('#".$id."', {\r\n";
- $str .= "cssPath : '".__ROOT__."/Public/Kindeditor/plugins/code/prettify.css',";
- //$str .= "uploadJson : '$upurl',";
- $str .= "fileManagerJson:'$upurl',";
- $str .= "editorid:'$id',";
- $str .= "upImgUrl:'$upImgUrl',";
- $str .= "upFlashUrl:'$upFlashUrl',";
- $str .= "upMediaUrl:'$upMediaUrl',";
- $str .= "allowFileManager : true\r\n";
- $str .= "});\r\n";
- $str .= "});\r\n";
- $str .= '</script>';
- $str .='<div class=\'editor_bottom2\'>';
- if($info['setup']['show_add_description']) $str .='<input type="checkbox" name="add_description" value="1" checked /> '.L('add_description').'
- <input type="text" name="description_length" value="200" style="width:24px;" size="3" />'.L('description_length');
- if($info['setup']['show_auto_thumb']) $str .='<input type="checkbox" name="auto_thumb" value="1" checked /> '.L('auto_thumb').'
- <input type="text" name="auto_thumb_no" value="1" size="1" />'.L('auto_thumb_no');
- $str .= '</div></div>';
- }
- return $str;
- }
- public function datetime($info,$value){
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $id = $field = $info['field'];
- $validate = getvalidate($info);
- if(ACTION_NAME=='add'){
- $value = $value ? $value : $info['setup']['default'];
- }else{
- $value = $value ? $value : $this->data[$field];
- }
- $value = $value ? toDate($value,"Y-m-d H:i:s") : toDate(time(),"Y-m-d H:i:s");
- $parseStr = '<input class="Wdate input-text '.$info['class'].'" '.$validate.' name="'.$field.'" type="text" id="'.$id.'" size="25" onFocus="WdatePicker({dateFmt:\'yyyy-MM-dd HH:mm:ss\'
- })" value="'.$value.'" />';
- return $parseStr;
- }
- public function groupid($info,$value){
- $newinfo = $info;
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $groups=F('Role');$options=array();
- foreach($groups as $key=>$r) {
- if($r['status']){
- $options[$key]=$r['name'];
- }
- }
- $newinfo['options']=$options;
- $fun=$info['setup']['inputtype'];
- return $this->$fun($newinfo,$value);
- }
- public function posid($info,$value){
- $newinfo = $info;
- $posids=F('Posid');
- $options=array();
- $options[0]= L('please_chose');
- foreach($posids as $key=>$r) {
- $options[$key]=$r['name'];
- }
- $newinfo['options']=$options;
- $fun=$info['setup']['inputtype'];
- return $this->select($newinfo,$value);
- }
- public function typeid($info,$value){
- $newinfo = $info;
- $types=F('Type');
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $id = $field = $info['field'];
- $value = $value ? $value : $this->data[$field];
- $parentid=$info['setup']['default'];
- $keyid = $types[$parentid]['keyid'];
- $options=array();
- $options[0]= L('please_chose');
- foreach((array)$types as $key => $r) {
- if($r['keyid']!=$keyid) continue;
- $r['id']=$r['typeid'];
- $array[] = $r;
- $options[$key]=$r['name'];
- }
- import ( '@.ORG.Tree' );
- $str = "<option value='\$typeid' \$selected>\$spacer \$name</option>";
- $tree = new Tree ($array);
- $tree->nbsp=' ';
- $select_type = $tree->get_tree(0, $str,$value);
- $fun=$info['setup']['inputtype'];
- if($fun=='select'){
- return '<SELECT id="'.$id.'" class="'.$info['class'].'" name="'.$field.'"><option value="0">'.L('please_chose').'</option>'. $select_type.'</select>';
- }else{
- $newinfo['options']=$options;
- return $this->$fun($newinfo,$value);
- }
- }
- public function template($info,$value){
- $templates= template_file(MODULE_NAME);
- $newinfo = $info;
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $options=array();
- $options[0]= L('please_chose');
- foreach($templates as $key=>$r) {
- if(strstr($r['value'],'show')){
- $options[$r['value']]=$r['filename'];
- }
- }
- $newinfo['options']=$options;
- $fun=$info['setup']['inputtype'];
- return $this->select($newinfo,$value);
- }
- public function image($info,$value){
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $id = $field = $info['field'];
- $validate = getvalidate($info);
- if(ACTION_NAME=='add'){
- $value = $value ? $value : $info['setup']['default'];
- }else{
- $value = $value ? $value : $this->data[$field];
- }
- if(empty($info['setup']['upload_maxsize'])){
- if(APP_LANG){
- $Config = F('Config_'.$this->lang);
- }else{
- $Config = F('Config');
- }
- $info['setup']['upload_maxsize'] = intval(byte_format($Config['attach_maxsize']));
- }
- $yourphp_auth_key = sysmd5(C('ADMIN_ACCESS').$_SERVER['HTTP_USER_AGENT']);
- $yourphp_auth = authcode($this->isadmin.'-'.$info['setup']['more'].'-0-1-'.$info['setup']['upload_allowext'].'-'.$info['setup']['upload_maxsize'].'-'.$info['moduleid'], 'ENCODE',$yourphp_auth_key);
- $parseStr = ' <div id="'.$field.'_aid_box"></div><input type="text" class="input-text '.$info['class'].'" name="'.$field.'" id="'.$id.'" value="'.$value.'" size="'.$info['setup']['size'].'" '.$validate.'/> <input type="button" class="button" value="'.L('upload_images').'" onclick="javascript:swfupload(\''.$field.'_uploadfile\',\''.$field.'\',\''.L('uploadfiles').'\','.$this->isadmin.','.$info['setup']['more'].',0,1,\''.$info['setup']['upload_allowext'].'\','.$info['setup']['upload_maxsize'].','.$info['moduleid'].',\''.$yourphp_auth.'\',up_image,nodo)"> ';
- return $parseStr;
- }
- public function images($info,$value){
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $id = $field = $info['field'];
- $validate = getvalidate($info);
- if(ACTION_NAME=='add'){
- $value = $value ? $value : $info['setup']['default'];
- }else{
- $value = $value ? $value : $this->data[$field];
- }
- $data='';
- $i=0;
- if($value){
- $options = explode(":::",$value);
- if(is_array($options)){
- foreach($options as $r) {
- $v = explode("|",$r);
- $k = trim($v[1]);
- $optionsarr[$k] = $v[0];
- $data .='<div id="uplistd_'.$i.'"><input type="text" size="50" class="input-text" name="'.$field.'[]" value="'.$v[0].'" /> <input type="text" class="input-text" name="'.$field.'_name[]" value="'.$v[1].'" size="30" /> <a href="javascript:remove_this(\'uplistd_'.$i.'\');">'.L('remove').'</a> </div>';
- $i++;
- }
- }
- }
- if(empty($info['setup']['upload_maxsize'])){
- if(APP_LANG){
- $Config = F('Config_'.$this->lang);
- }else{
- $Config = F('Config');
- }
- $info['setup']['upload_maxsize'] = intval(byte_format($Config['attach_maxsize']));
- }
- $yourphp_auth_key = sysmd5(C('ADMIN_ACCESS').$_SERVER['HTTP_USER_AGENT']);
- $yourphp_auth = authcode($this->isadmin.'-'.$info['setup']['more'].'-0-'.$info['setup']['upload_maxnum'].'-'.$info['setup']['upload_allowext'].'-'.$info['setup']['upload_maxsize'].'-'.$info['moduleid'], 'ENCODE',$yourphp_auth_key);
- $parseStr = '
- <fieldset class="images_box">
- <legend>'.L('upload_images').'</legend><center><div>'.L('upload_maxfiles').' <font color=\'red\'>'.$info['setup']['upload_maxnum'].'</font> '.L('zhang').'</div></center>
- <div id="'.$field.'_images" class="imagesList"><input type="hidden" name="'.$field.'[]" value=""/><input type="hidden" name="'.$field.'_name[]" value="" />'.$data.'</div>
- </fieldset>
- <div class="c"></div>
- <input type="button" class="button" value="'.L('upload_images').'" onclick="javascript:swfupload(\''.$field.'_uploadfile\',\''.$field.'\',\''.L('uploadfiles').'\','.$this->isadmin.','.$info['setup']['more'].',0,'.$info['setup']['upload_maxnum'].',\''.$info['setup']['upload_allowext'].'\','.$info['setup']['upload_maxsize'].','.$info['moduleid'].',\''.$yourphp_auth.'\',up_images,nodo)"> ';
- return $parseStr;
- }
- public function file($info,$value){
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $id = $field = $info['field'];
- $validate = getvalidate($info);
- if(ACTION_NAME=='add'){
- $value = $value ? $value : $info['setup']['default'];
- }else{
- $value = $value ? $value : $this->data[$field];
- }
- if(empty($info['setup']['upload_maxsize'])){
- if(APP_LANG){
- $Config = F('Config_'.$this->lang);
- }else{
- $Config = F('Config');
- }
- $info['setup']['upload_maxsize'] = intval(byte_format($Config['attach_maxsize']));
- }
- $yourphp_auth_key = sysmd5(C('ADMIN_ACCESS').$_SERVER['HTTP_USER_AGENT']);
- $yourphp_auth = authcode($this->isadmin.'-'.$info['setup']['more'].'-0-1-'.$info['setup']['upload_allowext'].'-'.$info['setup']['upload_maxsize'].'-'.$info['moduleid'], 'ENCODE',$yourphp_auth_key);
- $parseStr = ' <div id="'.$field.'_aid_box"></div><input type="text" class="input-text '.$info['class'].'" name="'.$field.'" id="'.$id.'" value="'.$value.'" size="'.$info['setup']['size'].'" '.$validate.'/> <input type="button" class="button" value="'.L('upload_files').'" onclick="javascript:swfupload(\''.$field.'_uploadfile\',\''.$field.'\',\''.L('uploadfiles').'\','.$this->isadmin.','.$info['setup']['more'].',0,1,\''.$info['setup']['upload_allowext'].'\','.$info['setup']['upload_maxsize'].','.$info['moduleid'].',\''.$yourphp_auth.'\',up_image,nodo)"> ';
- return $parseStr;
- }
- public function files($info,$value){
- $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
- $id = $field = $info['field'];
- $validate = getvalidate($info);
- if(ACTION_NAME=='add'){
- $value = $value ? $value : $info['setup']['default'];
- }else{
- $value = $value ? $value : $this->data[$field];
- }
- if(empty($info['setup']['upload_maxsize'])){
- if(APP_LANG){
- $Config = F('Config_'.$this->lang);
- }else{
- $Config = F('Config');
- }
- $info['setup']['upload_maxsize'] = intval(byte_format($Config['attach_maxsize']));
- }
- $yourphp_auth_key = sysmd5(C('ADMIN_ACCESS').$_SERVER['HTTP_USER_AGENT']);
- $yourphp_auth = authcode($this->isadmin.'-'.$info['setup']['more'].'-0-'.$info['setup']['upload_maxnum'].'-'.$info['setup']['upload_allowext'].'-'.$info['setup']['upload_maxsize'].'-'.$info['moduleid'], 'ENCODE',$yourphp_auth_key);
- $parseStr = '<fieldset class="images_box">
- <legend>'.L('upload_images').'</legend><center><div>'.L('upload_maxfiles').' <font color=\'red\'>'.$info['setup']['upload_maxnum'].'</font> '.L('zhang').'</div></center>
- <div id="'.$field.'_images" class="imagesList"></div>
- </fieldset>
- <input type="button" style="margin-left:5px;" class="button" value="'.L('upload_files').'" onclick="javascript:swfupload(\''.$field.'_uploadfile\',\''.$field.'\',\''.L('uploadfiles').'\','.$this->isadmin.','.$info['setup']['more'].',0,'.$info['setup']['upload_maxnum'].',\''.$info['setup']['upload_allowext'].'\','.$info['setup']['upload_maxsize'].','.$info['moduleid'].',\''.$yourphp_auth.'\',up_images,nodo)"> ';
- return $parseStr;
- }
- }
- ?>
|