psf
checkbox.php
1 <?php
2 
3 // Part of php simple framework (psf)
4 
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 
15 // Copyright (c) Petr Bena <petr@bena.rocks> 2015 - 2018
16 
17 if (!defined("PSF_ENTRY_POINT"))
18  die("Not a valid psf entry point");
19 
20 require_once (dirname(__FILE__) . "/../html/checkbox.php");
21 
22 class BS_CheckBox extends CheckBox
23 {
24  public $Inline = false;
25  public function __construct($_name = NULL, $_value = NULL, $_checked = false, $bs_class = NULL, $_parent = NULL, $_text = NULL)
26  {
27  $this->ClassName = "checkbox";
28  if ($bs_class !== NULL)
29  $this->ClassName .= " " . $bs_class;
30  parent::__construct($_name, $_value, $_checked, $_parent, $_text);
31  }
32 
33  public function ToHtml()
34  {
35  $extras = "";
36  if (!$this->Enabled)
37  $extras .= " disabled";
38  if ($this->Inline)
39  return "<div class=\"checkbox-inline\"" . $extras . ">" . parent::ToHtml() . "</div>";
40  else
41  return "<div class=\"checkbox\"" . $extras . ">" . parent::ToHtml() . "</div>";
42  }
43 }