/home/coolpkct/www/websites/cake3.cool.rocks/admin/classes/checkboxfield.php
<?php
/**
 * Part of Showkase web site management package
 *
 * @package Showkase
 * @author Jack Hardie {@link http://www.jhardie.com}
 * @copyright Copyright (c) 2012, SimpleViewer Inc.
 */
defined('SK_ACCESS')||die('<h1>403: Forbidden</h1>');
$ds = DIRECTORY_SEPARATOR;
require_once "classes{$ds}formfield.php";
 
/**
 * Html form input
 *
 * @package Showkase
 */
class CheckboxField extends FormField
{
    /**
     * @var array values
     */
    private $unchecked = 'false';
    
    /**
     * @var array values
     */
    private $checked = 'true';
    
    /**
     * constructor
     */
    public function __construct(array $iniVars)
    {
        parent::__construct($iniVars);
        if (isset($iniVars['values'][0])) {
            $this->unchecked = $iniVars['values'][0];
        }
        if (isset($iniVars['values'][1])) {
            $this->checked = $iniVars['values'][1];
        }
    }
    
    /**
     * Formats html string
     * Used outside the print/echo context
     *
     * @return string
     */
    public function getHtml(&$tab)
    {
        $tab++;
        $label = $this->getLabel();
        $checkString = (strtolower($this->value) == $this->checked)
            ? 'checked'
            : '';
        $html = <<<EOD
<div class="control-group">
  {$label}
  <div class="input">
    <input type="hidden" name="{$this->name}" value="{$this->unchecked}"><input type="checkbox" class="checkbox" name="{$this->name}" value="{$this->checked}" id="{$this->id}" tabindex="{$tab}" {$checkString}>
  </div>
</div>
EOD;
      return $html;
    }
}