diff --git a/README.md b/README.md
index 12656ce..1b5b810 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,52 @@
# Twitter Bootstrap CakePHP Helper
-CakePHP helper for rendering bootstrap appropriate markup. Uses the Twitter Bootstrap 2.0.
+CakePHP helper for rendering Twitter Bootstrap markup.
## Requirements
-* [CakePHP 2.0](https://github.com/cakephp/cakephp)
-* [Twitter Bootstrap CSS 2.0](http://twitter.github.com/bootstrap/)
-* *Optional* [Twitter Bootstrap JS](http://twitter.github.com/bootstrap/javascript.html)
+* [CakePHP](https://github.com/cakephp/cakephp)
+* [Twitter Bootstrap CSS](http://getbootstrap.com/)
+* *Optional* [Twitter Bootstrap JS](http://getbootstrap.com/)
+
+## WARNING
+
+master branch is just a wrapper. This plugin has two BIG versions: one for Twitter Bootstrap 2.3 and another for Twitter Bootsrap 3.0.
+
+## Versions
+
+This said, under the intallation instructions, replace "VERSION" with the version you want to use. Master versions are:
+[2.3.2-master](https://github.com/bardiel/twitter-bootstrap-helper/tree/2.3.2-master)
+[3.0.0-master](https://github.com/bardiel/twitter-bootstrap-helper/tree/3.0.0-master)
+
+## Changelogs
+
+### 2.3.2
+
+#### master
+As the repo was forked the time I forked it.
+
+### 3.0.0
+
+#### master (there's a changelog as it's based on 2.3.2-master)
+* TwitterBootsrap::flash($key, $options) has been rewriten to make it stintactically compatible with SessionHelper::flash($key, $options)
+* Lots of changes to make things compatible with Bootsrap 3.0.0.
+* Configuration Arrays for diffient methods (see version specific README)
+* Added TwitterBootstrap::navbar($options)
+* Added TwitterBootstrap::nav($options)
+* Added TwitterBootsrap::start_panel($options) and TwitterBootsrap::end_panel()
+* Deprecated TwitterBootsrap::button_form()
+* Deprecated TwitterBootsrap::flashes()
+* Deprecated TwitterBootsrap::block()
## Installation
Check out the the repo in the plugins directory
- git clone git://github.com/loadsys/twitter-bootstrap-helper TwitterBootstrap
+ git clone https://github.com/bardiel/twitter-bootstrap-helper.git -b VERSION TwitterBootstrap
+
+For example, if you are going to use Bootstrap 3.0, you should install like this:
+
+ git clone https://github.com/bardiel/twitter-bootstrap-helper.git -b 3.0.0-master TwitterBootstrap
Add the plugin inclusion in the project bootstrap file
@@ -31,169 +65,3 @@ Now available in your views is `$this->TwitterBootstrap`. If you'd like to make
"className" => "TwitterBootstrap.TwitterBootstrap"
)
);
-
-## Methods
-
-### TwitterBootstrapHelper::input(array $options)
-
-The form inputs in Twitter Bootstrap are quite different from the default html that the `FormHelper::input()` method. The `TwitterBootstrap->input()` aims to do the same type of thing that the `FormHelper::input()` would, but with the markup the bootstrap styles work with.
-
- echo $this->TwitterBootstrap->input("field_name", array(
- "input" => $this->Form->text("field_name"),
- "help_inline" => "Text to the right of the input",
- "help_block" => "Text under the input"
- ));
-
-The method will handle errors and update the class on the div surrounding the input and label to show the text and input border as red.
-
-### TwitterBootstrapHelper::basic_input(mixed $field, array $options)
-
-While the `input()` method outputs the more verbose markup; the `basic_input()` method just outputs the minimum markup (the labal and input tags).
-
- echo $this->TwitterBootstrap->basic_input("field_name", array(
- "label" => "Custom label text"
- ));
-
-### TwitterBootstrapHelper::search(string $name, array $options)
-
-Twitter Bootstrap offers a new search specific text input field, and this method will ouput that input with its special class.
-
- echo $this->TwitterBootstrap->search();
-
-### TwitterBootstrapHelper::radio(array $options)
-
-This method will render groups of radio inputs. Internally it will call `TwitterBootstrap->input()`, so the options are the same.
-
- echo $this->TwitterBootstrap->radio("field_name", array(
- "options" => array(
- "yes" => "Yes",
- "no" => "No",
- "maybe" => "Maybe"
- )
- ));
-
-### TwitterBootstrapHelper::button(string $value, array $options)
-
-`TwitterBootstrap->button()` will render the submit button for forms.
-
- echo $this->TwitterBootstrap->button("Save", array("style" => "primary", "size" => "large"));
-
-Valid styles for the button are "primary", "success", "info", and "danger". Valid sizes are "small" and "large". If either are left out, then the default styles will apply (A grey button and a medium size). There is another option, "disabled", that takes a bool. If true it will apply the disabled styles.
-
-### TwitterBootstrapHelper::button_dropdown(string $value, array $options)
-
-The method will build a button dropdown menu. The dropdown js plugin is required for the dropdown functionality. The list of links for the dropdown is supplied in any array of string links (the output of `HtmlHelper::link()`) or arrays (that are used as params for `HtmlHelper::link()`). A null value in the array will add a divider in the list of links. Other unique options are 'split', 'dropup', and 'right'. The 'split' option will make the caret appear in its own button instead of part of the main button. The 'dropup' option (if the value is true) will cause the list of links to appear above the button instead of below. The 'right' option will make the list be pulled right instead of the default left.
-
- echo $this->TwitterBootstrap->button_dropdown("Button Value", array(
- "split" => true,
- "dropup" => true,
- "right" => true,
- "links" => array(
- $this->Html->link("Link 1", "#"),
- array("Link 2", "#"),
- null, // Will produce a divider line
- array("Link 3", "#")
- )
- ));
-
-### TwitterBootstrapHelper::button_link(string $title, mixed $url, array $options, string $confirm)
-
-The `TwitterBootstrap::button_link()` builds a button similar to the `TwitterBootstrap::button()` but it uses `Html->link()` to make an anchor tag.
-
- echo $this->TwitterBootstrap->button_link("Edit", "/resource/edit/1", array("style" => "info", "size" => "small"));
-
-Like the `TwitterBootstrap->button()`, the "disabled" option can be passed to apply the disabled styles.
-
-### TwitterBootstrapHelper::button_form(string $title, mixed $url, array $options, string $confirm)
-
-The `TwitterBootstrap->button_form()` is the same as `TwitterBootstrap->button_link()`, but it uses `Form->postLink()` to create the link.
-
- echo $this->TwitterBootstrap->button_form("Delete", "/resource/delete/1", array("style" => "danger", "size" => "small"), "Are you sure?");
-
-Like the `TwitterBootstrap->button()`, the "disabled" option can be passed to apply the disabled styles.
-
-### TwitterBootstrapHelper::breadcrumbs(array $options)
-
-`TwitterBootstrap->breadcrumbs()` utilizes `HtmlHelper::getCrumbs()` to build the breadcrumbs markup specific to Twitter Bootstrap.
-
- $this->TwitterBootstrap->breadcrumbs(array("divider" => ">"));
-
-### TwitterBootstrapHelper::add_crumb(string $title, mixed $url, array $options)
-
-`TwitterBootstrap->add_crumb()` delegates to `HtmlHelper::addCrumb()`.
-
- $this->TwitterBootstrap->add_crumb("Crumb Item", "/path");
-
-### TwitterBootstrapHelper::label(string $message, string $style, array $options)
-
-Twitter Bootstrap has some reusable label styles, and `TwitterBootstrap->label()` simply returns this small html fragment.
-
- echo $this->TwitterBootstrap->label("Recent", "warning");
-
-The valid values for the second parameter are "success", "important", "warning", "info", "inverse". Passing no second param will use the default (grey) style.
-
-### TwitterBootstrapHelper::badge(int $num, string $style, array $options)
-
-The Twitter Bootstrap badges are similar to labels, but are meant to contain an integer.
-
- echo $this->TwitterBootstrap->badge(4, "error");
-
-The valid values for the second parameter are "success", "warning", "error", "info", "inverse". Passing no second param will use the default (grey) style.
-
-### TwitterBootstrapHelper::icon(string $name, string $color)
-
-This method will output the icon markup with the proper clases. The valid colors are 'white' and 'black' (default is 'black'). Valid icon names are detailed on the [Twitter Bootstrap docs](http://twitter.github.com/bootstrap/base-css.html#icons). Pass the name of the icon without 'icon-'.
-
- echo $this->TwitterBootstrap->icon("fire", "white");
-
-### TwitterBootstrapHelper::progress(array $options)
-
-The `progress()` method makes progress bars by specifying a width style inline. You can pass a 'width' option with a value from 0 to 100 and it will be applied as the beginning width. Passing the "striped" option will apply the striped styles, and passing the "active" option will make the progress bar animate.
-
- echo $this->TwitterBootstrap->progress(array("width" => 50, "striped" => true, "active" => true));
-
-The valid values for the "style" options are "info", "success", "warning", and "danger".
-
-### TwitterBootstrapHelper::flash(string $key, array $options)
-
-Twitter Bootstrap has some nice styles that would work great for the session flash message. By default, the method will return the value in the default key that `SessionComponent::setFlash()` sets (that is "flash").
-
- echo $this->TwitterBootstrap->flash("success");
-
-The flash message can be closable if the "closable" option is passed in the options array witha value of true. Here is info on the [javascript closable alerts](http://twitter.github.com/bootstrap/javascript.html#alerts). The alert styles offer some different styles and they are "warning", "error", "success", and "info". To set the class to use these different styles, call `setFlash()` like so:
-
- $this->Session->setFlash(__("Flash message"), "default", array(), "error");
-
-Note that the default "flash" key that will be used when a different key is not passed in the 4th param of the `setFlash()` method will use the "warning" styles.
-
-### TwitterBootstrapHelper::flashes(array $options)
-
-`TwitterBootstrap->flashes()` will loop through the valid alert types ("warning", "error", "success", "info") as well as the default flash type ("flash"), and optionally the "auth" flash.
-
- echo $this->TwitterBootstrap->flashes(array("auth" => true));
-
-Passing "auth" => true, will include the "auth" string in the loop of keys to try. You may also pass in an array of keys in the option "keys" for this method to loop through.
-
-### TwitterBootstrapHelper::block(string $message, array $links, array $options)
-
-`TwitterBootstrap->block()` will create the more detailed alerts. It take a string (could contain html), and an array of links. The links should be created with `TwitterBootstrap->button_link()`.
-
- echo $this->TwitterBootstrap->block(
- $html_content,
- array(
- $this->TwitterBootstrap->button_link("Action Link", "/path"),
- $this->TwitterBootstrap->button_link("Another Action", "/another/path")
- ),
- array(
- "style" => "success",
- "closable" => true
- )
- );
-
-The valid options for "style" are "warning", "error", "success", "info". If the "closable" option is passed with a value of true, then the close link is added. Here is info on the [javascript closable alerts](http://twitter.github.com/bootstrap/javascript.html#alerts).
-
-### TwitterBootstrapHelper::page_header(string)
-
-`TwitterBootstrap->page_header(string)` will print a page heading TB style.
-
- echo $this->TwitterBootstrap->page_header("Page Header");
diff --git a/Test/Case/View/Helper/BootstrapFormHelperTest.php b/Test/Case/View/Helper/BootstrapFormHelperTest.php
deleted file mode 100644
index 295106d..0000000
--- a/Test/Case/View/Helper/BootstrapFormHelperTest.php
+++ /dev/null
@@ -1,550 +0,0 @@
- array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
- 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- 'email' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- 'phone' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- 'password' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
- 'published' => array('type' => 'date', 'null' => true, 'default' => null, 'length' => null),
- 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
- 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null),
- 'age' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => null)
- );
-}
-
-class TestBootstrapFormHelper extends BootstrapFormHelper {
-
- public function parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
- return $this->_parseAttributes($options, $exclude, $insertBefore, $insertAfter);
- }
-
- public function getAttribute($attribute) {
- if (!isset($this->{$attribute})) {
- return null;
- }
- return $this->{$attribute};
- }
-}
-
-/**
- * HtmlHelperTest class
- *
- * @package Cake.Test.Case.View.Helper
- */
-class BootstrapFormHelperTest extends CakeTestCase {
-
- public $BootstrapForm;
- public $View;
-
- public $validLabel = 'Message';
-
- public $validButton = '';
-
- public function setUp() {
- parent::setUp();
- $this->View = $this->getMock('View', array('addScript'), array(new TestBootstrapFormController()));
-
- $this->BootstrapForm = new TestBootstrapFormHelper($this->View);
- $this->BootstrapForm->request = new CakeRequest('contacts/add', false);
- $this->BootstrapForm->request->here = '/contacts/add';
- $this->BootstrapForm->request['action'] = 'add';
- $this->BootstrapForm->request->webroot = '';
- $this->BootstrapForm->request->base = '';
-
- ClassRegistry::addObject('Contact', new Contact());
-
- Configure::write('Asset.timestamp', false);
- }
-
- public function tearDown() {
- parent::tearDown();
- unset($this->Bootstrap, $this->View);
- }
-
- /**
- * testValidButtonStyles
- *
- * @access public
- * @return void
- */
- public function testValidButtonStyles() {
- $expected = $this->validButton;
- // Default button
- $default = $this->BootstrapForm->button("Submit");
- $this->assertEquals(sprintf($expected, ""), $default);
- // Primary button
- $primary = $this->BootstrapForm->button("Submit", array("style" => "primary"));
- $this->assertEquals(sprintf($expected, " btn-primary"), $primary);
- // Info button
- $info = $this->BootstrapForm->button("Submit", array("style" => "info"));
- $this->assertEquals(sprintf($expected, " btn-info"), $info);
- // Success button
- $success = $this->BootstrapForm->button("Submit", array("style" => "success"));
- $this->assertEquals(sprintf($expected, " btn-success"), $success);
- // Warning button
- $success = $this->BootstrapForm->button("Submit", array("style" => "warning"));
- $this->assertEquals(sprintf($expected, " btn-warning"), $success);
- // Danger button
- $danger = $this->BootstrapForm->button("Submit", array("style" => "danger"));
- $this->assertEquals(sprintf($expected, " btn-danger"), $danger);
- // Inverse button
- $danger = $this->BootstrapForm->button("Submit", array("style" => "inverse"));
- $this->assertEquals(sprintf($expected, " btn-inverse"), $danger);
- }
-
- /**
- * testValidButtonSizes
- *
- * @access public
- * @return void
- */
- public function testValidButtonSizes() {
- $expected = $this->validButton;
- // Mini button
- $mini = $this->BootstrapForm->button("Submit", array("size" => "mini"));
- $this->assertEquals(sprintf($expected, " btn-mini"), $mini);
- // Small button
- $small = $this->BootstrapForm->button("Submit", array("size" => "small"));
- $this->assertEquals(sprintf($expected, " btn-small"), $small);
- // Large button
- $large = $this->BootstrapForm->button("Submit", array("size" => "large"));
- $this->assertEquals(sprintf($expected, " btn-large"), $large);
- // Mixed button
- $mixed = $this->BootstrapForm->button(
- "Submit",
- array("style" => "primary", "size" => "small")
- );
- $this->assertEquals(sprintf($expected, " btn-primary btn-small"), $mixed);
- }
-
- /**
- * testValidDisabledButton
- *
- * @access public
- * @return void
- */
- public function testValidDisabledButton() {
- $expected = $this->validButton;
- $disabled = $this->BootstrapForm->button("Submit", array("disabled" => true));
- $this->assertEquals(sprintf($expected, " disabled"), $disabled);
- }
-
- /**
- * testInvalidButtonStylesAndSizes
- *
- * @access public
- * @return void
- */
- public function testInvalidButtonStylesAndSizes() {
- $expected = $this->validButton;
- // Invalid size button
- $invalid_size = $this->BootstrapForm->button("Submit", array("size" => "invalid"));
- $this->assertEquals(sprintf($expected, ""), $invalid_size);
- // Invalid style button
- $invalid_style = $this->BootstrapForm->button("Submit", array("style" => "invalid"));
- $this->assertEquals(sprintf($expected, ""), $invalid_style);
- }
-
- /**
- * testValidButtonForm
- *
- * @access public
- * @return void
- */
- public function testValidButtonForm() {
- $expected = array(
- 'form' => array(
- 'method' => 'post', 'action', 'name' => 'preg:/post_\w+/',
- 'id' => 'preg:/post_\w+/', 'style' => 'display:none;'
- ),
- 'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'),
- '/form',
- 'a' => array(
- 'href' => '#',
- 'onclick' => 'preg:/document\.(.)+\.submit\(\); event\.returnValue = false; return false;/',
- 'class' => 'preg:/btn/'
- ),
- 'Link Text',
- '/a'
- );
-
- $result = $this->BootstrapForm->buttonForm("Link Text", "/home");
- $this->assertTags($result, $expected);
-
- $expected['a']['class'] = 'preg:/btn btn-small/';
- $result = $this->BootstrapForm->buttonForm(
- "Link Text",
- "/home",
- array("size" => "small")
- );
- $this->assertTags($result, $expected);
-
- $expected['a']['class'] = 'preg:/btn btn-danger/';
- $result = $this->BootstrapForm->buttonForm(
- "Link Text",
- "/home",
- array("style" => "danger")
- );
- $this->assertTags($result, $expected);
-
- $expected['a']['class'] = 'preg:/btn btn-success btn-large/';
- $result = $this->BootstrapForm->buttonForm(
- "Link Text",
- "/home",
- array("style" => "success", "size" => "large")
- );
- $this->assertTags($result, $expected);
- }
-
- /**
- * testInputWithOnlyField
- *
- * @access public
- * @return void
- */
- public function testInputWithOnlyField() {
- $expected = array(
- array('div' => array("class" => "control-group")),
- "label" => array("for" => "ContactName", "class" => "control-label"), "Name", "/label",
- array("div" => array("class" => "controls")),
- "input" => array(
- "name" => "data[Contact][name]", "maxlength" => 255, "type" => "text", "id" => "ContactName"
- ),
- "/div",
- "/div"
- );
- $this->BootstrapForm->create("Contact");
- $input = $this->BootstrapForm->input("name");
- $this->BootstrapForm->end();
- $this->assertTags($input, $expected);
- }
-
- /**
- * testInputWithInputClassDefined
- *
- * @access public
- * @return void
- */
- public function testInputWithInputClassDefined() {
- $expected = array(
- array('div' => array("class" => "control-group")),
- "label" => array("for" => "ContactName", "class" => "control-label"), "Name", "/label",
- array("div" => array("class" => "controls")),
- "input" => array(
- "name" => "data[Contact][name]",
- "maxlength" => 255,
- "type" => "text",
- "id" => "ContactName",
- "class" => "custom-class"
- ),
- "/div",
- "/div"
- );
- $this->BootstrapForm->create("Contact");
- $input = $this->BootstrapForm->input("name", array("class" => "custom-class"));
- $this->BootstrapForm->end();
- $this->assertTags($input, $expected);
- }
-
- /**
- * testInputWithOnlyFieldAndInput
- *
- * @access public
- * @return void
- */
- public function testInputWithOnlyFieldAndInput() {
- $expected = array(
- array('div' => array("class" => "control-group")),
- "label" => array("for" => "ContactName", "class" => "control-label"), "Name", "/label",
- array("div" => array("class" => "controls")),
- "input" => array(
- "name" => "data[Contact][name]", "type" => "text", "id" => "ContactName"
- ),
- "/div",
- "/div"
- );
- $this->BootstrapForm->create("Contact");
- $input = $this->BootstrapForm->input("name", array(
- "input" => $this->BootstrapForm->text("name")
- ));
- $this->BootstrapForm->end();
- $this->assertTags($input, $expected);
- $this->BootstrapForm->create("Contact");
- $input = $this->BootstrapForm->input(array(
- "field" => "name",
- "input" => $this->BootstrapForm->text("name")
- ));
- $this->BootstrapForm->end();
- $this->assertTags($input, $expected);
- }
-
- /**
- * testInputWithDefinedLabel
- *
- * @access public
- * @return void
- */
- public function testInputWithDefinedLabel() {
- $expected = array(
- array("div" => array("class" => "control-group")),
- "label" => array("for" => "ContactName", "class" => "control-label"), "Contact Name", "/label",
- array("div" => array("class" => "controls")),
- "input" => array(
- "name" => "data[Contact][name]", "maxlength" => 255, "type" => "text", "id" => "ContactName"
- ),
- "/div",
- "/div"
- );
- $this->BootstrapForm->create("Contact");
- $input = $this->BootstrapForm->input("name", array("label" => "Contact Name"));
- $this->BootstrapForm->end();
- $this->assertTags($input, $expected);
- }
-
- /**
- * testInputWithAppendAddon
- *
- * @access public
- * @return void
- */
- public function testInputWithAppendAddon() {
- $expected = array(
- array("div" => array("class" => "control-group")),
- "label" => array("for" => "ContactName", "class" => "control-label"), "Name", "/label",
- array("div" => array("class" => "controls")),
- array("div" => array("class" => "input-append")),
- "input" => array(
- "name" => "data[Contact][name]", "maxlength" => 255, "type" => "text", "id" => "ContactName"
- ),
- "span" => array("class" => "add-on"), "A", "/span",
- "/div",
- "/div",
- "/div"
- );
- $this->BootstrapForm->create("Contact");
- $input = $this->BootstrapForm->input("name", array("append" => "A"));
- $this->BootstrapForm->end();
- $this->assertTags($input, $expected);
- }
-
- /**
- * testInputWithAppendButtonAddon
- *
- * @access public
- * @return void
- */
- public function testInputWithAppendButtonAddon() {
- $expected = array(
- array("div" => array("class" => "control-group")),
- "label" => array("for" => "ContactName", "class" => "control-label"), "Name", "/label",
- array("div" => array("class" => "controls")),
- array("div" => array("class" => "input-append")),
- "input" => array(
- "name" => "data[Contact][name]", "maxlength" => 255, "type" => "text", "id" => "ContactName"
- ),
- "button" => array("class" => "btn", "type" => "button"), "Go", "/button",
- "/div",
- "/div",
- "/div"
- );
- $this->BootstrapForm->create("Contact");
- $input = $this->BootstrapForm->input("name", array(
- "append" => $this->BootstrapForm->button("Go", array("type" => "button"))
- ));
- $this->BootstrapForm->end();
- $this->assertTags($input, $expected);
- }
-
- /**
- * testInputWithAppendInputAddon
- *
- * @access public
- * @return void
- */
- public function testInputWithAppendInputAddon() {
- $expected = array(
- array("div" => array("class" => "control-group")),
- array("label" => array("for" => "ContactName", "class" => "control-label")),
- "Name",
- "/label",
- array("div" => array("class" => "controls")),
- array("div" => array("class" => "input-append")),
- array("input" => array(
- "name" => "data[Contact][name]",
- "maxlength" => 255,
- "type" => "text",
- "id" => "ContactName"
- )),
- array("label" => array("class" => "add-on")),
- array("input" => array(
- "type" => "checkbox",
- "name" => "data[Contact][confirm]",
- "value" => "1",
- "id" => "ContactConfirm"
- )),
- "/label",
- "/div",
- "/div",
- "/div"
- );
- $this->BootstrapForm->create("Contact");
- $input = $this->BootstrapForm->input("name", array(
- "append" => $this->BootstrapForm->checkbox("confirm", array("hiddenField" => false))
- ));
- $this->BootstrapForm->end();
- $this->assertTags($input, $expected);
- }
-
- /**
- * testInputWithPrependAddon
- *
- * @access public
- * @return void
- */
- public function testInputWithPrependAddon() {
- $expected = array(
- array("div" => array("class" => "control-group")),
- "label" => array("for" => "ContactName", "class" => "control-label"), "Name", "/label",
- array("div" => array("class" => "controls")),
- array("div" => array("class" => "input-prepend")),
- "span" => array("class" => "add-on"), "P", "/span",
- "input" => array(
- "name" => "data[Contact][name]", "maxlength" => 255, "type" => "text", "id" => "ContactName"
- ),
- "/div",
- "/div",
- "/div"
- );
- $this->BootstrapForm->create("Contact");
- $input = $this->BootstrapForm->input("name", array("prepend" => "P"));
- $this->BootstrapForm->end();
- $this->assertTags($input, $expected);
- }
-
- /**
- * testInputWithAppendInputAddon
- *
- * @access public
- * @return void
- */
- public function testInputWithPrependButtonAddon() {
- $expected = array(
- array("div" => array("class" => "control-group")),
- "label" => array("for" => "ContactName", "class" => "control-label"), "Name", "/label",
- array("div" => array("class" => "controls")),
- array("div" => array("class" => "input-prepend")),
- "button" => array("class" => "btn", "type" => "button"), "Go", "/button",
- "input" => array(
- "name" => "data[Contact][name]", "maxlength" => 255, "type" => "text", "id" => "ContactName"
- ),
- "/div",
- "/div",
- "/div"
- );
- $this->BootstrapForm->create("Contact");
- $input = $this->BootstrapForm->input("name", array(
- "prepend" => $this->BootstrapForm->button("Go", array("type" => "button"))
- ));
- $this->BootstrapForm->end();
- $this->assertTags($input, $expected);
- }
-
- /**
- * testInputWithPrependInputAddon
- *
- * @access public
- * @return void
- */
- public function testInputWithPrependInputAddon() {
- $expected = array(
- array("div" => array("class" => "control-group")),
- array("label" => array("for" => "ContactName", "class" => "control-label")),
- "Name",
- "/label",
- array("div" => array("class" => "controls")),
- array("div" => array("class" => "input-prepend")),
- array("label" => array("class" => "add-on")),
- array("input" => array(
- "type" => "checkbox",
- "name" => "data[Contact][confirm]",
- "value" => "1",
- "id" => "ContactConfirm"
- )),
- "/label",
- array("input" => array(
- "name" => "data[Contact][name]",
- "maxlength" => 255,
- "type" => "text",
- "id" => "ContactName"
- )),
- "/div",
- "/div",
- "/div"
- );
- $this->BootstrapForm->create("Contact");
- $input = $this->BootstrapForm->input("name", array(
- "prepend" => $this->BootstrapForm->checkbox("confirm", array("hiddenField" => false))
- ));
- $this->BootstrapForm->end();
- $this->assertTags($input, $expected);
- }
-
- /**
- * testInputWithBothAppendAndPrepend
- *
- * @access public
- * @return void
- */
- public function testInputWithBothAppendAndPrepend() {
- $expected = array(
- array("div" => array("class" => "control-group")),
- "label" => array("for" => "ContactName", "class" => "control-label"), "Name", "/label",
- array("div" => array("class" => "controls")),
- array("div" => array("class" => "input-append input-prepend")),
- array("span" => array("class" => "add-on")), "P", "/span",
- "input" => array(
- "name" => "data[Contact][name]", "maxlength" => 255, "type" => "text", "id" => "ContactName"
- ),
- array("span" => array("class" => "add-on")), "A", "/span",
- "/div",
- "/div",
- "/div"
- );
- $this->BootstrapForm->create("Contact");
- $input = $this->BootstrapForm->input("name", array(
- "prepend" => "P",
- "append" => "A"
- ));
- $this->BootstrapForm->end();
- $this->assertTags($input, $expected);
- }
-}
diff --git a/Test/Case/View/Helper/BootstrapHelperTest.php b/Test/Case/View/Helper/BootstrapHelperTest.php
deleted file mode 100644
index 945a493..0000000
--- a/Test/Case/View/Helper/BootstrapHelperTest.php
+++ /dev/null
@@ -1,464 +0,0 @@
-_parseAttributes($options, $exclude, $insertBefore, $insertAfter);
- }
-
- /**
- * Get a protected attribute value
- */
- public function getAttribute($attribute) {
- if (!isset($this->{$attribute})) {
- return null;
- }
- return $this->{$attribute};
- }
-
- /**
- * Overwriting method to return a static string.
- */
- public function _flash_content($key) {
- return "Flash content";
- }
-}
-
-class BootstrapHelperTest extends CakeTestCase {
-
- public $Bootstrap;
- public $View;
-
- public function setUp() {
- parent::setUp();
- $this->View = $this->getMock('View', array('append'), array(new TestBootstrapController()));
- $this->Bootstrap = new TestBootstrapHelper($this->View);
- Configure::write('Asset.timestamp', false);
- }
-
- public function tearDown() {
- parent::tearDown();
- unset($this->Bootstrap, $this->View);
- }
-
- public function testPageHeader() {
- $expected = array(
- array("div" => array("class" => "page-header")),
- array("h1" => true), "Page Header", "/h1",
- "/div"
- );
- $header = $this->Bootstrap->pageHeader("Page Header");
- $this->assertTags($header, $expected);
- }
-
- public function testValidLabels() {
- $expected = array(
- "span" => array("class" => "label"),
- "Message",
- "/span"
- );
- $default = $this->Bootstrap->label("Message");
- $this->assertTags($default, $expected);
- $expected = array(
- "span" => array("class" => "label label-success"),
- "Message",
- "/span"
- );
- $success = $this->Bootstrap->label("Message", "success");
- $this->assertTags($success, $expected);
- $expected = array(
- "span" => array("class" => "label label-warning"),
- "Message",
- "/span"
- );
- $warning = $this->Bootstrap->label("Message", "warning");
- $this->assertTags($warning, $expected);
- $expected = array(
- "span" => array("class" => "label label-important"),
- "Message",
- "/span"
- );
- $important = $this->Bootstrap->label("Message", "important");
- $this->assertTags($important, $expected);
- $expected = array(
- "span" => array("class" => "label label-info"),
- "Message",
- "/span"
- );
- $notice = $this->Bootstrap->label("Message", "info");
- $this->assertTags($notice, $expected);
- $expected = array(
- "span" => array("class" => "label label-inverse"),
- "Message",
- "/span"
- );
- $inverse = $this->Bootstrap->label("Message", "inverse");
- $this->assertTags($inverse, $expected);
- }
-
- public function testValidLabelsWithCustomClass() {
- $expected = array(
- "span" => array("class" => "label custom-class"),
- "Message",
- "/span"
- );
- $default = $this->Bootstrap->label("Message", null, array("class" => "custom-class"));
- $this->assertTags($default, $expected);
- $expected = array(
- "span" => array("class" => "label label-success custom-class"),
- "Message",
- "/span"
- );
- $success = $this->Bootstrap->label("Message", "success", array("class" => "custom-class"));
- $this->assertTags($success, $expected);
- $expected = array(
- "span" => array("class" => "label label-warning custom-class"),
- "Message",
- "/span"
- );
- $warning = $this->Bootstrap->label("Message", "warning", array("class" => "custom-class"));
- $this->assertTags($warning, $expected);
- $expected = array(
- "span" => array("class" => "label label-important custom-class"),
- "Message",
- "/span"
- );
- $important = $this->Bootstrap->label("Message", "important", array("class" => "custom-class"));
- $this->assertTags($important, $expected);
- $expected = array(
- "span" => array("class" => "label label-info custom-class"),
- "Message",
- "/span"
- );
- $notice = $this->Bootstrap->label("Message", "info", array("class" => "custom-class"));
- $this->assertTags($notice, $expected);
- $expected = array(
- "span" => array("class" => "label label-inverse custom-class"),
- "Message",
- "/span"
- );
- $inverse = $this->Bootstrap->label("Message", "inverse", array("class" => "custom-class"));
- $this->assertTags($inverse, $expected);
- }
-
- public function testInvalidLabel() {
- $expected = array("span" => array("class" => "label"), "Message", "/span");
- // Returns default label when passed invalid string
- $invalid_string = $this->Bootstrap->label("Message", "invalid");
- $this->assertTags($invalid_string, $expected);
- // Returns default label when passed invalid int
- $invalid_int = $this->Bootstrap->label("Message", 12);
- $this->assertTags($invalid_int, $expected);
- }
-
- public function testValidBadge() {
- $expected = array("span" => array("class" => "badge"), 1, "/span");
- $badge = $this->Bootstrap->badge(1);
- $this->assertTags($badge, $expected);
-
- $expected = array("span" => array("class" => "badge badge-success"), 1, "/span");
- $badge = $this->Bootstrap->badge(1, "success");
- $this->assertTags($badge, $expected);
-
- $expected = array("span" => array("class" => "badge badge-warning"), 1, "/span");
- $badge = $this->Bootstrap->badge(1, "warning");
- $this->assertTags($badge, $expected);
-
- $expected = array("span" => array("class" => "badge badge-important"), 1, "/span");
- $badge = $this->Bootstrap->badge(1, "important");
- $this->assertTags($badge, $expected);
-
- $expected = array("span" => array("class" => "badge badge-info"), 1, "/span");
- $badge = $this->Bootstrap->badge(1, "info");
- $this->assertTags($badge, $expected);
-
- $expected = array("span" => array("class" => "badge badge-inverse"), 1, "/span");
- $badge = $this->Bootstrap->badge(1, "inverse");
- $this->assertTags($badge, $expected);
- }
-
- public function testValidBadgeWithCustomClass() {
- $expected = array(
- "span" => array("class" => "badge custom-class"),
- 1,
- "/span"
- );
- $badge = $this->Bootstrap->badge(1, null, array("class" => "custom-class"));
- $this->assertTags($badge, $expected);
-
- $expected = array(
- "span" => array("class" => "badge badge-success custom-class"),
- 1,
- "/span"
- );
- $badge = $this->Bootstrap->badge(1, "success", array("class" => "custom-class"));
- $this->assertTags($badge, $expected);
-
- $expected = array(
- "span" => array("class" => "badge badge-warning custom-class"),
- 1,
- "/span"
- );
- $badge = $this->Bootstrap->badge(1, "warning", array("class" => "custom-class"));
- $this->assertTags($badge, $expected);
-
- $expected = array(
- "span" => array("class" => "badge badge-important custom-class"),
- 1,
- "/span"
- );
- $badge = $this->Bootstrap->badge(1, "important", array("class" => "custom-class"));
- $this->assertTags($badge, $expected);
-
- $expected = array(
- "span" => array("class" => "badge badge-info custom-class"),
- 1,
- "/span"
- );
- $badge = $this->Bootstrap->badge(1, "info", array("class" => "custom-class"));
- $this->assertTags($badge, $expected);
-
- $expected = array(
- "span" => array("class" => "badge badge-inverse custom-class"),
- 1,
- "/span"
- );
- $badge = $this->Bootstrap->badge(1, "inverse", array("class" => "custom-class"));
- $this->assertTags($badge, $expected);
- }
-
- public function testInvalidBadge() {
- $expected = array("span" => array("class" => "badge"), 1, "/span");
- $badge = $this->Bootstrap->badge(1, "invalid");
- $this->assertTags($badge, $expected);
- }
-
- public function testProgressBar() {
- $expected = array(
- array("div" => array("class" => "progress")),
- array("div" => array("class" => "bar", "style" => "width: 60%;")),
- array("/div" => true),
- array("/div" => true)
- );
- $progress = $this->Bootstrap->progress(array("width" => 60));
- $this->assertTags($progress, $expected);
-
- $expected = array(
- array("div" => array("class" => "progress progress-info progress-striped")),
- array("div" => array("class" => "bar", "style" => "width: 60%;")),
- array("/div" => true),
- array("/div" => true)
- );
- $progress = $this->Bootstrap->progress(array(
- "width" => 60,
- "style" => "info",
- "striped" => true
- ));
- $this->assertTags($progress, $expected);
-
- $expected = array(
- array("div" => array("class" => "progress progress-success progress-striped active")),
- array("div" => array("class" => "bar", "style" => "width: 60%;")),
- array("/div" => true),
- array("/div" => true)
- );
- $progress = $this->Bootstrap->progress(array(
- "width" => 60,
- "style" => "success",
- "striped" => true,
- "active" => true
- ));
- $this->assertTags($progress, $expected);
-
- $expected = array(
- array("div" => array("class" => "progress progress-warning")),
- array("div" => array("class" => "bar", "style" => "width: 60%;")),
- array("/div" => true),
- array("/div" => true)
- );
- $progress = $this->Bootstrap->progress(array(
- "width" => 60,
- "style" => "warning"
- ));
- $this->assertTags($progress, $expected);
-
- $expected = array(
- array("div" => array("class" => "progress progress-danger")),
- array("div" => array("class" => "bar", "style" => "width: 60%;")),
- array("/div" => true),
- array("/div" => true)
- );
- $progress = $this->Bootstrap->progress(array(
- "width" => 60,
- "style" => "danger"
- ));
- $this->assertTags($progress, $expected);
- }
-
- public function testIcon() {
- $expected = '';
- $result = $this->Bootstrap->icon("test");
- $this->assertEquals($result, $expected);
-
- $expected = '';
- $result = $this->Bootstrap->icon("test", "white");
- $this->assertEquals($result, $expected);
- }
-
- public function testValidFlash() {
- $expected = array(
- 'div' => array('class' => 'alert alert-warning'),
- 'Flash content',
- '/div'
- );
-
- $result = $this->Bootstrap->flash();
- $this->assertTags($result, $expected);
-
- $result = $this->Bootstrap->flash("flash");
- $this->assertTags($result, $expected);
-
- $result = $this->Bootstrap->flash("warning");
- $this->assertTags($result, $expected);
-
- $expected['div']['class'] = 'alert alert-info';
- $result = $this->Bootstrap->flash("info");
- $this->assertTags($result, $expected);
-
- $expected['div']['class'] = 'alert alert-success';
- $result = $this->Bootstrap->flash("success");
- $this->assertTags($result, $expected);
-
- $expected['div']['class'] = 'alert alert-error';
- $result = $this->Bootstrap->flash("error");
- $this->assertTags($result, $expected);
-
- $expected['div']['class'] = 'alert alert-error';
- $result = $this->Bootstrap->flash("auth");
- $this->assertTags($result, $expected);
- }
-
- public function testClosableFlash() {
- $expected = array(
- 'div' => array('class' => 'alert alert-warning'),
- 'a' => array("data-dismiss" => "alert", "class" => "close"), 'preg:/×/', '/a',
- 'Flash content',
- '/div'
- );
-
- $result = $this->Bootstrap->flash("flash", array("closable" => true));
- $this->assertTags($result, $expected);
-
- $expected['div']['class'] = 'alert alert-info';
- $result = $this->Bootstrap->flash("info", array("closable" => true));
- $this->assertTags($result, $expected);
- }
-
- public function testInvalidFlash() {
- $expected = array(
- 'div' => array('class' => 'alert alert-warning invalid'),
- 'Flash content',
- '/div'
- );
-
- $result = $this->Bootstrap->flash("invalid");
- $this->assertTags($result, $expected);
- }
-
- public function testFlashes() {
- $keys = array("info", "success", "error", "warning", "warning");
- $tmpl = '
Flash content
';
-
- $expected = '';
- foreach ($keys as $key) {
- $expected .= sprintf($tmpl, $key);
- }
- $flashes = $this->Bootstrap->flashes();
- $this->assertEquals($flashes, $expected);
-
- $keys[] = "error";
- $expected = '';
- foreach ($keys as $key) {
- $expected .= sprintf($tmpl, $key);
- }
- $flashes = $this->Bootstrap->flashes(array("auth" => true));
- $this->assertEquals($flashes, $expected);
- }
-
- public function testValidBlock() {
- $expected = array(
- 'div' => array('class' => 'alert alert-block'),
- 'Message content',
- '/div'
- );
-
- $result = $this->Bootstrap->block("Message content");
- $this->assertTags($result, $expected);
-
- $expected['div']['class'] = 'alert alert-block alert-info';
- $result = $this->Bootstrap->block(
- "Message content",
- array("style" => "info")
- );
- $this->assertTags($result, $expected);
-
- $expected['div']['class'] = 'alert alert-block alert-success';
- $result = $this->Bootstrap->block(
- "Message content",
- array("style" => "success")
- );
- $this->assertTags($result, $expected);
-
- $expected['div']['class'] = 'alert alert-block alert-error';
- $result = $this->Bootstrap->block(
- "Message content",
- array("style" => "error")
- );
- $this->assertTags($result, $expected);
-
- $expected['div']['class'] = 'alert alert-block';
- $result = $this->Bootstrap->block(
- "Message content",
- array("style" => "warning")
- );
- $this->assertTags($result, $expected);
-
- $expected = array(
- 'div' => array('class' => 'alert alert-block'),
- 'h4' => array('class' => 'alert-heading'), 'Block Heading', '/h4',
- 'Message content',
- '/div'
- );
- $result = $this->Bootstrap->block(
- "Message content",
- array("heading" => "Block Heading")
- );
- $this->assertTags($result, $expected);
- }
-
- public function testClosableBlock() {
- $expected = '';
- $result = $this->Bootstrap->block(
- "Message content",
- array("closable" => true, "style" => "info")
- );
- $this->assertEquals($result, $expected);
- }
-
-}
diff --git a/Test/Case/View/Helper/BootstrapHtmlHelperTest.php b/Test/Case/View/Helper/BootstrapHtmlHelperTest.php
deleted file mode 100644
index a007a2d..0000000
--- a/Test/Case/View/Helper/BootstrapHtmlHelperTest.php
+++ /dev/null
@@ -1,509 +0,0 @@
-_parseAttributes($options, $exclude, $insertBefore, $insertAfter);
- }
-
- /**
- * Get a protected attribute value
- */
- public function getAttribute($attribute) {
- if (!isset($this->{$attribute})) {
- return null;
- }
- return $this->{$attribute};
- }
-
- /**
- * Overwriting method to return a static string.
- */
- public function _flash_content($key) {
- return "Flash content";
- }
-}
-
-class BootstrapHtmlHelperTest extends CakeTestCase {
-
- public $BootstrapHtml;
- public $View;
-
- public function setUp() {
- parent::setUp();
- $this->View = $this->getMock('View', array('append'), array(new TestBootstrapHtmlController()));
- $this->BootstrapHtml = new TestBootstrapHtmlHelper($this->View);
- Configure::write('Asset.timestamp', false);
- }
-
- public function tearDown() {
- parent::tearDown();
- unset($this->Bootstrap, $this->View);
- }
-
- public function testButtonDropDownMenus() {
- $expected = array(
- "div" => array("class" => "btn-group"),
- array("button" => array(
- "class" => "btn dropdown-toggle", "data-toggle" => "dropdown"
- )),
- "Button Text",
- "span" => array("class" => "caret"),
- "/span",
- array("/button" => true),
- "ul" => array("class" => "dropdown-menu"),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 1",
- array("/a" => true),
- array("/li" => true),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 2",
- array("/a" => true),
- array("/li" => true),
- "/ul",
- "/div"
- );
- $button = $this->BootstrapHtml->buttonDropdown(
- "Button Text",
- array(
- "links" => array(
- array("Link 1", "#"),
- array("Link 2", "#")
- )
- )
- );
- $this->assertTags($button, $expected);
- }
-
- public function testButtonDropDownMenusSkipInvalidLinks() {
- $expected = array(
- "div" => array("class" => "btn-group"),
- array("button" => array(
- "class" => "btn dropdown-toggle", "data-toggle" => "dropdown"
- )),
- "Button Text",
- "span" => array("class" => "caret"),
- "/span",
- array("/button" => true),
- "ul" => array("class" => "dropdown-menu"),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 1",
- array("/a" => true),
- array("/li" => true),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 2",
- array("/a" => true),
- array("/li" => true),
- "/ul",
- "/div"
- );
- $button = $this->BootstrapHtml->buttonDropdown(
- "Button Text",
- array(
- "links" => array(
- array("Link 1", "#"),
- $this->BootstrapHtml->link("Link 2", "#"),
- array("key" => "value"),
- array("Link 3", "key" => "value")
- )
- )
- );
- $this->assertTags($button, $expected);
- }
-
- public function testSplitButtonDropDownMenus() {
- $expected = array(
- "div" => array("class" => "btn-group"),
- array("button" => array(
- "class" => "btn"
- )),
- "Button Text",
- array("/button" => true),
- array("button" => array(
- "class" => "btn dropdown-toggle", "data-toggle" => "dropdown"
- )),
- "span" => array("class" => "caret"),
- "/span",
- array("/button" => true),
- "ul" => array("class" => "dropdown-menu"),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 1",
- array("/a" => true),
- array("/li" => true),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 2",
- array("/a" => true),
- array("/li" => true),
- "/ul",
- "/div"
- );
- $button = $this->BootstrapHtml->buttonDropdown(
- "Button Text",
- array(
- "split" => true,
- "links" => array(
- array("Link 1", "#"),
- array("Link 2", "#")
- )
- )
- );
- $this->assertTags($button, $expected);
- }
-
- public function testButtonDropDownMenusStyles() {
- $expected = array(
- "div" => array("class" => "btn-group"),
- array("button" => array(
- "class" => "btn btn-primary dropdown-toggle", "data-toggle" => "dropdown"
- )),
- "Button Text",
- "span" => array("class" => "caret"),
- "/span",
- array("/button" => true),
- "ul" => array("class" => "dropdown-menu"),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 1",
- array("/a" => true),
- array("/li" => true),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 2",
- array("/a" => true),
- array("/li" => true),
- "/ul",
- "/div"
- );
- $button = $this->BootstrapHtml->buttonDropdown(
- "Button Text",
- array(
- "style" => "primary",
- "links" => array(
- array("Link 1", "#"),
- array("Link 2", "#")
- )
- )
- );
- $this->assertTags($button, $expected);
- }
-
- public function testButtonDropDownMenusSizes() {
- $expected = array(
- "div" => array("class" => "btn-group"),
- array("button" => array(
- "class" => "btn btn-large dropdown-toggle", "data-toggle" => "dropdown"
- )),
- "Button Text",
- "span" => array("class" => "caret"),
- "/span",
- array("/button" => true),
- "ul" => array("class" => "dropdown-menu"),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 1",
- array("/a" => true),
- array("/li" => true),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 2",
- array("/a" => true),
- array("/li" => true),
- "/ul",
- "/div"
- );
- $button = $this->BootstrapHtml->buttonDropdown(
- "Button Text",
- array(
- "size" => "large",
- "links" => array(
- array("Link 1", "#"),
- array("Link 2", "#")
- )
- )
- );
- $this->assertTags($button, $expected);
- }
-
- public function testButtonDropDownMenusWithDivider() {
- $expected = array(
- "div" => array("class" => "btn-group"),
- array("button" => array(
- "class" => "btn btn-danger dropdown-toggle", "data-toggle" => "dropdown"
- )),
- "Button Text",
- "span" => array("class" => "caret"),
- "/span",
- array("/button" => true),
- "ul" => array("class" => "dropdown-menu"),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 1",
- array("/a" => true),
- array("/li" => true),
- array("li" => array("class" => "divider")),
- array("/li" => true),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 2",
- array("/a" => true),
- array("/li" => true),
- "/ul",
- "/div"
- );
- $button = $this->BootstrapHtml->buttonDropdown(
- "Button Text",
- array(
- "style" => "danger",
- "links" => array(
- array("Link 1", "#"),
- null,
- array("Link 2", "#")
- )
- )
- );
- $this->assertTags($button, $expected);
- }
-
- public function testButtonDropUpMenus() {
- $expected = array(
- "div" => array("class" => "btn-group dropup"),
- array("button" => array(
- "class" => "btn btn-danger dropdown-toggle", "data-toggle" => "dropdown"
- )),
- "Button Text",
- "span" => array("class" => "caret"),
- "/span",
- array("/button" => true),
- "ul" => array("class" => "dropdown-menu"),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 1",
- array("/a" => true),
- array("/li" => true),
- array("li" => array("class" => "divider")),
- array("/li" => true),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 2",
- array("/a" => true),
- array("/li" => true),
- "/ul",
- "/div"
- );
- $button = $this->BootstrapHtml->buttonDropdown(
- "Button Text",
- array(
- "style" => "danger",
- "dropup" => true,
- "links" => array(
- array("Link 1", "#"),
- null,
- array("Link 2", "#")
- )
- )
- );
- $this->assertTags($button, $expected);
- }
-
- public function testButtonDropDownRightMenus() {
- $expected = array(
- "div" => array("class" => "btn-group"),
- array("button" => array(
- "class" => "btn btn-warning dropdown-toggle", "data-toggle" => "dropdown"
- )),
- "Button Text",
- "span" => array("class" => "caret"),
- "/span",
- array("/button" => true),
- "ul" => array("class" => "dropdown-menu pull-right"),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 1",
- array("/a" => true),
- array("/li" => true),
- array("li" => array("class" => "divider")),
- array("/li" => true),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 2",
- array("/a" => true),
- array("/li" => true),
- "/ul",
- "/div"
- );
- $button = $this->BootstrapHtml->buttonDropdown(
- "Button Text",
- array(
- "style" => "warning",
- "right" => true,
- "links" => array(
- array("Link 1", "#"),
- null,
- array("Link 2", "#")
- )
- )
- );
- $this->assertTags($button, $expected);
- }
-
- public function testButtonDropUpRightMenus() {
- $expected = array(
- "div" => array("class" => "btn-group dropup"),
- array("button" => array(
- "class" => "btn btn-warning dropdown-toggle", "data-toggle" => "dropdown"
- )),
- "Button Text",
- "span" => array("class" => "caret"),
- "/span",
- array("/button" => true),
- "ul" => array("class" => "dropdown-menu pull-right"),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 1",
- array("/a" => true),
- array("/li" => true),
- array("li" => array("class" => "divider")),
- array("/li" => true),
- array("li" => true),
- array("a" => array("href" => "#")),
- "Link 2",
- array("/a" => true),
- array("/li" => true),
- "/ul",
- "/div"
- );
- $button = $this->BootstrapHtml->buttonDropdown(
- "Button Text",
- array(
- "style" => "warning",
- "right" => true,
- "dropup" => true,
- "links" => array(
- array("Link 1", "#"),
- null,
- array("Link 2", "#")
- )
- )
- );
- $this->assertTags($button, $expected);
- }
-
- public function testValidButtonLinks() {
- $expected = array(
- 'a' => array(
- 'href' => '/home',
- 'class' => 'preg:/btn/'
- ),
- 'preg:/Link Text/',
- '/a'
- );
- $result = $this->BootstrapHtml->buttonLink("Link Text", "/home");
- $this->assertTags($result, $expected);
-
- $result = $this->BootstrapHtml->buttonLink(
- "Link Text",
- "/home",
- array("size" => "large")
- );
- $expected["a"]["class"] = 'preg:/btn btn-large/';
- $this->assertTags($result, $expected);
-
- $result = $this->BootstrapHtml->buttonLink(
- "Link Text",
- "/home",
- array("style" => "info")
- );
- $expected["a"]["class"] = 'preg:/btn btn-info/';
- $this->assertTags($result, $expected);
-
- $result = $this->BootstrapHtml->buttonLink(
- "Link Text",
- "/home",
- array("style" => "info", "size" => "mini")
- );
- $expected["a"]["class"] = 'preg:/btn btn-info btn-mini/';
- $this->assertTags($result, $expected);
-
- $result = $this->BootstrapHtml->buttonLink(
- "Link Text",
- "/home",
- array("style" => "info", "size" => "small", "class" => "some-class")
- );
- $expected["a"]["class"] = 'preg:/some-class btn btn-info btn-small/';
- $this->assertTags($result, $expected);
-
- $result = $this->BootstrapHtml->buttonLink(
- "Link Text",
- "/home",
- array("style" => "info", "size" => "small", "disabled" => true)
- );
- $expected["a"]["class"] = 'preg:/btn btn-info btn-small disabled/';
- $this->assertTags($result, $expected);
- }
-
- public function testBreadCrumbs() {
- $expected = array(
- "ul" => array("class" => "breadcrumb"),
- array("li" => true),
- array("a" => array("href" => "/")), "Home", "/a",
- array("span" => array("class" => "divider")),
- "preg:/\//",
- "/span",
- "/li",
- array("li" => array("class" => "active")),
- array("a" => array("href" => "/sub")), "Subpage", "/a",
- "/li",
- "/ul"
- );
- $this->BootstrapHtml->addCrumb("Home", "/");
- $this->BootstrapHtml->addCrumb("Subpage", "/sub");
- $results = $this->BootstrapHtml->breadcrumbs();
- $this->assertTags($results, $expected);
- }
-
- public function testBreadCrumbsWithOptions() {
- $expected = array(
- "ul" => array("class" => "custom-class breadcrumb"),
- array("li" => true),
- array("a" => array("href" => "/")), "Home", "/a",
- array("span" => array("class" => "divider")),
- "preg:/%/",
- "/span",
- "/li",
- array("li" => array("class" => "active")),
- array("a" => array("href" => "/sub")), "Subpage", "/a",
- "/li",
- "/ul"
- );
- $this->BootstrapHtml->addCrumb("Home", "/");
- $this->BootstrapHtml->addCrumb("Subpage", "/sub");
- $results = $this->BootstrapHtml->breadcrumbs(array(
- "class" => "custom-class",
- "divider" => "%"
- ));
- $this->assertTags($results, $expected);
- }
-
-}
diff --git a/Test/Fixture/empty b/Test/Fixture/empty
deleted file mode 100644
index e69de29..0000000
diff --git a/View/Helper/BootstrapFormHelper.php b/View/Helper/BootstrapFormHelper.php
deleted file mode 100644
index bddecc5..0000000
--- a/View/Helper/BootstrapFormHelper.php
+++ /dev/null
@@ -1,456 +0,0 @@
-_parseInputOptions($field, $options);
- if (!isset($options["field"])) { return ""; }
- $options["label"] = $this->_constructLabel($options);
- $options["input"] = $this->_constructInput($options);
- return $options["label"] . $options["input"];
- }
-
- /**
- * _parse_input_options
- *
- * @param mixed $field
- * @param array $options
- * @access public
- * @return void
- */
- public function _parseInputOptions($field, $options = array()) {
- if (is_array($field)) {
- $options = $field;
- } else {
- $options["field"] = $field;
- }
- $defaults = array(
- "type" => "",
- "help_inline" => "",
- "help_block" => "",
- "label" => "",
- "append" => false,
- "prepend" => false,
- "state" => false
- );
- return array_merge($defaults, $options);
- }
-
- /**
- * _construct_label
- *
- * @param mixed $options
- * @access public
- * @return void
- */
- public function _constructLabel($options, $basic = true) {
- if ($options["label"] === false) { return ""; }
- if (in_array($options["type"], array("checkbox"))) {
- $opt = $options;
- $opt["type"] = "";
- $input = $this->_constructInput($opt);
- $options["label"] = parent::label(
- $options["field"],
- $input . $options["label"],
- "checkbox"
- );
- } else {
- $class = (!$basic) ? "control-label" : null;
- if (!empty($options["label"])) {
- $options["label"] = parent::label(
- $options["field"],
- $options["label"],
- array("class" => $class)
- );
- } else {
- $options["label"] = parent::label(
- $options["field"],
- null,
- array("class" => $class)
- );
- }
- }
- return $options["label"];
- }
-
- /**
- * _construct_input
- *
- * @param mixed $options
- * @access public
- * @return void
- */
- public function _constructInput($options) {
- if (in_array($options["type"], array("checkbox"))) {
- $options["input"] = "";
- }
- if (isset($options["input"])) { return $options["input"]; }
- $options["input"] = parent::input($options["field"], array(
- "div" => false,
- "label" => false
- ));
- return $options["input"];
- }
-
- /**
- * _constuct_input_and_addon
- *
- * @param mixed $options
- * @access public
- * @return void
- */
- public function _constuctInputAndAddon($options) {
- if (isset($options["input"])) { return $options["input"]; }
- $options["input"] = $this->_constructInput($options);
- $options["input"] = $this->_handleInputAddon($options);
- return $options["input"];
- }
-
- /**
- * _handle_input_addon
- *
- * @param mixed $options
- * @access public
- * @return void
- */
- public function _handleInputAddon($options) {
- $input = $options["input"];
- if ($options["append"]) {
- $input = $this->inputAddon($options["append"], $input, "append");
- } elseif ($options["prepend"]) {
- $input = $this->inputAddon($options["prepend"], $input, "prepend");
- }
- return $input;
- }
-
- /**
- * input_addon
- *
- * @param mixed $content
- * @param mixed $input
- * @param string $type
- * @access public
- * @return void
- */
- public function inputAddon($content, $input, $type = "append") {
- $tag = (strpos("input", $content) !== false) ? "label" : "span";
- $addon = $this->Html->tag($tag, $content, array("class" => "add-on"));
- return $this->Html->tag(
- "div",
- $input . $content,
- array("class" => "input-{$type}")
- );
- }
-
- /**
- * search
- *
- * @param mixed $name
- * @param array $options
- * @access public
- * @return void
- */
- public function search($name = null, $options = array()) {
- $class = "search-query";
- if (!$name) {
- $name = "search";
- }
- if (isset($options["class"])) {
- $options["class"] .= " {$class}";
- } else {
- $options["class"] = $class;
- }
- return $this->text($name, $options);
- }
-
- /**
- * Takes an array of options to output markup that works with
- * twitter bootstrap forms.
- *
- * @param array $options
- * @access public
- * @return string
- */
- public function input($field, $options = array()) {
- $options = $this->_parseInputOptions($field, $options);
- if (!isset($options['field'])) { return ''; }
- $out = $help_inline = $help_block = '';
- /*$model = $this->defaultModel;
- if (strpos(".", $options["field"]) !== false) {
- $split = explode(".", $options["field"]);
- $model = $split[0];
- } else {
- $options["field"] = "{$model}.{$options["field"]}";
- }*/
- if ($options['label'] === false) {
- $options['label'] = '';
- } else if (!empty($options['label'])) {
- $options['label'] = $this->label(
- $options['field'],
- $options['label'],
- "control-label"
- );
- } else {
- $options['label'] = $this->label(
- $options['field'],
- null,
- "control-label"
- );
- }
- list($help_inline, $help_block) = $this->_helpMarkup($options);
- if ($this->error($options['field'])) {
- $options['state'] = 'error';
- $help_block = $this->Html->tag(
- "span",
- $this->error($options['field']),
- array("class" => "help-block")
- );
- }
- $options["input"] = $this->_combineInput($options);
- $input = $this->Html->tag(
- "div",
- $options['input'].$help_inline.$help_block,
- array("class" => "controls")
- );
- $wrap_class = "control-group";
- if ($options["state"] !== false) {
- $wrap_class = "{$wrap_class} {$options["state"]}";
- }
- return $this->Html->tag(
- "div",
- $options['label'].$input,
- array("class" => $wrap_class)
- );
- }
-
- /**
- * Takes the array of options and will apply the append or prepend bits
- * from the options and returns the input string.
- *
- * @param mixed $input
- * @param string $type
- * @access public
- * @return string
- */
- public function _combineInput($options) {
- $combine_markup = array("append" => "", "prepend" => "");
- $input = "";
- if (isset($options["input"])) {
- $input = $options["input"];
- } else {
- $opt = array("div" => false, "label" => false, "error" => false);
- foreach ($options as $key => $value) {
- if (!in_array($key, $this->__dontSendToFormHelper)) {
- if ($key !== 'type' || !empty($value)) $opt[$key] = $value;
- }
- }
- $input = parent::input($options["field"], $opt);
- if (isset($options["checkbox_label"])) {
- $input = $this->label($options["field"], $input.' '.$options["checkbox_label"], array('class' => 'checkbox'));
- }
- }
- foreach (array_keys($combine_markup) as $combine) {
- if (isset($options[$combine]) && !empty($options[$combine])) {
- $_tag = "span";
- if (strpos($options[$combine], "button") !== false) {
- $_tag = false;
- }
- if (strpos($options[$combine], "input") !== false) {
- $_tag = "label";
- }
- if ($_tag) {
- $combine_markup[$combine] = $this->Html->tag(
- $_tag,
- $options[$combine],
- array("class" => "add-on")
- );
- } else {
- $combine_markup[$combine] = $options[$combine];
- }
- }
- }
- $_class = "";
- if (!empty($combine_markup["append"])) {
- $input = $input . $combine_markup["append"];
- $_class .= " input-append";
- }
- if (!empty($combine_markup["prepend"])) {
- $input = $combine_markup["prepend"] . $input;
- $_class .= " input-prepend";
- }
- if (!empty($combine_markup["append"]) || !empty($combine_markup["prepend"])) {
- $input = $this->Html->tag(
- "div",
- $input,
- array("class" => trim($_class))
- );
- }
- return $input;
- }
-
- /**
- * Takes the options from the input method and returns an array of the
- * inline help and inline block content wrapped in the appropriate markup.
- *
- * @param mixed $options
- * @access public
- * @return string
- */
- public function _helpMarkup($options) {
- $help_markup = array("help_inline" => "", "help_block" => "");
- foreach (array_keys($help_markup) as $help) {
- if (isset($options[$help]) && !empty($options[$help])) {
- $help_class = str_replace("_", "-", $help);
- $help_markup[$help] = $this->Html->tag(
- "span",
- $options[$help],
- array("class" => $help_class)
- );
- }
- }
- return array_values($help_markup);
- }
-
- /**
- * Outputs a list of radio form elements with the proper
- * markup for twitter bootstrap styles
- *
- * @param array $options
- * @access public
- * @return string
- */
- public function radio($field, $options = array()) {
- if (is_array($field)) {
- $options = $field;
- } else {
- $options["field"] = $field;
- }
- if (!isset($options["options"]) || !isset($options["field"])) {
- return "";
- }
- $opt = $options["options"];
- unset($options["options"]);
- $inputs = "";
- $hiddenField = (isset($options['hiddenField']) && $options['hiddenField']);
- foreach ($opt as $key => $val) {
- $input = parent::radio(
- $options["field"],
- array($key => $val),
- array("label" => false, 'hiddenField' => $hiddenField)
- );
- $id = array();
- preg_match_all("/id=\"[a-zA-Z0-9_-]*\"/", $input, $id);
- if (!empty($id[0])) {
- $id = end($id[0]);
- $id = substr($id, 4);
- $id = substr($id, 0, -1);
- $input = $this->Html->tag(
- "label",
- $input,
- array("class" => "radio", "for" => $id)
- );
- }
- $inputs .= $input;
- }
- $options["input"] = $inputs;
- return $this->input($options);
- }
-
- /**
- * Wraps the form button method and just applies the Bootstrap classes to
- * the button before passing the options on to the FormHelper button method.
- *
- * @param string $value
- * @param array $options
- * @access public
- * @return string
- */
- public function button($value = "Submit", $options = array()) {
- $options = $this->buttonOptions($options);
- return parent::button($value, $options);
- }
-
- /**
- * Wraps the postLink method to create post links that use the bootstrap
- * button styles.
- *
- * @param mixed $title
- * @param mixed $url
- * @param array $options
- * @param mixed $confirm
- * @access public
- * @return string
- */
- public function buttonForm($title, $url, $opt = array(), $confirm = false) {
- $opt = $this->buttonOptions($opt);
- return $this->postLink($title, $url, $opt, $confirm);
- }
-
- /**
- * Takes the array of options from $this->button or $this->button_link
- * and returns the modified array with the bootstrap classes
- *
- * @param mixed $options
- * @access public
- * @return string
- */
- public function buttonOptions($options) {
- $valid_styles = array(
- "danger", "info", "primary",
- "warning", "success", "inverse"
- );
- $valid_sizes = array("mini", "small", "large");
- $style = isset($options["style"]) ? $options["style"] : "";
- $size = isset($options["size"]) ? $options["size"] : "";
- $disabled = false;
- if (isset($options["disabled"])) {
- $disabled = (bool)$options["disabled"];
- }
- $class = "btn";
- if (!empty($style) && in_array($style, $valid_styles)) {
- $class .= " btn-{$style}";
- }
- if (!empty($size) && in_array($size, $valid_sizes)) {
- $class .= " btn-{$size}";
- }
- if ($disabled) { $class .= " disabled"; }
- unset($options["style"]);
- unset($options["size"]);
- unset($options["disabled"]);
- if (isset($options["class"])) {
- $options["class"] = $options["class"] . " " . $class;
- } else {
- $options["class"] = $class;
- }
- return $options;
- }
-
-}
diff --git a/View/Helper/BootstrapHelper.php b/View/Helper/BootstrapHelper.php
deleted file mode 100644
index d62b20f..0000000
--- a/View/Helper/BootstrapHelper.php
+++ /dev/null
@@ -1,249 +0,0 @@
-Html->tag(
- "div",
- "$title
",
- array("class" => "page-header")
- );
- }
-
- /**
- * Creates a Bootstrap label with $messsage and optionally the $type. Any
- * options that could get passed to HtmlHelper::tag can be passed in the
- * third param.
- *
- * @param string $message
- * @param string $type
- * @param array $options
- * @access public
- * @return string
- */
- public function label($message = "", $style = "", $options = array()) {
- $class = "label";
- $valid = array("success", "important", "warning", "info", "inverse");
- if (!empty($style) && in_array($style, $valid)) {
- $class .= " label-{$style}";
- }
- if (isset($options["class"]) && !empty($options["class"])) {
- $options["class"] = $class . " " . $options["class"];
- } else {
- $options["class"] = $class;
- }
- return $this->Html->tag("span", $message, $options);
- }
-
- /**
- * Creates a Bootstrap badge with $num and optional $style. Any options
- * that could get passed to the HtmlHelper::tag can be passed in the 3rd
- * param
- *
- * @param integer $num
- * @param string $style
- * @param array $options
- * @return string
- */
- public function badge($num = 0, $style = "", $options = array()) {
- $class = "badge";
- $valid = array("success", "warning", "important", "info", "inverse");
- if (!empty($style) && in_array($style, $valid)) {
- $class .= " badge-{$style}";
- }
- if (isset($options["class"]) && !empty($options["class"])) {
- $options["class"] = $class . " " . $options["class"];
- } else {
- $options["class"] = $class;
- }
- return $this->Html->tag("span", $num, $options);
- }
-
- /**
- * progress
- *
- * @param string $style
- * @param array $options
- * @return string
- */
- public function progress($options = array()) {
- $class = "progress";
- $width = 0;
- $valid = array("info", "success", "warning", "danger");
- if (isset($options["style"]) && in_array($options["style"], $valid)) {
- $class .= " progress-{$options["style"]}";
- }
- if (isset($options["striped"]) && $options["striped"]) {
- $class .= " progress-striped";
- }
- if (isset($options["active"]) && $options["active"]) {
- $class .= " active";
- }
- if (
- isset($options["width"]) &&
- !empty($options["width"]) &&
- is_int($options["width"])
- ) {
- $width = $options["width"];
- }
- $bar = $this->Html->tag(
- "div",
- "",
- array("class" => "bar", "style" => "width: {$width}%;")
- );
- return $this->Html->tag("div", $bar, array("class" => $class));
- }
-
- /**
- * Takes the name of an icon and returns the i tag with the appropriately
- * named class. The second param will switch between black and white
- * icon sets.
- *
- * @param mixed $name
- * @access public
- * @return void
- */
- public function icon($name, $color = "black") {
- $class = "icon-{$name}";
- if ($color === "white") {
- $class = "{$class} icon-white";
- }
- return $this->Html->tag("i", false, array("class" => $class));
- }
-
- /**
- * Renders alert markup and takes a style and closable option
- *
- * @param mixed $content
- * @param array $options
- * @access public
- * @return void
- */
- public function alert($content, $options = array()) {
- $close = "";
- if (isset($options['closable']) && $options['closable']) {
- $close = '×';
- }
- $style = isset($options["style"]) ? $options["style"] : "warning";
- $types = array("info", "success", "error", "warning");
- if ($style === "flash") {
- $style = "warning";
- }
- if (strtolower($style) === "auth") {
- $style = "error";
- }
- if (!in_array($style, array_merge($types, array("auth", "flash")))) {
- $class = "alert alert-warning {$style}";
- } else {
- $class = "alert alert-{$style}";
- }
- return $this->Html->tag(
- 'div',
- "{$close}{$content}",
- array("class" => $class)
- );
- }
-
- /**
- * Captures the Session flash if it is set and renders it in the proper
- * markup for the twitter bootstrap styles. The default key of "flash",
- * gets translated to the warning styles. Other valid $keys are "info",
- * "success", "error". The $key "auth" with use the error styles because
- * that is when the auth form fails.
- *
- * @param string $key
- * @param $options
- * @access public
- * @return string
- */
- public function flash($key = "flash", $options = array()) {
- $content = $this->_flash_content($key);
- if (empty($content)) { return ''; }
- $close = false;
- if (isset($options['closable']) && $options['closable']) {
- $close = true;
- }
- return $this->alert($content, array("style" => $key, "closable" => $close));
- }
-
- /**
- * By default it checks $this->flash() for 5 different keys of valid
- * flash types and returns the string.
- *
- * @param array $options
- * @access public
- * @return string
- */
- public function flashes($options = array()) {
- if (!isset($options["keys"]) || !$options["keys"]) {
- $options["keys"] = array("info", "success", "error", "warning", "flash");
- }
- if (isset($options["auth"]) && $options["auth"]) {
- $options["keys"][] = "auth";
- unset($options["auth"]);
- }
- $keys = $options["keys"];
- unset($options["keys"]);
- $out = '';
- foreach($keys as $key) {
- $out .= $this->flash($key, $options);
- }
- return $out;
- }
-
- /**
- * Returns the content from SessionHelper::flash() for the passed in
- * $key.
- *
- * @param string $key
- * @access public
- * @return void
- */
- public function _flash_content($key = "flash") {
- return $this->Session->flash($key, array("element" => null));
- }
-
- /**
- * Displays the alert-message.block-messgae div's from the twitter
- * bootstrap.
- *
- * @param string $message
- * @param array $links
- * @param array $options
- * @access public
- * @return string
- */
- public function block($message = null, $options = array()) {
- $style = "";
- $valid = array("success", "info", "error");
- if (isset($options["style"]) && in_array($options["style"], $valid)) {
- $style = " alert-{$options["style"]}";
- }
- $class = "alert alert-block{$style}";
- $close = $heading = "";
- if (isset($options["closable"]) && $options["closable"]) {
- $close = '×';
- }
- if (isset($options["heading"]) && !empty($options["heading"])) {
- $heading = $this->Html->tag(
- "h4",
- $options["heading"],
- array("class" => "alert-heading")
- );
- }
- return $this->Html->tag(
- "div",
- $close.$heading.$message,
- array("class" => $class)
- );
- }
-
-}
diff --git a/View/Helper/BootstrapHtmlHelper.php b/View/Helper/BootstrapHtmlHelper.php
deleted file mode 100644
index 54128ba..0000000
--- a/View/Helper/BootstrapHtmlHelper.php
+++ /dev/null
@@ -1,175 +0,0 @@
-buttonOptions($options);
- $links = "";
- foreach ($_links as $link) {
- if (is_array($link)) {
- $title = $url = $opt = $confirm = null;
- if (isset($link[0])) {
- $title = $link[0];
- } else {
- continue;
- }
- if (isset($link[1])) {
- $url = $link[1];
- } else {
- continue;
- }
- $opt = isset($link[2]) ? $link[2] : array();
- $confirm = isset($link[3]) ? $link[3] : false;
- $l = "".$this->link($title, $url, $opt, $confirm)."";
- $links .= $l;
- } elseif (is_string($link)) {
- $links .= "{$link}";
- } else {
- $links .= '';
- }
- }
- if ($split) {
- $button = $this->tag(
- "button",
- $value,
- array(
- "class" => $options["class"]
- )
- );
- $button .= $this->tag(
- "button",
- "\n" . '',
- array(
- "class" => $options["class"] . " dropdown-toggle",
- "data-toggle" => "dropdown"
- )
- );
- } else {
- $button = $this->tag(
- "button",
- $value . ' ',
- array(
- "class" => $options["class"] . " dropdown-toggle",
- "data-toggle" => "dropdown"
- )
- );
- }
- $group_class = "btn-group";
- $ul_class = "dropdown-menu";
- if (isset($options["dropup"]) && $options["dropup"]) {
- $group_class .= " dropup";
- }
- if (isset($options["right"]) && $options["right"]) {
- $ul_class .= " pull-right";
- }
- $links = $this->tag("ul", $links, array("class" => $ul_class));
- return $this->tag(
- "div",
- $button . $links,
- array("class" => $group_class)
- );
- }
-
- /**
- * Wraps the html link method and applies the Bootstrap classes to the
- * options array before passing it on to the html link method.
- *
- * @param mixed $title
- * @param mixed $url
- * @param array $options
- * @param mixed $confirm
- * @access public
- * @return string
- */
- public function buttonLink($title, $url, $opt = array(), $confirm = false) {
- $opt = $this->buttonOptions($opt);
- return $this->link($title, $url, $opt, $confirm);
- }
-
- /**
- * Takes the array of options from $this->button or $this->button_link
- * and returns the modified array with the bootstrap classes
- *
- * @param mixed $options
- * @access public
- * @return string
- */
- public function buttonOptions($options) {
- $valid_styles = array(
- "danger", "info", "primary",
- "warning", "success", "inverse"
- );
- $valid_sizes = array("mini", "small", "large");
- $style = isset($options["style"]) ? $options["style"] : "";
- $size = isset($options["size"]) ? $options["size"] : "";
- $disabled = false;
- if (isset($options["disabled"])) {
- $disabled = (bool)$options["disabled"];
- }
- $class = "btn";
- if (!empty($style) && in_array($style, $valid_styles)) {
- $class .= " btn-{$style}";
- }
- if (!empty($size) && in_array($size, $valid_sizes)) {
- $class .= " btn-{$size}";
- }
- if ($disabled) { $class .= " disabled"; }
- unset($options["style"]);
- unset($options["size"]);
- unset($options["disabled"]);
- if (isset($options["class"])) {
- $options["class"] = $options["class"] . " " . $class;
- } else {
- $options["class"] = $class;
- }
- return $options;
- }
-
- /**
- * Delegates to the HtmlHelper::getCrumbList() method and sets the proper
- * class for the breadcrumbs class.
- *
- * @param array $options
- * @access public
- * @return string
- */
- public function breadcrumbs($options = array()) {
- $crumbs = $this->getCrumbs("%%");
- $crumbs = explode("%%", $crumbs);
- $out = "";
- $divider = "/";
- if (isset($options["class"])) {
- $options["class"] .= " breadcrumb";
- } else {
- $options["class"] = "breadcrumb";
- }
- if (isset($options["divider"])) {
- $divider = $options["divider"];
- unset($options["divider"]);
- }
- for ($i = 0; $i < count($crumbs); $i += 1) {
- $opt = array();
- $d = $this->tag("span", $divider, array("class" => "divider"));
- if (!isset($crumbs[$i + 1])) {
- $opt["class"] = "active";
- $d = "";
- }
- $out .= $this->tag("li", $crumbs[$i] . $d, $opt);
- }
- return $this->tag("ul", $out, $options);
- }
-
-}
diff --git a/View/Helper/TwitterBootstrapHelper.php b/View/Helper/TwitterBootstrapHelper.php
deleted file mode 100644
index 9a35b31..0000000
--- a/View/Helper/TwitterBootstrapHelper.php
+++ /dev/null
@@ -1,127 +0,0 @@
-BootstrapForm->basicInput($field, $options);
- }
-
- public function _parse_input_options($field, $options = array()) {
- return $this->BootstrapForm->_parseInputOptions($field, $options);
- }
-
- public function _construct_label($options, $basic = true) {
- return $this->BootstrapForm->_constructLabel($options, $basic);
- }
-
- public function _construct_input($options) {
- return $this->BootstrapForm->_constructInput($options);
- }
-
- public function _constuct_input_and_addon($options) {
- return $this->BootstrapForm->_constuctInputAndAddon($options);
- }
-
- public function _handle_input_addon($options) {
- return $this->BootstrapForm->_handleInputAddon($options);
- }
-
- public function input_addon($content, $input, $type = "append") {
- return $this->BootstrapForm->inputAddon($content, $input, $type);
- }
-
- public function search($name = null, $options = array()) {
- return $this->BootstrapForm->search($name, $options);
- }
-
- public function input($field, $options = array()) {
- return $this->BootstrapForm->input($field, $options);
- }
-
- public function _combine_input($options) {
- return $this->BootstrapForm->_combineInput($options);
- }
-
- public function _help_markup($options) {
- return $this->BootstrapForm->_helpMarkup($options);
- }
-
- public function radio($field, $options = array()) {
- return $this->BootstrapForm->radio($field, $options);
- }
-
- public function button($value = "Submit", $options = array()) {
- return $this->BootstrapForm->button($value, $options);
- }
-
- public function button_dropdown($value = "", $options = array()) {
- return $this->BootstrapHtml->buttonDropdown($value, $options);
- }
-
- public function button_link($title, $url, $opt = array(), $confirm = false) {
- return $this->BootstrapHtml->buttonLink($title, $url, $opt, $confirm);
- }
-
- public function button_form($title, $url, $opt = array(), $confirm = false) {
- return $this->BootstrapForm->buttonForm($title, $url, $opt, $confirm);
- }
-
- public function button_options($options) {
- return $this->BootstrapForm->buttonOptions($options);
- }
-
- public function breadcrumbs($options = array()) {
- return $this->BootstrapHtml->breadcrumbs($options);
- }
-
- public function add_crumb($title, $url, $options = array()) {
- return $this->BootstrapHtml->addCrumb($title, $url, $options);
- }
-
- public function label($message = "", $style = "", $options = array()) {
- return $this->Bootstrap->label($message, $style, $options);
- }
-
- public function badge($num = 0, $style = "", $options = array()) {
- return $this->Bootstrap->badge($num, $style, $options);
- }
-
- public function icon($name, $color = "black") {
- return $this->Bootstrap->icon($name, $color);
- }
-
- public function progress($options = array()) {
- return $this->Bootstrap->progress($options);
- }
-
- public function alert($content, $options = array()) {
- return $this->Bootstrap->alert($content, $options);
- }
-
- public function flash($key = "flash", $options = array()) {
- return $this->Bootstrap->flash($key, $options);
- }
-
- public function flashes($options = array()) {
- return $this->Bootstrap->flashes($options);
- }
-
- public function _flash_content($key = "flash") {
- return $this->Bootstrap->_flash_content($key);
- }
-
- public function block($message = null, $options = array()) {
- return $this->Bootstrap->block($message, $options);
- }
-
- public function page_header($title){
- return $this->Bootstrap->pageHeader($title);
- }
-
-}