Hawk - PHP documentation
  • Namespace
  • Class
  • Tree

Namespaces

  • Hawk
    • View
      • Plugins

Classes

  • Hawk\App
  • Hawk\ButtonInput
  • Hawk\Cache
  • Hawk\CheckboxInput
  • Hawk\ColorInput
  • Hawk\Conf
  • Hawk\Controller
  • Hawk\Crypto
  • Hawk\DatabaseSessionHandler
  • Hawk\DatetimeInput
  • Hawk\DB
  • Hawk\DBExample
  • Hawk\DeleteInput
  • Hawk\Dialogbox
  • Hawk\EmailInput
  • Hawk\ErrorHandler
  • Hawk\Event
  • Hawk\FileInput
  • Hawk\FileSystem
  • Hawk\FloatInput
  • Hawk\Form
  • Hawk\FormFieldset
  • Hawk\FormInput
  • Hawk\GenericModel
  • Hawk\GifImage
  • Hawk\HawkApi
  • Hawk\HawkUpdater
  • Hawk\HiddenInput
  • Hawk\HtmlInput
  • Hawk\HTTPRequest
  • Hawk\Icon
  • Hawk\Image
  • Hawk\IntegerInput
  • Hawk\ItemList
  • Hawk\ItemListField
  • Hawk\JpegImage
  • Hawk\Lang
  • Hawk\Language
  • Hawk\LeftSidebarTab
  • Hawk\Less
  • Hawk\Logger
  • Hawk\Mail
  • Hawk\MenuItem
  • Hawk\Model
  • Hawk\NoSidebarTab
  • Hawk\NumberInput
  • Hawk\ObjectInput
  • Hawk\Option
  • Hawk\Panel
  • Hawk\PasswordInput
  • Hawk\Permission
  • Hawk\Plugin
  • Hawk\PluginInstaller
  • Hawk\PngImage
  • Hawk\ProfileQuestion
  • Hawk\ProfileQuestionValue
  • Hawk\RadioInput
  • Hawk\Request
  • Hawk\Response
  • Hawk\RightSidebarTab
  • Hawk\Role
  • Hawk\RolePermission
  • Hawk\Route
  • Hawk\Router
  • Hawk\SelectInput
  • Hawk\Session
  • Hawk\Singleton
  • Hawk\SubmitInput
  • Hawk\Tabs
  • Hawk\TextareaInput
  • Hawk\TextInput
  • Hawk\Theme
  • Hawk\TimeInput
  • Hawk\Upload
  • Hawk\User
  • Hawk\View
  • Hawk\View\Plugins\Accordion
  • Hawk\View\Plugins\Button
  • Hawk\View\Plugins\Form
  • Hawk\View\Plugins\Icon
  • Hawk\View\Plugins\Import
  • Hawk\View\Plugins\Panel
  • Hawk\View\Plugins\Tabs
  • Hawk\View\Plugins\Text
  • Hawk\View\Plugins\Uri
  • Hawk\View\Plugins\Widget
  • Hawk\ViewPlugin
  • Hawk\Widget
  • Hawk\WysiwygInput

Traits

  • Hawk\Utils

Exceptions

  • Hawk\AppStopException
  • Hawk\DBExampleException
  • Hawk\DBException
  • Hawk\FileSystemException
  • Hawk\HawkApiException
  • Hawk\ImageException
  • Hawk\MailException
  • Hawk\UploadException
  • Hawk\ViewException
  1 <?php
  2 /**
  3  * ButtonInput.php
  4  *
  5  * @author  Elvyrra SAS
  6  * @license http://rem.mit-license.org/ MIT
  7  */
  8 
  9 namespace Hawk;
 10 
 11 /**
 12  * This class describes the button inputs in form (button, delete, dans submit)
 13  *
 14  * @package Form\Input
 15  */
 16 class ButtonInput extends FormInput{
 17     // the type of the input
 18     const TYPE = "button";
 19     // this type of input is independant, so not inserted in database
 20     const INDEPENDANT = true;
 21 
 22     /**
 23      * Defines the icons for most common buttons
 24      *
 25      * @static array $defaultIcons
 26      */
 27     private static $defaultIcons = array(
 28         'valid' => 'save',
 29         'save' => 'save',
 30         'cancel' => 'ban',
 31         'close' => 'times',
 32         'delete' => 'times',
 33         'back' => 'reply',
 34         'next' => 'step-forward',
 35         'previous' => 'step-backward',
 36         'send' => 'mail-closed'
 37     );
 38 
 39     /**
 40      * Defines if the input has to be displayed on a new line. For button inputs, this property is defaulty set to false
 41      *
 42      * @var boolean
 43      */
 44     public $nl = false;
 45 
 46     /**
 47      * Display the input
 48      *
 49      * @return string The dislayed HTML
 50      */
 51     public function display(){
 52         if(!empty($this->notDisplayed)) {
 53             return '';
 54         }
 55 
 56         $param = get_object_vars($this);
 57         $param["class"] .= " form-button";
 58         if(empty($param['icon']) && isset(self::$defaultIcons[$this->name]))
 59         $param['icon'] = self::$defaultIcons[$this->name];
 60 
 61         $param = array_filter(
 62             $param, function ($v) {
 63                 return !empty($v);
 64             }
 65         );
 66 
 67         if(!isset($param['label'])) {
 68             $param['label'] = $this->value;
 69         }
 70         $param['type'] = static::TYPE;
 71 
 72         $param = array_intersect_key($param, array_flip(array('id', 'class', 'icon', 'label', 'type', 'name', 'onclick', 'style', 'href', 'target', 'title')));
 73         $param = array_merge($param, $this->attributes);
 74 
 75         /*** Set the attributes of the button ***/
 76         if(!preg_match("!\bbtn-\w+\b!", $param['class'])) {
 77             $param['class'] .= " btn-default";
 78         }
 79 
 80         /*** Set the attribute and text to the span inside the button ***/
 81         $param = array_map(
 82             function ($v) {
 83                 return htmlentities($v, ENT_QUOTES);
 84             }, $param
 85         );
 86 
 87         return View::make(
 88             Theme::getSelected()->getView('button.tpl'), array(
 89             'class' => isset($param['class']) ? $param['class'] : '',
 90             'param' => $param,
 91             'icon' => isset($param['icon']) ? $param['icon'] : '',
 92             'label' => isset($param['label']) ? $param['label'] : '',
 93             'textStyle' => isset($param['textStyle']) ? $param['textStyle'] : '',
 94             )
 95         );
 96     }
 97 
 98 
 99     /**
100      * Check the submitted value
101      *
102      * @param Form $form The form the input is associated with
103      *
104      * @return bool This function always return true, because no value is expected from a button
105      */
106     public function check(&$form = null){
107         return true;
108     }
109 }
110 
Hawk - PHP documentation API documentation generated by ApiGen