You are here

function homebox_admin_page in Homebox 6.3

Same name and namespace in other branches
  1. 6 homebox.admin.inc \homebox_admin_page()
  2. 6.2 homebox.admin.inc \homebox_admin_page()
  3. 7.3 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

2 string references to 'homebox_admin_page'
homebox_forms in ./homebox.module
Implementation of hook_forms().
homebox_menu in ./homebox.module
Implementation of hook_menu().

File

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

Code

function homebox_admin_page() {

  // Already validated
  $page = homebox_get_page(arg(4));
  if ($page) {
    drupal_set_title(t('Edit @title', array(
      '@title' => $page->settings['title'],
    )));
  }
  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' => check_plain(isset($page->settings['title']) ? $page->settings['title'] : ''),
    '#maxlength' => 64,
    '#required' => TRUE,
    '#prefix' => theme('advanced_help_topic', 'homebox', 'new-page'),
    '#description' => t('The title of the page that will be created.'),
  );
  $form['page']['options']['path'] = array(
    '#type' => 'textfield',
    '#title' => t('Path'),
    '#size' => 32,
    '#default_value' => isset($page->settings['path']) ? $page->settings['path'] : '',
    '#maxlength' => 255,
    '#required' => TRUE,
    '#description' => t('Specify an alternative 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('Create a menu entry'),
    '#description' => t('If checked, a menu entry will be created for this page.'),
    '#default_value' => isset($page->settings['menu']) ? $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' => isset($page->settings['enabled']) ? $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' => isset($page->settings['auto_save']) ? $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' => isset($page->settings['full']) ? $page->settings['full'] : 0,
  );
  $result = db_query('SELECT rid, name FROM {role} ORDER BY name');
  $role_options = array();
  while ($role = db_fetch_object($result)) {
    $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' => isset($page->settings['roles']) && 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']['import_fieldset'] = array(
      '#type' => 'fieldset',
      '#title' => 'Import Homebox',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['page']['import_fieldset']['import'] = array(
      '#title' => t('Import data'),
      '#type' => 'textarea',
      '#description' => t('Optionally include an exported Homebox to import settings and block layout. Ensure that the path is currently not in use. The machine name supplied in the import data will be ignored.'),
    );
    $form['page']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Add page'),
    );
    $form['#submit'][] = 'homebox_admin_page_submit';
    $form['#validate'][] = 'homebox_admin_page_validate';
  }
  return $form;
}