You are here

function panels_sections_admin_settings_form in Panels Sections 6

Same name and namespace in other branches
  1. 6.2 panels_sections.module \panels_sections_admin_settings_form()
1 string reference to 'panels_sections_admin_settings_form'
panels_sections_menu in ./panels_sections.module
Implementation of hook_menu().

File

./panels_sections.module, line 121
Allows you to define panels_sections of your site and apply s to those panels_sections.

Code

function panels_sections_admin_settings_form($form_state, $section = NULL) {
  module_load_include('.inc', 'panels_page', 'panels_page.read');
  if (!is_object($section)) {
    $section = new stdClass();
  }
  $access = user_access('use PHP for block visibility');
  $form = array();
  $options = array(
    t('Take over all pages except the listed pages.'),
    t('Take over only the listed pages.'),
  );
  $description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
    '%blog' => 'blog',
    '%blog-wildcard' => 'blog/*',
    '%front' => '<front>',
  ));
  if ($access) {
    $options[] = t('Take over if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
    $description .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array(
      '%php' => '<?php ?>',
    ));
  }
  $form['section_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Section settings'),
  );
  $form['section_settings']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#default_value' => $section->name,
    '#size' => 40,
    '#maxlength' => 64,
    '#description' => t('Give the name of the section'),
  );
  $form['section_settings']['visibility'] = array(
    '#type' => 'radios',
    '#title' => t('Activate section on the specific pages'),
    '#options' => $options,
    '#default_value' => $section->visibility ? $section->visibility : 0,
  );
  $form['section_settings']['path'] = array(
    '#type' => 'textarea',
    '#title' => t('Pages'),
    '#default_value' => $section->path,
    '#cols' => 40,
    '#rows' => 5,
    '#description' => $description,
  );
  $form['section_settings']['status'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enabled'),
    '#default_value' => $section->status,
    '#description' => t('Enable or disable this section'),
  );
  $form['section_settings']['panels_page'] = array(
    '#type' => 'select',
    '#title' => t('Select Panels Page'),
    '#default_value' => $section->panels_page,
    '#options' => _panels_sections_panels_page_select(),
    '#description' => t('Select the Panels Page you want to use for this section'),
  );
  $form['section_settings']['weight'] = array(
    '#type' => 'weight',
    '#title' => t('Weight'),
    '#default_value' => $section->weight,
  );
  if ($section->sid) {

    //we are updating
    drupal_set_title(t('Edit section %name', array(
      '%name' => $section->name,
    )));
    $form['sid'] = array(
      '#type' => 'hidden',
      '#value' => $section->sid,
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save section'),
    );
  }
  else {

    //we are adding
    drupal_set_title(t('Add section'));
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Add section'),
    );
  }
  return $form;
}