| 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 = ''; |
| 7 |
protected $label = ''; |
| 8 |
protected $value = ''; |
| 9 |
|
| 10 |
protected $htmlId = ''; |
| 11 |
|
| 12 |
public function __construct( $htmlFactory, $name, $label = '', $value = '' ) |
| 13 |
{ |
| 14 |
static $useCount = 1; |
| 15 |
|
| 16 |
$this->htmlFactory = $htmlFactory; |
| 17 |
$this->name = $name; |
| 18 |
if( null !== $label ) |
| 19 |
$this->label = $label; |
| 20 |
if( null !== $value ) |
| 21 |
$this->setValue( $value ); |
| 22 |
|
| 23 |
$this->htmlId = ($useCount > 1) ? $this->name . $useCount : $this->name; |
| 24 |
$useCount++; |
| 25 |
} |
| 26 |
|
| 27 |
public function setValue( $value ) |
| 28 |
{ |
| 29 |
$this->value = $value; |
| 30 |
return $this; |
| 31 |
} |
| 32 |
|
| 33 |
public function htmlId() |
| 34 |
{ |
| 35 |
return $this->htmlId; |
| 36 |
} |
| 37 |
|
| 38 |
public function setHtmlId( $htmlId ) |
| 39 |
{ |
| 40 |
$this->htmlId = $htmlId; |
| 41 |
return $this; |
| 42 |
} |
| 43 |
|
| 44 |
public function htmlName() |
| 45 |
{ |
| 46 |
return $this->_prefix . $this->name; |
| 47 |
} |
| 48 |
|
| 49 |
public function name() |
| 50 |
{ |
| 51 |
return $this->name; |
| 52 |
} |
| 53 |
} |