00662 function & initWebControls()
00663 {
00664 return FLEA::getSingleton(FLEA::getAppInf('webControlsClassName'));
00665 }
'webControlsClassName'默認(rèn)是FLEA目錄下的webControls類,該類封裝了頁面組件的實現(xiàn),以及一些常用的頁面控件,在找不到這些自帶控件的時候就會去嘗試搜索我們自定義的以_ctl開頭的控件
/**
* 構(gòu)造一個控件的 HTML 代碼
*
* @param string $type
* @param string $name
* @param array $attribs
* @param boolean $return
*
* @return string
*/
function control($type, $name, $attribs = null, $return = false)
{
$type = strtolower($type);
$render = '_ctl' . ucfirst($type);
$attribs = (array)$attribs;
$__ctl_out = false;
if (method_exists($this, $render)) {
$__ctl_out = $this->{$render}($name, $attribs);
} else {
$extfilename = ucfirst($type) . '.php';
if (!isset($this->_extends[$type])) {
foreach ($this->_extendsDir as $dir) {
if (file_exists($dir . DS . $extfilename)) {
require($dir . DS . $extfilename);
$this->_extends[$type] = true;
break;
}
}
}
if (isset($this->_extends[$type])) {
$__ctl_out = call_user_func_array($render,
array('name' => $name, 'attribs' => $attribs));
}
}
if ($__ctl_out === false) {
$__ctl_out = "INVALID CONTROL TYPE \"{$type}\"";
}
if ($return) { return $__ctl_out; }
echo $__ctl_out;
return '';
}
實例化控件之后,在模版(也就是 .php)中:
如果使用smarty,調(diào)用方式就是:
{ webcontrol type='textbox' value=$textbox_value }
系統(tǒng)會自動去實例化控件對象