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.
		
		
		
		
			
				
					50 lines
				
				948 B
			
		
		
			
		
	
	
					50 lines
				
				948 B
			| 
											13 years ago
										 | <?php
 | ||
|  | /**
 | ||
|  |  * @link http://www.yiiframework.com/
 | ||
|  |  * @copyright Copyright (c) 2008 Yii Software LLC
 | ||
|  |  * @license http://www.yiiframework.com/license/
 | ||
|  |  */
 | ||
|  | 
 | ||
|  | namespace yii\widgets;
 | ||
|  | 
 | ||
|  | use yii\base\Widget;
 | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @author Qiang Xue <qiang.xue@gmail.com>
 | ||
|  |  * @since 2.0
 | ||
|  |  */
 | ||
| 
											13 years ago
										 | class Block extends Widget
 | ||
| 
											13 years ago
										 | {
 | ||
|  | 	/**
 | ||
| 
											13 years ago
										 | 	 * @var string the ID of this block.
 | ||
| 
											13 years ago
										 | 	 */
 | ||
|  | 	public $id;
 | ||
|  | 	/**
 | ||
| 
											13 years ago
										 | 	 * @var boolean whether to render the block content in place. Defaults to false,
 | ||
|  | 	 * meaning the captured block content will not be displayed.
 | ||
| 
											13 years ago
										 | 	 */
 | ||
|  | 	public $renderInPlace = false;
 | ||
|  | 
 | ||
|  | 	/**
 | ||
| 
											13 years ago
										 | 	 * Starts recording a block.
 | ||
| 
											13 years ago
										 | 	 */
 | ||
|  | 	public function init()
 | ||
|  | 	{
 | ||
|  | 		ob_start();
 | ||
|  | 		ob_implicit_flush(false);
 | ||
|  | 	}
 | ||
|  | 
 | ||
|  | 	/**
 | ||
| 
											13 years ago
										 | 	 * Ends recording a block.
 | ||
|  | 	 * This method stops output buffering and saves the rendering result as a named block in the controller.
 | ||
| 
											13 years ago
										 | 	 */
 | ||
|  | 	public function run()
 | ||
|  | 	{
 | ||
| 
											13 years ago
										 | 		$block = ob_get_clean();
 | ||
|  | 		if ($this->renderInPlace) {
 | ||
|  | 			echo $block;
 | ||
| 
											13 years ago
										 | 		}
 | ||
| 
											13 years ago
										 | 		$this->view->blocks[$this->id] = $block;
 | ||
| 
											13 years ago
										 | 	}
 | ||
| 
											13 years ago
										 | }
 |