callbacks.inc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <?php
  2. /**
  3. * @file Callbacks.inc
  4. * Minor menu callbacks for Panels helpers.
  5. */
  6. /**
  7. * A central administrative page for Panels.
  8. */
  9. function panels_admin_page() {
  10. // @todo I think this should return a renderable array somehow?
  11. return theme('panels_dashboard');
  12. }
  13. function panels_dashboard_final_blocks(&$vars) {
  14. // Add in links for missing modules that we still want to mention:
  15. if (empty($vars['links']['page_manager'])) {
  16. $vars['links']['page_manager'] = array(
  17. 'weight' => -100,
  18. 'title' => t('Panel page'),
  19. 'description' => '<em>' . t('You must activate the page manager module for this functionality.') . '</em>',
  20. );
  21. }
  22. if (empty($vars['links']['panels_mini'])) {
  23. $vars['links']['panels_mini'] = array(
  24. 'title' => t('Mini panel'),
  25. 'description' => '<em>' . t('You must activate the Mini panels module for this functionality.') . '</em>',
  26. );
  27. }
  28. if (empty($vars['links']['panels_node'])) {
  29. $vars['links']['panels_mini'] = array(
  30. 'title' => t('Panel node'),
  31. 'description' => '<em>' . t('You must activate the panel node module for this functionality.') . '</em>',
  32. );
  33. }
  34. }
  35. /**
  36. * Implementation of hook_panels_dashboard_blocks().
  37. *
  38. * Adds page information to the Panels dashboard.
  39. */
  40. function panels_panels_dashboard_blocks(&$vars) {
  41. $vars['links']['panels_layout'] = array(
  42. 'title' => l(t('Custom layout'), 'admin/structure/panels/layouts/add'),
  43. 'description' => t('Custom layouts can add more, site-specific layouts that you can use in your panels.'),
  44. );
  45. // Load all mini panels and their displays.
  46. ctools_include('export');
  47. $items = ctools_export_crud_load_all('panels_layout');
  48. $count = 0;
  49. $rows = array();
  50. foreach ($items as $item) {
  51. $rows[] = array(
  52. check_plain($item->admin_title),
  53. array(
  54. 'data' => l(t('Edit'), "admin/structure/panels/layouts/list/$item->name/edit"),
  55. 'class' => 'links',
  56. ),
  57. );
  58. // Only show 10.
  59. if (++$count >= 10) {
  60. break;
  61. }
  62. }
  63. if ($rows) {
  64. $content = theme('table', array('rows' => $rows, 'attributes' => array('class' => 'panels-manage')));
  65. }
  66. else {
  67. $content = '<p>' . t('There are no custom layouts.') . '</p>';
  68. }
  69. $vars['blocks']['panels_layout'] = array(
  70. 'title' => t('Manage custom layouts'),
  71. 'link' => l(t('Go to list'), 'admin/structure/panels/layouts'),
  72. 'content' => $content,
  73. 'class' => 'dashboard-layouts',
  74. 'section' => 'right',
  75. );
  76. }
  77. function template_preprocess_panels_dashboard(&$vars) {
  78. ctools_add_css('panels-dashboard', 'panels');
  79. ctools_include('plugins');
  80. $vars['image_path'] = ctools_image_path('', 'panels');
  81. $vars['links'] = array();
  82. $vars['blocks'] = array();
  83. foreach (module_implements('panels_dashboard_blocks') as $module) {
  84. $function = $module . '_panels_dashboard_blocks';
  85. $function($vars);
  86. }
  87. // Add in any default links for modules that are not active.
  88. panels_dashboard_final_blocks($vars);
  89. // If page manager module is enabled, add a very low eight block to
  90. // list the page wizards.
  91. if (module_exists('page_manager')) {
  92. $vars['blocks']['wizards'] = array(
  93. 'weight' => -101,
  94. 'section' => 'right',
  95. 'title' => t('Page wizards'),
  96. 'content' => '',
  97. 'class' => 'dashboard-wizards',
  98. );
  99. ctools_include('page-wizard');
  100. $plugins = page_manager_get_page_wizards();
  101. uasort($plugins, 'ctools_plugin_sort');
  102. foreach ($plugins as $id => $plugin) {
  103. if (isset($plugin['type']) && $plugin['type'] == 'panels') {
  104. $link = array(
  105. 'title' => l($plugin['title'], 'admin/structure/pages/wizard/' . $id),
  106. 'description' => $plugin['description'],
  107. );
  108. $vars['blocks']['wizards']['content'] .= theme('panels_dashboard_link', array('link' => $link));
  109. }
  110. }
  111. }
  112. uasort($vars['links'], 'ctools_plugin_sort');
  113. $vars['blocks']['links'] = array(
  114. 'weight' => -100,
  115. 'section' => 'left',
  116. 'title' => t('Create new') . '...',
  117. 'content' => '',
  118. 'class' => 'dashboard-create',
  119. );
  120. // Turn the links into a block.
  121. foreach ($vars['links'] as $link) {
  122. $vars['blocks']['links']['content'] .= theme('panels_dashboard_link', array('link' => $link));
  123. }
  124. uasort($vars['blocks'], 'ctools_plugin_sort');
  125. $vars['left'] = '';
  126. $vars['right'] = '';
  127. // Render all the blocks.
  128. foreach ($vars['blocks'] as $block) {
  129. $section = !empty($block['section']) ? $block['section'] : 'left';
  130. $vars[$section] .= theme('panels_dashboard_block', array('block' => $block));
  131. }
  132. }
  133. function panels_admin_settings_page() {
  134. $form = array();
  135. if (module_exists('page_manager')) {
  136. foreach (page_manager_get_tasks() as $task) {
  137. if ($function = ctools_plugin_get_function($task, 'admin settings')) {
  138. $function($form);
  139. }
  140. }
  141. }
  142. ctools_include('content');
  143. foreach (ctools_get_content_types() as $content) {
  144. if ($function = ctools_plugin_get_function($content, 'admin settings')) {
  145. $function($form);
  146. }
  147. }
  148. ctools_include('plugins', 'panels');
  149. $pipelines = panels_get_renderer_pipelines();
  150. $options = array();
  151. foreach ($pipelines as $key => $value) {
  152. $options[$key] = $value->admin_title;
  153. }
  154. if (count($options) > 1) {
  155. $form['panels_renderer_default'] = array(
  156. '#type' => 'select',
  157. '#title' => t('Default renderer'),
  158. '#options' => $options,
  159. '#default_value' => variable_get('panels_renderer_default', 'standard'),
  160. '#description' => t('The default renderer for new panel pages.'),
  161. );
  162. }
  163. if (empty($form)) {
  164. return array('#value' => t('There are currently no settings to change, but additional plugins or modules may provide them in the future.'));
  165. }
  166. return system_settings_form($form);
  167. }
  168. /**
  169. * Settings for panel contexts created by the page manager.
  170. */
  171. function panels_admin_panel_context_page() {
  172. ctools_include('common', 'panels');
  173. return drupal_get_form('panels_common_settings', 'panels_page');
  174. }