function quickedit_ctools_render_alter in Quick Edit 7
Implements hook_ctools_render_alter().
Sets data-quickedit-entity-id attribute in case of a panelized, full-page entity view.
See also
quickedit_preprocess_panelizer_view_mode()
File
- includes/
panelizer.inc, line 17 - Implements Quick Edit module hooks on behalf of panelizer.module.
Code
function quickedit_ctools_render_alter(&$info, &$page, &$context) {
// Ignore task handlers that do not set any content, such as HTTP responses.
if ($context['task']['task type'] == 'page' && isset($info['content'])) {
foreach ($context['contexts'] as $page_context) {
if ($page_context->type[1] === 'entity') {
$entity_id = $context['args'][0];
$entity_type = $page_context->type[2];
$prefix = '<div data-quickedit-entity-id="' . $entity_type . '/' . $entity_id . '">';
$suffix = '</div>';
// If page_manager is returning a form, this will be an array.
// Otherwise it's likely to be a string.
if (is_array($info['content'])) {
$info['content']['#prefix'] = $prefix;
$info['content']['#suffix'] = $suffix;
}
else {
$info['content'] = $prefix . $info['content'] . $suffix;
}
// Detect when an entity is being rendered by page_manager, and then set
// a global (GASP!) variable. This is necessary, because page manager
// has an incorrectly applied "contextual-links-region" class: it's set
// on the wrong element (by ctools_context_handler_render_handler(),
// hence breaking Quick Edit module's JS in the process. The worst part:
// it is *impossible* to override it in a sane way.
// As always, there is a work-around in Drupal, but it's not pretty:
// detect here whether an entity is being rendered by page manager, set
// a global variable, and then let quickedit_page_build() perform string
// manipulation on the final $page renderable array.
global $quickedit_workaround_for_fundamentally_broken_page_manager;
$quickedit_workaround_for_fundamentally_broken_page_manager = TRUE;
break;
}
}
}
}