public function sweaver_plugin_editor::sweaver_form_render in Sweaver 7
Same name and namespace in other branches
- 6 plugins/sweaver_plugin_editor/sweaver_plugin_editor.inc \sweaver_plugin_editor::sweaver_form_render()
Frontend form render.
Overrides sweaver_plugin::sweaver_form_render
File
- plugins/
sweaver_plugin_editor/ sweaver_plugin_editor.inc, line 244 - Properties editor class.
Class
- sweaver_plugin_editor
- @file Properties editor class.
Code
public function sweaver_form_render(&$vars, &$form, $plugin) {
$name = $plugin['name'];
$vars['tabs'][$name]['#tab_name'] = $form[$name]['#tab_name'];
$vars['tabs_data'][$name]['#tab_description'] = $form[$name]['#tab_description'];
$output = '';
$output .= '<div id="sweaver-editor" class="clearfix">';
// Tab switcher.
$output .= drupal_render($form[$name]['form']['editor_switcher']);
// Containers.
$vertical_tabs = '';
$containers = '';
foreach ($form[$name]['form']['#editor_containers'] as $key => $container_value) {
// Set the first tab as active by default.
$tab_class = '';
if ($key == 'one') {
$tab_class = 'class="active"';
}
// Combine all vertical tabs.
$vertical_tabs .= '<div id="tab-' . $key . '" class="vertical-tab"><a href="#" ' . $tab_class . '>' . $container_value['title'] . '</a></div>';
//TODO: All of the container count method has to be rethought
// Combine all properties in containers.
$i = 0;
$container_count = 1;
$container_total = 1;
foreach ($container_value['properties'] as $property) {
//var_dump($form[$name]['form'][$property]);
if (isset($form[$name]['form'][$property]['#theme'])) {
if ($form[$name]['form'][$property]['#theme'] == 'table') {
$form[$name]['form'][$property]['#rows'] = $this
->sweaver_recursive_table_element($form[$name]['form'][$property]['#rows'], $form[$name]['form'][$property]);
$i = 4;
// The container is closed after the table
}
elseif ($form[$name]['form'][$property]['#name'] == 'background-image') {
$i = 4;
// The container is closed after the table
}
}
$i++;
if ($i == 5) {
$container_total++;
$i = 0;
}
}
$i = 0;
$containers .= '<div id="container-' . $key . '" class="container-wrapper">';
foreach ($container_value['properties'] as $property) {
if ($i == 0) {
// Add first/last classes to the containers.
$container_class = '';
if ($container_count == 1) {
$container_class .= ' container-first';
}
if ($container_total == $container_count) {
$container_class .= ' container-last';
}
$containers .= '<div class="container ' . $container_class . '"><div class="container-inner">';
}
if (isset($form[$name]['form'][$property]['#theme'])) {
if ($form[$name]['form'][$property]['#theme'] == 'table') {
$form[$name]['form'][$property]['#rows'] = $this
->sweaver_recursive_table_element($form[$name]['form'][$property]['#rows'], $form[$name]['form'][$property]);
$i = 4;
// The container is closed after the table
}
elseif ($form[$name]['form'][$property]['#name'] == 'background-image') {
$i = 4;
// The container is closed after the table
}
}
$containers .= drupal_render($form[$name]['form'][$property]);
$i++;
if ($i == 5) {
$containers .= '</div></div>';
$container_count++;
$i = 0;
}
}
if ($i != 0) {
$containers .= '</div></div>';
}
$containers .= '</div>';
}
$output .= '<div class="vertical-tabs">' . $vertical_tabs . '</div>';
$output .= '<div class="vertical-content">' . $containers . '</div>';
$output .= '</div>';
$vars['tabs_data'][$name]['content'] = $output;
}