You are here

function _subform_page in Subform 5

Menu edit/view callback

1 string reference to '_subform_page'
subform_menu in ./subform.module

File

./subform.module, line 472

Code

function _subform_page() {
  $node_id = arg(1);
  $operation = arg(2);

  // drupal_add_js('misc/autocomplete.js');
  drupal_add_js('misc/collapse.js');
  drupal_add_css(drupal_get_path('module', 'content') . '/content.css');
  $node = node_load($node_id);
  if ($operation == 'edit') {

    // since the result of ALL edit operations is redirection to edit, we need to check if the requested op was delete
    // this chunk of code ripped from node.module
    if ($_POST['op'] == 'Delete') {
      if ($_REQUEST['destination']) {
        $destination = drupal_get_destination();
        unset($_REQUEST['destination']);
      }
      drupal_goto('subform/' . arg(1) . '/delete', $destination);
      return;
    }
    $form = node_form_array($node);
    unset($form['preview']);
    $form['#redirect'] = "subform/{$node_id}/edit";
    $content = drupal_get_form($node->type . '_node_form', $form, 'node_form');
    $messages = theme_status_messages();
  }
  else {
    if ($operation == 'delete') {
      node_delete($node_id);
      $content = '';
    }
    else {
      $content = node_view($node);
    }
  }
  $head = drupal_get_html_head();
  $styles = theme_get_styles();
  include_once 'subform.tpl.php';
}