Projet

Général

Profil

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

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

1
<?php
2

    
3
/**
4
 * Implementation of hook_ctools_plugin_directory().
5
 */
6
function panels_ipe_ctools_plugin_directory($module, $plugin) {
7
  if ($module == 'panels' && $plugin == 'display_renderers') {
8
    return 'plugins/' . $plugin;
9
  }
10
}
11

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

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

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

    
70
  $output = '<div class="panels-ipe-placeholder-content">';
71
  $output .= "<h3>$region_title</h3>";
72
  $output .= '</div>';
73
  return $output;
74
}
75

    
76
function template_preprocess_panels_ipe_pane_wrapper(&$vars) {
77
  $pane = $vars['pane'];
78
  $display = $vars['display'];
79
  $renderer = $vars['renderer'];
80

    
81
  $content_type = ctools_get_content_type($pane->type);
82
  $subtype = ctools_content_get_subtype($content_type, $pane->subtype);
83
  $vars['links'] = array();
84

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

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

    
111
  // Deleting is managed entirely in the js; this is just an attachment point
112
  // for it
113
  $vars['links']['delete'] = array(
114
    'title' => '<span>' . t('Delete') . '</span>',
115
    'href' => '#',
116
    'html' => TRUE,
117
    'attributes' => array(
118
      'class' => 'pane-delete',
119
      'id' => "pane-delete-panel-pane-$pane->pid",
120
      'title' => t('Delete'),
121
    ),
122
  );
123

    
124
  $context = array(
125
    'pane' => $pane,
126
    'display' => $display,
127
    'renderer' => $renderer
128
  );
129
  drupal_alter('panels_ipe_pane_links', $vars['links'], $context);
130

    
131
}
132

    
133
function theme_panels_ipe_pane_wrapper($vars) {
134
  $output = $vars['output'];
135
  $pane = $vars['pane'];
136
  $display = $vars['display'];
137

    
138
  $attributes = array(
139
    'class' => 'panels-ipe-linkbar',
140
  );
141

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

    
145
  $links = theme('links', array('links' => $vars['links'], 'attributes' => $attributes));
146

    
147
  if (!empty($pane->locks['type']) && $pane->locks['type'] == 'immovable') {
148
    $links = '<div class="panels-ipe-dragbar panels-ipe-nodraghandle clearfix">' . $links .$title .'</div>';
149
  }
150
  else {
151
    $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>';
152
  }
153

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

    
156
  return $handlebar . $output;
157
}
158

    
159
function theme_panels_ipe_region_wrapper($vars) {
160
  return $vars['controls'] . $vars['output'];
161
}
162

    
163
function template_preprocess_panels_ipe_add_pane_button(&$vars) {
164
  $region_id = $vars['region_id'];
165
  $display = $vars['display'];
166
  $renderer = $vars['renderer'];
167
  $vars['links'] = '';
168

    
169
  // Add option to configure style in IPE
170
  if (user_access('administer panels styles')) {
171
    $vars['links']['style'] = array(
172
      'title' => '<span>' . t('Region style') . '</span>',
173
      'href' => $renderer->get_url('style-type', 'region', $region_id),
174
      'html' => TRUE,
175
      'attributes' => array(
176
        'class' => array('ctools-use-modal', 'panels-ipe-hide-bar', 'style'),
177
        'title' => t('Region style'),
178
      ),
179
    );
180
  }
181

    
182
  // Add option to add items in the IPE
183
  $vars['links']['add-pane'] = array(
184
    'title' => '<span>' . t('Add new pane') . '</span>',
185
    'href' => $renderer->get_url('select-content', $region_id),
186
    'attributes' => array(
187
      'class' => array('ctools-use-modal', 'add', 'panels-ipe-hide-bar'),
188
      'title' => t('Add new pane'),
189
    ),
190
    'html' => TRUE,
191
  );
192

    
193
  $context = array(
194
    'region_id' => $region_id,
195
    'display' => $display,
196
    'renderer' => $renderer,
197
  );
198
  drupal_alter('panels_ipe_region_links', $vars['links'], $context);
199

    
200
}
201

    
202
function theme_panels_ipe_add_pane_button($vars) {
203
  $attributes = array(
204
    'class' => array('panels-ipe-linkbar', 'inline'),
205
  );
206

    
207
  $links = theme('links', array('links' => $vars['links'], 'attributes' => $attributes));
208

    
209
  return '<div class="panels-ipe-newblock panels-ipe-on">' . $links . '</div>';
210
}
211

    
212
/**
213
 * @deprecated
214
 */
215
function panels_ipe_get_cache_key($key = NULL) {
216
  return array();
217
}
218

    
219
/**
220
 * Add a button to the IPE toolbar.
221
 */
222
function panels_ipe_toolbar_add_button($cache_key, $id, $button) {
223
  $buttons = &drupal_static('panels_ipe_toolbar_buttons', array());
224
  $buttons[$cache_key][$id] = $button;
225
}
226

    
227
/**
228
 * Implementation of hook_footer()
229
 *
230
 * Adds the IPE control container.
231
 *
232
 * @param unknown_type $main
233
 */
234
function panels_ipe_page_alter(&$page) {
235
  $buttons = &drupal_static('panels_ipe_toolbar_buttons', array());
236
  if (empty($buttons)) {
237
    return;
238
  }
239

    
240
  $output = theme('panels_ipe_toolbar', array('buttons' => $buttons));
241

    
242
  $page['page_bottom']['panels_ipe'] = array(
243
    '#markup' => $output,
244
  );
245
}
246

    
247
function theme_panels_ipe_toolbar($vars) {
248
  $buttons = $vars['buttons'];
249

    
250
  $output = "<div id='panels-ipe-control-container' class='clearfix'>";
251
  foreach ($buttons as $key => $ipe_buttons) {
252
    $output .= "<div id='panels-ipe-control-$key' class='panels-ipe-control'>";
253

    
254
    // Controls in this container will appear when the IPE is not on.
255
    $output .= '<div class="panels-ipe-button-container clearfix">';
256
    foreach ($ipe_buttons as $button) {
257
      $output .= is_string($button) ? $button : drupal_render($button);
258
    }
259
    $output .= '</div>';
260

    
261
    // Controls in this container will appear when the IPE is on. It is usually
262
    // filled via AJAX.
263
    $output .= '<div class="panels-ipe-form-container clearfix"></div>';
264
    $output .= '</div>';
265
  }
266

    
267
  $output .= "</div>";
268

    
269
  return $output;
270
}