Skip to content

Commit

Permalink
Merge branch 'release/1.3.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
slywalker committed May 18, 2012
2 parents 91eed78 + cf47fbe commit c071a91
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 124 deletions.
9 changes: 7 additions & 2 deletions Controller/TwitterBootstrapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ class TwitterBootstrapController extends AppController {

public $uses = array();

public $layout = 'bootstrap';

public $components = array('Session');

public $helpers = array(
Expand All @@ -15,6 +13,13 @@ class TwitterBootstrapController extends AppController {
'Paginator' => array('className' => 'TwitterBootstrap.BootstrapPaginator'),
);

public function beforeFilter() {
if (Configure::read('debug') < 1) {
throw new MethodNotAllowedException(__('Debug setting does not allow access to this url.'));
}
parent::beforeFilter();
}

public function index() {
$this->Session->setFlash(__('Alert notice message testing...'), 'alert', array(
'plugin' => 'TwitterBootstrap',
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ The TwitterBootstrap Plugin provides an easy-to-use feature Bootstrap in CakePHP

[Bootstrap, from Twitter](http://twitter.github.com/bootstrap/)

This v1.3.4 supports Bootstrap v2.0.3
This v1.3.5 supports Bootstrap v2.0.3

##Installation
###This plugin
Expand Down
77 changes: 34 additions & 43 deletions View/Helper/BootstrapFormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,7 @@ class BootstrapFormHelper extends FormHelper {

protected $_Opts = array();

public function textarea($fieldName, $options, $before = false) {
if ($before) {
if ('textarea' === $options['type']) {
$options += array('cols' => false, 'rows' => '3');
}
return $options;
} else {
return parent::textarea($fieldName, $options);
}
}

public function uneditable($fieldName, $options, $before = false) {
public function uneditable($fieldName, $options = array(), $before = false) {
if ($before) {
$class = explode(' ', $this->_extractOption('class', $options));
if (in_array('uneditable-input', $class)) {
Expand All @@ -48,7 +37,7 @@ public function uneditable($fieldName, $options, $before = false) {
}
}

public function addon($fieldName, $options, $before = false) {
public function addon($fieldName, $options = array(), $before = false) {
if ($before) {
$prepend = $this->_extractOption('prepend', $options);
$append = $this->_extractOption('append', $options);
Expand Down Expand Up @@ -89,37 +78,40 @@ public function addon($fieldName, $options, $before = false) {
}
}

public function checkbox($fieldName, $options, $before = false) {
if ($before) {
if ('checkbox' === $options['type']) {
if (!$this->_extractOption('div', $options)) {
$options['label'] = false;
} else {
$options['after'] = null;
}
}
return $options;
} else {
$label = $this->_extractOption('label', $this->_Opts[$fieldName]);
if (!is_array($label)) {
$label = array('text' => $label);
}
$after = $this->_extractOption('after', $this->_Opts[$fieldName]);
public function checkbox($fieldName, $options = array()) {
$label = $this->_extractOption('label', $this->_Opts[$fieldName]);
if (!is_array($label)) {
$label = array('text' => $label);
}
$after = $this->_extractOption('after', $this->_Opts[$fieldName]);

if ($this->_extractOption('div', $this->_Opts[$fieldName])) {
$label['text'] = $after;
$label['class'] = null;
}
if ($this->_extractOption('div', $this->_Opts[$fieldName])) {
$label['text'] = $after;
$label['class'] = null;
}

$label = $this->addClass($label, 'checkbox');
$text = $label['text'];
unset($label['text']);
$out = parent::checkbox($fieldName, $options) . $text;
return $this->label($fieldName, $out, $label);
$label = $this->addClass($label, 'checkbox');
$text = $label['text'];
unset($label['text']);
$out = parent::checkbox($fieldName, $options) . $text;
return $this->label($fieldName, $out, $label);
}

protected function _setOptions($fieldName, $options) {
if ('textarea' === $options['type']) {
$options += array('cols' => false, 'rows' => '3');
}
if ('checkbox' === $options['type']) {
if (!$this->_extractOption('div', $options)) {
$options['label'] = false;
} else {
$options['after'] = null;
}
}
return $options;
}

public function radio($fieldName, $radioOptions, $options) {
public function radio($fieldName, $radioOptions = array(), $options = array()) {
$options['legend'] = false;
$options['separator'] = "\n";
$out = parent::radio($fieldName, $radioOptions, $options);
Expand All @@ -141,7 +133,7 @@ public function select($fieldName, $options = array(), $attributes = array()) {
protected function _restructureLabel($out, $options = array()) {
$out = explode("\n", $out);
foreach ($out as $key => &$_out) {
$input = strip_tags($_out, '<input>');
$input = strip_tags($_out, '<input><img>');
if ($input) {
$_out = $this->Html->tag('label', $input, $options);
}
Expand Down Expand Up @@ -202,8 +194,7 @@ public function input($fieldName, $options = array()) {
} else {
$options = $this->uneditable($fieldName, $options, true);
$options = $this->addon($fieldName, $options, true);
$options = $this->textarea($fieldName, $options, true);
$options = $this->checkbox($fieldName, $options, true);
$options = $this->_setOptions($fieldName, $options);
$options = $this->_controlGroupStates($fieldName, $options);
$options = $this->_buildAfter($options);

Expand Down Expand Up @@ -395,7 +386,7 @@ protected function _hidden($fieldName, $options) {
return $out;
}

public function help($text, $options) {
public function help($text, $options = array()) {
$classMap = array(
'inline' => array('wrap' => 'span', 'class' => 'help-inline'),
'block' => array('wrap' => 'p', 'class' => 'help-block'),
Expand Down
8 changes: 4 additions & 4 deletions View/Helper/BootstrapPaginatorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function pager($options = array()) {
return $this->Html->tag('ul', implode("\n", $out), compact('class'));
}

public function prev($title, $options = array()) {
public function prev($title = null, $options = array(), $disabledTitle = null, $disabledOptions = array()) {
$default = array(
'title' => '<',
'tag' => 'li',
Expand All @@ -89,7 +89,7 @@ public function prev($title, $options = array()) {
)));
}

public function next($title, $options = array()) {
public function next($title = null, $options = array(), $disabledTitle = null, $disabledOptions = array()) {
$default = array(
'title' => '>',
'tag' => 'li',
Expand Down Expand Up @@ -155,7 +155,7 @@ public function numbers($options = array()) {
return implode("\n", $out);
}

public function first($title, $options = array()) {
public function first($title = null, $options = array()) {
$default = array(
'title' => '<<',
'tag' => 'li',
Expand All @@ -178,7 +178,7 @@ public function first($title, $options = array()) {
);
}

public function last($title, $options = array()) {
public function last($title = null, $options = array()) {
$default = array(
'title' => '>>',
'tag' => 'li',
Expand Down
74 changes: 0 additions & 74 deletions View/Layouts/bootstrap.ctp

This file was deleted.

81 changes: 81 additions & 0 deletions View/Layouts/default.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>
<?php echo __('CakePHP: the rapid development php framework:'); ?>
<?php echo $title_for_layout; ?>
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<!-- Le styles -->
<?php echo $this->Html->css('bootstrap.min'); ?>
<style>
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
</style>
<?php echo $this->Html->css('bootstrap-responsive.min'); ?>

<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<!-- Le fav and touch icons -->
<!--
<link rel="shortcut icon" href="/ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="/ico/apple-touch-icon-57-precomposed.png">
-->
<?php
echo $this->fetch('meta');
echo $this->fetch('css');
?>
</head>

<body>

<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#"><?php echo __('CakePHP'); ?></a>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>

<div class="container">

<h1>Bootstrap starter template</h1>

<?php echo $this->Session->flash(); ?>

<?php echo $this->fetch('content'); ?>

</div> <!-- /container -->

<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<?php echo $this->Html->script('bootstrap.min'); ?>
<?php echo $this->fetch('script'); ?>

</body>
</html>

0 comments on commit c071a91

Please sign in to comment.