| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
abstract class HC3_Ui_Abstract_Input extends HC3_Ui_Abstract_Element |
| 3 |
{ |
| 4 |
protected $htmlFactory = NULL; |
| 5 |
protected $_prefix = 'hc-'; |
| 6 |
protected $name = NULL; |
| 7 |
protected $label = NULL; |
| 8 |
protected $value = NULL; |
| 9 |
|
| 10 |
protected $htmlId = NULL; |
| 11 |
|
| 12 |
public function __construct( $htmlFactory, $name, $label = NULL, $value = NULL ) |
| 13 |
{ |
| 14 |
static $useCount = 1; |
| 15 |
|
| 16 |
$this->htmlFactory = $htmlFactory; |
| 17 |
$this->name = $name; |
| 18 |
$this->label = $label; |
| 19 |
$this->setValue( $value ); |
| 20 |
|
| 21 |
$this->htmlId = ($useCount > 1) ? $this->name . $useCount : $this->name; |
| 22 |
$useCount++; |
| 23 |
} |
| 24 |
|
| 25 |
public function setValue( $value ) |
| 26 |
{ |
| 27 |
$this->value = $value; |
| 28 |
return $this; |
| 29 |
} |
| 30 |
|
| 31 |
public function htmlId() |
| 32 |
{ |
| 33 |
return $this->htmlId; |
| 34 |
} |
| 35 |
|
| 36 |
public function setHtmlId( $htmlId ) |
| 37 |
{ |
| 38 |
$this->htmlId = $htmlId; |
| 39 |
return $this; |
| 40 |
} |
| 41 |
|
| 42 |
public function htmlName() |
| 43 |
{ |
| 44 |
return $this->_prefix . $this->name; |
| 45 |
} |
| 46 |
|
| 47 |
public function name() |
| 48 |
{ |
| 49 |
return $this->name; |
| 50 |
} |
| 51 |
} |