? 558614-tabs-d7.patch Index: tabs.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tabs/tabs.admin.inc,v retrieving revision 1.5 diff -u -p -r1.5 tabs.admin.inc --- tabs.admin.inc 18 Jan 2010 06:30:10 -0000 1.5 +++ tabs.admin.inc 2 Dec 2010 23:08:28 -0000 @@ -11,47 +11,55 @@ */ function tabs_admin_settings() { $form = array(); - $form['tabs_slide'] = array( + $form['effects'] = array( + '#type' => 'fieldset', + '#title' => t('Effects'), + ); + $form['effects']['tabs_slide'] = array( '#type' => 'radios', '#title' => t('Slide effect'), '#description' => t('Apply slide effect when changing tabs.'), '#default_value' => variable_get('tabs_slide', 0), '#options' => array(t('disabled'), t('enabled')), ); - $form['tabs_fade'] = array( + $form['effects']['tabs_fade'] = array( '#type' => 'radios', '#title' => t('Fade effect'), '#description' => t('Apply fade effect when changing tabs.'), '#default_value' => variable_get('tabs_fade', 0), '#options' => array(t('disabled'), t('enabled')), ); - $form['tabs_speed'] = array( + $form['effects']['tabs_speed'] = array( '#type' => 'radios', '#title' => t('Effect speed'), '#description' => t('Speed at which to apply effects.'), '#default_value' => variable_get('tabs_speed', 'fast'), '#options' => array('slow' => t('slow'), 'fast' => t('fast'), '1' => t('immediate')), ); - $form['tabs_navigation'] = array( + $form['navigation'] = array( + '#type' => 'fieldset', + '#title' => t('Navigation'), + ); + $form['navigation']['tabs_navigation'] = array( '#type' => 'radios', '#title' => t('Navigation buttons'), '#description' => t('Enable to add "next" and "previous" buttons to the bottom of all tab sets.'), '#default_value' => variable_get('tabs_navigation', 0), '#options' => array(t('disabled'), t('enabled')), ); - $form['tabs_nav_next'] = array( + $form['navigation']['tabs_nav_next'] = array( '#type' => 'textfield', '#title' => t('Next button caption'), '#description' => t('The text to be displayed in the \'next\' button.'), '#default_value' => variable_get('tabs_nav_next', t('next')), ); - $form['tabs_nav_prev'] = array( + $form['navigation']['tabs_nav_prev'] = array( '#type' => 'textfield', '#title' => t('Previous button caption'), '#description' => t('The text to be displayed in the \'previous\' button.'), '#default_value' => variable_get('tabs_nav_prev', t('previous')), ); - $form['tabs_navigation_titles'] = array( + $form['navigation']['tabs_navigation_titles'] = array( '#type' => 'radios', '#title' => t('Take captions from tab titles'), '#description' => t('Enable to use tht titles of the next or previous tabs for "next" and "previous" button captions. If this option is enabled, the next and previous captions above will be ignored.'), @@ -65,6 +73,5 @@ function tabs_admin_settings() { '#default_value' => variable_get('tabs_descriptive_urls', 0), '#options' => array(t('disabled'), t('enabled')), ); - $form = system_settings_form($form); - return $form; + return system_settings_form($form); } Index: tabs.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tabs/tabs.info,v retrieving revision 1.3 diff -u -p -r1.3 tabs.info --- tabs.info 26 Aug 2009 15:12:08 -0000 1.3 +++ tabs.info 2 Dec 2010 23:08:28 -0000 @@ -1,4 +1,9 @@ ; $Id: tabs.info,v 1.3 2009/08/26 15:12:08 nedjo Exp $ name = Tabs description = A helper module for creating tabbed pages. -core = 6.x +core = 7.x + +files[] = tabs.admin.inc +files[] = tabs.install +files[] = tabs.module +files[] = tabs.theme.inc Index: tabs.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tabs/tabs.install,v retrieving revision 1.2 diff -u -p -r1.2 tabs.install --- tabs.install 25 Aug 2009 23:33:02 -0000 1.2 +++ tabs.install 2 Dec 2010 23:08:28 -0000 @@ -12,7 +12,7 @@ function tabs_update_1() { * Implementation of hook_uninstall(). */ function tabs_uninstall() { - foreach (array('slide', 'fade', 'speed', 'navigation', 'nav_next', 'nav_previous', 'descriptive_urls') as $type) { - variable_del('tabs_'. $type); - } + foreach (array('slide', 'fade', 'speed', 'navigation', 'nav_next', 'nav_previous', 'descriptive_urls') as $type) { + variable_del('tabs_'. $type); + } } Index: tabs.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tabs/tabs.module,v retrieving revision 1.30 diff -u -p -r1.30 tabs.module --- tabs.module 25 May 2010 04:56:40 -0000 1.30 +++ tabs.module 2 Dec 2010 23:08:28 -0000 @@ -9,12 +9,12 @@ */ /** - * Implementation of hook_menu(). + * Implements of hook_menu(). */ function tabs_menu() { $items = array(); - $items['admin/settings/tabs'] = array( + $items['admin/config/user-interface/tabs'] = array( 'title' => 'Tabs', 'description' => 'Configuration for tabs', 'page callback' => 'drupal_get_form', @@ -27,16 +27,16 @@ function tabs_menu() { } /** - * Implementation of hook_theme() + * Implements of hook_theme() */ function tabs_theme() { return array( 'tabset' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', 'file' => 'tabs.theme.inc', ), 'tabpage' => array( - 'arguments' => array('element' => NULL), + 'render element' => 'element', 'file' => 'tabs.theme.inc', ), ); @@ -51,26 +51,24 @@ function tabs_pre_render_tabset($element tabs_load(); // Assign a name, reading from the first parent (the key of this tabset element). - $name = $element['#tabset_name'] = form_clean_id(isset($element['#tabset_name']) && $element['#tabset_name'] ? $element['#tabset_name'] : (isset($element['#parents']) && count($element['#parents']) ? $element['#parents'][0] : 'tabset')); + $name = $element['#tabset_name'] = drupal_clean_css_identifier(isset($element['#tabset_name']) && $element['#tabset_name'] ? $element['#tabset_name'] : (isset($element['#parents']) && count($element['#parents']) ? $element['#parents'][0] : 'tabset')); // Add class. if (!isset($element['#attributes'])) { $element['#attributes'] = array(); } - $element['#attributes']['class'] = (isset($element['#attributes']['class']) ? $element['#attributes']['class'] .' ' : '') .'drupal-tabs js-hide'. (isset($element['#tabs_navigation']) && $element['#tabs_navigation'] ? ' tabs-navigation' : ''); + $element['#attributes']['class'] = (isset($element['#attributes']['class']) ? $element['#attributes']['class'] . ' ' : '') . 'drupal-tabs js-hide' . (isset($element['#tabs_navigation']) && $element['#tabs_navigation'] ? ' tabs-navigation' : ''); // Allow other modules to alter the tabset before further processing. drupal_alter('tabs', $element); - $children = element_children($element); - - foreach ($children as $index => $key) { + foreach (element_children($element) as $index => $key) { if (isset($element[$key]['#type']) && $element[$key]['#type'] == 'tabpage') { if (!isset($element[$key]['#content'])) { $element[$key]['#content'] = ''; } if (isset($element[$key]['#description']) && $element[$key]['#description']) { - $element[$key]['#content'] = '
'. $element[$key]['#description'] .'
' . $element[$key]['#content']; + $element[$key]['#content'] = '
' . $element[$key]['#description'] . '
' . $element[$key]['#content']; unset($element[$key]['#description']); } $is_ajax = isset($element[$key]['#ajax_url']) && $element[$key]['#ajax_url']; @@ -92,7 +90,7 @@ function tabs_pre_render_tabset($element if (!isset($element[$key]['#tab_name']) || empty($element[$key]['#tab_name'])) { $element[$key]['#tab_name'] = $element['#tabset_name'] . '-tab-' . $index; } - $element[$key]['#tab_name'] = form_clean_id($element[$key]['#tab_name']); + $element[$key]['#tab_name'] = drupal_clean_css_identifier($element[$key]['#tab_name']); if (!isset($element[$key]['#attributes'])) { $element[$key]['#attributes'] = array(); } @@ -103,7 +101,7 @@ function tabs_pre_render_tabset($element } // Otherwise we use a hash. else { - $element[$key]['#url'] = '#' . $element[$key]['#tab_name']; + $element[$key]['#url'] = '#' . $element[$key]['#tab_name']; } $element[$key]['#attributes']['class'] = (isset($element[$key]['#attributes']['class']) ? $element[$key]['#attributes']['class'] . ' ' : '') . $element[$key]['#tab_name']; // Add the ui-tabs-selected class if this tab is selected. @@ -128,21 +126,9 @@ function tabs_load() { $tabs_speed = (int) $tabs_speed; } $path = drupal_get_path('module', 'tabs'); - // TODO: remove this test in D7, since jquery_ui is in core. - if (module_exists('jquery_ui')) { - jquery_ui_add(array('ui.tabs')); - if (version_compare(jquery_ui_get_version(), '1.7', '>=')) { - drupal_add_js($path . '/tabs_ui.js'); - } - else { - drupal_add_js($path . '/tabs.js'); - } - } - else { - drupal_add_js($path . '/ui.core.js'); - drupal_add_js($path . '/ui.tabs.js'); - drupal_add_js($path . '/tabs.js'); - } + + drupal_add_library('system', 'ui.tabs'); + drupal_add_js($path . '/tabs_ui.js'); drupal_add_js( array('tabs' => array( @@ -161,18 +147,17 @@ function tabs_load() { } /** - * Render a tabset 'manually' (when not rendering as part of a regular form render). - */ -function tabs_render($form) { - return drupal_render($form); -} - -/** - * Implementation of hook_elements(). + * Implements of hook_element_info(). */ -function tabs_elements() { +function tabs_element_info() { $type = array(); - $type['tabset'] = array('#tabs_navigation' => variable_get('tabs_navigation', 0) ? TRUE : FALSE, '#pre_render' => array('tabs_pre_render_tabset')); - $type['tabpage'] = array('#content' => ''); + $type['tabset'] = array( + '#tabs_navigation' => variable_get('tabs_navigation', 0) ? TRUE : FALSE, + '#pre_render' => array('tabs_pre_render_tabset'), + '#theme' => array('tabset'), + ); + $type['tabpage'] = array( + '#theme' => array('tabpage'), + ); return $type; } Index: tabs.theme.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tabs/tabs.theme.inc,v retrieving revision 1.8 diff -u -p -r1.8 tabs.theme.inc --- tabs.theme.inc 18 Jan 2010 07:03:44 -0000 1.8 +++ tabs.theme.inc 2 Dec 2010 23:08:28 -0000 @@ -11,19 +11,27 @@ * * @themable */ -function theme_tabset($element) { +function theme_tabset($variables) { + $element = $variables['element']; $output = '
'; - $output .= '
'. $element['#description'] .'
'; + if (isset($element['#description'])) { + $output .= '
' . $element['#description'] . '
'; + } $output .= '
'; + return $output; foreach (element_children($element) as $key) { - if (isset($element[$key]['#type']) && $element[$key]['#type'] == 'tabpage') { + $child = &$element[$key]; + + if (isset($child['#type']) && $child['#type'] == 'tabpage') { // Ensure the tab has content before rendering it. if ( - (isset($element[$key]['#ajax_url']) && !empty($element[$key]['#ajax_url'])) || - (isset($element[$key]['#content']) && !empty($element[$key]['#content'])) || - (isset($element[$key]['#children']) && !empty($element[$key]['#children'])) + (isset($child['#ajax_url']) && !empty($child['#ajax_url'])) || + (isset($child['#content']) && !empty($child['#content'])) || + (isset($child['#children']) && !empty($child['#children'])) ) { - $output .= ''. $element[$key]['#title'] .''; + $output .= ''. $child['#title'] .''; } } } @@ -40,7 +48,8 @@ function theme_tabset($element) { * * @themable */ -function theme_tabpage($element) { +function theme_tabpage($variables) { + $element = $variables['element']; $output = ''; // Ensure the tab has content before rendering it. if (!empty($element['#ajax_url']) || !empty($element['#content']) || !empty($element['#children'])) { Index: docs/tabsexample.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tabs/docs/tabsexample.info,v retrieving revision 1.1 diff -u -p -r1.1 tabsexample.info --- docs/tabsexample.info 26 Mar 2008 23:05:50 -0000 1.1 +++ docs/tabsexample.info 2 Dec 2010 23:08:28 -0000 @@ -3,4 +3,4 @@ name = Tabs Example description = An example tabs implementation. Access the sample tabs at /tabsexample. package = User Interface dependencies[] = tabs -core = 6.x +core = 7.x Index: docs/tabsexample.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tabs/docs/tabsexample.module,v retrieving revision 1.8 diff -u -p -r1.8 tabsexample.module --- docs/tabsexample.module 25 May 2010 04:56:40 -0000 1.8 +++ docs/tabsexample.module 2 Dec 2010 23:08:28 -0000 @@ -52,6 +52,7 @@ function tabsexample_form() { '#title' => t('Two'), '#content' => t('Second tab content.'), ); + /* // Nest a second tabset. $form['example1']['tab2']['tabset2'] = array( '#type' => 'tabset', @@ -71,6 +72,7 @@ function tabsexample_form() { '#type' => 'textfield', '#title' => t('Name'), ); + */ $form['example1']['tab3'] = array( '#type' => 'tabpage', '#title' => t('Three'), @@ -99,10 +101,16 @@ function tabsexample_ajax_tabset() { // This will be the content of the tab. '#content' => t('First tab content.'), ); + $tabset['my_tabset']['second_tab'] = array( + '#type' => 'tabpage', + '#title' => t('Two'), + '#content' => t('Second tab content.'), + ); $tabset['my_tabset']['second_tab'] = array( '#type' => 'tabpage', '#title' => t('Two--Ajax loaded'), + '#content' => t('Not AJAX content.'), // The #ajax_url is the url to the content to be loaded. // Can be relative or absolute. // No content is needed as the content will be dynamically loaded. @@ -114,13 +122,13 @@ function tabsexample_ajax_tabset() { '#title' => t('Three'), // No content, so this tab should not be rendered. ); - // Render the tabset. - return tabs_render($tabset); + return $tabset; } /** * Menu callback: return sample AJAX content. */ function tabsexample_ajax() { - echo t('Sample content loaded via AJAX.'); + print t('Sample content loaded via AJAX.'); + exit; }