1 | <?php |
||
19 | class TbAlert extends TbWidget { |
||
20 | |||
21 | const CTX_ERROR = 'error'; |
||
22 | const CTX_ERROR_CLASS = 'danger'; |
||
23 | |||
24 | /** |
||
25 | * @var array The configuration for individual types of alerts. |
||
26 | * |
||
27 | * Here's the allowed array elements: |
||
28 | * |
||
29 | * 'visible' (= null) If set to false, this type of alerts will not be rendered. |
||
30 | * 'fade' (= widget value) The same as a global fade property. |
||
31 | * If set, alert will close itself fading away. |
||
32 | * It defaults to the widget-level fade property value. |
||
33 | * 'htmlOptions' (= array()) Attributes for the individual alert panels. |
||
34 | * Widget-level htmlOptions was for wrapper element around them. |
||
35 | * Note that the class attribute will be appended with classes required for alert to be Twitter Bootstrap alert. |
||
36 | * 'closeText' (= widget value) The same as a global closeText property. |
||
37 | * If set to false, close button will be removed from this type of alert. |
||
38 | * It defaults to the widget-level closeText property value. |
||
39 | * |
||
40 | * @note Instead of full arrays you can use just the names of alert types as a values of the alerts property. |
||
41 | * You can even mix the array configuration and plain names. |
||
42 | * |
||
43 | * Default is the array of all alert types defined as TYPE_* constants. |
||
44 | * If you want no alerts to be displayed, set this property to empty array, not `null` value. |
||
45 | */ |
||
46 | public $alerts; |
||
47 | |||
48 | /** |
||
49 | * @var string|boolean What to render as a button to close the alert panel. |
||
50 | * |
||
51 | * Default is to render a diagonal cross symbol. |
||
52 | * If set to false, no close button will be rendered, making user unable to close the alert. |
||
53 | */ |
||
54 | public $closeText = '×'; |
||
55 | |||
56 | /** |
||
57 | * @var boolean When set, alert will fade out using transitions when closed. Defaults to 'true' |
||
58 | */ |
||
59 | public $fade = true; |
||
60 | |||
61 | /** |
||
62 | * @var string[] The Javascript event handlers attached to all alert elements being rendered. |
||
63 | * |
||
64 | * It should be an array with elements being a javascript string containing event handler function definition (along with declaration) and indexed with the names of events. |
||
65 | * This will be fed to jQuery.on verbatim. |
||
66 | * |
||
67 | * @volatile |
||
68 | */ |
||
69 | public $events = array(); |
||
70 | |||
71 | /** |
||
72 | * @var array Traditional property to set attributes to the element wrapping all of alerts. |
||
73 | */ |
||
74 | public $htmlOptions = array(); |
||
75 | |||
76 | /** |
||
77 | * @var string Name of the component which will be used to get alert messages. |
||
78 | * |
||
79 | * It should implement getFlash() method which returns alert message by its type. |
||
80 | * Default is 'user'. |
||
81 | */ |
||
82 | public $userComponentId = 'user'; |
||
83 | |||
84 | protected static $_containerId = 0; |
||
85 | |||
86 | /** |
||
87 | *### .init() |
||
88 | * |
||
89 | * Initializes the widget. |
||
90 | */ |
||
91 | 3 | public function init() { |
|
112 | |||
113 | /** |
||
114 | *### .run() |
||
115 | * |
||
116 | * Runs the widget. |
||
117 | */ |
||
118 | public function run() { |
||
165 | |||
166 | /** |
||
167 | * @param $alert |
||
168 | * @param $context |
||
169 | * @param $alertText |
||
170 | * |
||
171 | * @internal param $type |
||
172 | */ |
||
173 | protected function renderSingleAlert($alert, $context, $alertText) { |
||
218 | |||
219 | /** |
||
220 | * only these are allowed for alerts |
||
221 | * |
||
222 | * @param bool $context |
||
223 | * |
||
224 | * @return bool |
||
225 | */ |
||
226 | protected function isValidContext($context = false) { |
||
235 | |||
236 | } |
||
237 |