GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

TbModal::init()   D
last analyzed

Complexity

Conditions 9
Paths 96

Size

Total Lines 41
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 90

Importance

Changes 0
Metric Value
dl 0
loc 41
ccs 0
cts 33
cp 0
rs 4.909
c 0
b 0
f 0
cc 9
eloc 25
nc 96
nop 0
crap 90
1
<?php
2
/**
3
 *## TbModal class file.
4
 *
5
 * @author Christoffer Niska <[email protected]>
6
 * @copyright Copyright &copy; Christoffer Niska 2011-
7
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
8
 */
9
10
/**
11
 *## Bootstrap modal widget.
12
 *
13
 * @see <http://twitter.github.com/bootstrap/javascript.html#modals>
14
 *
15
 * @since 0.9.3
16
 * @package booster.widgets.modals
17
 */
18
class TbModal extends CWidget {
19
	
20
	/**
21
	 * @var boolean indicates whether to automatically open the modal when initialized. Defaults to 'false'.
22
	 */
23
	public $autoOpen = false;
24
25
	/**
26
	 * @var boolean indicates whether the modal should use transitions. Defaults to 'true'.
27
	 */
28
	public $fade = true;
29
30
	/**
31
	 * @var array the options for the Bootstrap Javascript plugin.
32
	 */
33
	public $options = array();
34
35
	/**
36
	 * @var string[] the Javascript event handlers.
37
	 */
38
	public $events = array();
39
40
	/**
41
	 * @var array the HTML attributes for the widget container.
42
	 */
43
	public $htmlOptions = array();
44
	
45
 	/**
0 ignored issues
show
Coding Style introduced by
There is some trailing whitespace on this line which should be avoided as per coding-style.
Loading history...
46
     	 * @var array the HTML attributes for the modal-dialog div.
47
         */
48
        public $modalDialogOptions = array();
49
50
        /**
51
         * @var array the HTML attributes for the modal-content div.
52
         */
53
        public $modalContentOptions = array();
54
55
	/**
56
	 *### .init()
57
	 *
58
	 * Initializes the widget.
59
	 */
60
	public function init() {
61
		
62
		if (!isset($this->htmlOptions['id'])) {
63
			$this->htmlOptions['id'] = $this->getId();
64
		}
65
66
		if ($this->autoOpen === false && !isset($this->options['show'])) {
67
			$this->options['show'] = false;
68
		}
69
70
		$classes = array('modal');
71
72
		if ($this->fade === true) {
73
			$classes[] = 'fade';
74
		}
75
76
		if (!empty($classes)) {
77
			$classes = implode(' ', $classes);
78
			if (isset($this->htmlOptions['class'])) {
79
				$this->htmlOptions['class'] .= ' ' . $classes;
80
			} else {
81
				$this->htmlOptions['class'] = $classes;
82
			}
83
		}
84
		
85
        	if (isset($this->modalDialogOptions['class'])) {
86
            		$this->modalDialogOptions['class'] .= ' modal-dialog';
87
        	} else {
88
            		$this->modalDialogOptions['class'] = 'modal-dialog';
89
        	}
90
91
        	if (isset($this->modalContentOptions['class'])) {
92
            		$this->modalContentOptions['class'] .= ' modal-content';
93
        	} else {
94
            		$this->modalContentOptions['class'] = 'modal-content';
95
        	}
96
97
        	echo CHtml::openTag('div', $this->htmlOptions); //modal
98
        	echo CHtml::openTag('div', $this->modalDialogOptions); //modal-dialog
99
        	echo CHtml::openTag('div', $this->modalContentOptions); //modal-content
100
	}
101
102
	/**
103
	 *### .run()
104
	 *
105
	 * Runs the widget.
106
	 */
107
	public function run() {
108
		
109
		$id = $this->htmlOptions['id'];
110
111
		echo CHtml::closeTag('div'); //modal-content
112
        	echo CHtml::closeTag('div'); //modal-dialog
113
        	echo CHtml::closeTag('div'); //modal
114
115
		/** @var CClientScript $cs */
116
		$cs = Yii::app()->getClientScript();
117
118
		$options = !empty($this->options) ? CJavaScript::encode($this->options) : '';
119
		$cs->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').modal({$options});");
120
121
		foreach ($this->events as $name => $handler) {
122
			$handler = CJavaScript::encode($handler);
123
			$cs->registerScript(__CLASS__ . '#' . $id . '_' . $name, "jQuery('#{$id}').on('{$name}', {$handler});");
124
		}
125
	}
126
}
127