' . t('The Quicktabs module allows you to create blocks of tabbed content. Clicking on the tabs makes the corresponding content display instantly (it uses jQuery). The content for each tabbed section can be a node, view, block or another Quicktabs instance. You can create an unlimited number of Quicktabs instances, each of which will automatically have an associated block.') . '
'; $output .= '' . t('The quicktabs page displays all quicktabs currently available on your site. Create new quicktabs using the add quicktab page (the block containing a new quicktab must also be enabled on the blocks administration page).', array('@quicktabs' => url('admin/structure/quicktabs'), '@add-quicktab' => url('admin/structure/quicktab/add'), '@blocks' => url('admin/structure/block'))) . '
'; return $output; } if ($path == 'admin/structure/quicktabs' && module_exists('block')) { return '' . t('Each Quicktabs instance has a corresponding block that is managed on the blocks administration page.', array('@blocks' => url('admin/structure/block'))) . '
'; } } /** * Implements hook_menu(). */ function quicktabs_menu() { $items['admin/structure/quicktabs'] = array( 'title' => 'Quicktabs', 'description' => 'Create blocks of tabbed content.', 'page callback' => 'quicktabs_list', 'access callback' => 'user_access', 'access arguments' => array('administer quicktabs'), 'type' => MENU_NORMAL_ITEM, 'file' => 'quicktabs.admin.inc', ); $items['admin/structure/quicktabs/list'] = array( 'title' => 'List quicktabs', 'type' => MENU_DEFAULT_LOCAL_TASK, ); $items['admin/structure/quicktabs/add'] = array( 'title' => 'Add Quicktabs Instance', 'page callback' => 'drupal_get_form', 'page arguments' => array('quicktabs_form', 'add'), 'access arguments' => array('administer quicktabs'), 'type' => MENU_LOCAL_ACTION, 'file' => 'quicktabs.admin.inc', ); $items['admin/structure/quicktabs/manage/%quicktabs'] = array( 'title' => 'Edit quicktab', 'page callback' => 'drupal_get_form', 'page arguments' => array('quicktabs_form', 'edit', 4), 'access arguments' => array('administer quicktabs'), 'file' => 'quicktabs.admin.inc', ); $items['admin/structure/quicktabs/manage/%quicktabs/edit'] = array( 'title' => 'Edit quicktab', 'type' => MENU_DEFAULT_LOCAL_TASK, 'context' => MENU_CONTEXT_INLINE, ); $items['admin/structure/quicktabs/manage/%quicktabs/delete'] = array( 'title' => 'Delete quicktab', 'page callback' => 'drupal_get_form', 'page arguments' => array('quicktabs_block_delete', 4), 'access arguments' => array('administer quicktabs'), 'type' => MENU_LOCAL_TASK, 'file' => 'quicktabs.admin.inc', ); $items['admin/structure/quicktabs/manage/%quicktabs/clone'] = array( 'title' => 'Clone quicktab', 'page callback' => 'quicktabs_clone', 'page arguments' => array(4), 'access arguments' => array('administer quicktabs'), 'type' => MENU_LOCAL_TASK, 'file' => 'quicktabs.admin.inc', ); $items['admin/structure/quicktabs/manage/%quicktabs/export'] = array( 'title' => 'Export', 'page callback' => 'drupal_get_form', 'page arguments' => array('quicktabs_export_form', 4), 'access arguments' => array('administer quicktabs'), 'type' => MENU_LOCAL_TASK, 'file' => 'quicktabs.admin.inc', ); $items['quicktabs/ajax'] = array( 'page callback' => 'quicktabs_ajax', 'access callback' => 'user_access', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_permission(). */ function quicktabs_permission() { return array( 'administer quicktabs' => array( 'title' => t('Administer Quicktabs'), ), ); } /** * Implements hook_theme(). */ function quicktabs_theme() { return array( 'quicktabs_admin_form_tabs' => array( 'render element' => 'tabs', 'file' => 'quicktabs.admin.inc', ), 'qt_ui_tabs' => array( 'render element' => 'element', ), 'qt_ui_tabs_tabset' => array( 'render element' => 'tabset', ), 'qt_quicktabs' => array( 'render element' => 'element', ), 'qt_quicktabs_tabset' => array( 'render element' => 'tabset', ), 'qt_accordion' => array( 'render element' => 'element', ), 'quicktabs_tab_access_denied' => array( 'variables' => array('tab'), ), ); } /** * Implements hook_block_info(). */ function quicktabs_block_info() { $blocks = array(); foreach (quicktabs_load_multiple() as $qt_name => $quicktabs) { $blocks[$qt_name]['info'] = $quicktabs->title; } return $blocks; } /** * Implements hook_block_view(). */ function quicktabs_block_view($delta = '') { $block = array(); if ($qt = quicktabs_build_quicktabs($delta)) { if (isset($qt['content']) && !empty($qt['content'])) { $block['content'] = $qt['content']; $block['content']['#contextual_links']['quicktabs'] = array('admin/structure/quicktabs/manage', array($delta)); $block['subject'] = check_plain($qt['#title']); } } return $block; } /** * Constructs a Quicktabs instance. * * This function can be called by other modules to programmatically build a * quicktabs instance. * * @param name. The machine name of the Quicktabs instance to build - if a name * is passed that does not correspond to an existing instance, then it is taken * to be a completely custom instance and is built from only the custom tabs * that are passed in. * * @param settings. An array of settings that will override the options of the Quicktabs * instance from the database, or if no existing instance is being used, these * will override the default settings. Possible keys are 'style', 'hide_empty_tabs', * ajax', 'default_tab', 'renderer', 'title' and 'options'. * * @param custom_tabs. An array representing custom tab contents, which will be * appended to the Quicktabs instance from the database, or if no existing instance * is being used, the custom tabs will be the entire contents. An example custom_tabs * array would be array(array('title' => 'custom', 'contents' => array('#markup' => * t('Some markup'), 'weight' => 5)); * * @return A render array that can be used as block content in hook_block_view * (see quicktabs_block_view()), but can also just be added to the page array * during hook_page_alter, or output anywhere else where it's sure to get * passed through drupal_render(). */ function quicktabs_build_quicktabs($name, $settings = array(), $custom_tabs = array()) { if ($info = quicktabs_load($name)) { // Allow other modules to alter the Quicktabs instance before it gets output. drupal_alter('quicktabs', $info); $info = (array) $info; $settings = array_merge($info, $settings); $contents = $settings['tabs']; unset($settings['tabs'], $settings['machine_name']); } elseif (!empty($custom_tabs)) { // We'll be creating a custom Quicktabs instance. Make sure we're using an // alphanumeric name. $name = preg_replace('/[^[a-zA-Z]_]/', '_', $name); $contents = array(); } else { // If $name doesn't correspond to an existing Quicktabs instance, and there // are no custom tabs to render, then we have nothing to do. return array(); } $renderer = isset($settings['renderer']) ? $settings['renderer'] : 'quicktabs'; unset($settings['renderer']); foreach ($custom_tabs as &$tab) { $tab += array( 'type' => 'prerendered', 'weight' => 0, ); } $contents = array_merge($custom_tabs, $contents); $weight = array(); foreach ($contents as $key => $item) { // Load the plugin responsible for rendering this item, if it is not a // prerendered tab. if ($item['type'] != 'prerendered') { ctools_plugin_load_class('quicktabs', 'contents', $item['type'], 'handler'); } // Add item's weight to our weights array so that we can then sort by weight. $weight[$key] = $item['weight']; // Make sure we're not going to try to load the same QuickSet instance // inside itself. if ($item['type'] == 'qtabs' && $item['machine_name'] == $name) { unset($contents[$key]); unset($weight[$key]); } } // Only sort by weight if the tabs haven't already been sorted by some other // mechanism, e.g. Views in the case of the Views style plugin. if (!isset($settings['sorted']) || !$settings['sorted']) { array_multisort($weight, SORT_ASC, $contents); } else { unset($settings['sorted']); } if ($qt = quickset_renderer_factory($name, $contents, $renderer, $settings)) { $renderable_qt = array('#title' => $qt->getTitle(), 'content' => $qt->render()); return $renderable_qt; } return array(); } /** * Ajax callback for tab content. * * @param name The machine name of the quicktabs instance. * * @param index The tab index we're returning content for. * * @param type The type of content we're rendering. * * @return a json-formatted ajax commands array. */ function quicktabs_ajax($name, $index, $type) { $args = func_get_args(); $variable_args = array_slice($args, 3); // Add the Quicktabs machine name to the args we pass to the content renderer array_unshift($variable_args, $name); $data = QuickSet::ajaxRenderContent($type, $variable_args); $commands = array(); $tabpage_id = 'quicktabs-tabpage-'. $name .'-' . $index; $commands[] = ajax_command_append('#quicktabs-container-'. $name, '