温馨提示:这篇文章已超过879天没有更新,请注意相关的内容是否还可用!
帝国cms系统提示信息框都知道吧,帝国CMS所有的前后太提示框,都是他由printerror()函数处理的。大多数情况下我们都不需要自己编写printerror()函数弹窗功能,因为都是写好的,但是作为开发人员,帝国cms二次开发中printerror()函数还是用的比较多的。今天就来介绍下这个printerror()函数。
printerror()函数
功能:系统提示信息函数,根据传入的参数提示相关信息,并跳转到指定地址。
版本:7.2 7.5
语法:printerror($error,$gotourl,$ecms,$noautourl,$novar)
位置:/e/class/connect.PHP 200行
函数详细代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | //错误提示functionprinterror($error="",$gotourl="",$ecms=0,$noautourl=0,$novar=0){global$empire,$editor,$public_r,$ecms_config;if($editor==1){$a="../";}elseif($editor==2){$a="../../";}elseif($editor==3){$a="../../../";}else{$a="";}if($ecms==1||$ecms==9){$a=ECMS_PATH.'e/data/';}if(strstr($gotourl,"(")||emptyempty($gotourl)){if(strstr($gotourl,"(-2")){$gotourl_js="history.go(-2)";}else{$gotourl_js="history.go(-1)";$gotourl="javascript:history.go(-1)";}}else{$gotourl_js="self.location.href='$gotourl';";}if(emptyempty($error)){$error="DbError";}if($ecms==9)//前台弹出对话框{$error=emptyempty($novar)?$qmessage_r[$error]:$error;echo"";db_close();$empire=null;exit();}elseif($ecms==8)//后台弹出对话框{@include$a.LoadLang("pub/message.php");$error=emptyempty($novar)?$message_r[$error]:$error;echo"";db_close();$empire=null;exit();}elseif($ecms==7)//前台弹出对话框并关闭窗口{@include$a.LoadLang("pub/q_message.php");$error=emptyempty($novar)?$qmessage_r[$error]:$error;echo"";db_close();$empire=null;exit();}elseif($ecms==6)//后台弹出对话框并关闭窗口{@include$a.LoadLang("pub/message.php");$error=emptyempty($novar)?$message_r[$error]:$error;echo"";db_close();$empire=null;exit();}elseif($ecms==0){@include$a.LoadLang("pub/message.php");$error=emptyempty($novar)?$message_r[$error]:$error;@include($a."message.php");}else{@include$a.LoadLang("pub/q_message.php");$error=emptyempty($novar)?$qmessage_r[$error]:$error;@include($a."../message/index.php");}db_close();$empire=null;exit();} |
使用说明
$error:提示信息内容,可以为语言包变量,也可以直接提示内容。
$gotourl:提示信息转向链接地址
$ecms:0为后台提示信息、1为前台提示信息、8为后台提示信息(alert方式)、9为前台提示信息(alert方式)
$noautourl:0为自动转向页面,1为不自动转向页面。此参数可省略,默认为0
$novar:0为提示信息内容采用语言包变量,1为提示信息内容为直接提示内容。此参数可以省略,默认为0
使用范例:
1 | printerror('DbError','http://www.wdzzz.com',1), |
前台提示,提示信息内容为语言包DbError变量内容,转向我的站长站网站
附加说明:
此函数需结合$editor变量来确定目录层次。默认$editor变量为0。
当程序文件在/e/path/目录,$editor不用设置,也就是用默认0。
当程序文件在/e/path/path2/目录,$editor=1。
当程序文件在/e/path/path2/path3/目录,$editor=2。
当程序文件在/e/path/path2/path3/path4/目录,$editor=3。



还没有评论,来说两句吧...