You are here

function panelizer_edit_node_settings_page in Panelizer 7

Same name and namespace in other branches
  1. 6 includes/node.inc \panelizer_edit_node_settings_page()

Page to edit basic settings on a panelized node.

1 string reference to 'panelizer_edit_node_settings_page'
panelizer_menu in ./panelizer.module
Implements hook_menu().

File

includes/node.inc, line 186
Contains routines specific to handling nodes that are panelized.

Code

function panelizer_edit_node_settings_page($node) {
  $panelizer = panelizer_load_node_panelizer($node);
  if (empty($panelizer)) {

    // If this node is not yet panelized, and there is no default panel
    // do to configuration, give them the option of panelizing it.
    if (panelizer_has_default('node', $node->type)) {
      return MENU_NOT_FOUND;
    }

    // Set the form to the Panelize It! form.
    $form_id = 'panelizer_panelize_node_form';

    // Fetch a special default panelizer that is only accessible with the
    // default_anyway flag.
    $panelizer = panelizer_load_node_panelizer($node, TRUE);
  }
  else {
    $form_id = 'panelizer_settings_form';
    $reset_button = TRUE;
  }
  $form_state = array(
    'panelizer' => &$panelizer,
    'no_redirect' => TRUE,
  );
  if (!empty($reset_button)) {
    $form_state['reset button'] = TRUE;
  }
  ctools_include('common', 'panelizer');
  $output = drupal_build_form($form_id, $form_state);
  if (!empty($form_state['executed'])) {
    if (empty($form_state['clicked_button']['#reset'])) {
      drupal_set_message(t('The settings have been updated.'));
      panelizer_save_node_panelizer($panelizer);
    }
    else {
      panelizer_delete_node_panelizer($panelizer);
      drupal_set_message(t('The node panel has been reset to the default.'));
    }
    drupal_goto($_GET['q']);
  }
  return $output;
}