You are here

function front_page_admin in Front Page 6.2

Same name and namespace in other branches
  1. 5 front_page.module \front_page_admin()
  2. 6 front_page.module \front_page_admin()
  3. 7.2 front_page.admin.inc \front_page_admin()
  4. 7 front_page.module \front_page_admin()

Form for configuring front page settings.

1 string reference to 'front_page_admin'
front_page_menu in ./front_page.module
Implementation of hook_menu().

File

./front_page.admin.inc, line 11
Admin page callbacks for the front page module.

Code

function front_page_admin() {
  $form['front_page_enable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Front Page Override'),
    '#description' => t('Enable this if you want the front page module to manage the home page.'),
    '#default_value' => variable_get('front_page_enable', 0),
  );

  // Load any existing settings and build the by redirect by role form
  $form['roles'] = array(
    '#tree' => TRUE,
    '#type' => 'fieldset',
    '#title' => t('Roles'),
    '#description' => t('These are the settings for each role. If Front Page Override is enabled when a user reaches the home page the site will iterate through the roles below from top to bottom until firstly the user has the role and secondly the role is not set to SKIP. If no roles get selected the site front page will be shown. To rearrange the order in which the roles are processed you may do this at the !link.', array(
      '!link' => l(t('Arrange tab'), 'admin/config/front/arrange'),
    )),
    '#collapsible' => FALSE,
  );

  // build the form for roles
  $roles = user_roles();
  $front_page_data = front_page_get_all();

  // Set the type options common for all roles.
  $options = array(
    '' => t('skip'),
    'themed' => t('themed'),
    'full' => t('full'),
    'redirect' => t('redirect'),
    'alias' => t('alias'),
  );

  // Set the description common for all roles.
  $description = '<dl><dt>' . t('themed') . '</dt>
      <dd>' . t('means your default layout, theme and stylesheet will be loaded with your custom front_page.') . '</dd></dl>';
  $description .= '<dl><dt>' . t('full') . '</dt>
      <dd>' . t('allows you to have a completely different layout, style sheet etc.') . '</dd></dl>';
  $description .= '<dl><dt>' . t('redirect') . '</dt>
      <dd>' . t('will automatically redirect visitors already logged in to a specific page specified in the REDIRECT TO box.') . '</dd></dl>';
  $description .= '<dl><dt>' . t('alias') . '</dt>
      <dd>' . t('will display the page listed in path as if it were the home page. This option does not redirect.') . '</dd></dl>';
  foreach ($roles as $rid => $role) {
    $form['roles'][$rid] = array(
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#title' => t('Front Page for !rolename.', array(
        '!rolename' => $role,
      )),
      '#weight' => isset($front_page_data[$rid]['weight']) ? $front_page_data[$rid]['weight'] : 0,
    );
    $form['roles'][$rid]['mode'] = array(
      '#type' => 'select',
      '#title' => t('Select mode'),
      '#default_value' => isset($front_page_data[$rid]['mode']) ? $front_page_data[$rid]['mode'] : '',
      '#options' => $options,
      '#description' => '<p>' . $description . '</p>',
    );
    $form['roles'][$rid]['data'] = array(
      '#type' => 'textarea',
      '#title' => t('Data'),
      '#default_value' => isset($front_page_data[$rid]['data']) && isset($front_page_data[$rid]['mode']) && ($front_page_data[$rid]['mode'] == 'themed' || $front_page_data[$rid]['mode'] == 'full') ? $front_page_data[$rid]['data'] : NULL,
      '#description' => t('Paste your HTML or TEXT here.') . '<br /><br />' . t('You can paste in the full HTML code for a complete page and include a different style sheet in the HEAD of the document if you want a completely different layout and style to the rest of your site.'),
    );
    $format = !empty($front_page_data[$rid]['filter_format']) ? $front_page_data[$rid]['filter_format'] : NULL;
    $form['roles'][$rid]['filter_format'] = filter_form($format, NULL, array(
      'roles',
      $rid,
      'filter_format',
    ));
    $form['roles'][$rid]['path'] = array(
      '#type' => 'textfield',
      '#title' => t('Path'),
      '#default_value' => isset($front_page_data[$rid]['data']) && isset($front_page_data[$rid]['mode']) && ($front_page_data[$rid]['mode'] == 'redirect' || $front_page_data[$rid]['mode'] == 'alias') ? $front_page_data[$rid]['data'] : NULL,
      '#cols' => 20,
      '#rows' => 1,
      '#description' => t('If you are using <strong>Redirect</strong> or <strong>Alias</strong> you need to specify the path. An alias path should only include the URL part of a URL (eg "node/51"). A redirect path can contain a full URL including get parameters and fragment string (eg "node/51?page=5#anchor").'),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save Settings'),
  );
  return $form;
}