page_tabs.inc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * @file
  4. * Plugin to handle the 'page' content type which allows the standard page
  5. * template variables to be embedded into a panel.
  6. */
  7. /**
  8. * Plugins are described by creating a $plugin array which will be used
  9. * by the system that includes this file.
  10. */
  11. $plugin = array(
  12. 'title' => t('Tabs'),
  13. 'single' => TRUE,
  14. 'icon' => 'icon_page.png',
  15. 'description' => t('Add the tabs (local tasks) as content.'),
  16. 'category' => t('Page elements'),
  17. 'render last' => TRUE,
  18. 'defaults' => array(
  19. 'type' => 'both',
  20. 'id' => 'tabs',
  21. ),
  22. );
  23. /**
  24. * Output function for the 'page_tabs' content type.
  25. *
  26. * Outputs the tabs (local tasks) of the current page.
  27. */
  28. function ctools_page_tabs_content_type_render($subtype, $conf, $panel_args) {
  29. $block = new stdClass();
  30. $menus = menu_local_tabs();
  31. if (empty($menus['#secondary']) && empty($menus['#primary'])) {
  32. return;
  33. }
  34. switch ($conf['type']) {
  35. case 'primary':
  36. unset($menus['#secondary']);
  37. break;
  38. case 'secondary':
  39. unset($menus['#primary']);
  40. break;
  41. }
  42. if ($conf['id']) {
  43. $menus['#theme_wrappers'][] = 'container';
  44. $menus['#attributes']['id'] = $conf['id'];
  45. }
  46. $block->content = $menus;
  47. return $block;
  48. }
  49. function ctools_page_tabs_content_type_edit_form($form, &$form_state) {
  50. $conf = $form_state['conf'];
  51. $form['type'] = array(
  52. '#title' => t('Tabs type'),
  53. '#type' => 'select',
  54. '#options' => array(
  55. 'both' => t('Primary and secondary'),
  56. 'primary' => t('Primary'),
  57. 'secondary' => t('Secondary'),
  58. ),
  59. '#default_value' => $conf['type'],
  60. );
  61. $form['id'] = array(
  62. '#title' => t('CSS id to use'),
  63. '#type' => 'textfield',
  64. '#default_value' => $conf['id'],
  65. );
  66. return $form;
  67. }
  68. /**
  69. * The submit form stores the data in $conf.
  70. */
  71. function ctools_page_tabs_content_type_edit_form_submit($form, &$form_state) {
  72. foreach (array_keys($form_state['plugin']['defaults']) as $key) {
  73. if (isset($form_state['values'][$key])) {
  74. $form_state['conf'][$key] = $form_state['values'][$key];
  75. }
  76. }
  77. }