You are here

function node_page in Drupal 4

Menu callback; dispatches control to the appropriate operation handler.

2 string references to 'node_page'
comment_menu in modules/comment.module
Implementation of hook_menu().
node_menu in modules/node.module
Implementation of hook_menu().

File

modules/node.module, line 2086
The core that allows content to be submitted to the site.

Code

function node_page() {
  $op = arg(1);
  if (is_numeric($op)) {
    $op = arg(2) && !is_numeric(arg(2)) ? arg(2) : 'view';
  }
  switch ($op) {
    case 'view':
      if (is_numeric(arg(1))) {
        $node = node_load(arg(1));
        if ($node->nid) {
          drupal_set_title(check_plain($node->title));
          return node_show($node, arg(2));
        }
        else {
          if (db_result(db_query('SELECT nid FROM {node} WHERE nid = %d', arg(1)))) {
            drupal_access_denied();
          }
          else {
            drupal_not_found();
          }
        }
      }
      break;
    case 'add':
      return node_add(arg(2));
      break;
    case 'edit':
      if ($_POST['op'] == t('Delete')) {

        // Note: we redirect from node/uid/edit to node/uid/delete to make the tabs disappear.
        if ($_REQUEST['destination']) {
          $destination = drupal_get_destination();
          unset($_REQUEST['destination']);
        }
        drupal_goto('node/' . arg(1) . '/delete', $destination);
      }
      if (is_numeric(arg(1))) {
        $node = node_load(arg(1));
        if ($node->nid) {
          drupal_set_title(check_plain($node->title));
          return node_form($node);
        }
        else {
          if (db_result(db_query('SELECT nid FROM {node} WHERE nid = %d', arg(1)))) {
            drupal_access_denied();
          }
          else {
            drupal_not_found();
          }
        }
      }
      break;
    default:
      drupal_set_title('');
      return node_page_default();
  }
}