| 1 |
<?php |
| 2 |
|
| 3 |
class VP_Control_Field_HTML extends VP_Control_Field |
| 4 |
{ |
| 5 |
|
| 6 |
protected $_height; |
| 7 |
|
| 8 |
public function __construct() |
| 9 |
{ |
| 10 |
parent::__construct(); |
| 11 |
} |
| 12 |
|
| 13 |
public static function withArray($arr = array(), $class_name = null) |
| 14 |
{ |
| 15 |
if(is_null($class_name)) |
| 16 |
$instance = new self(); |
| 17 |
else |
| 18 |
$instance = new $class_name; |
| 19 |
$instance->_basic_make($arr); |
| 20 |
$instance->set_height(isset($arr['height']) ? $arr['height'] : 'auto'); |
| 21 |
return $instance; |
| 22 |
} |
| 23 |
|
| 24 |
protected function _setup_data() |
| 25 |
{ |
| 26 |
$this->add_data('height', $this->get_height()); |
| 27 |
parent::_setup_data(); |
| 28 |
} |
| 29 |
|
| 30 |
public function render($is_compact = false) |
| 31 |
{ |
| 32 |
// Setup Data |
| 33 |
$this->_setup_data(); |
| 34 |
$this->add_data('is_compact', $is_compact); |
| 35 |
return VP_View::instance()->load('control/html', $this->get_data()); |
| 36 |
} |
| 37 |
|
| 38 |
public function set_value($_value) |
| 39 |
{ |
| 40 |
// normalize linebreak to \n for all saved data |
| 41 |
if( is_string($_value) ) |
| 42 |
{ |
| 43 |
$_value = str_replace(array("\r\n", "\r"), "\n", $_value); |
| 44 |
} |
| 45 |
$this->_value = $_value; |
| 46 |
return $this; |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
/** |
| 51 |
* Get the Height of the Container |
| 52 |
* |
| 53 |
* @return String Height of the Container |
| 54 |
*/ |
| 55 |
public function get_height() { |
| 56 |
return $this->_height; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Set the Height of the Container |
| 61 |
* |
| 62 |
* @param String $_status Height of the Container |
| 63 |
*/ |
| 64 |
public function set_height($_height) { |
| 65 |
$this->_height = $_height; |
| 66 |
return $this; |
| 67 |
} |
| 68 |
|
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* EOF |
| 73 |
*/ |