1: <?php
2: /**
3: * TbHeroUnit class file.
4: * @author Christoffer Niska <[email protected]>
5: * @copyright Copyright © Christoffer Niska 2013-
6: * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
7: * @package bootstrap.widgets
8: */
9:
10: Yii::import('bootstrap.helpers.TbHtml');
11:
12: /**
13: * Bootstrap hero unit widget.
14: * @see http://twitter.github.com/bootstrap/javascript.html#affix
15: */
16: class TbHeroUnit extends CWidget
17: {
18: /**
19: * @var string the heading text.
20: */
21: public $heading;
22: /**
23: * @var array the HTML attributes for the heading.
24: */
25: public $headingOptions = array();
26: /**
27: * @var string the content text.
28: */
29: public $content;
30: /**
31: * @var string the path to a partial view.
32: */
33: public $view;
34: /**
35: * @var array the HTML attributes for the container tag.
36: */
37: public $htmlOptions = array();
38: /**
39: * @var array additional data to be passed to the view.
40: */
41: public $viewData = array();
42:
43: /**
44: * Initializes the widget.
45: */
46: public function init()
47: {
48: if (isset($this->view)) {
49: $controller = $this->getController();
50: if (isset($controller) && $controller->getViewFile($this->view) !== false) {
51: $this->content = $this->controller->renderPartial($this->view, $this->viewData, true);
52: }
53: }
54: $this->htmlOptions['headingOptions'] = $this->headingOptions;
55: }
56:
57: /**
58: * Runs the widget.
59: */
60: public function run()
61: {
62: echo TbHtml::heroUnit($this->heading, $this->content, $this->htmlOptions);
63: }
64: }
65: