* rewrite the comment in english.
This commit is contained in:
@@ -9,15 +9,74 @@
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
/**
|
||||
* The html class, to build html tags.
|
||||
*
|
||||
* @package framework
|
||||
*/
|
||||
class html
|
||||
{
|
||||
/**
|
||||
* create tags like <a href="">text</a>
|
||||
* Create the title tag.
|
||||
*
|
||||
* @param mixed $title
|
||||
* @access public
|
||||
* @return string.
|
||||
*/
|
||||
public static function title($title)
|
||||
{
|
||||
return "<title>$title</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 "<meta name='$name' content='$value'>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Create icon tag
|
||||
*
|
||||
* @param mixed $url the url of the icon.
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public static function icon($url)
|
||||
{
|
||||
return "<link rel='icon' href='$url' type='image/x-icon' />\n" .
|
||||
"<link rel='shortcut icon' href='$url' type='image/x-icon' />\n";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the rss tag.
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $title
|
||||
* @static
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public static function rss($url, $title = '')
|
||||
{
|
||||
return "<link href='$url' title='$title' type='application/rss+xml' rel='alternate' />";
|
||||
}
|
||||
|
||||
/**
|
||||
* Create tags like <a href="">text</a>
|
||||
*
|
||||
* @param string $href the link url.
|
||||
* @param string $title the link title.
|
||||
* @param string $target the target window
|
||||
* @param string $misc other params.
|
||||
* @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 = '')
|
||||
{
|
||||
@@ -27,10 +86,11 @@ class html
|
||||
}
|
||||
|
||||
/**
|
||||
* create tags like <a href="mailto:">text</a>
|
||||
* Create tags like <a href="mailto:">text</a>
|
||||
*
|
||||
* @param string $mail the email address
|
||||
* @param string $title the email title.
|
||||
* @param string $mail the email address
|
||||
* @param string $title the email title.
|
||||
* @return string
|
||||
*/
|
||||
static public function mailto($mail = '', $title = '')
|
||||
{
|
||||
@@ -39,12 +99,13 @@ class html
|
||||
}
|
||||
|
||||
/**
|
||||
* create tags like "<select><option></option></select>"
|
||||
* Create tags like "<select><option></option></select>"
|
||||
*
|
||||
* @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.
|
||||
* @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 = "")
|
||||
{
|
||||
@@ -60,7 +121,7 @@ class html
|
||||
$selectedItems = ",$selectedItems,";
|
||||
foreach($options as $key => $value)
|
||||
{
|
||||
$key = str_replace('item', '', $key); // 因为对象的元素不能为数字,所以需要在配置里面会在数字前面添加item,这个地方将item去掉。
|
||||
$key = str_replace('item', '', $key);
|
||||
$selected = strpos($selectedItems, ",$key,") !== false ? " selected='selected'" : '';
|
||||
$string .= "<option value='$key'$selected>$value</option>\n";
|
||||
}
|
||||
@@ -70,12 +131,13 @@ class html
|
||||
}
|
||||
|
||||
/**
|
||||
* create select with optgroup.
|
||||
* 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.
|
||||
* @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 = "")
|
||||
{
|
||||
@@ -107,10 +169,11 @@ class html
|
||||
/**
|
||||
* Create tags like "<input type='radio' />"
|
||||
*
|
||||
* @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.
|
||||
* @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 = '')
|
||||
{
|
||||
@@ -129,12 +192,13 @@ class html
|
||||
}
|
||||
|
||||
/**
|
||||
* create tags like "<input type='checkbox' />"
|
||||
* Create tags like "<input type='checkbox' />"
|
||||
*
|
||||
* @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.
|
||||
* @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 = "")
|
||||
{
|
||||
@@ -145,7 +209,7 @@ class html
|
||||
|
||||
foreach($options as $key => $value)
|
||||
{
|
||||
$key = str_replace('item', '', $key); // 因为对象的元素不能为数字,所以需要在配置里面会在数字前面添加item,这个地方将item去掉。
|
||||
$key = str_replace('item', '', $key);
|
||||
$string .= "<span><input type='checkbox' name='{$name}[]' value='$key' ";
|
||||
$string .= strpos($checked, ",$key,") !== false ? " checked ='checked'" : "";
|
||||
$string .= $attrib;
|
||||
@@ -155,11 +219,12 @@ class html
|
||||
}
|
||||
|
||||
/**
|
||||
* create tags like "<input type='text' />"
|
||||
* Create tags like "<input type='text' />"
|
||||
*
|
||||
* @param string $name the name of the text input tag.
|
||||
* @param string $value the default value.
|
||||
* @param string $attrib other attribs.
|
||||
* @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 = "")
|
||||
{
|
||||
@@ -167,11 +232,12 @@ class html
|
||||
}
|
||||
|
||||
/**
|
||||
* create tags like "<input type='hidden' />"
|
||||
* Create tags like "<input type='hidden' />"
|
||||
*
|
||||
* @param string $name the name of the text input tag.
|
||||
* @param string $value the default value.
|
||||
* @param string $attrib other attribs.
|
||||
* @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 = "")
|
||||
{
|
||||
@@ -179,11 +245,12 @@ class html
|
||||
}
|
||||
|
||||
/**
|
||||
* create tags like "<input type='password' />"
|
||||
* Create tags like "<input type='password' />"
|
||||
*
|
||||
* @param string $name the name of the text input tag.
|
||||
* @param string $value the default value.
|
||||
* @param string $attrib other attribs.
|
||||
* @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 = "")
|
||||
{
|
||||
@@ -191,11 +258,12 @@ class html
|
||||
}
|
||||
|
||||
/**
|
||||
* create tags like "<textarea></textarea>"
|
||||
* Create tags like "<textarea></textarea>"
|
||||
*
|
||||
* @param string $name the name of the textarea tag.
|
||||
* @param string $value the default value of the textarea tag.
|
||||
* @param string $attrib other attribs.
|
||||
* @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 = "")
|
||||
{
|
||||
@@ -203,10 +271,11 @@ class html
|
||||
}
|
||||
|
||||
/**
|
||||
* create tags like "<input type='file' />".
|
||||
* Create tags like "<input type='file' />".
|
||||
*
|
||||
* @param string $name the name of the file name.
|
||||
* @param string $attrib other attribs.
|
||||
* @param string $name the name of the file name.
|
||||
* @param string $attrib other attribs.
|
||||
* @return string
|
||||
*/
|
||||
static public function file($name, $attrib = "")
|
||||
{
|
||||
@@ -214,11 +283,13 @@ class html
|
||||
}
|
||||
|
||||
/**
|
||||
* create submit button.
|
||||
*
|
||||
* 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.
|
||||
* @return string the submit button tag.
|
||||
*/
|
||||
public static function submitButton($label = '', $misc = '')
|
||||
{
|
||||
@@ -231,11 +302,11 @@ class html
|
||||
}
|
||||
|
||||
/**
|
||||
* create reset button.
|
||||
*
|
||||
* Create reset button.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @return string the reset button tag.
|
||||
* @return string the reset button tag.
|
||||
*/
|
||||
public static function resetButton()
|
||||
{
|
||||
@@ -244,11 +315,13 @@ class html
|
||||
}
|
||||
|
||||
/**
|
||||
* create common button.
|
||||
*
|
||||
* Create common button.
|
||||
*
|
||||
* @param string $label the label of the button
|
||||
* @param string $misc other params
|
||||
* @static
|
||||
* @access public
|
||||
* @return string the reset button tag.
|
||||
* @return string the common button tag.
|
||||
*/
|
||||
public static function commonButton($label = '', $misc = '')
|
||||
{
|
||||
@@ -256,11 +329,14 @@ class html
|
||||
}
|
||||
|
||||
/**
|
||||
* create a button with a link.
|
||||
*
|
||||
* 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 the reset button tag.
|
||||
* @return string
|
||||
*/
|
||||
public static function linkButton($label = '', $link = '', $misc = '')
|
||||
{
|
||||
@@ -269,198 +345,85 @@ class html
|
||||
|
||||
/**
|
||||
* create a export link.
|
||||
*
|
||||
*
|
||||
* @param string $label
|
||||
* @param string $pluginTitle
|
||||
* @param string $misc
|
||||
* @static
|
||||
* @access public
|
||||
* @return string the reset button tag.
|
||||
* @return void
|
||||
*/
|
||||
public static function export2csv($label = '', $pluginTitle, $misc = '')
|
||||
{
|
||||
return "<a href='#' onclick=\"$('.datatable').table2CSV({title:'$pluginTitle'})\" $misc />$label</a>\n<div id='exporter' class='hidden'></div>\n";
|
||||
}
|
||||
|
||||
/*!
|
||||
* ubb2html support for php
|
||||
* @requires xhEditor
|
||||
*
|
||||
* @author Yanis.Wang<yanis.wang@gmail.com>
|
||||
* @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("/>/",'>',$sHtml);
|
||||
$sHtml=preg_replace("/\r?\n/",'<br />',$sHtml);
|
||||
|
||||
$sHtml=preg_replace("/\[(\/?)(b|u|i|s|sup|sub)\]/i",'<$1$2>',$sHtml);
|
||||
$sHtml=preg_replace('/\[color\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\]/i','<span style="color:$1;">',$sHtml);
|
||||
if(!$bUbb2htmlFunctionInit)
|
||||
{
|
||||
function getSizeName($match)
|
||||
{
|
||||
$arrSize=array('8pt','10pt','12pt','14pt','18pt','24pt','36pt');
|
||||
return '<span style="font-size:'.$arrSize[$match[1]-1].';">';
|
||||
}
|
||||
}
|
||||
$sHtml=preg_replace_callback("/\[size\s*=\s*(\d+?)\s*\]/i",'getSizeName',$sHtml);
|
||||
$sHtml=preg_replace('/\[font\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\]/i','<span style="font-family:$1;">',$sHtml);
|
||||
$sHtml=preg_replace('/\[back\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\]/i','<span style="background-color:$1;">',$sHtml);
|
||||
$sHtml=preg_replace("/\[\/(color|size|font|back)\]/i",'</span>',$sHtml);
|
||||
|
||||
for($i=0;$i<3;$i++)$sHtml=preg_replace('/\[align\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\](((?!\[align(?:\s+[^\]]+)?\])[\s\S])*?)\[\/align\]/','<p align="$1">$2</p>',$sHtml);
|
||||
$sHtml=preg_replace('/\[img\]\s*(((?!")[\s\S])+?)(?:"[\s\S]*?)?\s*\[\/img\]/i','<img src="$1" alt="" />',$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 '<img src="'.$src.'" alt="'.$alt.'"'.(is_numeric($p1)?' width="'.$p1.'"':'').(is_numeric($p2)?' height="'.$p2.'"':'').($a?' align="'.$a.'"':'').' />';
|
||||
}
|
||||
}
|
||||
|
||||
$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 '<img src="'.$path.'" alt="'.$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','<a href="$1">$1</a>',$sHtml);
|
||||
$sHtml=preg_replace('/\[url\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\]\s*([\s\S]*?)\s*\[\/url\]/i','<a href="$1">$2</a>',$sHtml);
|
||||
$sHtml=preg_replace('/\[email\]\s*(((?!")[\s\S])+?)(?:"[\s\S]*?)?\s*\[\/email\]/i','<a href="mailto:$1">$1</a>',$sHtml);
|
||||
$sHtml=preg_replace('/\[email\s*=\s*([^\]"]+?)(?:"[^\]]*?)?\s*\]\s*([\s\S]+?)\s*\[\/email\]/i','<a href="mailto:$1">$2</a>',$sHtml);
|
||||
$sHtml=preg_replace("/\[quote\]([\s\S]*?)\[\/quote\]/i",'<blockquote>$1</blockquote>',$sHtml);
|
||||
if(!$bUbb2htmlFunctionInit)
|
||||
{
|
||||
function getFlash($match)
|
||||
{
|
||||
$w=$match[1];$h=$match[2];$url=$match[3];
|
||||
if(!$w)$w=480;if(!$h)$h=400;
|
||||
return '<embed type="application/x-shockwave-flash" src="'.$url.'" wmode="opaque" quality="high" bgcolor="#ffffff" menu="false" play="true" loop="true" width="'.$w.'" height="'.$h.'" />';
|
||||
}
|
||||
}
|
||||
$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 '<embed type="application/x-mplayer2" src="'.$url.'" enablecontextmenu="false" autostart="'.($play=='1'?'true':'false').'" width="'.$w.'" height="'.$h.'" />';
|
||||
}
|
||||
}
|
||||
$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 '<table'.(isset($match[1])?' width="'.$match[1].'"':'').(isset($match[2])?' bgcolor="'.$match[2].'"':'').'>';
|
||||
}
|
||||
}
|
||||
$sHtml=preg_replace_callback('/\[table\s*(?:=(\d{1,4}%?)\s*(?:,\s*([^\]"]+)(?:"[^\]]*?)?)?)?\s*\]/i','getTable',$sHtml);
|
||||
if(!$bUbb2htmlFunctionInit)
|
||||
{
|
||||
function getTR($match){return '<tr'.(isset($match[1])?' bgcolor="'.$match[1].'"':'').'>';}
|
||||
}
|
||||
$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 '<td'.($col>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",'<li>$1</li>',$sHtml);
|
||||
if(!$bUbb2htmlFunctionInit)
|
||||
{
|
||||
function getUL($match)
|
||||
{
|
||||
$str='<ul';
|
||||
if(isset($match[1]))$str.=' type="'.$match[1].'"';
|
||||
return $str.'>';
|
||||
}
|
||||
}
|
||||
$sHtml=preg_replace_callback('/\[list\s*(?:=\s*([^\]"]+))?(?:"[^\]]*?)?\s*\]/i','getUL',$sHtml);
|
||||
$sHtml=preg_replace("/\[\/list\]/i",'</ul>',$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
|
||||
{
|
||||
/* The start of javascript. */
|
||||
static private function start()
|
||||
/**
|
||||
* Import a js file.
|
||||
*
|
||||
* @param mixed $url
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public static function import($url)
|
||||
{
|
||||
return <<<EOT
|
||||
<html>
|
||||
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
|
||||
<script language='Javascript'>
|
||||
EOT;
|
||||
echo "<script src='$url' type='text/javascript'></script>\n";
|
||||
}
|
||||
|
||||
/* The end of javascript. */
|
||||
/**
|
||||
* The start of javascript.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
static private function start($full = true)
|
||||
{
|
||||
if($full) return "<html><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><script language='Javascript'>";
|
||||
return "<script language='Javascript'>";
|
||||
}
|
||||
|
||||
/**
|
||||
* The end of javascript.
|
||||
*
|
||||
* @static
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
static private function end()
|
||||
{
|
||||
return "\n</script>\n";
|
||||
}
|
||||
|
||||
/* Show a alert box. */
|
||||
/**
|
||||
* Show a alert box.
|
||||
*
|
||||
* @param string $message
|
||||
* @static
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
static public function alert($message = '')
|
||||
{
|
||||
return self::start() . "alert('" . $message . "')" . self::end();
|
||||
}
|
||||
|
||||
/* 弹出错误。其中message可以是一条字符串,也可以是一维或者二维数组。*/
|
||||
/**
|
||||
* Show error info.
|
||||
*
|
||||
* @param string|array $message
|
||||
* @static
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
static public function error($message)
|
||||
{
|
||||
$alertMessage = '';
|
||||
@@ -481,11 +444,12 @@ EOT;
|
||||
/**
|
||||
* 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'.
|
||||
* @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)
|
||||
{
|
||||
@@ -530,7 +494,7 @@ EOT;
|
||||
*
|
||||
* @param string $url the url will go to.
|
||||
* @param string $target the target of the url.
|
||||
* @return string the javascript string.
|
||||
* @return string the javascript string.
|
||||
*/
|
||||
static public function locate($url, $target = "self")
|
||||
{
|
||||
@@ -546,7 +510,13 @@ EOT;
|
||||
return $js . self::end();
|
||||
}
|
||||
|
||||
/* Close current window. */
|
||||
/**
|
||||
* Close current window.
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
static public function closeWindow()
|
||||
{
|
||||
return self::start(). "window.close();" . self::end();
|
||||
@@ -558,7 +528,7 @@ EOT;
|
||||
* @param string $url the url will go to.
|
||||
* @param string $target the target of the url.
|
||||
* @param int $time the timer, msec.
|
||||
* @return string the javascript string.
|
||||
* @return string the javascript string.
|
||||
*/
|
||||
static public function refresh($url, $target = "self", $time = 3000)
|
||||
{
|
||||
@@ -572,7 +542,7 @@ EOT;
|
||||
* Reload a window.
|
||||
*
|
||||
* @param string $window the window to reload.
|
||||
* @return string the javascript string.
|
||||
* @return string the javascript string.
|
||||
*/
|
||||
static public function reload($window = 'self')
|
||||
{
|
||||
@@ -587,7 +557,7 @@ EOT;
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @return string
|
||||
* @return void
|
||||
*/
|
||||
static public function exportConfigVars()
|
||||
{
|
||||
@@ -599,26 +569,45 @@ EOT;
|
||||
$clientLang = $app->getClientLang();
|
||||
$requiredFields = '';
|
||||
if(isset($config->$moduleName->$methodName->requiredFields)) $requiredFields = str_replace(' ', '', $config->$moduleName->$methodName->requiredFields);
|
||||
$js = <<<EOT
|
||||
<script language = 'javascript'>
|
||||
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';
|
||||
</script>
|
||||
|
||||
EOT;
|
||||
return $js;
|
||||
$jsConfig->webRoot = $config->webRoot;
|
||||
$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->router = $app->server->PHP_SELF;
|
||||
|
||||
$js = self::start(false);
|
||||
$js .= 'var config=' . json_encode($jsConfig);
|
||||
$js .= self::end();
|
||||
echo $js;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* css class.
|
||||
*
|
||||
* @package front
|
||||
*/
|
||||
class css
|
||||
{
|
||||
/**
|
||||
* Import a css file.
|
||||
*
|
||||
* @param mixed $url
|
||||
* @access public
|
||||
* @return vod
|
||||
*/
|
||||
public static function import($url)
|
||||
{
|
||||
echo "<link rel='stylesheet' href='$url' type='text/css' media='screen' />\n";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user