diff --git a/CHANGELOG b/CHANGELOG index acd837678..d60920f0f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -40,6 +40,7 @@ Version 1.1.1 to be released - Enh: Added CDataProvider::setTotalItemCount() (Qiang) - Enh: Added skipOnError property to built-in validators (Qiang) - Enh: Added CDbConnection::initSQLs (Qiang) +- Enh: Added CHtml::refresh() (Qiang) - Chg #841: Changed CUrlManager::parsePathInfo() to non-static (Qiang) - Chg #851: yiic tool no longer turns off E_NOTICE (Qiang) - Chg #974: CComponent::evaluateExpression() no longer suppresses expression error (Qiang) diff --git a/framework/web/CClientScript.php b/framework/web/CClientScript.php index 4cd273bfd..a5229e8db 100644 --- a/framework/web/CClientScript.php +++ b/framework/web/CClientScript.php @@ -451,11 +451,11 @@ class CClientScript extends CApplicationComponent public function registerMetaTag($content,$name=null,$httpEquiv=null,$options=array()) { $this->_hasScripts=true; - $options['content']=$content; if($name!==null) $options['name']=$name; if($httpEquiv!==null) $options['http-equiv']=$httpEquiv; + $options['content']=$content; $this->_metas[serialize($options)]=$options; $params=func_get_args(); $this->recordCachingAction('clientScript','registerMetaTag',$params); diff --git a/framework/web/helpers/CHtml.php b/framework/web/helpers/CHtml.php index 7ff303773..28a74f78b 100644 --- a/framework/web/helpers/CHtml.php +++ b/framework/web/helpers/CHtml.php @@ -201,6 +201,23 @@ class CHtml return ""; } + /** + * Registers a 'refresh' meta tag. + * This method can be invoked anywhere in a view. It will register a 'refresh' + * meta tag with {@link CClientScript} so that the page can be refreshed in + * the specified seconds. + * @param integer the number of seconds to wait before refreshing the page + * @param string the URL to which the page should be redirected to. If empty, it means the current page. + * @since 1.1.1 + */ + public static function refresh($seconds, $url='') + { + $content="$seconds"; + if($url!=='') + $content.=';'.self::normalizeUrl($url); + Yii::app()->clientScript->registerMetaTag($content,null,'refresh'); + } + /** * Links to the specified CSS file. * @param string the CSS URL