diff --git a/cakephp/app/.htaccess b/cakephp/app/.htaccess old mode 100644 new mode 100755 diff --git a/cakephp/app/Controller/UsersController.php b/cakephp/app/Controller/UsersController.php index 2a9865c..d543abb 100644 --- a/cakephp/app/Controller/UsersController.php +++ b/cakephp/app/Controller/UsersController.php @@ -9,6 +9,7 @@ App::import('Vendor', 'location_distance'); App::uses('AppController', 'Controller'); + class UsersController extends AppController { public $helpers = array('Html', 'Form'); @@ -17,76 +18,79 @@ class UsersController extends AppController public function index() { - $this->set('user', $this->Auth->user()); - $this->layout = 'indexLayout'; - $this->Session->write('Visitor.id',$this->Auth->user('id')); - - $userdata = $this->User->find('all', - array( - 'conditions' => array('user.parentid' => 1) - ) - ); - - $otherdata = $this->User->find('all', - array( - 'conditions' => array( - 'NOT' => array( - 'user.parentid' => '' - ), - 'NOT' => array( - 'user.parentid' => $this->Session->read('Visitor.id') + if(0===$this->Session->read('isParent')){ + $this->redirect('friend'); + }else{ + $this->set('user', $this->Auth->user()); + $this->layout = 'indexLayout'; + $this->Session->write('Visitor.id',$this->Auth->user('id')); + + $userdata = $this->User->find('all', + array( + 'conditions' => array('user.parentid' => $this->Session->read('Visitor.id')) ) - ) - ) - ); + ); - /* ◯◯くんの近くには誰くんと?がいます を出力*/ - //userdataから1人取り出し、友達の情報をリストアップ - $frienddata = array(); - $tmpdata = array(); - foreach ($userdata as $dat) { - foreach ($dat['friend'] as $tmp) { - $tmpdata[] = $this->User->find('all', - array( - 'conditions' => array('user.id' => $tmp['friendsid']) + $otherdata = $this->User->find('all', + array( + 'conditions' => array( + 'NOT' => array( + 'user.parentid' => '' + ), + 'NOT' => array( + 'user.parentid' => $this->Session->read('Visitor.id') + ) + ) ) ); + + /* ◯◯くんの近くには誰くんと?がいます を出力*/ + //userdataから1人取り出し、友達の情報をリストアップ + $frienddata = array(); + $tmpdata = array(); + foreach ($userdata as $dat) { + foreach ($dat['friend'] as $tmp) { + $tmpdata[] = $this->User->find('all', + array( + 'conditions' => array('user.id' => $tmp['friendsid']) + ) + ); + } + $frienddata[]=$tmpdata; + $tmpdata= array(); } - $frienddata[]=$tmpdata; - $tmpdata= array(); - } - $resulttmp=array(); + $resulttmp=array(); //子供とその友達の距離を測り、近傍に居るか否か見分ける - for($i=0;$iset("otherdata", $otherdata); + $this->set("userdata", $userdata); } - $this->set("otherdata", $otherdata); - $this->set("userdata", $userdata); } - //どのアクションが呼ばれてもはじめに実行される関数 public function beforeFilter() { @@ -94,25 +98,30 @@ public function beforeFilter() $this->response->disableCache(); //未ログインでアクセスできるアクションを指定 //これ以外のアクションへのアクセスはloginにリダイレクトされる規約になっている - $this->Auth->allow('register', 'login'); - + if(null===$this->Session->check('Visitor.id'))$this->Auth->allow('register', 'login'); + else{ + if(isset($isParent))$this->Auth->allow('register', 'login' , 'friend'); + if(!isset($isParent))$this->Auth->allow('register', 'login' , 'parent' , 'index'); + } } - public function friend(){ - + public function friend(){ + if(0!==$this->Session->read('isParent')){ + $this->redirect('index'); + }else{ //友達登録ボタンを押していたら、データベースを更新する - if($this->request->is('post')){ - $this->loadModel('Friend'); - if(isset($this->request->data['register'])) { - $this->Friend->save($this->request->data); - } - if(isset($this->request->data['delete'])) { + if($this->request->is('post')){ + $this->loadModel('Friend'); + if(isset($this->request->data['register'])) { + $this->Friend->save($this->request->data); + } + if(isset($this->request->data['delete'])) { $delete_id = $this->Friend->find('first', array( 'fields' => array('friend.id'), 'conditions' => array('friend.user_id' => $this->request->data['Friend']['user_id'], 'friend.friendsid' => $this->request->data['Friend']['friendsid']) - ) - ); + ) + ); $this->Friend->delete($delete_id['Friend']['id']); } } @@ -120,9 +129,9 @@ public function friend(){ //ログインユーザの情報を取得する $user = $this->User->find('first', array( - 'conditions' => array('user.id' => $this->Auth->user('id')) - ) - ); + 'conditions' => array('user.id' => $this->Auth->user('id')) + ) + ); //ログインユーザの友達の情報を取得する $friends = array(); @@ -131,47 +140,78 @@ public function friend(){ $this->User->find('all', array( 'conditions' => array('user.id' => $friend['friendsid']) + ) ) - ) - ); + ); } $this->set('friends', $friends); $this->set('user', $this->Auth->user()); $this->layout = 'indexLayout'; } +} - public function parent() { +public function parent() { + if(0===$this->Session->read('isParent')){ + $this->redirect('friend'); + }else{ $this->set('user', $this->Auth->user()); $this->layout = 'indexLayout'; - } - + $this->Session->write('Visitor.id',$this->Auth->user('id')); + $userdata = $this->User->find('all', + array( + 'conditions' => array('user.parentid' => $this->Session->read('Visitor.id')) + ) + ); + $this->set("userdata", $userdata); + //var_dump($this->request->data); + if($this->request->is('post')){ + if(isset($this->request->data['User']))$this->User->save($this->request->data); + if(isset($this->request->data['delete']))$this->User->delete($this->request->data['delete']['deleteid']); + $this->redirect('parent'); + } + } +} - public function register(){ +public function register(){ //$this->requestにPOSTされたデータが入っている //POSTメソッドかつユーザ追加が成功したら - if($this->request->is('post') && $this->User->save($this->request->data)){ + if($this->request->is('post') && $this->User->save($this->request->data)){ //ログイン //$this->request->dataの値を使用してログインする規約になっている - $this->Auth->login(); - $this->redirect('index'); - } + $this->Auth->login(); + $this->redirect('index'); } +} - public function login(){ - if($this->request->is('post')) { - if($this->Auth->login()) - return $this->redirect('index'); - else - $this->Session->setFlash('ログイン失敗'); - } +public function login(){ + if($this->request->is('post')) { + if($this->Auth->login()){ + $this->Session->write('Visitor.id',$this->Auth->user('id')); + $isParent = $this->User->find('count', + array( + 'conditions' => array( + array( + 'user.id' => $this->Auth->user('id') + ), + array( + 'user.parentid' => '' + ) + ) + ) + ); + $this->Session->write('isParent',$isParent); + if($isParent!=NULL)return $this->redirect('index'); + else return $this->redirect('friend'); + }else $this->Session->setFlash('ログイン失敗'); } +} - public function logout(){ - $this->Auth->logout(); - $this->redirect('login'); - } +public function logout(){ + $this->Auth->logout(); + $this->redirect('login'); +} } diff --git a/cakephp/app/Lib/empty b/cakephp/app/Lib/empty deleted file mode 100644 index e69de29..0000000 diff --git a/cakephp/app/Plugin/BoostCake/.travis.yml b/cakephp/app/Plugin/BoostCake/.travis.yml new file mode 100755 index 0000000..8c760a0 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/.travis.yml @@ -0,0 +1,37 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + +env: + global: + - PLUGIN_NAME=BoostCake + + matrix: + - DB=mysql CAKE_VERSION=2.4 + - DB=mysql CAKE_VERSION=2.5 + +matrix: + include: + - php: 5.5 + env: + - PHPCS=1 PHPCS_IGNORE="*/Test/*" + +install: + - sh -c "if [ -n \"$CAKE_VERSION\" ]; then composer global require 'phpunit/phpunit=3.7.*'; fi" + +before_script: + - git clone https://github.com/FriendsOfCake/travis.git --depth 1 ../travis + - ../travis/before_script.sh + - sh -c "if [ -n \"$CAKE_VERSION\" ]; then ln -s ~/.composer/vendor/phpunit/phpunit/PHPUnit ../cakephp/vendors/PHPUnit; fi" + +script: + - ../travis/script.sh + +after_success: + - ../travis/after_success.sh + +notifications: + email: false diff --git a/cakephp/app/Plugin/BoostCake/Controller/BoostCakeController.php b/cakephp/app/Plugin/BoostCake/Controller/BoostCakeController.php new file mode 100755 index 0000000..ea09f06 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/Controller/BoostCakeController.php @@ -0,0 +1,80 @@ + array('className' => 'BoostCake.BoostCakeHtml'), + 'Form' => array('className' => 'BoostCake.BoostCakeForm'), + 'Paginator' => array('className' => 'BoostCake.BoostCakePaginator'), + ); + +/** + * Before filter + * + * @throws MethodNotAllowedException + * @return void + */ + public function beforeFilter() { + if (Configure::read('debug') < 1) { + throw new MethodNotAllowedException(__('Debug setting does not allow access to this url.')); + } + parent::beforeFilter(); + } + +/** + * Action for plugin documentation home page + * + * @return void + */ + public function index() { + } + +/** + * Action for Bootstrap 2 example page + * + * @return void + */ + public function bootstrap2() { + $this->Session->setFlash(__('Alert notice message testing...'), 'alert', array( + 'plugin' => 'BoostCake', + ), 'notice'); + $this->Session->setFlash(__('Alert success message testing...'), 'alert', array( + 'plugin' => 'BoostCake', + 'class' => 'alert-success' + ), 'success'); + $this->Session->setFlash(__('Alert error message testing...'), 'alert', array( + 'plugin' => 'BoostCake', + 'class' => 'alert-error' + ), 'error'); + } + +/** + * Action for Bootstrap 3 example page + * + * @return void + */ + public function bootstrap3() { + $this->Session->setFlash(__('Alert success message testing...'), 'alert', array( + 'plugin' => 'BoostCake', + 'class' => 'alert-success' + ), 'success'); + $this->Session->setFlash(__('Alert info message testing...'), 'alert', array( + 'plugin' => 'BoostCake', + 'class' => 'alert-info' + ), 'info'); + $this->Session->setFlash(__('Alert warning message testing...'), 'alert', array( + 'plugin' => 'BoostCake', + 'class' => 'alert-warning' + ), 'warning'); + $this->Session->setFlash(__('Alert danger message testing...'), 'alert', array( + 'plugin' => 'BoostCake', + 'class' => 'alert-danger' + ), 'danger'); + } + +} diff --git a/cakephp/app/Plugin/BoostCake/Model/BoostCake.php b/cakephp/app/Plugin/BoostCake/Model/BoostCake.php new file mode 100755 index 0000000..78aa01e --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/Model/BoostCake.php @@ -0,0 +1,22 @@ + array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '10'), + 'text' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), + 'email' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), + 'password' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), + 'price' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '10'), + 'textarea' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), + 'checkbox' => array('type' => 'boolean', 'null' => false, 'default' => false), + 'remember' => array('type' => 'boolean', 'null' => false, 'default' => false), + 'select' => array('type' => 'integer', 'length' => '10', 'null' => true), + 'radio' => array('type' => 'integer', 'length' => '10', 'null' => true), + 'datetime' => array('type' => 'datetime') + ); + +} diff --git a/cakephp/app/Plugin/BoostCake/README.md b/cakephp/app/Plugin/BoostCake/README.md new file mode 100755 index 0000000..12901df --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/README.md @@ -0,0 +1,79 @@ +# BoostCake + +[![Build Status](https://travis-ci.org/slywalker/cakephp-plugin-boost_cake.png)](https://travis-ci.org/slywalker/cakephp-plugin-boost_cake) +[![Total Downloads](https://poser.pugx.org/slywalker/boost_cake/d/total.png)](https://packagist.org/packages/slywalker/boost_cake) +[![Latest Stable Version](https://poser.pugx.org/slywalker/boost_cake/v/stable.png)](https://packagist.org/packages/slywalker/boost_cake) + +BoostCake is a plugin for CakePHP using Bootstrap + +* [Bootstrap(2.3.2)](http://getbootstrap.com/2.3.2/) +* [Bootstrap(3.0.0)](http://getbootstrap.com/) + +## Requirements + +* CakePHP >= 2.3 +* Bootstrap >= 2.3 (3.0 support) + +## Installation + +Ensure require is present in composer.json. This will install the plugin into Plugin/BoostCake: + + { + "require": { + "slywalker/boost_cake": "*" + } + } + +### Enable plugin + +You need to enable the plugin in your app/Config/bootstrap.php file: + +`CakePlugin::load('BoostCake');` + +If you are already using `CakePlugin::loadAll();`, then this is not necessary. + +## Documentation + +[BoostCake - Bootstrap Plugin for CakePHP](http://slywalker.github.io/cakephp-plugin-boost_cake/) + +## Development Policy + +More Simple! Simple! Simple! + +* Develop only those that method's $options in FormHelper unable to solve. +* Don't develop ajax/js helper + +If you want to simplify the options, you can develop WrapBoostCake plugin. + +### What this plugin solves + +* Replaces the `label` of checkboxes and radios +* Adds a wrapping `div` to inputs +* Adds content before and after `input` +* Adds error class in outer `div` +* Changes pagination tags +* Changes SessionHelper::flash()`s template + +## License + +The MIT License (MIT) + +Copyright (c) 2014 Yasuo Harada + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/cakephp/app/Plugin/BoostCake/Test/Case/AllBoostCakeTest.php b/cakephp/app/Plugin/BoostCake/Test/Case/AllBoostCakeTest.php new file mode 100755 index 0000000..53f6e2a --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/Test/Case/AllBoostCakeTest.php @@ -0,0 +1,16 @@ +addTestDirectory($path . DS . 'View' . DS . 'Helper'); + return $suite; + } + +} diff --git a/cakephp/app/Plugin/BoostCake/Test/Case/View/Helper/BoostCakeFormHelperTest.php b/cakephp/app/Plugin/BoostCake/Test/Case/View/Helper/BoostCakeFormHelperTest.php new file mode 100755 index 0000000..6d6486f --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/Test/Case/View/Helper/BoostCakeFormHelperTest.php @@ -0,0 +1,476 @@ + 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 BoostCakeFormHelperTest extends CakeTestCase { + +/** + * setUp + * + * @return void + */ + public function setUp() { + parent::setUp(); + $this->View = new View(); + $this->Form = new BoostCakeFormHelper($this->View); + + ClassRegistry::addObject('Contact', new Contact()); + } + +/** + * tearDown + * + * @return void + */ + public function tearDown() { + unset($this->View); + unset($this->Form); + } + +/** + * testInput + * + * @return void + */ + public function testInput() { + $result = $this->Form->input('name'); + $this->assertTags($result, array( + array('div' => array()), + 'label' => array('for' => 'name'), + 'Name', + '/label', + array('div' => array('class' => 'input text')), + array('input' => array('name' => 'data[name]', 'type' => 'text', 'id' => 'name')), + '/div', + '/div' + )); + + $result = $this->Form->input('name', array( + 'div' => 'row', + 'wrapInput' => 'col col-lg-10', + 'label' => array( + 'class' => 'col col-lg-2 control-label' + ) + )); + $this->assertTags($result, array( + array('div' => array('class' => 'row')), + 'label' => array('for' => 'name', 'class' => 'col col-lg-2 control-label'), + 'Name', + '/label', + array('div' => array('class' => 'col col-lg-10')), + array('input' => array('name' => 'data[name]', 'type' => 'text', 'id' => 'name')), + '/div', + '/div' + )); + + $result = $this->Form->input('name', array('div' => false)); + $this->assertTags($result, array( + 'label' => array('for' => 'name'), + 'Name', + '/label', + array('div' => array('class' => 'input text')), + array('input' => array('name' => 'data[name]', 'type' => 'text', 'id' => 'name')), + '/div' + )); + + $result = $this->Form->input('name', array('wrapInput' => false)); + $this->assertTags($result, array( + array('div' => array()), + 'label' => array('for' => 'name'), + 'Name', + '/label', + array('input' => array('name' => 'data[name]', 'type' => 'text', 'id' => 'name')), + '/div' + )); + + $result = $this->Form->input('name', array( + 'div' => false, + 'wrapInput' => false + )); + $this->assertTags($result, array( + 'label' => array('for' => 'name'), + 'Name', + '/label', + array('input' => array('name' => 'data[name]', 'type' => 'text', 'id' => 'name')) + )); + } + +/** + * testBeforeInputAfterInput + * + * @return void + */ + public function testBeforeInputAfterInput() { + $result = $this->Form->input('name', array( + 'beforeInput' => 'Before Input', + 'afterInput' => 'After Input', + )); + $this->assertTags($result, array( + array('div' => array()), + 'label' => array('for' => 'name'), + 'Name', + '/label', + array('div' => array('class' => 'input text')), + 'Before Input', + array('input' => array('name' => 'data[name]', 'type' => 'text', 'id' => 'name')), + 'After Input', + '/div', + '/div' + )); + } + +/** + * testCheckbox + * + * @return void + */ + public function testCheckbox() { + $result = $this->Form->input('name', array('type' => 'checkbox')); + $this->assertTags($result, array( + array('div' => array()), + array('div' => array('class' => 'input checkbox')), + array('div' => array('class' => 'checkbox')), + array('input' => array('type' => 'hidden', 'name' => 'data[name]', 'id' => 'name_', 'value' => '0')), + 'label' => array('for' => 'name'), + array('input' => array('name' => 'data[name]', 'type' => 'checkbox', 'value' => '1', 'id' => 'name')), + ' Name', + '/label', + '/div', + '/div', + '/div' + )); + + $result = $this->Form->input('name', array( + 'type' => 'checkbox', + 'before' => '', + 'label' => false + )); + $this->assertTags($result, array( + array('div' => array()), + array('label' => array()), + 'Name', + '/label', + array('div' => array('class' => 'input checkbox')), + array('div' => array('class' => 'checkbox')), + array('input' => array('type' => 'hidden', 'name' => 'data[name]', 'id' => 'name_', 'value' => '0')), + array('input' => array('name' => 'data[name]', 'type' => 'checkbox', 'value' => '1', 'id' => 'name')), + '/div', + '/div', + '/div' + )); + + $result = $this->Form->input('name', array( + 'type' => 'checkbox', + 'checkboxDiv' => false + )); + $this->assertTags($result, array( + array('div' => array()), + array('div' => array('class' => 'input checkbox')), + array('input' => array('type' => 'hidden', 'name' => 'data[name]', 'id' => 'name_', 'value' => '0')), + 'label' => array('for' => 'name'), + array('input' => array('name' => 'data[name]', 'type' => 'checkbox', 'value' => '1', 'id' => 'name')), + ' Name', + '/label', + '/div', + '/div' + )); + } + +/** + * testCheckboxLabelEscape + * + * @return void + */ + public function testCheckboxLabelEscape() { + $result = $this->Form->input('name', array( + 'type' => 'checkbox', + 'label' => 'I want $1' + )); + $this->assertTags($result, array( + array('div' => array()), + array('div' => array('class' => 'input checkbox')), + array('div' => array('class' => 'checkbox')), + array('input' => array('type' => 'hidden', 'name' => 'data[name]', 'id' => 'name_', 'value' => '0')), + 'label' => array('for' => 'name'), + array('input' => array('name' => 'data[name]', 'type' => 'checkbox', 'value' => '1', 'id' => 'name')), + ' I want $1', + '/label', + '/div', + '/div', + '/div' + )); + } + +/** + * testSelectMultipleCheckbox + * + * @return void + */ + public function testSelectMultipleCheckbox() { + $result = $this->Form->select('name', + array( + 1 => 'one', + 2 => 'two', + 3 => 'three' + ), + array( + 'multiple' => 'checkbox', + 'class' => 'checkbox-inline' + ) + ); + $this->assertTags($result, array( + array('input' => array('type' => 'hidden', 'name' => 'data[name]', 'value' => '', 'id' => 'name')), + array('label' => array('for' => 'Name1', 'class' => 'checkbox-inline')), + array('input' => array('type' => 'checkbox', 'name' => 'data[name][]', 'value' => '1', 'id' => 'Name1')), + ' one', + '/label', + array('label' => array('for' => 'Name2', 'class' => 'checkbox-inline')), + array('input' => array('type' => 'checkbox', 'name' => 'data[name][]', 'value' => '2', 'id' => 'Name2')), + ' two', + '/label', + array('label' => array('for' => 'Name3', 'class' => 'checkbox-inline')), + array('input' => array('type' => 'checkbox', 'name' => 'data[name][]', 'value' => '3', 'id' => 'Name3')), + ' three', + '/label' + )); + + $result = $this->Form->select('name', + array( + 1 => 'one', + 2 => 'two', + 3 => 'three' + ), + array( + 'multiple' => 'checkbox', + 'class' => 'checkbox-inline', + 'value' => 2 + ) + ); + $this->assertTags($result, array( + array('input' => array('type' => 'hidden', 'name' => 'data[name]', 'value' => '', 'id' => 'name')), + array('label' => array('for' => 'Name1', 'class' => 'checkbox-inline')), + array('input' => array('type' => 'checkbox', 'name' => 'data[name][]', 'value' => '1', 'id' => 'Name1')), + ' one', + '/label', + array('label' => array('for' => 'Name2', 'class' => 'selected checkbox-inline')), + array('input' => array('type' => 'checkbox', 'name' => 'data[name][]', 'value' => '2', 'id' => 'Name2', 'checked' => 'checked')), + ' two', + '/label', + array('label' => array('for' => 'Name3', 'class' => 'checkbox-inline')), + array('input' => array('type' => 'checkbox', 'name' => 'data[name][]', 'value' => '3', 'id' => 'Name3')), + ' three', + '/label' + )); + + $result = $this->Form->select('name', + array( + 1 => 'bill', + 'Smith' => array( + 2 => 'fred', + 3 => 'fred jr.' + ) + ), + array( + 'multiple' => 'checkbox', + 'class' => 'checkbox-inline' + ) + ); + $this->assertTags($result, array( + array('input' => array('type' => 'hidden', 'name' => 'data[name]', 'value' => '', 'id' => 'name')), + array('label' => array('for' => 'Name1', 'class' => 'checkbox-inline')), + array('input' => array('type' => 'checkbox', 'name' => 'data[name][]', 'value' => '1', 'id' => 'Name1')), + ' bill', + '/label', + 'fieldset' => array(), + 'legend' => array(), + 'Smith', + '/legend', + array('label' => array('for' => 'Name2', 'class' => 'checkbox-inline')), + array('input' => array('type' => 'checkbox', 'name' => 'data[name][]', 'value' => '2', 'id' => 'Name2')), + ' fred', + '/label', + array('label' => array('for' => 'Name3', 'class' => 'checkbox-inline')), + array('input' => array('type' => 'checkbox', 'name' => 'data[name][]', 'value' => '3', 'id' => 'Name3')), + ' fred jr.', + '/label', + '/fieldset' + )); + } + +/** + * testRadio + * + * @return void + */ + public function testRadio() { + $result = $this->Form->input('name', array( + 'type' => 'radio', + 'options' => array( + 'one' => 'This is one', + 'two' => 'This is two' + ) + )); + $this->assertTags($result, array( + array('div' => array()), + array('div' => array('class' => 'input radio')), + 'fieldset' => array(), + 'legend' => array(), + 'Name', + '/legend', + array('input' => array('type' => 'hidden', 'name' => 'data[name]', 'id' => 'name_', 'value' => '')), + array('label' => array('for' => 'nameOne', 'class' => 'radio')), + array('input' => array('name' => 'data[name]', 'type' => 'radio', 'value' => 'one', 'id' => 'nameOne')), + ' This is one', + '/label', + array('label' => array('for' => 'nameTwo', 'class' => 'radio')), + array('input' => array('name' => 'data[name]', 'type' => 'radio', 'value' => 'two', 'id' => 'nameTwo')), + ' This is two', + '/label', + '/fieldset', + '/div', + '/div' + )); + } + +/** + * testErrorMessage + * + * @return void + */ + public function testErrorMessage() { + $Contact = ClassRegistry::getObject('Contact'); + $Contact->validationErrors['password'] = array('Please provide a password'); + + $result = $this->Form->input('Contact.password', array( + 'div' => 'row', + 'label' => array( + 'class' => 'col col-lg-2 control-label' + ), + 'class' => 'input-with-feedback' + )); + $this->assertTags($result, array( + array('div' => array('class' => 'row has-error error')), + 'label' => array('for' => 'ContactPassword', 'class' => 'col col-lg-2 control-label'), + 'Password', + '/label', + array('div' => array('class' => 'input password')), + 'input' => array( + 'type' => 'password', 'name' => 'data[Contact][password]', + 'id' => 'ContactPassword', 'class' => 'input-with-feedback form-error' + ), + array('span' => array('class' => 'help-block text-danger')), + 'Please provide a password', + '/span', + '/div', + '/div' + )); + + $result = $this->Form->input('Contact.password', array( + 'div' => 'row', + 'label' => array( + 'class' => 'col col-lg-2 control-label' + ), + 'class' => 'input-with-feedback', + 'errorMessage' => false + )); + $this->assertTags($result, array( + array('div' => array('class' => 'row has-error error')), + 'label' => array('for' => 'ContactPassword', 'class' => 'col col-lg-2 control-label'), + 'Password', + '/label', + array('div' => array('class' => 'input password')), + 'input' => array( + 'type' => 'password', 'name' => 'data[Contact][password]', + 'id' => 'ContactPassword', 'class' => 'input-with-feedback form-error' + ), + '/div', + '/div' + )); + + $result = $this->Form->input('Contact.password', array( + 'div' => 'control-group', + 'label' => array( + 'class' => 'control-label' + ), + 'wrapInput' => 'controls', + 'beforeInput' => '
', + 'afterInput' => 'AddOn
' + )); + $this->assertTags($result, array( + array('div' => array('class' => 'control-group has-error error')), + 'label' => array('for' => 'ContactPassword', 'class' => 'control-label'), + 'Password', + '/label', + array('div' => array('class' => 'controls')), + array('div' => array('class' => 'input-append')), + 'input' => array( + 'type' => 'password', 'name' => 'data[Contact][password]', + 'id' => 'ContactPassword', 'class' => 'form-error' + ), + array('span' => array('class' => 'add-on')), + 'AddOn', + '/span', + '/div', + array('span' => array('class' => 'help-block text-danger')), + 'Please provide a password', + '/span', + '/div', + '/div' + )); + } + +/** + * testPostLink + * + * @return void + */ + public function testPostLink() { + $result = $this->Form->postLink('Delete', '/posts/delete/1', array( + 'block' => 'form' + )); + $this->assertTags($result, array( + 'a' => array('href' => '#', 'onclick' => 'preg:/document\.post_\w+\.submit\(\); event\.returnValue = false; return false;/'), + 'Delete', + '/a' + )); + + $result = $this->View->fetch('form'); + $this->assertTags($result, array( + 'form' => array( + 'method' => 'post', 'action' => '/posts/delete/1', + 'name' => 'preg:/post_\w+/', 'id' => 'preg:/post_\w+/', 'style' => 'display:none;' + ), + 'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'), + '/form' + )); + } + +} diff --git a/cakephp/app/Plugin/BoostCake/Test/Case/View/Helper/BoostCakeHtmlHelperTest.php b/cakephp/app/Plugin/BoostCake/Test/Case/View/Helper/BoostCakeHtmlHelperTest.php new file mode 100755 index 0000000..93b3e44 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/Test/Case/View/Helper/BoostCakeHtmlHelperTest.php @@ -0,0 +1,71 @@ +Html = new BoostCakeHtmlHelper($View); + } + +/** + * tearDown + * + * @return void + */ + public function tearDown() { + unset($this->Html); + } + +/** + * testUseTag + * + * @return void + */ + public function testUseTag() { + $result = $this->Html->useTag( + 'radio', 'one', 'two', array('three' => 'four'), '' + ); + $this->assertTags($result, array( + 'label' => array('class' => 'radio', 'for' => 'one'), + 'input' => array('type' => 'radio', 'name' => 'one', 'id' => 'two', 'three' => 'four'), + ' label', + '/label' + )); + + $result = $this->Html->useTag( + 'radio', 'one', 'two', array('class' => 'radio-inline', 'three' => 'four'), '' + ); + $this->assertTags($result, array( + 'label' => array('class' => 'radio-inline', 'for' => 'one'), + 'input' => array('type' => 'radio', 'name' => 'one', 'id' => 'two', 'three' => 'four'), + ' label', + '/label' + )); + } + +/** + * testImage + * + * @return void + */ + public function testImage() { + $result = $this->Html->image('', array('data-src' => 'holder.js/24x24')); + $this->assertTags($result, array( + 'img' => array('src' => '/', 'data-src' => 'holder.js/24x24', 'alt' => '') + )); + + $result = $this->Html->image('some.jpg', array('data-src' => 'holder.js/24x24')); + $this->assertTags($result, array( + 'img' => array('src' => '/img/some.jpg', 'alt' => '') + )); + } + +} diff --git a/cakephp/app/Plugin/BoostCake/Test/Case/View/Helper/BoostCakePaginatorHelperTest.php b/cakephp/app/Plugin/BoostCake/Test/Case/View/Helper/BoostCakePaginatorHelperTest.php new file mode 100755 index 0000000..55df447 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/Test/Case/View/Helper/BoostCakePaginatorHelperTest.php @@ -0,0 +1,452 @@ +Paginator = new BoostCakePaginatorHelper($View); + } + +/** + * tearDown method + * + * @return void + */ + public function tearDown() { + unset($this->Paginator); + + parent::tearDown(); + } + +/** + * testPaginationEmpty + * + * @return void + */ + public function testPaginationEmpty() { + $this->Paginator->request->params['paging']['Post'] = array( + 'page' => 1, + 'current' => 0, + 'count' => 0, + 'prevPage' => false, + 'nextPage' => false, + 'pageCount' => 1, + 'order' => null, + 'limit' => 20, + 'options' => array( + 'page' => 1, + 'conditions' => array() + ), + 'paramType' => 'named' + ); + $numbers = $this->Paginator->pagination(array('model' => 'Post')); + $this->assertSame('', $numbers); + } + +/** + * testPaginationTwoModel + * + * @return void + */ + public function testPaginationTwoModel() { + $this->Paginator->request->params['paging']['Post'] = array( + 'page' => 1, + 'current' => 0, + 'count' => 0, + 'prevPage' => false, + 'nextPage' => false, + 'pageCount' => 1, + 'order' => null, + 'limit' => 20, + 'options' => array( + 'page' => 1, + 'conditions' => array() + ), + 'paramType' => 'named' + ); + $this->Paginator->request->params['paging']['Article'] = array( + 'page' => 1, + 'current' => 0, + 'count' => 40, + 'prevPage' => false, + 'nextPage' => true, + 'pageCount' => 2, + 'order' => null, + 'limit' => 20, + 'options' => array( + 'page' => 1, + 'conditions' => array() + ), + 'paramType' => 'named' + ); + + $result = $this->Paginator->pagination(array( + 'model' => 'Article', + 'div' => 'pagination' + )); + + $version = (float)Configure::version(); + $pageOne = '/index/page:1'; + if ($version >= 2.4) { + $pageOne = '/'; + } + + $this->assertTags($result, array( + 'div' => array('class' => 'pagination'), + 'ul' => array(), + array('li' => array('class' => 'disabled')), + array('a' => array('href' => $pageOne)), + '<', + '/a', + '/li', + array('li' => array('class' => 'current disabled')), + array('a' => array('href' => '#')), + '1', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:2')), + '2', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:2', 'rel' => 'next')), + '>', + '/a', + '/li', + '/ul', + '/div' + )); + } + +/** + * testPaginationTwo + * + * @return void + */ + public function testPaginationTwo() { + $this->Paginator->request->params['paging']['Post'] = array( + 'page' => 1, + 'current' => 0, + 'count' => 40, + 'prevPage' => false, + 'nextPage' => true, + 'pageCount' => 2, + 'order' => null, + 'limit' => 20, + 'options' => array( + 'page' => 1, + 'conditions' => array() + ), + 'paramType' => 'named' + ); + + $result = $this->Paginator->pagination(array( + 'model' => 'Post', + 'div' => 'pagination' + )); + + $version = (float)Configure::version(); + $pageOne = '/index/page:1'; + if ($version >= 2.4) { + $pageOne = '/'; + } + + $this->assertTags($result, array( + 'div' => array('class' => 'pagination'), + 'ul' => array(), + array('li' => array('class' => 'disabled')), + array('a' => array('href' => $pageOne)), + '<', + '/a', + '/li', + array('li' => array('class' => 'current disabled')), + array('a' => array('href' => '#')), + '1', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:2')), + '2', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:2', 'rel' => 'next')), + '>', + '/a', + '/li', + '/ul', + '/div' + )); + + $result = $this->Paginator->pagination(array( + 'model' => 'Post', + 'ul' => 'pagination' + )); + + $version = (float)Configure::version(); + $pageOne = '/index/page:1'; + if ($version >= 2.4) { + $pageOne = '/'; + } + + $this->assertTags($result, array( + 'ul' => array('class' => 'pagination'), + array('li' => array('class' => 'disabled')), + array('a' => array('href' => $pageOne)), + '<', + '/a', + '/li', + array('li' => array('class' => 'current disabled')), + array('a' => array('href' => '#')), + '1', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:2')), + '2', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:2', 'rel' => 'next')), + '>', + '/a', + '/li', + '/ul' + )); + } + +/** + * testNumbersEmpty + * + * @return void + */ + public function testNumbersEmpty() { + $this->Paginator->request->params['paging']['Post'] = array( + 'page' => 1, + 'current' => 0, + 'count' => 0, + 'prevPage' => false, + 'nextPage' => false, + 'pageCount' => 1, + 'order' => null, + 'limit' => 20, + 'options' => array( + 'page' => 1, + 'conditions' => array() + ), + 'paramType' => 'named' + ); + $numbers = $this->Paginator->numbers(array('model' => 'Post')); + $this->assertSame('', $numbers); + } + +/** + * testNumbersSimple + * + * @return void + */ + public function testNumbersSimple() { + $this->Paginator->request->params['paging']['Post'] = array( + 'page' => 1, + 'current' => 20, + 'count' => 100, + 'prevPage' => false, + 'nextPage' => true, + 'pageCount' => 5, + 'order' => null, + 'limit' => 20, + 'options' => array( + 'page' => 1, + 'conditions' => array() + ), + 'paramType' => 'named' + ); + + $result = $this->Paginator->numbers(array('model' => 'Post')); + $this->assertTags($result, array( + array('li' => array('class' => 'current disabled')), + array('a' => array('href' => '#')), + '1', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:2')), + '2', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:3')), + '3', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:4')), + '4', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:5')), + '5', + '/a', + '/li' + )); + } + +/** + * testNumbersElipsis + * + * @return void + */ + public function testNumbersElipsis() { + $this->Paginator->request->params['paging']['Post'] = array( + 'page' => 10, + 'current' => 20, + 'count' => 1000, + 'prevPage' => true, + 'nextPage' => true, + 'pageCount' => 200, + 'order' => null, + 'limit' => 20, + 'options' => array( + 'page' => 1, + 'conditions' => array() + ), + 'paramType' => 'named' + ); + + $result = $this->Paginator->numbers(array( + 'model' => 'Post', + 'modulus' => 8, + 'first' => 1, + 'last' => 1, + )); + + $version = (float)Configure::version(); + $pageOne = '/index/page:1'; + if ($version >= 2.4) { + $pageOne = '/'; + } + + $this->assertTags($result, array( + array('li' => array()), + array('a' => array('href' => $pageOne)), + '1', + '/a', + '/li', + array('li' => array('class' => 'disabled')), + array('a' => array('href' => '#')), + '…', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:6')), + '6', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:7')), + '7', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:8')), + '8', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:9')), + '9', + '/a', + '/li', + array('li' => array('class' => 'current disabled')), + array('a' => array('href' => '#')), + '10', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:11')), + '11', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:12')), + '12', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:13')), + '13', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:14')), + '14', + '/a', + '/li', + array('li' => array('class' => 'disabled')), + array('a' => array('href' => '#')), + '…', + '/a', + '/li', + array('li' => array()), + array('a' => array('href' => '/index/page:200')), + '200', + '/a', + '/li', + )); + } + +/** + * testPager + * + * @return void + */ + public function testPager() { + $this->Paginator->request->params['paging']['Post'] = array( + 'page' => 10, + 'current' => 20, + 'count' => 1000, + 'prevPage' => true, + 'nextPage' => true, + 'pageCount' => 200, + 'order' => null, + 'limit' => 20, + 'options' => array( + 'page' => 1, + 'conditions' => array() + ), + 'paramType' => 'named' + ); + + $result = $this->Paginator->pager(); + $this->assertTags($result, array( + 'ul' => array('class' => 'pager'), + array('li' => array('class' => 'previous')), + array('a' => array('href' => '/index/page:9', 'rel' => 'prev')), + 'Previous', + '/a', + '/li', + array('li' => array('class' => 'next')), + array('a' => array('href' => '/index/page:11', 'rel' => 'next')), + 'Next', + '/a', + '/li', + '/ul' + )); + } + +} diff --git a/cakephp/app/Plugin/BoostCake/View/BoostCake/bootstrap2.ctp b/cakephp/app/Plugin/BoostCake/View/BoostCake/bootstrap2.ctp new file mode 100755 index 0000000..eae510c --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/BoostCake/bootstrap2.ctp @@ -0,0 +1,163 @@ +layout = 'bootstrap2'; ?> +set('title_for_layout', 'Bootstrap2 examples'); ?> + +
+ +
+

BoostCake Examples Bootstrap Version 2.3.2

+ +
+ + +

Default styles

+

Individual form controls receive styling, but without any required base class on the <form> or large changes in markup. Results in stacked, left-aligned labels on top of form controls.

+ + element('BoostCake.bootstrap2/default_form'); ?> +
+
+ +

Search form

+

Add .form-search to the form and .search-query to the <input> for an extra-rounded text input.

+ + element('BoostCake.bootstrap2/search_form'); ?> +
+
+ +

Inline form

+

Add .form-inline for left-aligned labels and inline-block controls for a compact layout.

+ + element('BoostCake.bootstrap2/inline_form'); ?> +
+
+ +

Horizontal form

+

+ Right align labels and float them to the left to make them appear on the same line as controls. + Requires the most markup changes from a default form: +

+
    +
  • Add .form-horizontal to the form
  • +
  • Wrap labels and controls in .control-group
  • +
  • Add .control-label to the label
  • +
  • Wrap any associated controls in .controls for proper alignment
  • +
+ + element('BoostCake.bootstrap2/horizontal_form'); ?> +
+
+ +

Other form example

+ validationErrors['price_error'] = array('Please provide a price'); + $BoostCake->validationErrors['password'] = array('Please provide a password'); + ?> + + element('BoostCake.bootstrap2/other_form'); ?> +
+ +
+ +
+ + +

Standard pagination

+

+ Simple pagination inspired by Rdio, great for apps and search results. + The large block is hard to miss, easily scalable, and provides large click areas. +

+ + Paginator->request->params['paging']['Post'] = array( + 'page' => 10, + 'current' => 20, + 'count' => 1000, + 'prevPage' => true, + 'nextPage' => true, + 'pageCount' => 200, + 'order' => null, + 'limit' => 20, + 'options' => array( + 'page' => 1, + 'conditions' => array() + ), + 'paramType' => 'named' + ); + $this->Paginator->options(array('model' => 'Post')); + ?> + + element('BoostCake.bootstrap2/standard_pagination'); ?> +
+ +

Sizes

+

+ Fancy larger or smaller pagination? Add .pagination-large, + .pagination-small, or .pagination-mini for additional sizes. +

+ + element('BoostCake.bootstrap2/sizes_pagination'); ?> +
+ +

Alignment

+

+ Add one of two optional classes to change the alignment of pagination links: + .pagination-centered and .pagination-right. +

+ + element('BoostCake.bootstrap2/alignment_pagination'); ?> +
+ +

Pager

+

+ Quick previous and next links for simple pagination implementations with light markup and styles. + It's great for simple sites like blogs or magazines. +

+ + element('BoostCake.bootstrap2/pager'); ?> +
+ +
+ +
+ + + Session->flash('notice'); ?> + Session->flash('success'); ?> + Session->flash('error'); ?> + +
+
+
+
\ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/BoostCake/bootstrap3.ctp b/cakephp/app/Plugin/BoostCake/View/BoostCake/bootstrap3.ctp new file mode 100755 index 0000000..cbea67b --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/BoostCake/bootstrap3.ctp @@ -0,0 +1,136 @@ +layout = 'bootstrap3'; ?> +set('title_for_layout', 'Bootstrap3 examples'); ?> + +
+ +
+

BoostCake Examples Bootstrap Version 3.0.0

+ +
+ + +

Default styles

+

Individual form controls receive styling, but without any required base class on the <form> or large changes in markup. Results in stacked, left-aligned labels on top of form controls.

+ + element('BoostCake.bootstrap3/default_form'); ?> +
+
+ +

Inline form

+

Add .form-inline for left-aligned labels and inline-block controls for a compact layout.

+ + element('BoostCake.bootstrap3/inline_form'); ?> +
+
+ +

Horizontal form

+

+ Use Bootstrap's predefined grid classes to align labels and groups of form controls in a horizontal layout. +

+ + element('BoostCake.bootstrap3/horizontal_form'); ?> +
+
+ +

Other form example

+ validationErrors['password'] = array('Please provide a password'); + $BoostCake->validationErrors['price_error'] = array('Please provide a password'); + ?> + + element('BoostCake.bootstrap3/other_form'); ?> +
+
+ +
+ + +

Standard pagination

+

+ Simple pagination inspired by Rdio, great for apps and search results. + The large block is hard to miss, easily scalable, and provides large click areas. +

+ + Paginator->request->params['paging']['Post'] = array( + 'page' => 10, + 'current' => 20, + 'count' => 1000, + 'prevPage' => true, + 'nextPage' => true, + 'pageCount' => 200, + 'order' => null, + 'limit' => 20, + 'options' => array( + 'page' => 1, + 'conditions' => array() + ), + 'paramType' => 'named' + ); + $this->Paginator->options(array('model' => 'Post')); + ?> + + element('BoostCake.bootstrap3/standard_pagination'); ?> +
+ +

Sizes

+

+ Fancy larger or smaller pagination? Add .pagination-lg, + .pagination-sm, or .pagination-mini for additional sizes. +

+ + element('BoostCake.bootstrap3/sizes_pagination'); ?> +
+ +

Pager

+

+ Quick previous and next links for simple pagination implementations with light markup and styles. + It's great for simple sites like blogs or magazines. +

+ + element('BoostCake.bootstrap3/pager'); ?> +
+ +
+ +
+ + + Session->flash('success'); ?> + Session->flash('info'); ?> + Session->flash('warning'); ?> + Session->flash('danger'); ?> + +
+
+
+
diff --git a/cakephp/app/Plugin/BoostCake/View/BoostCake/index.ctp b/cakephp/app/Plugin/BoostCake/View/BoostCake/index.ctp new file mode 100755 index 0000000..89d1839 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/BoostCake/index.ctp @@ -0,0 +1,86 @@ +layout = 'bootstrap3'; ?> +set('title_for_layout', 'Bootstrap Plugin for CakePHP'); ?> + +
+

+ BoostCake + +

+

+ This is a plugin for CakePHP using Bootstrap +

+

+ + Build Status + + + Total Downloads + + + Latest Stable Version + +

+

+ + Github Project + + + Packagist + +

+
+ + + +

Composer

+

+ Ensure require is present in composer.json. + This will install the plugin into Plugin/BoostCake: +

+ +
{
+	"require": {
+		"slywalker/boost_cake": "*"
+	}
+}
+ +

Enable plugin

+

You need to enable the plugin in your app/Config/bootstrap.php file:

+
CakePlugin::load('BoostCake');
+

If you are already using CakePlugin::loadAll();, then this is not necessary.

+ +

Add helpers

+

You need to add helpers at controller.

+
 array('className' => 'BoostCake.BoostCakeHtml'),
+		'Form' => array('className' => 'BoostCake.BoostCakeForm'),
+		'Paginator' => array('className' => 'BoostCake.BoostCakePaginator'),
+	);
+
+}"); ?>
+ +

AuthComponent setting

+

Substitute alert-error with alert-danger if Bootstrap 3.

+
 array(
+			'flash' => array(
+				'element' => 'alert',
+				'key' => 'auth',
+				'params' => array(
+					'plugin' => 'BoostCake',
+					'class' => 'alert-error'
+				)
+			)
+		)
+	);
+
+}"); ?>
diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/alert.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/alert.ctp new file mode 100755 index 0000000..1830935 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/alert.ctp @@ -0,0 +1,14 @@ + +
+ + × + + +
\ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/alerts.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/alerts.ctp new file mode 100755 index 0000000..b814980 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/alerts.ctp @@ -0,0 +1,19 @@ +Session->flash(); + +// Controller +$this->Session->setFlash(__('Alert notice message testing...'), 'alert', array( + 'plugin' => 'BoostCake', +)); + +$this->Session->setFlash(__('Alert success message testing...'), 'alert', array( + 'plugin' => 'BoostCake', + 'class' => 'alert-success' +)); + +$this->Session->setFlash(__('Alert error message testing...'), 'alert', array( + 'plugin' => 'BoostCake', + 'class' => 'alert-error' +)); +?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/alignment_pagination.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/alignment_pagination.ctp new file mode 100755 index 0000000..a79bae7 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/alignment_pagination.ctp @@ -0,0 +1,7 @@ +Paginator->pagination(array( + 'div' => 'pagination pagination-centered' +)); ?> + +Paginator->pagination(array( + 'div' => 'pagination pagination-right' +)); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/default_form.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/default_form.ctp new file mode 100755 index 0000000..8303fb5 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/default_form.ctp @@ -0,0 +1,23 @@ +Form->create('BoostCake', array( + 'inputDefaults' => array( + 'div' => false, + 'wrapInput' => false + ), + 'class' => 'well' +)); ?> +
+ Legend + Form->input('text', array( + 'label' => 'Label name', + 'placeholder' => 'Type something…', + 'after' => 'Example block-level help text here.' + )); ?> + Form->input('checkbox', array( + 'label' => 'Check me out' + )); ?> + Form->submit('Submit', array( + 'div' => false, + 'class' => 'btn' + )); ?> +
+Form->end(); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/horizontal_form.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/horizontal_form.ctp new file mode 100755 index 0000000..e290ed2 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/horizontal_form.ctp @@ -0,0 +1,23 @@ +Form->create('BoostCake', array( + 'inputDefaults' => array( + 'div' => 'control-group', + 'label' => array( + 'class' => 'control-label' + ), + 'wrapInput' => 'controls' + ), + 'class' => 'well form-horizontal' +)); ?> + Form->input('email', array( + 'placeholder' => 'Email' + )); ?> + Form->input('password', array( + 'placeholder' => 'Password' + )); ?> + Form->input('remember', array( + 'label' => 'Remember me', + 'afterInput' => $this->Form->submit('Sign in', array( + 'class' => 'btn' + )) + )); ?> +Form->end(); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/inline_form.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/inline_form.ctp new file mode 100755 index 0000000..c6ae5b1 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/inline_form.ctp @@ -0,0 +1,28 @@ +Form->create('BoostCake', array( + 'inputDefaults' => array( + 'div' => false, + 'label' => false, + 'wrapInput' => false + ), + 'class' => 'well form-inline' +)); ?> + Form->input('email', array( + 'class' => 'input-small', + 'placeholder' => 'Email' + )); ?> + Form->input('password', array( + 'class' => 'input-small', + 'placeholder' => 'Password' + )); ?> + Form->input('remember', array( + 'label' => array( + 'text' => 'Remember me', + 'class' => 'checkbox' + ), + 'checkboxDiv' => false + )); ?> + Form->submit('Sign in', array( + 'div' => false, + 'class' => 'btn' + )); ?> +Form->end(); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/other_form.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/other_form.ctp new file mode 100755 index 0000000..875f3bf --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/other_form.ctp @@ -0,0 +1,107 @@ +Form->create('BoostCake', array( + 'inputDefaults' => array( + 'div' => 'control-group', + 'label' => array( + 'class' => 'control-label' + ), + 'wrapInput' => 'controls' + ), + 'class' => 'well form-horizontal' +)); ?> + Form->input('select', array( + 'label' => array( + 'text' => 'Select Nested Options' + ), + 'empty' => '選択してください', + 'options' => array( + '東京' => array( + 1 => '渋谷', + 2 => '秋葉原' + ), + '大阪' => array( + 3 => '梅田', + 4 => '難波' + ) + ), + )); ?> + Form->input('select', array( + 'label' => array( + 'text' => 'Select Nested Options Checkbox' + ), + 'class' => 'checkbox inline', + 'multiple' => 'checkbox', + 'options' => array( + '東京' => array( + 1 => '渋谷', + 2 => '秋葉原' + ), + '大阪' => array( + 3 => '梅田', + 4 => '難波' + ) + ) + )); ?> + Form->input('radio', array( + 'type' => 'radio', + 'before' => '', + 'legend' => false, + 'options' => array( + 1 => 'Option one is this and that—be sure to include why it\'s great', + 2 => 'Option two can be something else and selecting it will deselect option one' + ) + )); ?> + Form->input('username', array( + 'placeholder' => 'Username', + 'div' => 'control-group', + 'label' => array( + 'text' => 'Prepend', + ), + 'beforeInput' => '
@', + 'afterInput' => '
' + )); ?> + Form->input('price', array( + 'label' => array( + 'text' => 'Append', + ), + 'beforeInput' => '
', + 'afterInput' => '.00
' + )); ?> + Form->input('price_error', array( + 'label' => array( + 'text' => 'Append Error', + ), + 'beforeInput' => '
', + 'afterInput' => '.00
' + )); ?> + Form->input('password', array( + 'label' => array( + 'text' => 'Show Error Message' + ), + 'placeholder' => 'Password', + )); ?> + Form->input('password', array( + 'label' => array( + 'text' => 'Hide Error Message' + ), + 'placeholder' => 'Password', + 'errorMessage' => false + )); ?> + Form->input('checkbox', array( + 'label' => array('class' => null), + 'afterInput' => 'Checkbox Bootstrap Style' + )); ?> + Form->input('checkbox', array( + 'div' => false, + 'label' => false, + 'before' => '', + 'wrapInput' => 'controls', + 'afterInput' => 'Checkbox CakePHP Style' + )); ?> +
+ Form->submit('Save changes', array( + 'div' => false, + 'class' => 'btn btn-primary' + )); ?> + +
+Form->end(); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/pager.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/pager.ctp new file mode 100755 index 0000000..3579c75 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/pager.ctp @@ -0,0 +1,6 @@ +Paginator->pager(); ?> + +Paginator->pager(array( + 'prev' => '← Older', + 'next' => 'Newer →' +)); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/search_form.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/search_form.ctp new file mode 100755 index 0000000..2f1f591 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/search_form.ctp @@ -0,0 +1,16 @@ +Form->create('BoostCake', array( + 'inputDefaults' => array( + 'div' => false, + 'wrapInput' => false + ), + 'class' => 'well form-search' +)); ?> + Form->input('text', array( + 'label' => false, + 'class' => 'input-medium search-query', + )); ?> + Form->submit('Search', array( + 'div' => false, + 'class' => 'btn' + )); ?> +Form->end(); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/sizes_pagination.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/sizes_pagination.ctp new file mode 100755 index 0000000..854a77b --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/sizes_pagination.ctp @@ -0,0 +1,15 @@ +Paginator->pagination(array( + 'div' => 'pagination pagination-large' +)); ?> + +Paginator->pagination(array( + 'div' => 'pagination' +)); ?> + +Paginator->pagination(array( + 'div' => 'pagination pagination-small' +)); ?> + +Paginator->pagination(array( + 'div' => 'pagination pagination-mini' +)); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/standard_pagination.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/standard_pagination.ctp new file mode 100755 index 0000000..d1bd53a --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap2/standard_pagination.ctp @@ -0,0 +1,3 @@ +Paginator->pagination(array( + 'div' => 'pagination' +)); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/alerts.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/alerts.ctp new file mode 100755 index 0000000..247145c --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/alerts.ctp @@ -0,0 +1,25 @@ +Session->flash(); + +// Controller +$this->Session->setFlash(__('Alert success message testing...'), 'alert', array( + 'plugin' => 'BoostCake', + 'class' => 'alert-success' +)); + +$this->Session->setFlash(__('Alert info message testing...'), 'alert', array( + 'plugin' => 'BoostCake', + 'class' => 'alert-info' +)); + +$this->Session->setFlash(__('Alert warning message testing...'), 'alert', array( + 'plugin' => 'BoostCake', + 'class' => 'alert-warning' +)); + +$this->Session->setFlash(__('Alert danger message testing...'), 'alert', array( + 'plugin' => 'BoostCake', + 'class' => 'alert-danger' +)); +?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/default_form.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/default_form.ctp new file mode 100755 index 0000000..a51e4c4 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/default_form.ctp @@ -0,0 +1,25 @@ +Form->create('BoostCake', array( + 'inputDefaults' => array( + 'div' => 'form-group', + 'wrapInput' => false, + 'class' => 'form-control' + ), + 'class' => 'well' +)); ?> +
+ Legend + Form->input('text', array( + 'label' => 'Label name', + 'placeholder' => 'Type something…', + 'after' => 'Example block-level help text here.' + )); ?> + Form->input('checkbox', array( + 'label' => 'Check me out', + 'class' => false + )); ?> + Form->submit('Submit', array( + 'div' => 'form-group', + 'class' => 'btn btn-default' + )); ?> +
+Form->end(); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/horizontal_form.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/horizontal_form.ctp new file mode 100755 index 0000000..2d01637 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/horizontal_form.ctp @@ -0,0 +1,29 @@ +Form->create('BoostCake', array( + 'inputDefaults' => array( + 'div' => 'form-group', + 'label' => array( + 'class' => 'col col-md-3 control-label' + ), + 'wrapInput' => 'col col-md-9', + 'class' => 'form-control' + ), + 'class' => 'well form-horizontal' +)); ?> + Form->input('email', array( + 'placeholder' => 'Email' + )); ?> + Form->input('password', array( + 'placeholder' => 'Password' + )); ?> + Form->input('remember', array( + 'wrapInput' => 'col col-md-9 col-md-offset-3', + 'label' => 'Remember me', + 'class' => false + )); ?> +
+ Form->submit('Sign in', array( + 'div' => 'col col-md-9 col-md-offset-3', + 'class' => 'btn btn-default' + )); ?> +
+Form->end(); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/inline_form.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/inline_form.ctp new file mode 100755 index 0000000..69bc201 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/inline_form.ctp @@ -0,0 +1,25 @@ +Form->create('BoostCake', array( + 'inputDefaults' => array( + 'div' => 'form-group', + 'label' => false, + 'wrapInput' => false, + 'class' => 'form-control' + ), + 'class' => 'well form-inline' +)); ?> + Form->input('email', array( + 'placeholder' => 'Email' + )); ?> + Form->input('password', array( + 'placeholder' => 'Password' + )); ?> + Form->input('remember', array( + 'div' => 'checkbox', + 'class' => false, + 'label' => 'Remember me' + )); ?> + Form->submit('Sign in', array( + 'div' => 'form-group', + 'class' => 'btn btn-default' + )); ?> +Form->end(); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/other_form.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/other_form.ctp new file mode 100755 index 0000000..3e6fea2 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/other_form.ctp @@ -0,0 +1,111 @@ +Form->create('BoostCake', array( + 'inputDefaults' => array( + 'div' => 'form-group', + 'label' => array( + 'class' => 'col col-md-3 control-label' + ), + 'wrapInput' => 'col col-md-9', + 'class' => 'form-control' + ), + 'class' => 'well form-horizontal' +)); ?> + Form->input('select', array( + 'label' => array( + 'text' => 'Select Nested Options' + ), + 'empty' => '選択してください', + 'options' => array( + '東京' => array( + 1 => '渋谷', + 2 => '秋葉原' + ), + '大阪' => array( + 3 => '梅田', + 4 => '難波' + ) + ), + )); ?> + Form->input('select', array( + 'label' => array( + 'text' => 'Select Nested Options Checkbox' + ), + 'class' => 'checkbox-inline', + 'multiple' => 'checkbox', + 'options' => array( + '東京' => array( + 1 => '渋谷', + 2 => '秋葉原' + ), + '大阪' => array( + 3 => '梅田', + 4 => '難波' + ) + ) + )); ?> + Form->input('radio', array( + 'type' => 'radio', + 'before' => '', + 'legend' => false, + 'class' => false, + 'options' => array( + 1 => 'Option one is this and that—be sure to include why it\'s great', + 2 => 'Option two can be something else and selecting it will deselect option one' + ) + )); ?> + Form->input('username', array( + 'placeholder' => 'Username', + 'label' => array( + 'text' => 'Prepend', + ), + 'beforeInput' => '
@', + 'afterInput' => '
' + )); ?> + Form->input('price', array( + 'label' => array( + 'text' => 'Append', + ), + 'beforeInput' => '
', + 'afterInput' => '.00
' + )); ?> + Form->input('price_error', array( + 'label' => array( + 'text' => 'Append Error', + ), + 'beforeInput' => '
', + 'afterInput' => '.00
' + )); ?> + Form->input('password', array( + 'label' => array( + 'text' => 'Show Error Message' + ), + 'placeholder' => 'Password' + )); ?> + Form->input('password', array( + 'label' => array( + 'text' => 'Hide Error Message' + ), + 'placeholder' => 'Password', + 'errorMessage' => false + )); ?> + Form->input('checkbox', array( + 'wrapInput' => 'col col-md-9 col-md-offset-3', + 'label' => array('class' => null), + 'class' => false, + 'afterInput' => 'Checkbox Bootstrap Style' + )); ?> + Form->input('checkbox', array( + 'before' => '', + 'label' => false, + 'class' => false, + 'afterInput' => 'Checkbox CakePHP Style' + )); ?> +
+
+ Form->submit('Save changes', array( + 'div' => false, + 'class' => 'btn btn-primary' + )); ?> + +
+
+Form->end(); ?> diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/pager.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/pager.ctp new file mode 100755 index 0000000..3579c75 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/pager.ctp @@ -0,0 +1,6 @@ +Paginator->pager(); ?> + +Paginator->pager(array( + 'prev' => '← Older', + 'next' => 'Newer →' +)); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/sizes_pagination.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/sizes_pagination.ctp new file mode 100755 index 0000000..67b2cf8 --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/sizes_pagination.ctp @@ -0,0 +1,11 @@ +Paginator->pagination(array( + 'ul' => 'pagination pagination-lg' +)); ?> + +Paginator->pagination(array( + 'ul' => 'pagination' +)); ?> + +Paginator->pagination(array( + 'ul' => 'pagination pagination-sm' +)); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/standard_pagination.ctp b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/standard_pagination.ctp new file mode 100755 index 0000000..87d85ef --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Elements/bootstrap3/standard_pagination.ctp @@ -0,0 +1,3 @@ +Paginator->pagination(array( + 'ul' => 'pagination' +)); ?> \ No newline at end of file diff --git a/cakephp/app/Plugin/BoostCake/View/Helper/BoostCakeFormHelper.php b/cakephp/app/Plugin/BoostCake/View/Helper/BoostCakeFormHelper.php new file mode 100755 index 0000000..b02af8b --- /dev/null +++ b/cakephp/app/Plugin/BoostCake/View/Helper/BoostCakeFormHelper.php @@ -0,0 +1,290 @@ + array( + 'className' => 'BoostCake.BoostCakeHtml' + )); + + protected $_divOptions = array(); + + protected $_inputOptions = array(); + + protected $_inputType = null; + + protected $_fieldName = null; + +/** + * Overwrite FormHelper::input() + * + * - Generates a form input element complete with label and wrapper div + * + * ### Options + * + * See each field type method for more information. Any options that are part of + * $attributes or $options for the different **type** methods can be included in `$options` for input().i + * Additionally, any unknown keys that are not in the list below, or part of the selected type's options + * will be treated as a regular html attribute for the generated input. + * + * - `type` - Force the type of widget you want. e.g. `type => 'select'` + * - `label` - Either a string label, or an array of options for the label. See FormHelper::label(). + * - `div` - Either `false` to disable the div, or an array of options for the div. + * See HtmlHelper::div() for more options. + * - `options` - For widgets that take options e.g. radio, select. + * - `error` - Control the error message that is produced. Set to `false` to disable any kind of error reporting (field + * error and error messages). + * - `errorMessage` - Boolean to control rendering error messages (field error will still occur). + * - `empty` - String or boolean to enable empty select box options. + * - `before` - Content to place before the label + input. + * - `after` - Content to place after the label + input. + * - `between` - Content to place between the label + input. + * - `format` - Format template for element order. Any element that is not in the array, will not be in the output. + * - Default input format order: array('before', 'label', 'between', 'input', 'after', 'error') + * - Default checkbox format order: array('before', 'input', 'between', 'label', 'after', 'error') + * - Hidden input will not be formatted + * - Radio buttons cannot have the order of input and label elements controlled with these settings. + * + * Added options + * - `wrapInput` - Either `false` to disable the div wrapping input, or an array of options for the div. + * See HtmlHelper::div() for more options. + * - `checkboxDiv` - Wrap input checkbox tag's class. + * - `beforeInput` - Content to place before the input. + * - `afterInput` - Content to place after the input. + * - `errorClass` - Wrap input tag's error message class. + * + * @param string $fieldName This should be "Modelname.fieldname" + * @param array $options Each type of input takes different options. + * @return string Completed form widget. + * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#creating-form-elements + */ + public function input($fieldName, $options = array()) { + $this->_fieldName = $fieldName; + + $default = array( + 'error' => array( + 'attributes' => array( + 'wrap' => 'span', + 'class' => 'help-block text-danger' + ) + ), + 'wrapInput' => array( + 'tag' => 'div' + ), + 'checkboxDiv' => 'checkbox', + 'beforeInput' => '', + 'afterInput' => '', + 'errorClass' => 'has-error error' + ); + + if (isset($options['label']) && is_string($options['label'])) { + $options['label'] = array( + 'text' => $options['label'] + ); + } + + $options = Hash::merge( + $default, + $this->_inputDefaults, + $options + ); + + $this->_inputOptions = $options; + + $options['error'] = false; + if (isset($options['wrapInput'])) { + unset($options['wrapInput']); + } + if (isset($options['checkboxDiv'])) { + unset($options['checkboxDiv']); + } + if (isset($options['beforeInput'])) { + unset($options['beforeInput']); + } + if (isset($options['afterInput'])) { + unset($options['afterInput']); + } + if (isset($options['errorClass'])) { + unset($options['errorClass']); + } + + $inputDefaults = $this->_inputDefaults; + $this->_inputDefaults = array(); + + $html = parent::input($fieldName, $options); + + $this->_inputDefaults = $inputDefaults; + + if ($this->_inputType === 'checkbox') { + if (isset($options['before'])) { + $html = str_replace($options['before'], '%before%', $html); + } + $regex = '/()(.*?<\/label>)/'; + if (preg_match($regex, $html, $label)) { + $label = str_replace('$', '\$', $label); + $html = preg_replace($regex, '', $html); + $html = preg_replace( + '/()/', + $label[1] . '$1 ' . $label[2], + $html + ); + } + if (isset($options['before'])) { + $html = str_replace('%before%', $options['before'], $html); + } + } + + return $html; + } + +/** + * Overwrite FormHelper::_divOptions() + * + * - Generate inner and outer div options + * - Generate div options for input + * + * @param array $options Options list. + * @return array + */ + protected function _divOptions($options) { + $this->_inputType = $options['type']; + + $divOptions = array( + 'type' => $options['type'], + 'div' => $this->_inputOptions['wrapInput'] + ); + $this->_divOptions = parent::_divOptions($divOptions); + + $default = array('div' => array('class' => null)); + $options = Hash::merge($default, $options); + $divOptions = parent::_divOptions($options); + if ($this->tagIsInvalid() !== false) { + $divOptions = $this->addClass($divOptions, $this->_inputOptions['errorClass']); + } + return $divOptions; + } + +/** + * Overwrite FormHelper::_getInput() + * + * - Wrap `
` input element + * - Generates an input element + * + * @param array $args The options for the input element + * @return string The generated input element + */ + protected function _getInput($args) { + $input = parent::_getInput($args); + if ($this->_inputType === 'checkbox' && $this->_inputOptions['checkboxDiv'] !== false) { + $input = $this->Html->div($this->_inputOptions['checkboxDiv'], $input); + } + + $beforeInput = $this->_inputOptions['beforeInput']; + $afterInput = $this->_inputOptions['afterInput']; + + $error = null; + $errorOptions = $this->_extractOption('error', $this->_inputOptions, null); + $errorMessage = $this->_extractOption('errorMessage', $this->_inputOptions, true); + if ($this->_inputType !== 'hidden' && $errorOptions !== false) { + $errMsg = $this->error($this->_fieldName, $errorOptions); + if ($errMsg && $errorMessage) { + $error = $errMsg; + } + } + + $html = $beforeInput . $input . $afterInput . $error; + + if ($this->_divOptions) { + $tag = $this->_divOptions['tag']; + unset($this->_divOptions['tag']); + $html = $this->Html->tag($tag, $html, $this->_divOptions); + } + + return $html; + } + +/** + * Overwrite FormHelper::_selectOptions() + * + * - If $attributes['style'] is `` then replace `