function generate_stack_option() { $stack_option = json_decode(stripslashes($_POST['option']), true); $stack_config = json_decode(stripslashes($_POST['config']), true); $stack_subgroup = json_decode(stripslashes($_POST['subgroup']), true); if (!is_array($stack_subgroup)) { $stack_subgroup = array(); } $stack_subgroup[] = $_POST['stack_id']; // modify option id, toggle, toggle_group $extend = '-' . $_POST['stack_id']; $stack_config['stack_id'] = $_POST['stack_id']; $stack_config['subgroup'] = $stack_subgroup; // generate stack option $input_tool = new input_tool($stack_option, $stack_config); $input_tool->generate_stack_option(); }
function stack($option) { $value = $this->value($option); if ($value == '') { $value = array(); } // workaround for no stack // workaround for remove all stacks echo '<input type="hidden" name="' . $this->name($option) . '" />'; echo '<div class="stack_container" id="' . $this->id($option) . '-stack_container" name="' . $this->id($option) . '-stack_container">'; // Default Page Content Stack $page_content_stack = array('stack_id' => 0, 'template_id' => 'page_content'); if (isset($option['stack_builder']) && $option['stack_builder'] && !in_array($page_content_stack, $value)) { $value[] = $page_content_stack; } $subgroup = array(); if (isset($this->config['subgroup']) && is_array($this->config['subgroup'])) { $subgroup = $this->config['subgroup']; } $subgroup[] = $option['id']; // Empty Stack if (count($value) == 0) { echo '<div class="dummy-stack"></div>'; } foreach ($value as $stack) { if (!is_array($stack)) { continue; } $stack_stack_id = $stack['stack_id']; $stack_template_id = $stack['template_id']; $stack_template_title = ''; $stack_config = json_decode(json_encode($this->config), true); $stack_option = array(); // find template foreach ($option['templates'] as $template) { if ($template['id'] == $stack_template_id) { $stack_option = $template; break; } } // modify option id, toggle, toggle_group $extend = '-' . $stack_stack_id; $stack_config['stack_id'] = $stack_stack_id; $stack_config['subgroup'] = array_merge($subgroup, array($stack_stack_id)); // generate stack option $stack_input_tool = new input_tool($stack_option, $stack_config); $stack_input_tool->generate_stack_option($this->saved_data); } echo '</div>'; echo '<div class="stack_menu">'; $show_stack_select_template = count($option['templates']) > 1 ? '' : ' hidden'; echo '<select class="stack_select_template ' . $show_stack_select_template . '" id="' . $this->id($option) . '-stack_select">'; foreach ($option['templates'] as $template) { if (!in_array($template['id'], array('page_content'))) { echo '<option value="' . $template['id'] . '" opt="' . htmlspecialchars(json_encode($template), ENT_QUOTES) . '" conf="' . htmlspecialchars(json_encode($this->config), ENT_QUOTES) . '">' . $template['title'] . '</option>'; } } echo '</select>'; echo '<input class="button stack_add_button" type="button" id="' . $this->id($option) . '-add_button" subgroup="' . htmlspecialchars(json_encode($subgroup), ENT_QUOTES) . '" value="' . $option['stack_button'] . '" />'; echo '</div>'; }