Révision 64156087
Ajouté par Assos Assos il y a plus de 7 ans
drupal7/sites/all/modules/panels/plugins/task_handlers/panel_context.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* |
|
6 | 5 |
* This is the task handler plugin to handle attaching a panel to any |
7 | 6 |
* task that advertises itself as a 'context' type, which all of the |
8 | 7 |
* basic page tasks provided by page_manager.module do by default. |
9 | 8 |
*/ |
10 | 9 |
|
11 |
// Plugin definition |
|
10 |
// Plugin definition.
|
|
12 | 11 |
$plugin = array( |
13 |
// is a 'context' handler type, meaning it supports the API of the
|
|
12 |
// Is a 'context' handler type, meaning it supports the API of the
|
|
14 | 13 |
// context handlers provided by ctools context plugins. |
15 | 14 |
'handler type' => 'context', |
16 | 15 |
'visible' => TRUE, // may be added up front. |
17 | 16 |
|
18 | 17 |
// Administrative fields. |
19 | 18 |
'title' => t('Panel'), |
20 |
'admin summary' =>'panels_panel_context_admin_summary', |
|
19 |
'admin summary' => 'panels_panel_context_admin_summary',
|
|
21 | 20 |
'admin title' => 'panels_panel_context_title', |
22 | 21 |
'operations' => array( |
23 | 22 |
'settings' => array( |
... | ... | |
115 | 114 |
|
116 | 115 |
// Callback to render the data. |
117 | 116 |
'render' => 'panels_panel_context_render', |
118 |
// Callback to return addressable data |
|
117 |
// Callback to return addressable data.
|
|
119 | 118 |
'addressable callback' => 'panels_panel_context_get_addressable', |
120 | 119 |
|
121 | 120 |
// Various callbacks for operations performed on the handler to ensure |
... | ... | |
216 | 215 |
* simply means that the display has been modified and is awaiting |
217 | 216 |
* save. The modified one should always be used for editing purposes. |
218 | 217 |
* - If none of the above is true, then a new display needs to be created |
219 |
* for the handler and pla |
|
218 |
* for the handler and pla.
|
|
220 | 219 |
*/ |
221 | 220 |
function &panels_panel_context_get_display(&$handler) { |
222 | 221 |
if (!isset($handler->conf['display'])) { |
... | ... | |
269 | 268 |
ctools_include('context-task-handler'); |
270 | 269 |
ctools_include('plugins', 'panels'); |
271 | 270 |
|
272 |
// Add my contexts |
|
271 |
// Add my contexts.
|
|
273 | 272 |
$contexts = ctools_context_handler_get_handler_contexts($base_contexts, $handler); |
274 | 273 |
|
275 | 274 |
// Test. |
... | ... | |
281 | 280 |
ctools_context_handler_pre_render($handler, $contexts, $args); |
282 | 281 |
} |
283 | 282 |
|
284 |
// Load the display |
|
283 |
// Load the display.
|
|
285 | 284 |
$display = panels_panel_context_get_display($handler); |
286 | 285 |
|
287 | 286 |
$display->context = $contexts; |
... | ... | |
298 | 297 |
$css_id = 'panel_context:' . $handler->name; |
299 | 298 |
$filename = ctools_css_retrieve($css_id); |
300 | 299 |
if (!$filename) { |
301 |
// Add keywords from context |
|
300 |
// Add keywords from context.
|
|
302 | 301 |
$css = ctools_context_keyword_substitute($handler->conf['css'], array(), $contexts, array('css safe' => TRUE)); |
303 | 302 |
$filename = ctools_css_store($css_id, $css); |
304 | 303 |
} |
... | ... | |
311 | 310 |
$renderer = panels_get_renderer($handler->conf['pipeline'], $display); |
312 | 311 |
// If the IPE is enabled, but the user does not have access to edit |
313 | 312 |
// load the standard renderer instead. |
314 |
|
|
315 | 313 |
$parents = class_parents($renderer); |
316 | 314 |
if (!empty($parents['panels_renderer_editor']) && !user_access('user page manager') && !user_access('use ipe with page manager')) { |
317 | 315 |
$renderer = panels_get_renderer_handler('standard', $display); |
318 | 316 |
} |
319 | 317 |
|
320 |
// Remove and add body element classes |
|
318 |
// Remove and add body element classes.
|
|
321 | 319 |
$panel_body_css = &drupal_static('panel_body_css'); |
322 | 320 |
|
323 | 321 |
if (isset($handler->conf['body_classes_to_remove'])) { |
... | ... | |
325 | 323 |
if (!isset($panel_body_css['body_classes_to_remove'])) { |
326 | 324 |
$panel_body_css['body_classes_to_remove'] = check_plain($classes); |
327 | 325 |
} |
328 |
else{ |
|
326 |
else {
|
|
329 | 327 |
$panel_body_css['body_classes_to_remove'] .= ' ' . check_plain($classes); |
330 | 328 |
} |
331 | 329 |
} |
332 | 330 |
if (isset($handler->conf['body_classes_to_add'])) { |
333 | 331 |
$classes = ctools_context_keyword_substitute($handler->conf['body_classes_to_add'], array(), $contexts, array('css safe' => TRUE)); |
334 | 332 |
if (!isset($panel_body_css['body_classes_to_add'])) { |
335 |
$panel_body_css['body_classes_to_add'] = check_plain($classes); |
|
333 |
$panel_body_css['body_classes_to_add'] = check_plain($classes);
|
|
336 | 334 |
} |
337 | 335 |
else { |
338 |
$panel_body_css['body_classes_to_add'] .= ' '. check_plain($classes); |
|
336 |
$panel_body_css['body_classes_to_add'] .= ' ' . check_plain($classes);
|
|
339 | 337 |
} |
340 | 338 |
} |
341 | 339 |
|
... | ... | |
399 | 397 |
/** |
400 | 398 |
* When a handler is cloned, we have to clone the display. |
401 | 399 |
*/ |
402 |
function panels_panel_context_clone(&$handler) {
|
|
400 |
function panels_panel_context_clone(&$handler) { |
|
403 | 401 |
$old_display = panels_panel_context_get_display($handler); |
404 | 402 |
$code = panels_export_display($old_display); |
405 | 403 |
eval($code); |
... | ... | |
454 | 452 |
ctools_include('context'); |
455 | 453 |
ctools_include('context-task-handler'); |
456 | 454 |
|
457 |
// Get the operations |
|
455 |
// Get the operations.
|
|
458 | 456 |
$operations = page_manager_get_operations($page); |
459 | 457 |
|
460 | 458 |
// Get operations for just this handler. |
... | ... | |
529 | 527 |
|
530 | 528 |
$output .= '<div class="clearfix">'; |
531 | 529 |
if ($show_title) { |
532 |
$output .= '<div class="handler-title clearfix">'; |
|
530 |
$output .= '<div class="handler-title clearfix">';
|
|
533 | 531 |
$output .= '<div class="actions handler-actions">' . $rendered_operations['actions'] . '</div>'; |
534 | 532 |
$output .= '<span class="title-label">' . $title . '</span>'; |
535 | 533 |
} |
... | ... | |
537 | 535 |
$output .= '</div>'; |
538 | 536 |
$output .= $info; |
539 | 537 |
$output .= '</div>'; |
540 |
/* |
|
538 |
/*
|
|
541 | 539 |
$output .= '<div class="right-container">'; |
542 | 540 |
$output .= '<h3 class="context-title">' . t('Contexts') . $context_link . '</h3>'; |
543 | 541 |
$output .= $contexts; |
544 | 542 |
$output .= '</div>'; |
545 | 543 |
|
546 | 544 |
$output .= '<div class="left-container">'; |
547 |
// $output .= $icon; |
|
545 |
// $output .= $icon;
|
|
548 | 546 |
$output .= '<h3 class="handler-title">' . t('Content') . $content_link . '</h3>'; |
549 | 547 |
$output .= $content; |
550 | 548 |
$output .= '</div>'; |
551 |
*/ |
|
549 |
*/
|
|
552 | 550 |
return $output; |
553 | 551 |
} |
554 | 552 |
|
555 | 553 |
// -------------------------------------------------------------------------- |
556 |
// Forms |
|
557 |
|
|
554 |
// Forms. |
|
558 | 555 |
/** |
559 | 556 |
* General notes about forms: The handler is automatically cached by the form |
560 | 557 |
* wizard, so anything we store on $form_state['handler'] anywhere will get |
... | ... | |
689 | 686 |
$form = panels_change_layout($form, $form_state); |
690 | 687 |
|
691 | 688 |
// Change the 'back' button to just go directly to the previous form |
692 |
// $task_id = $form_state['task']['name']; |
|
693 |
// $handler_id = $form_state['handler']->handler; |
|
694 |
// $name = $form_state['handler']->name; |
|
695 |
|
|
689 |
// $task_id = $form_state['task']['name']; |
|
690 |
// $handler_id = $form_state['handler']->handler; |
|
691 |
// $name = $form_state['handler']->name; |
|
696 | 692 |
// This form is outside the normal wizard list, so we need to specify the |
697 | 693 |
// previous/next forms. |
698 | 694 |
$form['buttons']['previous']['#next'] = 'layout'; |
... | ... | |
750 | 746 |
panels_edit_display_form_submit($form, $form_state); |
751 | 747 |
$handler = &$form_state['handler']; |
752 | 748 |
|
753 |
// update the cached display:
|
|
749 |
// Update the cached display:
|
|
754 | 750 |
$display = $form_state['page']->display_cache[$form_state['handler_id']]->display; |
755 | 751 |
$handler->conf['display'] = $display; |
756 | 752 |
unset($form_state['page']->display_cache[$form_state['handler_id']]); |
... | ... | |
761 | 757 |
} |
762 | 758 |
|
763 | 759 |
/** |
764 |
* General settings for the panel |
|
760 |
* General settings for the panel.
|
|
765 | 761 |
*/ |
766 | 762 |
function panels_panel_context_edit_settings($form, &$form_state) { |
767 | 763 |
$conf = $form_state['handler']->conf; |
... | ... | |
874 | 870 |
$form['preview'] = array(); |
875 | 871 |
ctools_context_replace_form($form['preview'], $contexts); |
876 | 872 |
|
877 |
// automatically preview if there are no argument placeholders.
|
|
873 |
// Automatically preview if there are no argument placeholders.
|
|
878 | 874 |
if (empty($form['preview'])) { |
879 | 875 |
$display = panels_panel_context_get_display($form_state['handler']); |
880 | 876 |
$display->context = $contexts; |
... | ... | |
913 | 909 |
} |
914 | 910 |
|
915 | 911 |
function panels_panel_context_get_addressable($task, $subtask_name, $handler, $address, $contexts, $arguments, $type) { |
916 |
// Load the display |
|
912 |
// Load the display.
|
|
917 | 913 |
$display = panels_panel_context_get_display($handler); |
918 | 914 |
|
919 | 915 |
$display->context = $contexts; |
Formats disponibles : Unified diff
Weekly update of contrib modules