forked from patricktalmadge/bootstrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buttongroup.php
56 lines (49 loc) · 1.18 KB
/
buttongroup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php namespace Bootstrapper;
use \HTML;
/**
* ButtonGroup for creating Twitter Bootstrap style Buttons groups.
*
* @package Bundles
* @subpackage Twitter
* @author Patrick Talmadge - Follow @patricktalmadge
*
* @see http://twitter.github.com/bootstrap/
*/
class ButtonGroup
{
/**
* Puts the ButtonGroup in a checkbox mode.
*
* @var string
*/
const TOGGLE_CHECKBOX = 'checkbox';
/**
* Puts the ButtonGroup in a radio button mode. Allowing only
* one button to be selected at a time.
*
* @var string
*/
const TOGGLE_RADIO = 'radio';
/**
* Opens a new ButtonGroup section.
* @param string $toggle
* @param array $attributes
* @return string
*/
public static function open($toggle = null, $attributes = array())
{
$validToggles = array(ButtonGroup::TOGGLE_CHECKBOX, ButtonGroup::TOGGLE_RADIO);
if (isset($toggle) && in_array($toggle, $validToggles))
$attributes['data-toggle'] = 'buttons-'.$toggle;
$attributes = Helpers::add_class($attributes, 'btn-group');
return '<div'.HTML::attributes($attributes).'>';
}
/**
* Closes the ButtonGroup section.
* @return string
*/
public static function close()
{
return '</div>';
}
}