* @package framework * @version $Id$ * @link http://www.zentao.net */ /** * The html class, to build html tags. * * @package framework */ class html { /** * Create the title tag. * * @param mixed $title * @access public * @return string. */ public static function title($title) { return "$title\n"; } /** * Create a meta. * * @param mixed $name the meta name * @param mixed $value the meta value * @access public * @return string */ public static function meta($name, $value) { return "\n"; } /** * Create icon tag * * @param mixed $url the url of the icon. * @access public * @return string */ public static function icon($url) { return "\n" . "\n"; } /** * Create the rss tag. * * @param string $url * @param string $title * @static * @access public * @return string */ public static function rss($url, $title = '') { return ""; } /** * Create tags like text * * @param string $href the link url. * @param string $title the link title. * @param string $target the target window * @param string $misc other params. * @return string */ static public function a($href = '', $title = '', $target = "_self", $misc = '') { if(empty($title)) $title = $href; if($target == '_self') return "$title\n"; return "$title\n"; } /** * Create tags like text * * @param string $mail the email address * @param string $title the email title. * @return string */ static public function mailto($mail = '', $title = '') { if(empty($title)) $title = $mail; return "$title"; } /** * Create tags like "" * * @param string $name the name of the select tag. * @param array $options the array to create select tag from. * @param string $selectedItems the item(s) to be selected, can like item1,item2. * @param string $attrib other params such as multiple, size and style. * @return string */ static public function select($name = '', $options = array(), $selectedItems = "", $attrib = "") { $options = (array)($options); if(!is_array($options) or empty($options)) return false; /* The begin. */ $id = $name; if($pos = strpos($name, '[')) $id = substr($name, 0, $pos); $string = "\n"; } /** * Create select with optgroup. * * @param string $name the name of the select tag. * @param array $groups the option groups. * @param string $selectedItems the item(s) to be selected, can like item1,item2. * @param string $attrib other params such as multiple, size and style. * @return string */ static public function selectGroup($name = '', $groups = array(), $selectedItems = "", $attrib = "") { if(!is_array($groups) or empty($groups)) return false; /* The begin. */ $id = $name; if($pos = strpos($name, '[')) $id = substr($name, 0, $pos); $string = "\n"; } /** * Create tags like "" * * @param string $name the name of the radio tag. * @param array $options the array to create radio tag from. * @param string $checked the value to checked by default. * @param string $attrib other attribs. * @return string */ static public function radio($name = '', $options = array(), $checked = '', $attrib = '') { $options = (array)($options); if(!is_array($options) or empty($options)) return false; $string = ''; foreach($options as $key => $value) { $string .= "" * * @param string $name the name of the checkbox tag. * @param array $options the array to create checkbox tag from. * @param string $checked the value to checked by default, can be item1,item2 * @param string $attrib other attribs. * @return string */ static public function checkbox($name, $options, $checked = "", $attrib = "") { $options = (array)($options); if(!is_array($options) or empty($options)) return false; $string = ''; $checked = ",$checked,"; foreach($options as $key => $value) { $key = str_replace('item', '', $key); $string .= "" * * @param string $name the name of the text input tag. * @param string $value the default value. * @param string $attrib other attribs. * @return string */ static public function input($name, $value = "", $attrib = "") { return "\n"; } /** * Create tags like "" * * @param string $name the name of the text input tag. * @param string $value the default value. * @param string $attrib other attribs. * @return string */ static public function hidden($name, $value = "", $attrib = "") { return "\n"; } /** * Create tags like "" * * @param string $name the name of the text input tag. * @param string $value the default value. * @param string $attrib other attribs. * @return string */ static public function password($name, $value = "", $attrib = "") { return "\n"; } /** * Create tags like "" * * @param string $name the name of the textarea tag. * @param string $value the default value of the textarea tag. * @param string $attrib other attribs. * @return string */ static public function textarea($name, $value = "", $attrib = "") { return "\n"; } /** * Create tags like "". * * @param string $name the name of the file name. * @param string $attrib other attribs. * @return string */ static public function file($name, $attrib = "") { return "\n"; } /** * Create submit button. * * @param string $label the label of the button * @param string $misc other params * @static * @access public * @return string the submit button tag. */ public static function submitButton($label = '', $misc = '') { if(empty($label)) { global $lang; $label = $lang->save; } return " "; } /** * Create reset button. * * @static * @access public * @return string the reset button tag. */ public static function resetButton() { global $lang; return " "; } /** * Create common button. * * @param string $label the label of the button * @param string $misc other params * @static * @access public * @return string the common button tag. */ public static function commonButton($label = '', $misc = '') { return " "; } /** * create a button, when click, go to a link. * * @param string $label the link title * @param string $link the link url * @param string $misc other params * @static * @access public * @return string */ public static function linkButton($label = '', $link = '', $misc = '') { return " "; } /** * create a export link. * * @param string $label * @param string $pluginTitle * @param string $misc * @static * @access public * @return void */ public static function export2csv($label = '', $pluginTitle, $misc = '') { return "$label\n\n"; } /** * ubb2html support for php * @requires xhEditor * * @author Yanis.Wang * @site http://xheditor.com/ * @licence LGPL(http://www.opensource.org/licenses/lgpl-license.php) * * @Version: 0.9.8 (build 100505) */ public static function parseUBB($sUBB) { $sHtml=$sUBB; global $emotPath,$cnum,$arrcode,$bUbb2htmlFunctionInit;$cnum=0;$arrcode=array(); $emotPath='../xheditor_emot/'; if(!$bUbb2htmlFunctionInit) { function saveCodeArea($match) { global $cnum,$arrcode; $cnum++;$arrcode[$cnum]=$match[0]; return "[\tubbcodeplace_".$cnum."\t]"; } } $sHtml=preg_replace_callback('/\[code\s*(?:=\s*((?:(?!")[\s\S])+?)(?:"[\s\S]*?)?)?\]([\s\S]*?)\[\/code\]/i','saveCodeArea',$sHtml); //$sHtml=preg_replace("/&/",'&',$sHtml); //$sHtml=preg_replace("//",'>',$sHtml); $sHtml=preg_replace("/\r?\n/",'
',$sHtml); $sHtml=preg_replace("/\[(\/?)(b|u|i|s|sup|sub)\]/i",'<$1$2>',$sHtml); $sHtml=preg_replace('/\[color\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\]/i','',$sHtml); if(!$bUbb2htmlFunctionInit) { function getSizeName($match) { $arrSize=array('8pt','10pt','12pt','14pt','18pt','24pt','36pt'); return ''; } } $sHtml=preg_replace_callback("/\[size\s*=\s*(\d+?)\s*\]/i",'getSizeName',$sHtml); $sHtml=preg_replace('/\[font\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\]/i','',$sHtml); $sHtml=preg_replace('/\[back\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\]/i','',$sHtml); $sHtml=preg_replace("/\[\/(color|size|font|back)\]/i",'',$sHtml); for($i=0;$i<3;$i++)$sHtml=preg_replace('/\[align\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\](((?!\[align(?:\s+[^\]]+)?\])[\s\S])*?)\[\/align\]/','

