diff --git a/CHANGELOG b/CHANGELOG index 9bac2311f..897bfdd0a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,7 @@ Version 1.0b To be released - Added CVarDumper (Qiang) - Added CDateParser (Qiang) - Added CTypeValidator (Qiang) +- Added CViewRenderer and CPradoViewRenderer (Qiang) Version 1.0a October 5, 2008 ============================= diff --git a/framework/YiiBase.php b/framework/YiiBase.php index f09096d43..dda910486 100644 --- a/framework/YiiBase.php +++ b/framework/YiiBase.php @@ -507,8 +507,8 @@ class YiiBase 'CHtml' => '/web/helpers/CHtml.php', 'CJSON' => '/web/helpers/CJSON.php', 'CJavaScript' => '/web/helpers/CJavaScript.php', - 'CPradoViewRenderer - Copy' => '/web/renderers/CPradoViewRenderer - Copy.php', 'CPradoViewRenderer' => '/web/renderers/CPradoViewRenderer.php', + 'CViewRenderer' => '/web/renderers/CViewRenderer.php', 'CAutoComplete' => '/web/widgets/CAutoComplete.php', 'CCaptcha' => '/web/widgets/CCaptcha.php', 'CClipWidget' => '/web/widgets/CClipWidget.php', diff --git a/framework/utils/CFileHelper.php b/framework/utils/CFileHelper.php index 83db45ef1..715d7990b 100644 --- a/framework/utils/CFileHelper.php +++ b/framework/utils/CFileHelper.php @@ -75,20 +75,6 @@ class CFileHelper return $list; } - /** - * Creates a directory. - * This method also creates parent directories if they do not exist. - * @param string the directory to be created. - */ - public static function mkdir($directory) - { - if(!is_dir($directory)) - { - self::mkdir(dirname($directory)); - mkdir($directory); - } - } - /** * Copies a directory. * This method is mainly used by {@link copyDirectory}. diff --git a/framework/web/CBaseController.php b/framework/web/CBaseController.php index 1082de64d..ea167f8ff 100644 --- a/framework/web/CBaseController.php +++ b/framework/web/CBaseController.php @@ -193,10 +193,12 @@ abstract class CBaseController extends CComponent * Begins recording a clip. * This method is a shortcut to beginning {@link CClipWidget}. * @param string the clip ID. + * @param array initial property values for {@link CClipWidget}. */ - public function beginClip($id) + public function beginClip($id,$properties=array()) { - $this->beginWidget('CClipWidget',array('id'=>$id)); + $properties['id']=$id; + $this->beginWidget('CClipWidget',$properties); } /** @@ -251,13 +253,16 @@ abstract class CBaseController extends CComponent /** * Begins the rendering of content that is to be decorated by the specified view. - * @param string the name of the view that will embed the content in. The actual view script + * @param string the name of the view that will be used to decorate the content. The actual view script * is resolved via {@link getViewFile}. + * @param array initial property values for {@link CContentDecorator}. * @see beginContent + * @see CContentDecorator */ - public function beginContent($view) + public function beginContent($view,$properties=array()) { - $this->beginWidget('CContentDecorator',array('view'=>$view)); + $properties['view']=$view; + $this->beginWidget('CContentDecorator',$properties); } /** diff --git a/framework/web/helpers/CHtml.php b/framework/web/helpers/CHtml.php index 678d2cdee..906fa622e 100644 --- a/framework/web/helpers/CHtml.php +++ b/framework/web/helpers/CHtml.php @@ -43,9 +43,9 @@ class CHtml * @return string the encoded data * @see http://www.php.net/manual/en/function.htmlspecialchars.php */ - public static function encode($str) + public static function encode($text) { - return htmlspecialchars($str,ENT_QUOTES,Yii::app()->charset); + return htmlspecialchars($text,ENT_QUOTES,Yii::app()->charset); } /** @@ -73,9 +73,9 @@ class CHtml * @param string the string to be enclosed * @return string the CDATA tag with the enclosed content. */ - public static function cdata($content) + public static function cdata($text) { - return ''; + return ''; } /** @@ -84,11 +84,11 @@ class CHtml * @param string the media that this CSS should apply to. * @return string the CSS properly enclosed */ - public static function css($css,$media='') + public static function css($text,$media='') { if($media!=='') $media=' media="'.$media.'"'; - return ""; + return ""; } /** @@ -97,11 +97,11 @@ class CHtml * @param string the media that this CSS should apply to. * @return string the CSS link. */ - public static function cssFile($cssFile,$media='') + public static function cssFile($url,$media='') { if($media!=='') $media=' media="'.$media.'"'; - return ''; + return ''; } /** @@ -109,9 +109,9 @@ class CHtml * @param string the JavaScript to be enclosed * @return string the enclosed JavaScript */ - public static function script($script) + public static function script($text) { - return ""; + return ""; } /** @@ -119,9 +119,9 @@ class CHtml * @param string URL for the JavaScript file * @return string the JavaScript file tag */ - public static function scriptFile($scriptFile) + public static function scriptFile($url) { - return ''; + return ''; } /** @@ -133,9 +133,9 @@ class CHtml * @param array additional HTML attributes. * @return string the generated form tag. */ - public static function form($url='',$method='post',$htmlOptions=array()) + public static function form($action='',$method='post',$htmlOptions=array()) { - $htmlOptions['action']=self::normalizeUrl($url); + $htmlOptions['action']=self::normalizeUrl($action); $htmlOptions['method']=$method; return self::tag('form',$htmlOptions,false,false); } @@ -151,11 +151,11 @@ class CHtml * @see normalizeUrl * @see clientChange */ - public static function link($body,$url='#',$htmlOptions=array()) + public static function link($text,$url='#',$htmlOptions=array()) { $htmlOptions['href']=self::normalizeUrl($url); self::clientChange('click',$htmlOptions); - return self::tag('a',$htmlOptions,$body); + return self::tag('a',$htmlOptions,$text); } /** @@ -228,9 +228,9 @@ class CHtml * @return string the generated button tag * @see clientChange */ - public static function imageButton($imageUrl,$htmlOptions=array()) + public static function imageButton($src,$htmlOptions=array()) { - $htmlOptions['src']=$imageUrl; + $htmlOptions['src']=$src; $htmlOptions['type']='image'; return self::button('submit',$htmlOptions); } @@ -258,9 +258,9 @@ class CHtml * @param array additional HTML attributes. * @return string the generated label tag */ - public static function label($label,$forID,$htmlOptions=array()) + public static function label($label,$for,$htmlOptions=array()) { - $htmlOptions['for']=$forID; + $htmlOptions['for']=$for; return self::tag('label',$htmlOptions,$label); } @@ -399,9 +399,9 @@ class CHtml * @see inputField * @see listData */ - public static function dropDownList($name,$selection,$listData,$htmlOptions=array()) + public static function dropDownList($name,$select,$data,$htmlOptions=array()) { - $options="\n".self::listOptions($selection,$listData,$htmlOptions); + $options="\n".self::listOptions($select,$data,$htmlOptions); self::clientChange('change',$htmlOptions); return self::tag('select',$htmlOptions,$options); } @@ -418,11 +418,11 @@ class CHtml * @see inputField * @see listData */ - public static function listBox($name,$selection,$listData,$htmlOptions=array()) + public static function listBox($name,$select,$data,$htmlOptions=array()) { if(!isset($htmlOptions['size'])) $htmlOptions['size']=4; - return self::dropDownList($name,$selection,$listData,$htmlOptions); + return self::dropDownList($name,$select,$data,$htmlOptions); } /** @@ -436,14 +436,14 @@ class CHtml * @see normalizeUrl * @see ajax */ - public static function ajaxLink($body,$url,$ajaxOptions=array(),$htmlOptions=array()) + public static function ajaxLink($text,$url,$ajaxOptions=array(),$htmlOptions=array()) { if(!isset($htmlOptions['href'])) $htmlOptions['href']='#'; $ajaxOptions['url']=$url; $htmlOptions['ajax']=$ajaxOptions; self::clientChange('click',$htmlOptions); - return self::tag('a',$htmlOptions,$body); + return self::tag('a',$htmlOptions,$text); } /** @@ -712,10 +712,10 @@ class CHtml * @see clientChange * @see listData */ - public static function activeDropDownList($model,$attribute,$listData,$htmlOptions=array()) + public static function activeDropDownList($model,$attribute,$data,$htmlOptions=array()) { $selection=$model->$attribute; - $options="\n".self::listOptions($selection,$listData,$htmlOptions); + $options="\n".self::listOptions($selection,$data,$htmlOptions); self::resolveNameID($model,$attribute,$htmlOptions); self::clientChange('change',$htmlOptions); if($model->hasErrors($attribute)) @@ -736,11 +736,11 @@ class CHtml * @see clientChange * @see listData */ - public static function activeListBox($model,$attribute,$listData,$htmlOptions=array()) + public static function activeListBox($model,$attribute,$data,$htmlOptions=array()) { if(!isset($htmlOptions['size'])) $htmlOptions['size']=4; - return self::dropDownList($model,$attribute,$listData,$htmlOptions); + return self::dropDownList($model,$attribute,$data,$htmlOptions); } /** @@ -764,16 +764,16 @@ class CHtml * @see CModel::getErrors * @see errorSummaryCss */ - public static function errorSummary($models,$header='',$footer='') + public static function errorSummary($model,$header='',$footer='') { if($header==='') $header='

'.Yii::t('yii#Please fix the following input errors:').'

'; $content=''; - if(!is_array($models)) - $models=array($models); - foreach($models as $model) + if(!is_array($model)) + $model=array($model); + foreach($model as $m) { - foreach($model->getErrors() as $errors) + foreach($m->getErrors() as $errors) { foreach($errors as $error) $content.="
  • $error
  • \n"; diff --git a/framework/web/renderers/CPradoViewRenderer.php b/framework/web/renderers/CPradoViewRenderer.php new file mode 100644 index 000000000..cc183611b --- /dev/null +++ b/framework/web/renderers/CPradoViewRenderer.php @@ -0,0 +1,240 @@ + + * @link http://www.yiiframework.com/ + * @copyright Copyright © 2008 Yii Software LLC + * @license http://www.yiiframework.com/license/ + */ + +/** + * CPradoViewRenderer implements a view renderer that allows users to use a template syntax similar to PRADO templates. + * + * To use CPradoViewRenderer, configure it as an application component named "viewRenderer" in the application configuration: + *
    + * array(
    + *     'components'=>array(
    + *         ......
    + *         'viewRenderer'=>array(
    + *             'class'=>'CPradoViewRenderer',
    + *         ),
    + *     ),
    + * )
    + * 
    + * + * CPradoViewRenderer allows you to write view files with the following syntax: + * + * + * @author Steve Heyns http://customgothic.com/ + * @author Qiang Xue + * @version $Id$ + * @package system.web.renderers + * @since 1.0 + */ +class CPradoViewRenderer extends CViewRenderer +{ + private $_input; + private $_output; + + /** + * Parses the source view file and saves the results as another file. + * This method is required by the parent class. + * @param string the source view file path + * @param string the resulting view file path + */ + protected function generateViewFile($sourceFile,$viewFile) + { + static $regexRules=array( + '<%=?\s*(.*?)\s*%>', // PHP statements or expressions + '<\/?(com|cache|clip):([\w\.]+)\s*((?:\s*\w+\s*=\s*\'.*?(?', // component tags + '', // template comments + ); + $this->_input=file_get_contents($sourceFile); + $n=preg_match_all('/'.implode('|',$regexRules).'/msS',$this->_input,$matches,PREG_SET_ORDER|PREG_OFFSET_CAPTURE); + $textStart=0; + $this->_output="\n"; + for($i=0;$i<$n;++$i) + { + $match=&$matches[$i]; + $str=$match[0][0]; + $matchStart=$match[0][1]; + $matchEnd=$matchStart+strlen($str)-1; + + if($matchStart>$textStart) + $this->_output.=substr($this->_input,$textStart,$matchStart-$textStart); + $textStart=$matchEnd+1; + + if(strpos($str,'_output.=$this->processOpenWidget($type,$match[4][0],$match[2][1]); + else + $this->_output.=$this->processWidget($type,$match[4][0],$match[2][1]); + } + else if(strpos($str,'_output.=$this->processEndWidget($match[3][0],$match[2][1]); + else if(strpos($str,'_output.=$this->processBeginCache($id,$match[4][0],$match[2][1]); + else + $this->_output.=$this->processCache($id,$match[4][0],$match[2][1]); + } + else if(strpos($str,'_output.=$this->processEndCache($match[3][0],$match[2][1]); + else if(strpos($str,'_output.=$this->processBeginClip($id,$match[4][0],$match[2][1]); + else + $this->_output.=$this->processClip($id,$match[4][0],$match[2][1]); + } + else if(strpos($str,'_output.=$this->processEndClip($match[3][0],$match[2][1]); + else if(strpos($str,'<%=')===0) // expression + $this->_output.=$this->processExpression($match[1][0],$match[1][1]); + else if(strpos($str,'<%')===0) // statement + $this->_output.=$this->processStatement($match[1][0],$match[1][1]); + } + if($textStart_input)) + $this->_output.=substr($this->_input,$textStart); + + file_put_contents($viewFile,$this->_output); + } + + private function processWidget($type,$attributes,$offset) + { + $attrs=$this->processAttributes($attributes); + if(empty($attrs)) + return $this->generatePhpCode("\$this->widget('$type');",$offset); + else + return $this->generatePhpCode("\$this->widget('$type', array($attrs));",$offset); + } + + private function processBeginWidget($type,$attributes,$offset) + { + $attrs=$this->processAttributes($attributes); + if(empty($attrs)) + return $this->generatePhpCode("\$this->beginWidget('$type');",$offset); + else + return $this->generatePhpCode("\$this->beginWidget('$type', array($attrs));",$offset); + } + + private function processEndWidget($type,$offset) + { + return $this->generatePhpCode("\$this->endWidget('$type');",$offset); + } + + private function processCache($id,$attributes,$offset) + { + return $this->processBeginCache($id,$attributes,$offset) . $this->processEndCache($id,$offset); + } + + private function processBeginCache($id,$attributes,$offset) + { + $attrs=$this->processAttributes($attributes); + if(empty($attrs)) + return $this->generatePhpCode("if(\$this->beginCache('$id')):",$offset); + else + return $this->generatePhpCode("if(\$this->beginCache('$id', array($attrs))):",$offset); + } + + private function processEndCache($id,$offset) + { + return $this->generatePhpCode("\$this->endCache('$id'); endif;",$offset); + } + + private function processClip($id,$attributes,$offset) + { + return $this->processBeginClip($id,$attributes,$offset) . $this->processEndClip($id,$offset); + } + + private function processBeginClip($id,$attributes,$offset) + { + $attrs=$this->processAttributes($attributes); + if(empty($attrs)) + return $this->generatePhpCode("\$this->beginClip('$id');",$offset); + else + return $this->generatePhpCode("\$this->beginClip('$id', array($attrs));",$offset); + } + + private function processEndClip($id,$offset) + { + return $this->generatePhpCode("\$this->endClip('$id');",$offset); + } + + private function processExpression($expression,$offset) + { + return $this->generatePhpCode('echo '.$expression,$offset); + } + + private function processStatement($statement,$offset) + { + return $this->generatePhpCode($statement,$offset); + } + + private function generatePhpCode($code,$offset) + { + $line=$this->getLineNumber($offset); + return ""; + } + + private function processAttributes($str) + { + static $pattern='/(\w+)\s*=\s*(\'.*?(?".substr($value,1,-1); + else + $attributes[]="'$name'=>$value"; + } + return implode(', ',$attributes); + } + + private function getLineNumber($offset) + { + return count(explode("\n",substr($this->_input,0,$offset))); + } +} diff --git a/framework/web/renderers/CViewRenderer.php b/framework/web/renderers/CViewRenderer.php new file mode 100644 index 000000000..a29f268de --- /dev/null +++ b/framework/web/renderers/CViewRenderer.php @@ -0,0 +1,93 @@ + + * @link http://www.yiiframework.com/ + * @copyright Copyright © 2008 Yii Software LLC + * @license http://www.yiiframework.com/license/ + */ + +/** + * CViewRenderer is the base class for view renderer classes. + * + * A view renderer is an application component that renders views written + * in a customized syntax. + * + * Once installing a view renderer as a 'viewRenderer' application component, + * the normal view rendering process will be intercepted by the renderer. + * The renderer will first parse the source view file and then render the + * the resulting view file. + * + * Parsing results are saved as temporary files that may be stored + * under the application runtime directory or together with the source view file. + * + * @author Steve Heyns http://customgothic.com/ + * @author Qiang Xue + * @version $Id$ + * @package system.web.renderers + * @since 1.0 + */ +abstract class CViewRenderer extends CApplicationComponent implements IViewRenderer +{ + /** + * @var boolean whether to store the parsing results in the application's + * runtime directory. Defaults to true. If false, the parsing results will + * be saved as files under the same directory as the source view files and the + * file names will be the source file names appended with letter 'c'. + */ + public $useRuntimePath=true; + /** + * @param integer the chmod permission for temporary directories and files + * generated during parsing. Defaults to 0755 (owner rwx, group rx and others rx). + */ + public $filePermission=0755; + + /** + * Parses the source view file and saves the results as another file. + * @param string the source view file path + * @param string the resulting view file path + */ + abstract protected function generateViewFile($sourceFile,$viewFile); + + /** + * Renders a view file. + * This method is required by {@link IViewRenderer}. + * @param CBaseController the controller or widget who is rendering the view file. + * @param string the view file path + * @param mixed the data to be passed to the view + * @param boolean whether the rendering result should be returned + * @return mixed the rendering result, or null if the rendering result is not needed. + */ + public function renderFile($context,$sourceFile,$data,$return) + { + if(!is_file($sourceFile) || ($file=realpath($sourceFile))===false) + throw new CException(Yii::t('yii#View file "{file}" does not exist.',array('{file}'=>$sourceFile))); + $viewFile=$this->getViewFile($sourceFile); + if(@filemtime($sourceFile)>@filemtime($viewFile)) + { + $this->generateViewFile($sourceFile,$viewFile); + @chmod($viewFile,$this->filePermission); + } + return $context->renderInternal($viewFile,$data,$return); + } + + /** + * Generates the resulting view file path. + * @param string source view file path + * @return string resulting view file path + */ + protected function getViewFile($file) + { + if($this->useRuntimePath) + { + $crc=sprintf('%x', crc32(get_class($this).Yii::getVersion().dirname($file))); + $viewFile=Yii::app()->getRuntimePath().DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.$crc.DIRECTORY_SEPARATOR.basename($file); + if(!is_file($viewFile)) + @mkdir(dirname($viewFile),$this->filePermission,true); + return $viewFile; + } + else + return $viewFile.'c'; + } +} diff --git a/framework/web/widgets/CClipWidget.php b/framework/web/widgets/CClipWidget.php index 000f2ef26..d4aedd1c5 100644 --- a/framework/web/widgets/CClipWidget.php +++ b/framework/web/widgets/CClipWidget.php @@ -24,6 +24,12 @@ */ class CClipWidget extends CWidget { + /** + * @var boolean whether to render the clip content in place. Defaults to false, + * meaning the captured clip will not be displayed. + */ + public $renderClip=false; + private $_level; /** @@ -42,6 +48,8 @@ class CClipWidget extends CWidget public function run() { $clip=ob_get_clean(); + if($this->renderClip) + echo $clip; $this->getController()->getClips()->add($this->getId(),$clip); } } \ No newline at end of file diff --git a/framework/yiilite.php b/framework/yiilite.php index 10f8b71ed..c7efdfaec 100644 --- a/framework/yiilite.php +++ b/framework/yiilite.php @@ -313,8 +313,8 @@ class YiiBase 'CHtml' => '/web/helpers/CHtml.php', 'CJSON' => '/web/helpers/CJSON.php', 'CJavaScript' => '/web/helpers/CJavaScript.php', - 'CPradoViewRenderer - Copy' => '/web/renderers/CPradoViewRenderer - Copy.php', 'CPradoViewRenderer' => '/web/renderers/CPradoViewRenderer.php', + 'CViewRenderer' => '/web/renderers/CViewRenderer.php', 'CAutoComplete' => '/web/widgets/CAutoComplete.php', 'CCaptcha' => '/web/widgets/CCaptcha.php', 'CClipWidget' => '/web/widgets/CClipWidget.php', @@ -2142,9 +2142,10 @@ abstract class CBaseController extends CComponent throw new CException(Yii::t('yii#{controller} has an extra endWidget({id}) call in its view.', array('{controller}'=>get_class($this),'{id}'=>$id))); } - public function beginClip($id) + public function beginClip($id,$properties=array()) { - $this->beginWidget('CClipWidget',array('id'=>$id)); + $properties['id']=$id; + $this->beginWidget('CClipWidget',$properties); } public function endClip() { @@ -2166,9 +2167,10 @@ abstract class CBaseController extends CComponent { $this->endWidget('COutputCache'); } - public function beginContent($view) + public function beginContent($view,$properties=array()) { - $this->beginWidget('CContentDecorator',array('view'=>$view)); + $properties['view']=$view; + $this->beginWidget('CContentDecorator',$properties); } public function endContent() { @@ -2957,9 +2959,9 @@ class CHtml public static $errorMessageCss='errorMessage'; public static $errorCss='error'; private static $_count=0; - public static function encode($str) + public static function encode($text) { - return htmlspecialchars($str,ENT_QUOTES,Yii::app()->charset); + return htmlspecialchars($text,ENT_QUOTES,Yii::app()->charset); } public static function tag($tag,$htmlOptions=array(),$content=false,$closeTag=true) { @@ -2971,41 +2973,41 @@ class CHtml else return $closeTag ? $html.'>'.$content.'' : $html.'>'.$content; } - public static function cdata($content) + public static function cdata($text) { - return ''; + return ''; } - public static function css($css,$media='') + public static function css($text,$media='') { if($media!=='') $media=' media="'.$media.'"'; - return ""; + return ""; } - public static function cssFile($cssFile,$media='') + public static function cssFile($url,$media='') { if($media!=='') $media=' media="'.$media.'"'; - return ''; + return ''; } - public static function script($script) + public static function script($text) { - return ""; + return ""; } - public static function scriptFile($scriptFile) + public static function scriptFile($url) { - return ''; + return ''; } - public static function form($url='',$method='post',$htmlOptions=array()) + public static function form($action='',$method='post',$htmlOptions=array()) { - $htmlOptions['action']=self::normalizeUrl($url); + $htmlOptions['action']=self::normalizeUrl($action); $htmlOptions['method']=$method; return self::tag('form',$htmlOptions,false,false); } - public static function link($body,$url='#',$htmlOptions=array()) + public static function link($text,$url='#',$htmlOptions=array()) { $htmlOptions['href']=self::normalizeUrl($url); self::clientChange('click',$htmlOptions); - return self::tag('a',$htmlOptions,$body); + return self::tag('a',$htmlOptions,$text); } public static function image($src,$alt='',$htmlOptions=array()) { @@ -3034,9 +3036,9 @@ class CHtml $htmlOptions['type']='reset'; return self::button($label,$htmlOptions); } - public static function imageButton($imageUrl,$htmlOptions=array()) + public static function imageButton($src,$htmlOptions=array()) { - $htmlOptions['src']=$imageUrl; + $htmlOptions['src']=$src; $htmlOptions['type']='image'; return self::button('submit',$htmlOptions); } @@ -3047,9 +3049,9 @@ class CHtml $url=isset($htmlOptions['href']) ? $htmlOptions['href'] : '#'; return self::link($label,$url,$htmlOptions); } - public static function label($label,$forID,$htmlOptions=array()) + public static function label($label,$for,$htmlOptions=array()) { - $htmlOptions['for']=$forID; + $htmlOptions['for']=$for; return self::tag('label',$htmlOptions,$label); } public static function textField($name,$value='',$htmlOptions=array()) @@ -3099,26 +3101,26 @@ class CHtml self::clientChange('click',$htmlOptions); return self::inputField('checkbox',$name,$checked,$htmlOptions); } - public static function dropDownList($name,$selection,$listData,$htmlOptions=array()) + public static function dropDownList($name,$select,$data,$htmlOptions=array()) { - $options="\n".self::listOptions($selection,$listData,$htmlOptions); + $options="\n".self::listOptions($select,$data,$htmlOptions); self::clientChange('change',$htmlOptions); return self::tag('select',$htmlOptions,$options); } - public static function listBox($name,$selection,$listData,$htmlOptions=array()) + public static function listBox($name,$select,$data,$htmlOptions=array()) { if(!isset($htmlOptions['size'])) $htmlOptions['size']=4; - return self::dropDownList($name,$selection,$listData,$htmlOptions); + return self::dropDownList($name,$select,$data,$htmlOptions); } - public static function ajaxLink($body,$url,$ajaxOptions=array(),$htmlOptions=array()) + public static function ajaxLink($text,$url,$ajaxOptions=array(),$htmlOptions=array()) { if(!isset($htmlOptions['href'])) $htmlOptions['href']='#'; $ajaxOptions['url']=$url; $htmlOptions['ajax']=$ajaxOptions; self::clientChange('click',$htmlOptions); - return self::tag('a',$htmlOptions,$body); + return self::tag('a',$htmlOptions,$text); } public static function ajaxButton($label,$url,$ajaxOptions=array(),$htmlOptions=array()) { @@ -3234,36 +3236,36 @@ class CHtml self::clientChange('click',$htmlOptions); return self::activeInputField('checkbox',$model,$attribute,$htmlOptions); } - public static function activeDropDownList($model,$attribute,$listData,$htmlOptions=array()) + public static function activeDropDownList($model,$attribute,$data,$htmlOptions=array()) { $selection=$model->$attribute; - $options="\n".self::listOptions($selection,$listData,$htmlOptions); + $options="\n".self::listOptions($selection,$data,$htmlOptions); self::resolveNameID($model,$attribute,$htmlOptions); self::clientChange('change',$htmlOptions); if($model->hasErrors($attribute)) self::addErrorCss($htmlOptions); return self::tag('select',$htmlOptions,$options); } - public static function activeListBox($model,$attribute,$listData,$htmlOptions=array()) + public static function activeListBox($model,$attribute,$data,$htmlOptions=array()) { if(!isset($htmlOptions['size'])) $htmlOptions['size']=4; - return self::dropDownList($model,$attribute,$listData,$htmlOptions); + return self::dropDownList($model,$attribute,$data,$htmlOptions); } public static function getActiveId($model,$attribute) { return get_class($model).'_'.$attribute; } - public static function errorSummary($models,$header='',$footer='') + public static function errorSummary($model,$header='',$footer='') { if($header==='') $header='

    '.Yii::t('yii#Please fix the following input errors:').'

    '; $content=''; - if(!is_array($models)) - $models=array($models); - foreach($models as $model) + if(!is_array($model)) + $model=array($model); + foreach($model as $m) { - foreach($model->getErrors() as $errors) + foreach($m->getErrors() as $errors) { foreach($errors as $error) $content.="
  • $error
  • \n";