Discuz!开发之网站后台消息提醒函数cpmsg()介绍

定义文件:\source\function\function_admincp.php

函数定义:

function cpmsg($message, $url = '', $type = '', $values = array(), $extra = '', $halt = TRUE, $cancelurl = '') {
	global $_G;
	$vars = explode(':', $message);
	$values['ADMINSCRIPT'] = ADMINSCRIPT;
	if(count($vars) == 2) {
		$message = lang('plugin/'.$vars[0], $vars[1], $values);
	} else {
		$message = cplang($message, $values);
	}
	switch($type) {
		case 'download':
		case 'succeed': $classname = 'infotitle2';break;
		case 'error': $classname = 'infotitle3';break;
		case 'loadingform': case 'loading': $classname = 'infotitle1';break;
		default: $classname = 'marginbot normal';break;
	}
	if($url) {
		$url = substr($url, 0, 5) == 'http:' ? $url : ADMINSCRIPT.'?'.$url;
	}
	$message = "

$message

"; $url .= $url && !empty($_GET['scrolltop']) ? '&scrolltop='.intval($_GET['scrolltop']) : ''; if($type == 'form') { $message = "
". "
$message$extra
". "

\n". ($cancelurl ? "" : ""). "


"; } elseif($type == 'loadingform') { $message = "

$message$extra
". '

'.cplang('message_redirect').'


'; } else { $message .= $extra.($type == 'loading' ? '' : ''); if($url) { if($type == 'button') { $message = "
$message

"; } else { $message .= '

'.cplang($type == 'download' ? 'message_download' : 'message_redirect').'

'; $timeout = $type != 'loading' ? 3000 : 1000; $message .= ""; } } elseif($type != 'succeed') { $message .= '

'. "". '

'; } } if($halt) { echo '

'.cplang('discuz_message').'

'.$message.'
'; exit(); } else { echo '
'.$message.'
'; } }

参数介绍:
$message - lang_admincp_msg.php 语言包中需要输出的key

$url - 提示信息后跳转的页面,留空则返回上一页

$type - 特殊提示信息时指定页面的提示样式,可选参数:succeed、error、download、loadingform

$values - 为语言包中的变量关键词指定值,以数组形式输入

$extra - 消息文字扩展

$halt - 是否输出“Discuz! 提示”标题

你可能感兴趣的:(Discuz!,函数)