You are here

function homebox_admin_page in Homebox 7.3

Same name and namespace in other branches
  1. 6.3 homebox.admin.inc \homebox_admin_page()
  2. 6 homebox.admin.inc \homebox_admin_page()
  3. 6.2 homebox.admin.inc \homebox_admin_page()
  4. 7.2 homebox.admin.inc \homebox_admin_page()

@file Homebox admin file, takes care admin interface for homebox

Defines homebox pages, default layout, settings

1 call to homebox_admin_page()
homebox_clone_page in ./homebox.admin.inc
Form callback for cloning a homebox.
2 string references to 'homebox_admin_page'
homebox_forms in ./homebox.module
Implements hook_forms().
homebox_menu in ./homebox.module
Implements hook_menu().

File

./homebox.admin.inc, line 10
Homebox admin file, takes care admin interface for homebox

Code

function homebox_admin_page($form, &$form_state, $page = FALSE) {
  if (!$page) {
    $form['page'] = array(
      '#type' => 'fieldset',
      '#title' => t('Add a new page'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
  }
  $form['page']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Machine name'),
    '#required' => TRUE,
    '#size' => 32,
    '#maxlength' => 64,
    '#description' => t('The machine readable name of this page. It must be unique, and it must contain only alphanumeric characters and underscores. Once created, you will not be able to change this value!'),
  );
  if ($page) {
    $form['page']['name']['#value'] = $page->name;
    $form['page']['name']['#disabled'] = TRUE;
  }
  $form['page']['options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Homebox options'),
    '#collapsible' => TRUE,
  );
  if (!$page) {
    $form['page']['options']['#collapsed'] = TRUE;
  }
  $form['page']['options']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#size' => 32,
    '#default_value' => $page ? $page->settings['title'] : '',
    '#maxlength' => 64,
    '#required' => TRUE,
    '#description' => t('The title of the page that will be created.'),
  );
  $form['page']['options']['path'] = array(
    '#type' => 'textfield',
    '#title' => t('Path'),
    '#required' => TRUE,
    '#size' => 32,
    '#default_value' => $page ? $page->settings['path'] : '',
    '#maxlength' => 255,
    '#description' => t('Apecify a URL by which this page can be accessed. For example, type "dashboard" when creating a Dashboard page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
  );
  $form['page']['options']['menu'] = array(
    '#type' => 'checkbox',
    '#title' => t('Visible menu item'),
    '#description' => t('Can be positioned in <a href="!url">Menus admin</a>.', array(
      '!url' => url('admin/structure/menu'),
    )),
    '#default_value' => $page ? $page->settings['menu'] : 1,
  );
  $form['page']['options']['enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable the page'),
    '#description' => t('If unchecked, only users with the <em>administer homebox</em> permission will be able to view this page.'),
    '#default_value' => $page ? $page->settings['enabled'] : 1,
  );
  $form['page']['options']['auto_save'] = array(
    '#type' => 'checkbox',
    '#title' => t('Auto-save on changes'),
    '#description' => t('If checked, changes by users are saved immediately.'),
    '#default_value' => $page ? $page->settings['auto_save'] : 1,
  );
  $form['page']['options']['full'] = array(
    '#type' => 'checkbox',
    '#title' => t('Disable block regions'),
    '#description' => t('If checked, the theme block regions will be disabled for this page, giving more room for the homebox.'),
    '#default_value' => $page ? $page->settings['full'] : 0,
  );
  $result = db_query('SELECT rid, name FROM {role} ORDER BY name');
  $role_options = array();
  foreach ($result as $role) {
    $role_options[$role->name] = $role->name;
  }
  $form['page']['options']['roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Allow only certain roles to access the page'),
    '#default_value' => $page && count($page->settings['roles']) ? $page->settings['roles'] : array(
      'authenticated user',
    ),
    '#options' => $role_options,
    '#description' => t('Select which roles can view the page.'),
  );
  if ($page) {
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save page'),
      '#weight' => 2,
    );
    $form['delete'] = array(
      '#type' => 'submit',
      '#value' => homebox_page_is_api($page->name) ? t('Revert page') : t('Delete page'),
      '#weight' => 3,
    );
  }
  else {
    $form['page']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Add page'),
    );
    $form['#submit'][] = 'homebox_admin_page_submit';
    $form['#validate'][] = 'homebox_admin_page_validate';
  }
  return $form;
}