You are here

function panelizer_settings_page_form in Panelizer 7

Same name and namespace in other branches
  1. 6 includes/admin.inc \panelizer_settings_page_form()
  2. 7.3 includes/admin.inc \panelizer_settings_page_form()
  3. 7.2 includes/admin.inc \panelizer_settings_page_form()

Primary settings page.

This settings page allows the administrator to select which node types can be panelized, whether they have a default, and provides links to edit those defaults.

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

File

includes/admin.inc, line 14
Contains administrative forms and settings.

Code

function panelizer_settings_page_form($form, &$form_state) {
  ctools_include('dependent');
  $form = array();
  $task = page_manager_get_task('node_view');
  if (!empty($task->disabled)) {
    drupal_set_message('The node template page is currently not enabled in page manager. You must enable this for Panelizer to be able to panelize nodes.', 'warning');
  }
  $handler = page_manager_load_task_handler($task, '', 'node_view_panelizer');
  if (!empty($handler->disabled)) {
    drupal_set_message('The panelizer variant on the node template page is currently not enabled in page manager. You must enable this for Panelizer to be able to panelize nodes.', 'warning');
  }
  $form['types'] = array(
    '#tree' => TRUE,
  );

  // Add 'node' settings
  $form['types']['node'] = array(
    '#theme' => 'panelizer_node_settings_page_form',
  );
  $types = node_type_get_names();
  $context = 'node';
  drupal_alter('panelizer_default_types', $types, $context);
  foreach ($types as $type => $title) {
    $base_id = str_replace(array(
      '][',
      '_',
      ' ',
    ), '-', '#edit-types-node-' . $type);
    $base_url = 'admin/config/content/panelizer/node/' . $type;
    $settings = variable_get('panelizer_defaults_node_' . $type, array());
    $form['types']['node'][$type]['title'] = array(
      '#markup' => $title,
    );
    $form['types']['node'][$type]['status'] = array(
      '#type' => 'checkbox',
      '#default_value' => !empty($settings['status']),
    );
    $form['types']['node'][$type]['default'] = array(
      '#type' => 'checkbox',
      '#default_value' => !empty($settings['default']),
      '#states' => array(
        'visible' => array(
          $base_id . '-status' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );
    $form['types']['node'][$type]['choice'] = array(
      '#type' => 'checkbox',
      '#default_value' => !empty($settings['choice']),
      '#status' => array(
        'visible' => array(
          $base_id . '-status' => array(
            'checked' => TRUE,
          ),
        ),
      ),
      '#access' => FALSE,
    );
    $form['types']['node'][$type]['links'] = array(
      '#prefix' => '<div class="container-inline">',
      '#suffix' => '</div>',
    );

    // Panelize is on all content types get this option
    $links = array(
      'settings' => array(
        'title' => t('allowed content'),
        'href' => $base_url . '/allowed',
      ),
    );
    $form['types']['node'][$type]['links']['basic'] = array(
      '#type' => 'item',
      '#title' => theme('links', array(
        'links' => $links,
        'attributes' => array(
          'class' => 'links inline',
        ),
      )),
      '#states' => array(
        'visible' => array(
          $base_id . '-status' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );

    // Panelize is enabled and a default panel will be provided
    $links = array(
      'settings' => array(
        'title' => t('settings'),
        'href' => $base_url . '/settings',
      ),
      'context' => array(
        'title' => t('context'),
        'href' => $base_url . '/context',
      ),
      'layout' => array(
        'title' => t('layout'),
        'href' => $base_url . '/layout',
      ),
      'content' => array(
        'title' => t('content'),
        'href' => $base_url . '/content',
      ),
    );
    $form['types']['node'][$type]['links']['default'] = array(
      '#type' => 'item',
      '#title' => theme('links', array(
        'links' => $links,
        'attributes' => array(
          'class' => 'links inline',
        ),
      )),
      '#states' => array(
        'visible' => array(
          $base_id . '-default' => array(
            'checked' => TRUE,
          ),
        ),
      ),
    );

    /*
    $links = array(
      'list' => array(
        'title' => t('list'),
        'href' => $base_url . '/list',
      ),
    );

    $form['types']['node'][$type]['links']['default2'] = array(
      '#type' => 'item',
      '#title' => theme('links', array(
        'links' => $links,
        'attributes' => array('class' => 'links inline'),
      )),
      '#states' => array(
        'visible' => array(
          $base_id . '-status' => array('checked' => TRUE),
          $base_id . '-choice' => array('checked' => TRUE),
        ),
      ),
    );
    */
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}