You are here

function quickedit_preprocess_page in Quick Edit 7

Implements hook_preprocess_page().

Wraps title field when viewing a node page to make it in-place editable.

File

./quickedit.module, line 495
Provides in-place content editing functionality for fields.

Code

function quickedit_preprocess_page(&$variables) {

  // If the user lacks the appropriate permission, return early to avoid
  // processing.
  if (!user_access('access in-place editing')) {
    return;
  }

  // If we don't have a node object to work with, return early to avoid
  // processing.
  if (empty($variables['node'])) {
    return;
  }

  // On full node pages the title of the node becomes the page title so we
  // must handle it differently. In this case, we add a wrapper around the
  // title with the required attributes to enable in-place editability.
  $node = $variables['node'];
  $node_type = node_type_get_type($node->type);
  if ($node_type->has_title) {
    $language = !empty($node->language) ? $node->language : LANGUAGE_NONE;
    $variables['title'] = quickedit_wrap_pseudofield(drupal_get_title(), "node/{$node->nid}/title/{$language}/full");
  }
}