'',
'type' => 'group',
'layout' => 'table',
'show_header' => true,
'controls' => array(),
'default_value' => array(),
'show_controls' => false
);
public function RsGroup(){
$this->addControl('group', 'group');
}
public function render($options = array()){
if(!$options = $this->parseOptions($options)){
return $this->renderError();
}
if(empty($options['name'])) {
$options['wrap_id'] = uniqid('rs-group-');
}
else{
$options['name'] = str_replace('[]', '', $options['name']);
}
$wrapid = $this->addConditionalLogic($options);
if(!is_array($options['controls'])){
return rs::message('Controls must be an array.', 'Group ' . $options['name']);
}
if(!is_array($options['value'])){
$options['value'] = array();
}
$render_by = null;
if(empty($options['name'])){
if(isset($options['render_by'])){
if($options['render_by'] == 'metabox'){
$render_by = 'metabox';
}
elseif($options['render_by'] == 'cpanel'){
$render_by = 'cpanel';
}
}
}
foreach($options['controls'] as $key => $control){
if(is_array($control)){
if(empty($control['name']) && $control['type'] != 'group'){
$control['name'] = $control['type'];
}
if(empty($control['label']) && isset($control['name'])){
$control['label'] = ucfirst($control['name']);
}
if(empty($control['description'])){
$control['description'] = '';
}
if(isset($control['name']) && isset($options['value'][$control['name']])){
$control['value'] = $options['value'][$control['name']];
}
elseif(isset($control['name']) && $control['name']){
if($render_by == 'metabox'){
$control['value'] = rs::getField($control['name'], $options['render_for'] . '_' . $options['render_object_id']);
}
elseif($render_by == 'cpanel'){
$control['value'] = rs::getOption($control['name']);
}
}
if( isset($control['type']) && $control['type'] == 'group'){
$control['render_by'] = $options['render_by'];
$control['render_for'] = $options['render_for'];
$control['render_object_id'] = $options['render_object_id'];
}
if(isset($control['name']) && $options['name']){
$control['name'] = $options['name'].'['.$control['name'].']';
$control['name_prefix'] = null;
}
elseif($options['name_prefix']){
$control['name_prefix'] = $options['name_prefix'];
}
elseif(empty($control['name_prefix'] )){
$control['name_prefix'] = null;
}
$options['controls'][$key] = $control;
}
else{
unset($options['controls'][$key]);
}
}
$class_box_closed = (isset($options['show_controls']) && $options['show_controls'] ) ? '' : ' closed';
?>
renderRowLayout($options);
}
elseif($options['layout'] == 'none'){
$this->renderNoneLayout($options);
}
else{
$this->renderTableLayout($options);
}
?>
renderError($return['message']);
}
}
function renderTableLayout($options){
?>
renderError('Group could be child controls');
return;
}
else{
$width = 100/count($options['controls']);
foreach($options['controls'] as $key=>$control) { ?>
|
|
$control) { ?>
|
renderControl($control);
if($control['description']){
?>
|
|
|
renderControl($control);
if($control['description']){
?>
|
';
if($options['show_header']) {
echo ($check ? '' : '');
?>
' : '');
}
echo ($check ? '
' : '');
$this->renderControl($control);
echo ($check ? '
' : '');
echo ($check ? '
' : '');
echo '
';
}
}
public function serializeName($name, $name_prefix){
return str_replace(" ", "_", $name_prefix . $name);
}
}
rs::loadStyle('rs-group', RS_LIB_URL . '/controls/group/group.css');
rs::loadScript('rs-group', RS_LIB_URL . '/controls/group/group.js');