Projet

Général

Profil

Paste
Télécharger (8,63 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / panels / panels_ipe / panels_ipe.module @ 64156087

1
<?php
2

    
3
/**
4
 * @file
5
 */
6

    
7
/**
8
 * Implementation of hook_ctools_plugin_directory().
9
 */
10
function panels_ipe_ctools_plugin_directory($module, $plugin) {
11
  if ($module == 'panels' && $plugin == 'display_renderers') {
12
    return 'plugins/' . $plugin;
13
  }
14
}
15

    
16
/**
17
 * Implementation of hook_ctools_plugin_api().
18
 *
19
 * Inform CTools about version information for various plugins implemented by
20
 * Panels.
21
 *
22
 * @param string $owner
23
 *   The system name of the module owning the API about which information is
24
 *   being requested.
25
 * @param string $api
26
 *   The name of the API about which information is being requested.
27
 */
28
function panels_ipe_ctools_plugin_api($owner, $api) {
29
  if ($owner == 'panels' && $api == 'pipelines') {
30
    return array(
31
      'version' => 1,
32
      'path' => drupal_get_path('module', 'panels_ipe') . '/includes',
33
    );
34
  }
35
}
36

    
37
/**
38
 * Implementation of hook_theme().
39
 */
40
function panels_ipe_theme() {
41
  return array(
42
    'panels_ipe_pane_wrapper' => array(
43
      'variables' => array('output' => NULL, 'pane' => NULL, 'display' => NULL, 'renderer' => NULL),
44
    ),
45
    'panels_ipe_region_wrapper' => array(
46
      'variables' => array('output' => NULL, 'region_id' => NULL, 'display' => NULL, 'controls' => NULL, 'renderer' => NULL),
47
    ),
48
    'panels_ipe_add_pane_button' => array(
49
      'variables' => array('region_id' => NULL, 'display' => NULL, 'renderer' => NULL),
50
    ),
51
    'panels_ipe_placeholder_pane' => array(
52
      'variables' => array('region_id' => NULL, 'region_title' => NULL),
53
    ),
54
    'panels_ipe_dnd_form_container' => array(
55
      'variables' => array('link' => NULL, 'cache_key' => NULL, 'display' => NULL),
56
    ),
57
    'panels_ipe_toolbar' => array(
58
      'variables' => array('buttons' => NULL),
59
    ),
60
  );
61
}
62

    
63
/**
64
 * Theme the 'placeholder' pane, which is shown on an active IPE when no panes
65
 * live in that region.
66
 *
67
 * @param string $region_id
68
 * @param string $region_title
69
 */
70
function theme_panels_ipe_placeholder_pane($vars) {
71
  $region_id = $vars['region_id'];
72
  $region_title = $vars['region_title'];
73

    
74
  $output = '<div class="panels-ipe-placeholder-content">';
75
  $output .= "<h3>$region_title</h3>";
76
  $output .= '</div>';
77
  return $output;
78
}
79

    
80
function template_preprocess_panels_ipe_pane_wrapper(&$vars) {
81
  $pane = $vars['pane'];
82
  $display = $vars['display'];
83
  $renderer = $vars['renderer'];
84

    
85
  $content_type = ctools_get_content_type($pane->type);
86
  $subtype = ctools_content_get_subtype($content_type, $pane->subtype);
87
  $vars['links'] = array();
88

    
89
  if (ctools_content_editable($content_type, $subtype, $pane->configuration)) {
90
    $vars['links']['edit'] = array(
91
      'title' => isset($content_type['edit text']) ? '<span>' . $content_type['edit text'] . '</span>' : '<span>' . t('Settings') . '</span>',
92
      'href' => $renderer->get_url('edit-pane', $pane->pid),
93
      'html' => TRUE,
94
      'attributes' => array(
95
        'class' => array('ctools-use-modal', 'panels-ipe-hide-bar'),
96
        'title' => isset($content_type['edit text']) ? $content_type['edit text'] : t('Settings'),
97
        // 'id' => "pane-edit-panel-pane-$pane->pid",.
98
      ),
99
    );
100
  }
101

    
102
  // Add option to configure style in IPE.
103
  if (user_access('administer panels pane styles')) {
104
    $vars['links']['style'] = array(
105
      'title' => '<span>' . t('Style') . '</span>',
106
      'href' => $renderer->get_url('style-type', 'pane', $pane->pid),
107
      'html' => TRUE,
108
      'attributes' => array(
109
        'class' => array('ctools-use-modal', 'panels-ipe-hide-bar'),
110
        'title' => t('Style'),
111
      ),
112
    );
113
  }
114

    
115
  // Add option to configure CSS.
116
  if (user_access('administer advanced pane settings')) {
117
    $vars['links']['css'] = array(
118
      'title' => '<span>' . t('CSS') . '</span>',
119
      'href' => $renderer->get_url('pane-css', $pane->pid),
120
      'html' => TRUE,
121
      'attributes' => array(
122
        'class' => array('ctools-use-modal', 'panels-ipe-hide-bar'),
123
        'title' => t('CSS'),
124
      ),
125
    );
126
  }
127

    
128
  // Deleting is managed entirely in the js; this is just an attachment point
129
  // for it.
130
  $vars['links']['delete'] = array(
131
    'title' => '<span>' . t('Delete') . '</span>',
132
    'href' => '#',
133
    'html' => TRUE,
134
    'attributes' => array(
135
      'class' => 'pane-delete',
136
      'id' => "pane-delete-panel-pane-$pane->pid",
137
      'title' => t('Delete'),
138
    ),
139
  );
140

    
141
  $context = array(
142
    'pane' => $pane,
143
    'display' => $display,
144
    'renderer' => $renderer,
145
  );
146
  drupal_alter('panels_ipe_pane_links', $vars['links'], $context);
147

    
148
}
149

    
150
function theme_panels_ipe_pane_wrapper($vars) {
151
  $output = $vars['output'];
152
  $pane = $vars['pane'];
153
  $display = $vars['display'];
154

    
155
  $attributes = array(
156
    'class' => 'panels-ipe-linkbar',
157
  );
158

    
159
  $type = ctools_get_content_type($pane->type);
160
  $title = '<span class = "panels-ipe-dragbar-admin-title">' . ctools_content_admin_title($type, $pane->subtype, $pane->configuration, $display->context) . '</span>';
161

    
162
  $links = theme('links', array('links' => $vars['links'], 'attributes' => $attributes));
163

    
164
  if (!empty($pane->locks['type']) && $pane->locks['type'] == 'immovable') {
165
    $links = '<div class="panels-ipe-dragbar panels-ipe-nodraghandle clearfix">' . $links . $title . '</div>';
166
  }
167
  else {
168
    $links = '<div class="panels-ipe-dragbar panels-ipe-draghandle clearfix">' . $links . $title . '<span class="panels-ipe-draghandle-icon"><span class="panels-ipe-draghandle-icon-inner"></span></span></div>';
169
  }
170

    
171
  $handlebar = '<div class="panels-ipe-handlebar-wrapper panels-ipe-on">' . $links . '</div>';
172

    
173
  return $handlebar . $output;
174
}
175

    
176
function theme_panels_ipe_region_wrapper($vars) {
177
  return $vars['controls'] . $vars['output'];
178
}
179

    
180
function template_preprocess_panels_ipe_add_pane_button(&$vars) {
181
  $region_id = $vars['region_id'];
182
  $display = $vars['display'];
183
  $renderer = $vars['renderer'];
184
  $vars['links'] = array();
185

    
186
  // Add option to configure style in IPE.
187
  if (user_access('administer panels region styles')) {
188
    $vars['links']['style'] = array(
189
      'title' => '<span>' . t('Region style') . '</span>',
190
      'href' => $renderer->get_url('style-type', 'region', $region_id),
191
      'html' => TRUE,
192
      'attributes' => array(
193
        'class' => array('ctools-use-modal', 'panels-ipe-hide-bar', 'style'),
194
        'title' => t('Region style'),
195
      ),
196
    );
197
  }
198

    
199
  // Add option to add items in the IPE.
200
  $vars['links']['add-pane'] = array(
201
    'title' => '<span>' . t('Add new pane') . '</span>',
202
    'href' => $renderer->get_url('select-content', $region_id),
203
    'attributes' => array(
204
      'class' => array('ctools-use-modal', 'add', 'panels-ipe-hide-bar'),
205
      'title' => t('Add new pane'),
206
    ),
207
    'html' => TRUE,
208
  );
209

    
210
  $context = array(
211
    'region_id' => $region_id,
212
    'display' => $display,
213
    'renderer' => $renderer,
214
  );
215
  drupal_alter('panels_ipe_region_links', $vars['links'], $context);
216

    
217
}
218

    
219
function theme_panels_ipe_add_pane_button($vars) {
220
  $attributes = array(
221
    'class' => array('panels-ipe-linkbar', 'inline'),
222
  );
223

    
224
  $links = theme('links', array('links' => $vars['links'], 'attributes' => $attributes));
225

    
226
  return '<div class="panels-ipe-newblock panels-ipe-on">' . $links . '</div>';
227
}
228

    
229
/**
230
 * @deprecated
231
 */
232
function panels_ipe_get_cache_key($key = NULL) {
233
  return array();
234
}
235

    
236
/**
237
 * Add a button to the IPE toolbar.
238
 */
239
function panels_ipe_toolbar_add_button($cache_key, $id, $button) {
240
  $buttons = &drupal_static('panels_ipe_toolbar_buttons', array());
241
  drupal_alter('panels_ipe_button', $button, $id, $cache_key);
242
  $buttons[$cache_key][$id] = $button;
243
}
244

    
245
/**
246
 * Implementation of hook_footer().
247
 *
248
 * Adds the IPE control container.
249
 *
250
 * @param unknown_type $main
251
 */
252
function panels_ipe_page_alter(&$page) {
253
  $buttons = &drupal_static('panels_ipe_toolbar_buttons', array());
254
  if (empty($buttons)) {
255
    return;
256
  }
257

    
258
  $output = theme('panels_ipe_toolbar', array('buttons' => $buttons));
259

    
260
  $page['page_bottom']['panels_ipe'] = array(
261
    '#markup' => $output,
262
  );
263
}
264

    
265
function theme_panels_ipe_toolbar($vars) {
266
  $buttons = $vars['buttons'];
267
  ctools_include('cleanstring');
268

    
269
  $output = "<div id='panels-ipe-control-container' class='clearfix'>";
270
  foreach ($buttons as $key => $ipe_buttons) {
271
    $key = ctools_cleanstring($key);
272
    $output .= "<div id='panels-ipe-control-$key' class='panels-ipe-control'>";
273

    
274
    // Controls in this container will appear when the IPE is not on.
275
    $output .= '<div class="panels-ipe-button-container clearfix">';
276
    foreach ($ipe_buttons as $button) {
277
      $output .= is_string($button) ? $button : drupal_render($button);
278
    }
279
    $output .= '</div>';
280

    
281
    // Controls in this container will appear when the IPE is on. It is usually
282
    // filled via AJAX.
283
    $output .= '<div class="panels-ipe-form-container clearfix"></div>';
284
    $output .= '</div>';
285
  }
286

    
287
  $output .= "</div>";
288

    
289
  return $output;
290
}