You are here

function commons_bw_handler_node_partial_form::render in Drupal Commons 7.3

Render the area.

Overrides views_handler_area::render

File

modules/commons/commons_bw/includes/views/handlers/commons_bw_handler_node_partial_form.inc, line 26

Class

commons_bw_handler_node_partial_form
Minified node creation form.

Code

function render($empty = FALSE) {
  $cache =& drupal_static(__METHOD__, array());
  $bundle = $this->options['bundle'];
  $group_id = !empty($this->view->args[0]) ? $this->view->args[0] : NULL;

  // Verify content creation access.
  $permission = "create {$bundle} content";
  if ($group_id && !og_user_access('node', $group_id, $permission)) {
    return;
  }
  elseif (!user_access($permission)) {
    return;
  }

  // Avoid rendering a form for the same bundle twice; Instead, mark that it
  // should be moved to this position from previously rendered form.
  // See partial_node_form.js.
  if (!empty($cache[$bundle])) {
    return '<div class="partial-node-form-placeholder" data-bundle="' . $bundle . '"></div>';
  }
  $cache[$bundle] = TRUE;
  $form = drupal_get_form("commons_bw_partial_node_form__{$bundle}", $bundle, $group_id);
  return render($form);
}