Form.class.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <?php
  2. /**
  3. *
  4. * Form.php (模型表单生成)
  5. *
  6. */
  7. class Form extends Think {
  8. public $data = array() ,$isadmin=1,$doThumb=1,$doAttach=1,$lang;
  9. public function __construct($data=array()) {
  10. $this->data = $data;
  11. if(APP_LANG)$this->lang = LANG_NAME;
  12. }
  13. public function catid($info,$value){
  14. $validate = getvalidate($info);
  15. if(APP_LANG){
  16. $Category = F('Category_'.$this->lang);
  17. }else{
  18. $Category = F('Category');
  19. }
  20. $id = $field = $info['field'];
  21. $value = $value ? $value : $this->data[$field];
  22. $moduleid =$info['moduleid'];
  23. foreach ($Category as $r){
  24. $postgroup = explode(',',$r['postgroup']);
  25. //if( ($this->isadmin && $_SESSION['groupid']!=1 && !in_array($_SESSION['groupid'],$postgroup)) || (empty($this->isadmin) && !in_array( cookie('groupid'),$postgroup)) ) continue;
  26. //if($r['type']==1) continue;
  27. $arr= explode(",",$r['arrchildid']);
  28. $show=0;
  29. foreach((array)$arr as $rr){
  30. if($Category[$rr]['moduleid'] ==$moduleid) $show=1;
  31. }
  32. if(empty($show))continue;
  33. $r['disabled'] = $r['child'] ? ' disabled' :'';
  34. $array[] = $r;
  35. }
  36. import ( '@.ORG.Tree' );
  37. $str = "<option value='\$id' \$disabled \$selected>\$spacer \$catname</option>";
  38. $tree = new Tree ($array);
  39. $parseStr .= '<select id="'.$id.'" name="'.$field.'" class=" '.$info['class'].'" '.$validate.'>';
  40. $parseStr .= '<option value="">'.L('please_chose').'</option>';
  41. $parseStr .= $tree->get_tree(0, $str, $value);
  42. $parseStr .= '</select>';
  43. return $parseStr;
  44. }
  45. public function title($info,$value){
  46. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  47. $thumb=$info['setup']['thumb'];
  48. $style=$info['setup']['style'];
  49. $id = $field = $info['field'];
  50. $validate = getvalidate($info);
  51. $value = $value ? $value : $this->data[$field];
  52. $title_style = explode(';',$this->data['title_style']);
  53. $style_color = explode(':',$title_style[0]);
  54. $style_color = $style_color[1];
  55. $style_bold = explode(':',$title_style[1]);
  56. $style_bold = $style_bold[1];
  57. if(empty($info['setup']['upload_maxsize'])){
  58. if(APP_LANG){
  59. $Config = F('Config_'.$this->lang);
  60. }else{
  61. $Config = F('Config');
  62. }
  63. $info['setup']['upload_maxsize'] = intval(byte_format($Config['attach_maxsize']));
  64. }
  65. $yourphp_auth_key = sysmd5(C('ADMIN_ACCESS').$_SERVER['HTTP_USER_AGENT']);
  66. $yourphp_auth = authcode($this->isadmin.'-1-1-1-jpeg,jpg,png,gif-'.$info['setup']['upload_maxsize'].'-'.$info['moduleid'], 'ENCODE',$yourphp_auth_key);
  67. $thumb_ico = $this->data['thumb']? $this->data['thumb'] : __ROOT__.'/Public/Images/admin_upload_thumb.png';
  68. $boldchecked= $style_bold=='bold' ? 'checked' : '';
  69. $thumbstr ='<div class="thumb_box" id="thumb_box"><div id="thumb_aid_box"></div>
  70. <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" />
  71. <input type="hidden" id="thumb" name="thumb" value="'.$this->data['thumb'].'" /><span class="thumb_tips"></span></div>';
  72. $parseStr = '<input type="text" class="input-text input-title" name="'.$field.'" id="'.$id.'" value="'.$value.'" size="'.$info['setup']['size'].'" '.$validate.' /> &nbsp;';
  73. //gzse7en
  74. /*
  75. $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>';
  76. */
  77. if($thumb && $this->doThumb)$parseStr = $thumbstr.$parseStr;
  78. if($style) $parseStr = $parseStr.$stylestr;
  79. return $parseStr;
  80. }
  81. public function text($info,$value){
  82. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  83. $id = $field = $info['field'];
  84. $validate = getvalidate($info);
  85. $info['setup']['ispassword'] ? $inputtext = 'password' : $inputtext = 'text';
  86. if(ACTION_NAME=='add'){
  87. $value = $value ? $value : $info['setup']['default'];
  88. }else{
  89. $value = $value ? $value : $this->data[$field];
  90. }
  91. $parseStr = '<input type="'.$inputtext.'" class="input-text '.$info['class'].'" name="'.$field.'" id="'.$id.'" value="'.stripcslashes($value).'" size="'.$info['setup']['size'].'" '.$validate.'/> ';
  92. return $parseStr;
  93. }
  94. public function verify($info,$value){
  95. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  96. $id = $field = $info['field'];
  97. $validate = getvalidate($info);
  98. $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"/>';
  99. return $parseStr;
  100. }
  101. public function number($info,$value){
  102. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  103. $id = $field = $info['field'];
  104. $validate = getvalidate($info);
  105. $info['setup']['ispassowrd'] ? $inputtext = 'passowrd' : $inputtext = 'text';
  106. if(ACTION_NAME=='add'){
  107. $value = $value ? $value : $info['setup']['default'];
  108. }else{
  109. $value = $value ? $value : $this->data[$field];
  110. }
  111. $parseStr = '<input type="'.$inputtext.'" class="input-text '.$info['class'].'" name="'.$field.'" id="'.$id.'" value="'.$value.'" size="'.$info['setup']['size'].'" '.$validate.'/> ';
  112. return $parseStr;
  113. }
  114. public function textarea($info,$value){
  115. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  116. $id = $field = $info['field'];
  117. $validate = getvalidate($info);
  118. if(ACTION_NAME=='add'){
  119. $value = $value ? $value : $info['setup']['default'];
  120. }else{
  121. $value = $value ? $value : $this->data[$field];
  122. }
  123. $parseStr = '<textarea class="'.$info['class'].'" name="'.$field.'" rows="'.$info['setup']['rows'].'" cols="'.$info['setup']['cols'].'" id="'.$id.'" '.$validate.'/>'.stripcslashes($value).'</textarea>';
  124. return $parseStr;
  125. }
  126. public function select($info,$value){
  127. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  128. $id = $field = $info['field'];
  129. $validate = getvalidate($info);
  130. if(ACTION_NAME=='add'){
  131. $value = $value ? $value : $info['setup']['default'];
  132. }else{
  133. $value = $value ? $value : $this->data[$field];
  134. }
  135. if($value != '') $value = strpos($value, ',') ? explode(',', $value) : $value;
  136. if(is_array($info['options'])){
  137. if($info['options_key']){
  138. $options_key=explode(',',$info['options_key']);
  139. foreach((array)$info['options'] as $key=>$res){
  140. if($options_key[0]=='key'){
  141. $optionsarr[$key]=$res[$options_key[1]];
  142. }else{
  143. $optionsarr[$res[$options_key[0]]]=$res[$options_key[1]];
  144. }
  145. }
  146. }else{
  147. $optionsarr = $info['options'];
  148. }
  149. }else{
  150. $options = $info['setup']['options'];
  151. $options = explode("\n",$info['setup']['options']);
  152. foreach($options as $r) {
  153. $v = explode("|",$r);
  154. $k = trim($v[1]);
  155. $optionsarr[$k] = $v[0];
  156. }
  157. }
  158. if(!empty($info['setup']['multiple'])) {
  159. $parseStr = '<select id="'.$id.'" name="'.$field.'" onchange="'.$info['setup']['onchange'].'" class="'.$info['class'].'" '.$validate.' size="'.$info['setup']['size'].'" multiple="multiple" >';
  160. }else {
  161. $parseStr = '<select id="'.$id.'" name="'.$field.'" onchange="'.$info['setup']['onchange'].'" class="'.$info['class'].'" '.$validate.'>';
  162. }
  163. if(is_array($optionsarr)) {
  164. foreach($optionsarr as $key=>$val) {
  165. if(!empty($value)){
  166. $selected='';
  167. if($value==$key || in_array($key,$value)) $selected = ' selected="selected"';
  168. $parseStr .= '<option '.$selected.' value="'.$key.'">'.$val.'</option>';
  169. }else{
  170. $parseStr .= '<option value="'.$key.'">'.$val.'</option>';
  171. }
  172. }
  173. }
  174. $parseStr .= '</select>';
  175. return $parseStr;
  176. }
  177. public function checkbox($info,$value){
  178. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  179. $id = $field = $info['field'];
  180. $validate = getvalidate($info);
  181. if(ACTION_NAME=='add'){
  182. $value = $value ? $value : $info['setup']['default'];
  183. }else{
  184. $value = $value ? $value : $this->data[$field];
  185. }
  186. $labelwidth = $info['setup']['labelwidth'];
  187. if(is_array($info['options'])){
  188. if($info['options_key']){
  189. $options_key=explode(',',$info['options_key']);
  190. foreach((array)$info['options'] as $key=>$res){
  191. if($options_key[0]=='key'){
  192. $optionsarr[$key]=$res[$options_key[1]];
  193. }else{
  194. $optionsarr[$res[$options_key[0]]]=$res[$options_key[1]];
  195. }
  196. }
  197. }else{
  198. $optionsarr = $info['options'];
  199. }
  200. }else{
  201. $options = $info['setup']['options'];
  202. $options = explode("\n",$info['setup']['options']);
  203. foreach($options as $r) {
  204. $v = explode("|",$r);
  205. $k = trim($v[1]);
  206. $optionsarr[$k] = $v[0];
  207. }
  208. }
  209. if($value != '') $value = (strpos($value, ',') && !is_array($value)) ? explode(',', $value) : $value ;
  210. $value = is_array($value) ? $value : array($value);
  211. $i = 1;
  212. $onclick = $info['setup']['onclick'] ? ' onclick="'.$info['setup']['onclick'].'" ' : '' ;
  213. foreach($optionsarr as $key=>$r) {
  214. $key = trim($key);
  215. if($i>1) $validate='';
  216. $checked = ($value && in_array($key, $value)) ? 'checked' : '';
  217. if($labelwidth) $parseStr .= '<label style="float:left;width:'.$labelwidth.'px" class="checkbox_'.$id.'" >';
  218. $parseStr .= '<input type="checkbox" class="input_checkbox '.$info['class'].'" name="'.$field.'[]" id="'.$id.'_'.$i.'" '.$checked.$onclick.' value="'.htmlspecialchars($key).'" '.$validate.'> '.htmlspecialchars($r);
  219. if($labelwidth) $parseStr .= '</label>';
  220. $i++;
  221. }
  222. return $parseStr;
  223. }
  224. public function radio($info,$value){
  225. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  226. $id = $field = $info['field'];
  227. $validate = getvalidate($info);
  228. if(ACTION_NAME=='add'){
  229. $value = $value ? $value : $info['setup']['default'];
  230. }else{
  231. $value = $value ? $value : $this->data[$field];
  232. }
  233. $labelwidth = $info['setup']['labelwidth'];
  234. if(is_array($info['options'])){
  235. if($info['options_key']){
  236. $options_key=explode(',',$info['options_key']);
  237. foreach((array)$info['options'] as $key=>$res){
  238. if($options_key[0]=='key'){
  239. $optionsarr[$key]=$res[$options_key[1]];
  240. }else{
  241. $optionsarr[$res[$options_key[0]]]=$res[$options_key[1]];
  242. }
  243. }
  244. }else{
  245. $optionsarr = $info['options'];
  246. }
  247. }else{
  248. $options = $info['setup']['options'];
  249. $options = explode("\n",$info['setup']['options']);
  250. foreach($options as $r) {
  251. $v = explode("|",$r);
  252. $k = trim($v[1]);
  253. $optionsarr[$k] = $v[0];
  254. }
  255. }
  256. $onclick = $info['setup']['onclick'] ? ' onclick="'.$info['setup']['onclick'].'" ' : '' ;
  257. $i = 1;
  258. foreach($optionsarr as $key=>$r) {
  259. if($i>1) $validate ='';
  260. $checked = trim($value)==trim($key) ? 'checked' : '';
  261. if(empty($value) && empty($key) ) $checked = 'checked';
  262. if($labelwidth) $parseStr .= '<label style="float:left;width:'.$labelwidth.'px" class="checkbox_'.$id.'" >';
  263. $parseStr .= '<input type="radio" class="input_radio '.$info['class'].'" name="'.$field.'" id="'.$id.'_'.$i.'" '.$checked.$onclick.' value="'.$key.'" '.$validate.'> '.$r;
  264. if($labelwidth) $parseStr .= '</label>';
  265. $i++;
  266. }
  267. return $parseStr;
  268. }
  269. public function editor($info,$value){
  270. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  271. $id = $field = $info['field'];
  272. $validate = getvalidate($info);
  273. if(ACTION_NAME=='add'){
  274. $value = $value ? $value : $info['setup']['default'];
  275. }else{
  276. $value = $value ? $value : $this->data[$field];
  277. }
  278. $textareaid = $field;
  279. $toolbar = $info['setup']['toolbar'];
  280. $moduleid = $info['moduleid'];
  281. $height = $info['setup']['height'] ? $info['setup']['height'] : 300;
  282. $flashupload = $info['setup']['flashupload']==1 ? 1 : '';
  283. $alowuploadexts = $info['setup']['alowuploadexts'] ? $info['setup']['alowuploadexts'] : 'jpg,gif,png';
  284. $alowuploadlimit=$info['setup']['alowuploadlimit'] ? $info['setup']['alowuploadlimit'] : 20 ;
  285. $show_page=$info['setup']['showpage'];
  286. if(APP_LANG){
  287. $Config = F('Config_'.$this->lang);
  288. }else{
  289. $Config = F('Config');
  290. }
  291. $file_size = intval(byte_format($Config['attach_maxsize']));
  292. $yourphp_auth_key = sysmd5(C('ADMIN_ACCESS').$_SERVER['HTTP_USER_AGENT']);
  293. $attach_auth = authcode("$this->isadmin-1-0-$alowuploadlimit-$Config[attach_allowext]-$file_size-$moduleid", 'ENCODE',$yourphp_auth_key);
  294. $yourphp_auth = authcode("$this->isadmin-1-0-$alowuploadlimit-$alowuploadexts-$file_size-$moduleid", 'ENCODE',$yourphp_auth_key);
  295. $str ='';
  296. $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>';
  297. $show_page = $show_page ? 1 : 0;
  298. if ($info['setup']['edittype']=='Xheditor'){
  299. if($toolbar=='basic'){
  300. $modtools = 'simple';
  301. } elseif($toolbar == 'full') {
  302. $modtools = $this->isadmin ? 'full' : 'mfull';
  303. } elseif($toolbar == 'desc') {
  304. $modtools = 'mini';
  305. } else {
  306. $modtools = '';
  307. }
  308. $str .="<script type=\"text/javascript\" src=\"".__ROOT__."/Public/Xheditor/xheditor-zh-cn.min.js\"></script>";
  309. $str .="<script type=\"text/javascript\"> \r\n";
  310. $str .="var editor_".$id."=$('#".$id."').xheditor({ ";
  311. $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\"";
  312. if($flashupload){
  313. $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\"";
  314. $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\"";
  315. $yourphp_auth = authcode("$this->isadmin-1-0-$alowuploadlimit-swf-$file_size-$moduleid", 'ENCODE',$yourphp_auth_key);
  316. $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\"";
  317. $yourphp_auth = authcode("$this->isadmin-1-0-$alowuploadlimit-mpg,wmv,avi,wma,mp3,mid,asf,rm-$file_size-$moduleid", 'ENCODE',$yourphp_auth_key);
  318. $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\"";
  319. $str .=",onUpload:upokis,modalWidth:\"600\",modalHeight:\"455\"";
  320. }
  321. $str .= "});</script>";
  322. $str .='<div class=\'editor_bottom1\'>';
  323. if($show_page) $str .='<a href="javascript:void(0);" onclick="editor_'.$id.'.pasteText(\'[page]\');return false;">'.L('page_break').'</a>';
  324. 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');
  325. 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');
  326. $str .= '</div></div>';
  327. }else{
  328. $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";
  329. $yourphp_auth = authcode("$this->isadmin-1-0-1-gif,jpg,jpeg,png,bmp-$file_size-$moduleid", 'ENCODE',$yourphp_auth_key);
  330. $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";
  331. $yourphp_auth = authcode("$this->isadmin-1-0-1-swf,flv-$file_size-$moduleid", 'ENCODE',$yourphp_auth_key);
  332. $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";
  333. $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);
  334. $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";
  335. $str .="<script type=\"text/javascript\" src=\"".__ROOT__."/Public/Kindeditor/kindeditor-min.js\"></script>";
  336. $str .= "<script type=\"text/javascript\">\r\n";
  337. $str .= "KindEditor.ready(function(K) {\r\n";
  338. $str .= "K.create('#".$id."', {\r\n";
  339. $str .= "cssPath : '".__ROOT__."/Public/Kindeditor/plugins/code/prettify.css',";
  340. //$str .= "uploadJson : '$upurl',";
  341. $str .= "fileManagerJson:'$upurl',";
  342. $str .= "editorid:'$id',";
  343. $str .= "upImgUrl:'$upImgUrl',";
  344. $str .= "upFlashUrl:'$upFlashUrl',";
  345. $str .= "upMediaUrl:'$upMediaUrl',";
  346. $str .= "allowFileManager : true\r\n";
  347. $str .= "});\r\n";
  348. $str .= "});\r\n";
  349. $str .= '</script>';
  350. $str .='<div class=\'editor_bottom2\'>';
  351. if($info['setup']['show_add_description']) $str .='<input type="checkbox" name="add_description" value="1" checked /> '.L('add_description').'
  352. <input type="text" name="description_length" value="200" style="width:24px;" size="3" />'.L('description_length');
  353. if($info['setup']['show_auto_thumb']) $str .='<input type="checkbox" name="auto_thumb" value="1" checked /> '.L('auto_thumb').'
  354. <input type="text" name="auto_thumb_no" value="1" size="1" />'.L('auto_thumb_no');
  355. $str .= '</div></div>';
  356. }
  357. return $str;
  358. }
  359. public function datetime($info,$value){
  360. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  361. $id = $field = $info['field'];
  362. $validate = getvalidate($info);
  363. if(ACTION_NAME=='add'){
  364. $value = $value ? $value : $info['setup']['default'];
  365. }else{
  366. $value = $value ? $value : $this->data[$field];
  367. }
  368. $value = $value ? toDate($value,"Y-m-d H:i:s") : toDate(time(),"Y-m-d H:i:s");
  369. $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\'
  370. })" value="'.$value.'" />';
  371. return $parseStr;
  372. }
  373. public function groupid($info,$value){
  374. $newinfo = $info;
  375. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  376. $groups=F('Role');$options=array();
  377. foreach($groups as $key=>$r) {
  378. if($r['status']){
  379. $options[$key]=$r['name'];
  380. }
  381. }
  382. $newinfo['options']=$options;
  383. $fun=$info['setup']['inputtype'];
  384. return $this->$fun($newinfo,$value);
  385. }
  386. public function posid($info,$value){
  387. $newinfo = $info;
  388. $posids=F('Posid');
  389. $options=array();
  390. $options[0]= L('please_chose');
  391. foreach($posids as $key=>$r) {
  392. $options[$key]=$r['name'];
  393. }
  394. $newinfo['options']=$options;
  395. $fun=$info['setup']['inputtype'];
  396. return $this->select($newinfo,$value);
  397. }
  398. public function typeid($info,$value){
  399. $newinfo = $info;
  400. $types=F('Type');
  401. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  402. $id = $field = $info['field'];
  403. $value = $value ? $value : $this->data[$field];
  404. $parentid=$info['setup']['default'];
  405. $keyid = $types[$parentid]['keyid'];
  406. $options=array();
  407. $options[0]= L('please_chose');
  408. foreach((array)$types as $key => $r) {
  409. if($r['keyid']!=$keyid) continue;
  410. $r['id']=$r['typeid'];
  411. $array[] = $r;
  412. $options[$key]=$r['name'];
  413. }
  414. import ( '@.ORG.Tree' );
  415. $str = "<option value='\$typeid' \$selected>\$spacer \$name</option>";
  416. $tree = new Tree ($array);
  417. $tree->nbsp='&nbsp;&nbsp;';
  418. $select_type = $tree->get_tree(0, $str,$value);
  419. $fun=$info['setup']['inputtype'];
  420. if($fun=='select'){
  421. return '<SELECT id="'.$id.'" class="'.$info['class'].'" name="'.$field.'"><option value="0">'.L('please_chose').'</option>'. $select_type.'</select>';
  422. }else{
  423. $newinfo['options']=$options;
  424. return $this->$fun($newinfo,$value);
  425. }
  426. }
  427. public function template($info,$value){
  428. $templates= template_file(MODULE_NAME);
  429. $newinfo = $info;
  430. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  431. $options=array();
  432. $options[0]= L('please_chose');
  433. foreach($templates as $key=>$r) {
  434. if(strstr($r['value'],'show')){
  435. $options[$r['value']]=$r['filename'];
  436. }
  437. }
  438. $newinfo['options']=$options;
  439. $fun=$info['setup']['inputtype'];
  440. return $this->select($newinfo,$value);
  441. }
  442. public function image($info,$value){
  443. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  444. $id = $field = $info['field'];
  445. $validate = getvalidate($info);
  446. if(ACTION_NAME=='add'){
  447. $value = $value ? $value : $info['setup']['default'];
  448. }else{
  449. $value = $value ? $value : $this->data[$field];
  450. }
  451. if(empty($info['setup']['upload_maxsize'])){
  452. if(APP_LANG){
  453. $Config = F('Config_'.$this->lang);
  454. }else{
  455. $Config = F('Config');
  456. }
  457. $info['setup']['upload_maxsize'] = intval(byte_format($Config['attach_maxsize']));
  458. }
  459. $yourphp_auth_key = sysmd5(C('ADMIN_ACCESS').$_SERVER['HTTP_USER_AGENT']);
  460. $yourphp_auth = authcode($this->isadmin.'-'.$info['setup']['more'].'-0-1-'.$info['setup']['upload_allowext'].'-'.$info['setup']['upload_maxsize'].'-'.$info['moduleid'], 'ENCODE',$yourphp_auth_key);
  461. $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)"> ';
  462. return $parseStr;
  463. }
  464. public function images($info,$value){
  465. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  466. $id = $field = $info['field'];
  467. $validate = getvalidate($info);
  468. if(ACTION_NAME=='add'){
  469. $value = $value ? $value : $info['setup']['default'];
  470. }else{
  471. $value = $value ? $value : $this->data[$field];
  472. }
  473. $data='';
  474. $i=0;
  475. if($value){
  476. $options = explode(":::",$value);
  477. if(is_array($options)){
  478. foreach($options as $r) {
  479. $v = explode("|",$r);
  480. $k = trim($v[1]);
  481. $optionsarr[$k] = $v[0];
  482. $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" /> &nbsp;<a href="javascript:remove_this(\'uplistd_'.$i.'\');">'.L('remove').'</a> </div>';
  483. $i++;
  484. }
  485. }
  486. }
  487. if(empty($info['setup']['upload_maxsize'])){
  488. if(APP_LANG){
  489. $Config = F('Config_'.$this->lang);
  490. }else{
  491. $Config = F('Config');
  492. }
  493. $info['setup']['upload_maxsize'] = intval(byte_format($Config['attach_maxsize']));
  494. }
  495. $yourphp_auth_key = sysmd5(C('ADMIN_ACCESS').$_SERVER['HTTP_USER_AGENT']);
  496. $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);
  497. $parseStr = '
  498. <fieldset class="images_box">
  499. <legend>'.L('upload_images').'</legend><center><div>'.L('upload_maxfiles').' <font color=\'red\'>'.$info['setup']['upload_maxnum'].'</font> '.L('zhang').'</div></center>
  500. <div id="'.$field.'_images" class="imagesList"><input type="hidden" name="'.$field.'[]" value=""/><input type="hidden" name="'.$field.'_name[]" value="" />'.$data.'</div>
  501. </fieldset>
  502. <div class="c"></div>
  503. <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)"> ';
  504. return $parseStr;
  505. }
  506. public function file($info,$value){
  507. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  508. $id = $field = $info['field'];
  509. $validate = getvalidate($info);
  510. if(ACTION_NAME=='add'){
  511. $value = $value ? $value : $info['setup']['default'];
  512. }else{
  513. $value = $value ? $value : $this->data[$field];
  514. }
  515. if(empty($info['setup']['upload_maxsize'])){
  516. if(APP_LANG){
  517. $Config = F('Config_'.$this->lang);
  518. }else{
  519. $Config = F('Config');
  520. }
  521. $info['setup']['upload_maxsize'] = intval(byte_format($Config['attach_maxsize']));
  522. }
  523. $yourphp_auth_key = sysmd5(C('ADMIN_ACCESS').$_SERVER['HTTP_USER_AGENT']);
  524. $yourphp_auth = authcode($this->isadmin.'-'.$info['setup']['more'].'-0-1-'.$info['setup']['upload_allowext'].'-'.$info['setup']['upload_maxsize'].'-'.$info['moduleid'], 'ENCODE',$yourphp_auth_key);
  525. $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)"> ';
  526. return $parseStr;
  527. }
  528. public function files($info,$value){
  529. $info['setup']=is_array($info['setup']) ? $info['setup'] : string2array($info['setup']);
  530. $id = $field = $info['field'];
  531. $validate = getvalidate($info);
  532. if(ACTION_NAME=='add'){
  533. $value = $value ? $value : $info['setup']['default'];
  534. }else{
  535. $value = $value ? $value : $this->data[$field];
  536. }
  537. if(empty($info['setup']['upload_maxsize'])){
  538. if(APP_LANG){
  539. $Config = F('Config_'.$this->lang);
  540. }else{
  541. $Config = F('Config');
  542. }
  543. $info['setup']['upload_maxsize'] = intval(byte_format($Config['attach_maxsize']));
  544. }
  545. $yourphp_auth_key = sysmd5(C('ADMIN_ACCESS').$_SERVER['HTTP_USER_AGENT']);
  546. $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);
  547. $parseStr = '<fieldset class="images_box">
  548. <legend>'.L('upload_images').'</legend><center><div>'.L('upload_maxfiles').' <font color=\'red\'>'.$info['setup']['upload_maxnum'].'</font> '.L('zhang').'</div></center>
  549. <div id="'.$field.'_images" class="imagesList"></div>
  550. </fieldset>
  551. <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)"> ';
  552. return $parseStr;
  553. }
  554. }
  555. ?>