';}
}
$sHtml=preg_replace_callback('/\[tr\s*(?:=(\s*[^\]"]+))?(?:"[^\]]*?)?\s*\]/i','getTR',$sHtml);
if(!$bUbb2htmlFunctionInit)
{
function getTD($match)
{
$col=isset($match[1])?$match[1]:0;$row=isset($match[2])?$match[2]:0;$w=isset($match[3])?$match[3]:null;
return '1?' colspan="'.$col.'"':'').($row>1?' rowspan="'.$row.'"':'').($w?' width="'.$w.'"':'').'>';
}
}
$sHtml=preg_replace_callback("/\[td\s*(?:=\s*(\d{1,2})\s*,\s*(\d{1,2})\s*(?:,\s*(\d{1,4}%?))?)?\s*\]/i",'getTD',$sHtml);
$sHtml=preg_replace("/\[\/(table|tr|td)\]/i",'$1>',$sHtml);
$sHtml=preg_replace("/\[\*\]((?:(?!\[\*\]|\[\/list\]|\[list\s*(?:=[^\]]+)?\])[\s\S])+)/i",'$1',$sHtml);
if(!$bUbb2htmlFunctionInit)
{
function getUL($match)
{
$str='';
}
}
$sHtml=preg_replace_callback('/\[list\s*(?:=\s*([^\]"]+))?(?:"[^\]]*?)?\s*\]/i','getUL',$sHtml);
$sHtml=preg_replace("/\[\/list\]/i",' ',$sHtml);
for($i=1;$i<=$cnum;$i++)$sHtml=str_replace("[\tubbcodeplace_".$i."\t]", $arrcode[$i],$sHtml);
if(!$bUbb2htmlFunctionInit)
{
function fixText($match)
{
$text=$match[2];
$text=preg_replace("/\t/",' ',$text);
$text=preg_replace("/ /",' ',$text);
return $match[1].$text;
}
}
$sHtml=preg_replace_callback('/(^|<\/?\w+(?:\s+[^>]*?)?>)([^<$]+)/i','fixText',$sHtml);
$bUbb2htmlFunctionInit=true;
return $sHtml;
}
}
class js
{
/* The start of javascript. */
static private function start()
{
return <<
\n";
}
/* Show a alert box. */
static public function alert($message = '')
{
return self::start() . "alert('" . $message . "')" . self::end();
}
/* 弹出错误。其中message可以是一条字符串,也可以是一维或者二维数组。*/
static public function error($message)
{
$alertMessage = '';
if(is_array($message))
{
foreach($message as $item)
{
is_array($item) ? $alertMessage .= join('\n', $item) . '\n' : $alertMessage .= $item . '\n';
}
}
else
{
$alertMessage = $message;
}
return self::alert($alertMessage);
}
/**
* show a confirm box, press ok go to okURL, else go to cancleURL.
*
* @param string $message the text to be showed.
* @param string $okURL the url to go to when press 'ok'.
* @param string $cancleURL the url to go to when press 'cancle'.
* @param string $okTarget the target to go to when press 'ok'.
* @param string $cancleTarget the target to go to when press 'cancle'.
*/
static public function confirm($message = '', $okURL = '', $cancleURL = '', $okTarget = "self", $cancleTarget = "self", $Echo = true)
{
$js = self::start();
$confirmAction = '';
if(strtolower($okURL) == "back")
{
$confirmAction = "history.back(-1);";
}
elseif(!empty($okURL))
{
$confirmAction = "$okTarget.location = '$okURL';";
}
$cancleAction = '';
if(strtolower($cancleURL) == "back")
{
$cancleAction = "history.back(-1);";
}
elseif(!empty($cancleURL))
{
$cancleAction = "$cancleTarget.location = '$cancleURL';";
}
$js .= <<getViewType();
$themeRoot = $app->getWebRoot() . 'theme/';
$moduleName = $app->getModuleName();
$methodName = $app->getMethodName();
$clientLang = $app->getClientLang();
$requiredFields = '';
if(isset($config->$moduleName->$methodName->requiredFields)) $requiredFields = str_replace(' ', '', $config->$moduleName->$methodName->requiredFields);
$js = <<
webRoot = '$config->webRoot';
requestType = '$config->requestType';
pathType = '$config->pathType';
requestFix = '$config->requestFix';
moduleVar = '$config->moduleVar';
methodVar = '$config->methodVar';
viewVar = '$config->viewVar';
defaultView = '$defaultViewType';
themeRoot = '$themeRoot';
currentModule = '$moduleName';
currentMethod = '$methodName';
clientLang = '$clientLang';
requiredFields = '$requiredFields';
lblShowAll = '$lang->showAll';
lblHideClosed = '$lang->hideClosed';
EOT;
return $js;
}
}
|