Projet

Général

Profil

Paste
Télécharger (5,88 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / panels / includes / callbacks.inc @ 5a7e6170

1
<?php
2
/**
3
 * @file callbacks.inc
4
 * Minor menu callbacks for Panels helpers.
5
 */
6

    
7
/**
8
 * A central administrative page for Panels.
9
 */
10
function panels_admin_page() {
11
  // @todo I think this should return a renderable array somehow?
12
  return theme('panels_dashboard');
13
}
14

    
15
function panels_dashboard_final_blocks(&$vars) {
16
  // Add in links for missing modules that we still want to mention:
17
  if (empty($vars['links']['page_manager'])) {
18
    $vars['links']['page_manager'] = array(
19
      'weight' => -100,
20
      'title' => t('Panel page'),
21
      'description' => '<em>' . t('You must activate the page manager module for this functionality.') . '</em>',
22
    );
23
  }
24
  if (empty($vars['links']['panels_mini'])) {
25
    $vars['links']['panels_mini'] = array(
26
      'title' => t('Mini panel'),
27
      'description' => '<em>' . t('You must activate the Mini panels module for this functionality.') . '</em>',
28
    );
29
  }
30
  if (empty($vars['links']['panels_node'])) {
31
    $vars['links']['panels_mini'] = array(
32
      'title' => t('Panel node'),
33
      'description' => '<em>' . t('You must activate the panel node module for this functionality.') . '</em>',
34
    );
35
  }
36
}
37

    
38
/**
39
 * Implementation of hook_panels_dashboard_blocks().
40
 *
41
 * Adds page information to the Panels dashboard.
42
 */
43
function panels_panels_dashboard_blocks(&$vars) {
44
  $vars['links']['panels_layout'] = array(
45
    'title' => l(t('Custom layout'), 'admin/structure/panels/layouts/add'),
46
    'description' => t('Custom layouts can add more, site-specific layouts that you can use in your panels.'),
47
  );
48

    
49
   // Load all mini panels and their displays.
50
  ctools_include('export');
51
  $items = ctools_export_crud_load_all('panels_layout');
52
  $count = 0;
53
  $rows = array();
54

    
55
  foreach ($items as $item) {
56
    $rows[] = array(
57
      check_plain($item->admin_title),
58
      array(
59
        'data' => l(t('Edit'), "admin/structure/panels/layouts/list/$item->name/edit"),
60
        'class' => 'links',
61
      ),
62
    );
63

    
64
    // Only show 10.
65
    if (++$count >= 10) {
66
      break;
67
    }
68
  }
69

    
70
  if ($rows) {
71
    $content = theme('table', array('rows' => $rows, 'attributes' => array('class' => 'panels-manage')));
72
  }
73
  else {
74
    $content = '<p>' . t('There are no custom layouts.') . '</p>';
75
  }
76

    
77
  $vars['blocks']['panels_layout'] = array(
78
    'title' => t('Manage custom layouts'),
79
    'link' => l(t('Go to list'), 'admin/structure/panels/layouts'),
80
    'content' => $content,
81
    'class' => 'dashboard-layouts',
82
    'section' => 'right',
83
  );
84
}
85

    
86
function template_preprocess_panels_dashboard(&$vars) {
87
  ctools_add_css('panels-dashboard', 'panels');
88
  ctools_include('plugins');
89

    
90
  $vars['image_path'] = ctools_image_path('', 'panels');
91

    
92
  $vars['links'] = array();
93
  $vars['blocks'] = array();
94

    
95
  foreach (module_implements('panels_dashboard_blocks') as $module) {
96
    $function = $module . '_panels_dashboard_blocks';
97
    $function($vars);
98
  }
99

    
100
  // Add in any default links for modules that are not active
101
  panels_dashboard_final_blocks($vars);
102

    
103
  // If page manager module is enabled, add a very low eight block to
104
  // list the page wizards.
105
  if (module_exists('page_manager')) {
106
    $vars['blocks']['wizards'] = array(
107
      'weight' => -101,
108
      'section' => 'right',
109
      'title' => t('Page wizards'),
110
      'content' => '',
111
      'class' => 'dashboard-wizards',
112
    );
113

    
114
    ctools_include('page-wizard');
115
    $plugins = page_manager_get_page_wizards();
116
    uasort($plugins, 'ctools_plugin_sort');
117

    
118
    foreach ($plugins as $id => $plugin) {
119
      if (isset($plugin['type']) && $plugin['type'] == 'panels') {
120
        $link = array(
121
          'title' => l($plugin['title'], 'admin/structure/pages/wizard/' . $id),
122
          'description' => $plugin['description'],
123
        );
124

    
125
        $vars['blocks']['wizards']['content'] .= theme('panels_dashboard_link', array('link' => $link));
126
      }
127
    }
128

    
129
  }
130

    
131
  uasort($vars['links'], 'ctools_plugin_sort');
132

    
133
  $vars['blocks']['links'] = array(
134
    'weight' => -100,
135
    'section' => 'left',
136
    'title' => t('Create new') . '...',
137
    'content' => '',
138
    'class' => 'dashboard-create',
139
  );
140

    
141
  // Turn the links into a block
142
  foreach ($vars['links'] as $link) {
143
    $vars['blocks']['links']['content'] .= theme('panels_dashboard_link', array('link' => $link));
144
  }
145

    
146
  uasort($vars['blocks'], 'ctools_plugin_sort');
147

    
148
  $vars['left'] = '';
149
  $vars['right'] = '';
150

    
151
  // Render all the blocks
152
  foreach ($vars['blocks'] as $block) {
153
    $section = !empty($block['section']) ? $block['section'] : 'left';
154
    $vars[$section] .= theme('panels_dashboard_block', array('block' => $block));
155
  }
156
}
157

    
158
function panels_admin_settings_page() {
159
  $form = array();
160
  if (module_exists('page_manager')) {
161
    foreach (page_manager_get_tasks() as $task) {
162
      if ($function = ctools_plugin_get_function($task, 'admin settings')) {
163
        $function($form);
164
      }
165
    }
166
  }
167

    
168
  ctools_include('content');
169
  foreach (ctools_get_content_types() as $content) {
170
    if ($function = ctools_plugin_get_function($content, 'admin settings')) {
171
      $function($form);
172
    }
173
  }
174

    
175
  ctools_include('plugins', 'panels');
176
  $pipelines = panels_get_renderer_pipelines();
177
  $options = array();
178
  foreach ($pipelines as $key => $value) {
179
    $options[$key] = $value->admin_title;
180
  }
181
  if (count($options) > 1) {
182
    $form['panels_renderer_default'] = array(
183
      '#type' => 'select',
184
      '#title' => t('Default renderer'),
185
      '#options' => $options,
186
      '#default_value' => variable_get('panels_renderer_default', 'standard'),
187
      '#description' => t('The default renderer for new panel pages.'),
188
    );
189
  }
190

    
191
  if (empty($form)) {
192
    return array('#value' => t('There are currently no settings to change, but additional plugins or modules may provide them in the future.'));
193
  }
194

    
195
  return system_settings_form($form);
196
}
197

    
198
/**
199
 * Settings for panel contexts created by the page manager.
200
 */
201
function panels_admin_panel_context_page() {
202
  ctools_include('common', 'panels');
203
  return drupal_get_form('panels_common_settings', 'panels_page');
204
}
205