$2

',$sHtml); $sHtml=preg_replace('/\[img\]\s*(((?!")[\s\S])+?)(?:"[\s\S]*?)?\s*\[\/img\]/i','',$sHtml); if(!$bUbb2htmlFunctionInit) { function getImg($match) { $alt=$match[1];$p1=$match[2];$p2=$match[3];$p3=$match[4];$src=$match[5]; $a=$p3?$p3:(!is_numeric($p1)?$p1:''); return ''.$alt.''; } } $sHtml=preg_replace_callback('/\[img\s*=([^,\]]*)(?:\s*,\s*(\d*%?)\s*,\s*(\d*%?)\s*)?(?:,?\s*(\w+))?\s*\]\s*(((?!")[\s\S])+?)(?:"[\s\S]*)?\s*\[\/img\]/i','getImg',$sHtml); if(!$bUbb2htmlFunctionInit) { function getEmot($match) { global $emotPath; $arr=split(',',$match[1]); if(!isset($arr[1])){$arr[1]=$arr[0];$arr[0]='default';} $path=$emotPath.$arr[0].'/'.$arr[1].'.gif'; return ''.$arr[1].''; } } $sHtml=preg_replace_callback('/\[emot\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\/\]/i','getEmot',$sHtml); $sHtml=preg_replace('/\[url\]\s*(((?!")[\s\S])*?)(?:"[\s\S]*?)?\s*\[\/url\]/i','$1',$sHtml); $sHtml=preg_replace('/\[url\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\]\s*([\s\S]*?)\s*\[\/url\]/i','$2',$sHtml); $sHtml=preg_replace('/\[email\]\s*(((?!")[\s\S])+?)(?:"[\s\S]*?)?\s*\[\/email\]/i','$1',$sHtml); $sHtml=preg_replace('/\[email\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\]\s*([\s\S]+?)\s*\[\/email\]/i','$2',$sHtml); $sHtml=preg_replace("/\[quote\]([\s\S]*?)\[\/quote\]/i",'
$1
',$sHtml); if(!$bUbb2htmlFunctionInit) { function getFlash($match) { $w=$match[1];$h=$match[2];$url=$match[3]; if(!$w)$w=480;if(!$h)$h=400; return ''; } } $sHtml=preg_replace_callback('/\[flash\s*(?:=\s*(\d+)\s*,\s*(\d+)\s*)?\]\s*(((?!")[\s\S])+?)(?:"[\s\S]*?)?\s*\[\/flash\]/i','getFlash',$sHtml); if(!$bUbb2htmlFunctionInit) { function getMedia($match) { $w=$match[1];$h=$match[2];$play=$match[3];$url=$match[4]; if(!$w)$w=480;if(!$h)$h=400; return ''; } } $sHtml=preg_replace_callback('/\[media\s*(?:=\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+)\s*)?)?\]\s*(((?!")[\s\S])+?)(?:"[\s\S]*?)?\s*\[\/media\]/i','getMedia',$sHtml); if(!$bUbb2htmlFunctionInit) { function getTable($match) { return ''; } } $sHtml=preg_replace_callback('/\[table\s*(?:=(\d{1,4}%?)\s*(?:,\s*([^\]"]+)(?:"[^\]]*?)?)?)?\s*\]/i','getTable',$sHtml); if(!$bUbb2htmlFunctionInit) { function getTR($match){return '';} } $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",'',$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; } } /** * JS class. * * @package front */ class js { /** * Import a js file. * * @param string $url * @param string $version * @access public * @return string */ public static function import($url, $version = '') { echo "\n"; } /** * The start of javascript. * * @static * @access private * @return string */ static private function start($full = true) { if($full) return "\n"; } /** * Show a alert box. * * @param string $message * @static * @access public * @return string */ static public function alert($message = '') { return self::start() . "alert('" . $message . "')" . self::end(); } /** * Show error info. * * @param string|array $message * @static * @access public * @return string */ 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'. * @return string */ 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); $jsConfig->webRoot = $config->webRoot; $jsConfig->cookieLife = ceil(($config->cookieLife - time()) / 86400); $jsConfig->requestType = $config->requestType; $jsConfig->pathType = $config->pathType; $jsConfig->requestFix = $config->requestFix; $jsConfig->moduleVar = $config->moduleVar; $jsConfig->methodVar = $config->methodVar; $jsConfig->viewVar = $config->viewVar; $jsConfig->defaultView = $defaultViewType; $jsConfig->themeRoot = $themeRoot; $jsConfig->currentModule = $moduleName; $jsConfig->currentMethod = $methodName; $jsConfig->clientLang = $clientLang; $jsConfig->requiredFields = $requiredFields; $jsConfig->lblShowAll = $lang->showAll; $jsConfig->lblHideClosed = $lang->hideClosed; $jsConfig->submitting = $lang->submitting; $jsConfig->save = $lang->save; $jsConfig->router = $app->server->PHP_SELF; $js = self::start(false); $js .= 'var config=' . json_encode($jsConfig); $js .= self::end(); echo $js; } /** * Execute some js code. * * @param string $code * @static * @access public * @return string */ static public function execute($code) { $js = self::start(); $js .= $code; $js .= self::end(); echo $js; } } /** * css class. * * @package front */ class css { /** * Import a css file. * * @param string $url * @param string $version * @access public * @return vod */ public static function import($url, $version = '') { echo "\n"; } /** * Print a css code. * * @param string $css * @static * @access public * @return void */ public static function internal($css) { echo ""; } }