Overview

Namespaces

  • Cakestrap
    • View
      • Helper

Classes

  • Cakestrap\View\Helper\AlertHelper
  • Cakestrap\View\Helper\AssetHelper
  • Cakestrap\View\Helper\BadgeHelper
  • Cakestrap\View\Helper\Basic
  • Cakestrap\View\Helper\ButtonItemsHelper
  • Cakestrap\View\Helper\CakestrapHelper
  • Cakestrap\View\Helper\CallOutHelper
  • Cakestrap\View\Helper\CollapseHelper
  • Cakestrap\View\Helper\DropdownHelper
  • Cakestrap\View\Helper\ListGroupHelper
  • Cakestrap\View\Helper\ModalHelper
  • Cakestrap\View\Helper\PanelHelper
  • Cakestrap\View\Helper\TabHelper
  • Cakestrap\View\Helper\TableHelper
  • Cakestrap\View\Helper\Templates
  • Cakestrap\View\Helper\WellHelper
  • Overview
  • Namespace
  • Class
  1: <?php
  2: /**
  3:  * Copyright (c) CMNWorks
  4:  *
  5:  * Licensed under The MIT License
  6:  * For full copyright and license information, please see the LICENSE.txt
  7:  * Redistributions of files must retain the above copyright notice.
  8:  *
  9:  * @copyright     Copyright (c) CMNWorks Christopher M. Natan
 10:  * @author        Christopher M. Natan
 11:  * @link          http://cmnworks.com
 12:  * @since         1.8.8
 13:  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 14:  */
 15: namespace Cakestrap\View\Helper;
 16: 
 17: /**
 18:  * List group items may be buttons instead of list items.
 19:  *
 20:  * <code>
 21:  * <?php
 22:  * echo $this->Cakestrap->ButtonItems()
 23:  *                      ->button("One")
 24:  *                      ->button("Two")
 25:  *                      ->button("Three")
 26:  *                      ->set()
 27:  * ?>
 28:  * </code>
 29:  *
 30:  * @method options(array $options)
 31:  *
 32:  * @package Cakestrap\View\Helper
 33:  * @link http://getbootstrap.com/components/#list-group-buttons
 34:  */
 35: class ButtonItemsHelper extends Basic
 36: {
 37:     /**
 38:      * Default helper options.
 39:      * These options are merged with the user-provided options.
 40:      *
 41:      * @var array
 42:      */
 43:     protected  $_options  = [ 'class' => null ];
 44: 
 45:     /**
 46:      * An array to hold the button items
 47:      *
 48:      * @var array
 49:      */
 50:     protected $_button = [];
 51: 
 52:     /**
 53:      * Set the button items
 54:      *
 55:      * @param string $button
 56:      * @return object $this
 57:      */
 58:     public function button($button = null)
 59:     {
 60:         $this->_button[] = $this->_stringTemplate->format('button', ['button'=>$button]);;
 61:         return $this;
 62:     }
 63: 
 64:     /**
 65:      * Set all defined values.
 66:      * This will return the final html template.
 67:      *
 68:      * @return string $container
 69:      */
 70:     public function set()
 71:     {
 72:         $this->_setButton();
 73:         $this->_addToContainer();
 74:         $this->_reset();
 75: 
 76:         return $this->_container;
 77:     }
 78: 
 79:     /**
 80:      * Extract all the button items
 81:      *
 82:      * @return void
 83:      */
 84:     protected function _setButton()
 85:     {
 86:         $button = implode("", $this->_button);
 87:         $this->_button = $button;
 88:     }
 89: 
 90:     /**
 91:      * Add all button items to parent container
 92:      *
 93:      * @return void
 94:      */
 95:     protected function _addToContainer()
 96:     {
 97:         $this->_container = $this->_stringTemplate->format('container', [
 98:             'container' => $this->_button,
 99:             'class' => $this->_options['class']]);
100:     }
101: }
API documentation generated by ApiGen