diff --git a/framework/web/CClientScript.php b/framework/web/CClientScript.php index f69fcb126..25c3753ee 100644 --- a/framework/web/CClientScript.php +++ b/framework/web/CClientScript.php @@ -100,7 +100,11 @@ class CClientScript extends CComponent $output=preg_replace('/(.*?)(<\\/head\s*>)/is','$1'.$html.'$2',$output,1); if($html2!=='') - $output=preg_replace('/(<\\/body\s*>.*?<\/html\s*>)/is',$html2.'$1',$output,1); + { + $output=preg_replace('/(<\\/body\s*>.*?<\/html\s*>)/is',$html2.'$1',$output,1,$count); + if(!$count) + $output.=$html2; + } return $output; } diff --git a/framework/web/CController.php b/framework/web/CController.php index d6711e51d..2a025fc59 100644 --- a/framework/web/CController.php +++ b/framework/web/CController.php @@ -206,7 +206,7 @@ class CController extends CBaseController /** * Postprocesses the output generated by {@link render()}. - * This method is invoked at the end of {@link render()}. + * This method is invoked at the end of {@link render()} and {@link renderText()}. * If there are registered client scripts, this method will insert them into the output * at appropriate places. If there are dynamic contents, they will also be inserted. * @param string the output generated by the current action @@ -452,16 +452,22 @@ class CController extends CBaseController * about how the view script is resolved. * @param array data to be extracted into PHP variables and made available to the view script * @param boolean whether the rendering result should be returned instead of being displayed to end users + * @param boolean whether the rendering result should be postprocessed using {@link processOutput}. + * This parameter should be set true if renderPartial is the only method used to generate + * the output when handling a user request. * @return string the rendering result. Null if the rendering result is not required. * @throws CException if the view does not exist * @see getViewFile + * @see processOutput * @see render */ - public function renderPartial($view,$data=null,$return=false) + public function renderPartial($view,$data=null,$return=false,$processOutput=false) { if(($viewFile=$this->getViewFile($view))!==false) { $output=$this->renderFile($viewFile,$data,true); + if($processOutput) + $output=$this->processOutput($output); if($return) return $output; else