You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					53 lines
				
				1.2 KiB
			
		
		
			
		
	
	
					53 lines
				
				1.2 KiB
			| 
											13 years ago
										 | <?php
 | ||
|  | /**
 | ||
|  |  * @link http://www.yiiframework.com/
 | ||
| 
											13 years ago
										 |  * @copyright Copyright (c) 2008 Yii Software LLC
 | ||
| 
											13 years ago
										 |  * @license http://www.yiiframework.com/license/
 | ||
|  |  */
 | ||
|  | 
 | ||
| 
											13 years ago
										 | namespace yii\widgets;
 | ||
|  | 
 | ||
|  | use yii\base\InvalidConfigException;
 | ||
|  | use yii\base\Widget;
 | ||
|  | 
 | ||
| 
											13 years ago
										 | /**
 | ||
|  |  * @author Qiang Xue <qiang.xue@gmail.com>
 | ||
| 
											13 years ago
										 |  * @since 2.0
 | ||
| 
											13 years ago
										 |  */
 | ||
| 
											13 years ago
										 | class ContentDecorator extends Widget
 | ||
| 
											13 years ago
										 | {
 | ||
|  | 	/**
 | ||
| 
											13 years ago
										 | 	 * @var string the view file that will be used to decorate the content enclosed by this widget.
 | ||
|  | 	 * This can be specified as either the view file path or path alias.
 | ||
| 
											13 years ago
										 | 	 */
 | ||
| 
											13 years ago
										 | 	public $viewFile;
 | ||
| 
											13 years ago
										 | 	/**
 | ||
|  | 	 * @var array the parameters (name=>value) to be extracted and made available in the decorative view.
 | ||
|  | 	 */
 | ||
|  | 	public $params = array();
 | ||
| 
											13 years ago
										 | 
 | ||
|  | 	/**
 | ||
| 
											13 years ago
										 | 	 * Starts recording a clip.
 | ||
| 
											13 years ago
										 | 	 */
 | ||
| 
											13 years ago
										 | 	public function init()
 | ||
| 
											13 years ago
										 | 	{
 | ||
| 
											13 years ago
										 | 		if ($this->viewFile === null) {
 | ||
|  | 			throw new InvalidConfigException('ContentDecorator::viewFile must be set.');
 | ||
| 
											13 years ago
										 | 		}
 | ||
|  | 		ob_start();
 | ||
|  | 		ob_implicit_flush(false);
 | ||
| 
											13 years ago
										 | 	}
 | ||
|  | 
 | ||
|  | 	/**
 | ||
| 
											13 years ago
										 | 	 * Ends recording a clip.
 | ||
|  | 	 * This method stops output buffering and saves the rendering result as a named clip in the controller.
 | ||
| 
											13 years ago
										 | 	 */
 | ||
| 
											13 years ago
										 | 	public function run()
 | ||
| 
											13 years ago
										 | 	{
 | ||
| 
											13 years ago
										 | 		$params = $this->params;
 | ||
|  | 		$params['content'] = ob_get_clean();
 | ||
| 
											13 years ago
										 | 		// render under the existing context
 | ||
|  | 		echo $this->view->renderFile($this->viewFile, $params);
 | ||
| 
											13 years ago
										 | 	}
 | ||
|  | }
 |