diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2011-10-11 18:48:36 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2011-10-11 18:48:36 -0300 |
commit | 85cfc842e9d3af84c41ab674abd646c732a1931d (patch) | |
tree | 12de03e4c020e4c40b3089f3765baf369e993334 | |
parent | 8464818a77538dc4fa157f4347a50208fd949ac1 (diff) | |
download | muambeiro-85cfc842e9d3af84c41ab674abd646c732a1931d.tar.gz muambeiro-85cfc842e9d3af84c41ab674abd646c732a1931d.tar.bz2 |
Adding tabs panels plugin
-rw-r--r-- | muambeiro.info | 5 | ||||
-rw-r--r-- | plugins/styles/tabs.inc | 86 |
2 files changed, 90 insertions, 1 deletions
diff --git a/muambeiro.info b/muambeiro.info index dc3c2e9..49ff5a4 100644 --- a/muambeiro.info +++ b/muambeiro.info @@ -45,8 +45,11 @@ features[] = node_user_picture features[] = comment_user_picture features[] = comment_user_verification +; STYLES +;------------------------------------------------------------------------------- +plugins[panels][styles] = plugins/styles + ; Information added by drupal.org packaging script on January 1, 1970 - 00:00 version = "7.x-0.1" core = "7.x" project = "muambeiro" - diff --git a/plugins/styles/tabs.inc b/plugins/styles/tabs.inc new file mode 100644 index 0000000..8076f73 --- /dev/null +++ b/plugins/styles/tabs.inc @@ -0,0 +1,86 @@ +<?php + +/** + * @file + * Definition of the 'vertical tabs' panel style. + * See https://drupal.org/node/1101536 + */ + +// Plugin definition +$plugin = array( + 'title' => t('Tabs'), + 'description' => t('Presents the panes in a tabs fieldset.'), + 'render region' => 'panels_tabs_style_render_region', + 'settings form' => 'panels_tabs_style_settings_form', + 'settings validate' => 'panels_tabs_style_settings_validate', +); + +/** + * Render callback. + * + * @ingroup themeable + */ +function theme_panels_tabs_style_render_region($vars) { + $display = $vars['display']; + $region_id = $vars['region_id']; + $panes = $vars['panes']; + $settings = $vars['settings']; + + //Build items and fieldset + $items = array(); + $owner = $vars['owner_id']; + + $build[$owner] = array( + '#type' => 'vertical_tabs', + '#weight' => 99, + ); + + foreach ($panes as $pane_id => $item) { + + // Only getting the "Override Title" for now... needs work to get the pane title + $title = $display->content[$pane_id]->configuration['override_title_text']; + $pane_class = "pane_" . $pane_id; + + $build[$pane_class] = array( + '#type' => 'fieldset', + '#title' => $title, + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#group' => $owner, + '#attributes' => array( + 'class' => array($pane_class), + ), + '#tree' => TRUE, + '#weight' => -2, + ); + + $build[$pane_class]['items'] = array( + '#markup' => $item, + ); + } + + return theme($settings['tabs_type'], array( + 'element' => array( + '#children' => render($build), + ), + )); +} + +/** + * Settings form callback. + */ +function panels_tabs_style_settings_form($style_settings) { + //Vertical tabs are in core + $options['vertical_tabs'] = t('Vertical'); + //field_group.module allows same structure, for horizontal tabs + if (module_exists('field_group')) $options['horizontal_tabs'] = t('Horizontal'); + + $form['tabs_type'] = array( + '#type' => 'select', + '#title' => t('Tabs type'), + '#options' => $options, + '#default_value' => (isset($style_settings['tabs_type'])) ? $style_settings['tabs_type'] : 'vertical_tabs', + ); + + return $form; +} |