1 <?php
2 /**
3 * TbHeroUnit class file.
4 * @author Christoffer Niska <ChristofferNiska@gmail.com>
5 * @copyright Copyright © Christoffer Niska 2011-
6 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
7 * @package bootstrap.widgets
8 * @since 0.9.10
9 */
10
11 /**
12 * Modest bootstrap hero unit widget.
13 * Thanks to Christphe Boulain for suggesting content capturing.
14 * @see http://twitter.github.com/bootstrap/components.html#typography
15 */
16 class TbHeroUnit extends CWidget
17 {
18 /**
19 * @var string the heading text.
20 */
21 public $heading;
22 /**
23 * @var boolean indicates whether to encode the heading.
24 */
25 public $encodeHeading = true;
26 /**
27 * @var array the HTML attributes for the heading element.
28 * @since 1.0.0
29 */
30 public $headingOptions = array();
31 /**
32 * @var array the HTML attributes for the widget container.
33 */
34 public $htmlOptions = array();
35
36 /**
37 * Initializes the widget.
38 */
39 public function init()
40 {
41 if (isset($this->htmlOptions['class']))
42 $this->htmlOptions['class'] .= ' hero-unit';
43 else
44 $this->htmlOptions['class'] = 'hero-unit';
45
46 if ($this->encodeHeading)
47 $this->heading = CHtml::encode($this->heading);
48
49 echo CHtml::openTag('div', $this->htmlOptions);
50
51 if (isset($this->heading))
52 echo CHtml::tag('h1', $this->headingOptions, $this->heading);
53 }
54
55 /**
56 * Runs the widget.
57 */
58 public function run()
59 {
60 echo '</div>';
61 }
62 }
63