| 1 |
<?php |
| 2 |
|
| 3 |
class VP_Option_Control_Group_Section extends VP_Option_Control_Group |
| 4 |
{ |
| 5 |
|
| 6 |
/** |
| 7 |
* Collection of fields |
| 8 |
* @var VP_Control_Field |
| 9 |
*/ |
| 10 |
private $_fields; |
| 11 |
|
| 12 |
/** |
| 13 |
* dependency pattern string |
| 14 |
* @var String |
| 15 |
*/ |
| 16 |
protected $_dependency; |
| 17 |
|
| 18 |
/** |
| 19 |
* Whether to hide this control in first rendering |
| 20 |
*/ |
| 21 |
protected $_is_hidden; |
| 22 |
|
| 23 |
public function __construct() |
| 24 |
{ |
| 25 |
parent::__construct(); |
| 26 |
$this->_fields = array(); |
| 27 |
} |
| 28 |
|
| 29 |
public function render($extra = array()) |
| 30 |
{ |
| 31 |
// Setup data |
| 32 |
$this->_setup_data(); |
| 33 |
|
| 34 |
if($this->is_hidden()) |
| 35 |
{ |
| 36 |
$this->add_container_extra_classes('vp-hide'); |
| 37 |
} |
| 38 |
|
| 39 |
$this->add_data('section', $this); |
| 40 |
$this->add_data('container_extra_classes', implode(' ', $this->get_container_extra_classes())); |
| 41 |
|
| 42 |
foreach ($extra as $key => $value) |
| 43 |
{ |
| 44 |
$this->add_data($key, $value); |
| 45 |
} |
| 46 |
return VP_View::instance()->load('option/section', $this->get_data()); |
| 47 |
} |
| 48 |
|
| 49 |
public function add_field($field) |
| 50 |
{ |
| 51 |
$this->_fields[] = $field; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Getter of fields |
| 56 |
* |
| 57 |
* @return Array Collection of fields object |
| 58 |
*/ |
| 59 |
public function get_fields() { |
| 60 |
return $this->_fields; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Setter of fields |
| 65 |
* |
| 66 |
* @param Array $_fields Collection of fields object |
| 67 |
*/ |
| 68 |
public function set_fields($_fields) { |
| 69 |
$this->_fields = $_fields; |
| 70 |
return $this; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Getter for $_dependency |
| 75 |
* |
| 76 |
* @return String dependency pattern in string |
| 77 |
*/ |
| 78 |
public function get_dependency() { |
| 79 |
return $this->_dependency; |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* Setter for $_dependency |
| 84 |
* |
| 85 |
* @param String $_dependency dependency pattern in string |
| 86 |
*/ |
| 87 |
public function set_dependency($_dependency) { |
| 88 |
$this->_dependency = $_dependency; |
| 89 |
return $this; |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* Get is_hidden status, will set the status if a boolean passed |
| 94 |
* |
| 95 |
* @return bool is_hidden status |
| 96 |
*/ |
| 97 |
public function is_hidden($_is_hidden = null) { |
| 98 |
if(!is_null($_is_hidden)) |
| 99 |
$this->_is_hidden = (bool) $_is_hidden; |
| 100 |
return $this->_is_hidden; |
| 101 |
} |
| 102 |
|
| 103 |
} |