You are here

function image_gallery_admin_settings in Image 7

Same name and namespace in other branches
  1. 5.2 contrib/image_gallery/image_gallery.module \image_gallery_admin_settings()
  2. 5 contrib/image_gallery/image_gallery.module \image_gallery_admin_settings()
  3. 6 contrib/image_gallery/image_gallery.admin.inc \image_gallery_admin_settings()

Menu callback for settings page.

1 string reference to 'image_gallery_admin_settings'
image_gallery_menu in contrib/image_gallery/image_gallery.module
Implementation of hook_menu().

File

contrib/image_gallery/image_gallery.admin.inc, line 11
Contains menu callbacks for image_gallery admin pages.

Code

function image_gallery_admin_settings() {
  _image_check_settings();

  // Show various messages if Views module is enabled.
  if (module_exists('views')) {

    // Test the status of the view:
    // It's enabled by default, so either:
    // - not set: view enabled
    // - FALSE:   view enabled
    // - TRUE:    view disabled
    // @see views_get_all_views().
    $status = variable_get('views_defaults', array());
    if (isset($status['image_gallery']) && $status['image_gallery']) {

      // The view is disabled: tell the user that more interesting things can be done.
      $form['info']['#value'] = t('Enabling the <a href="!views-link">image_gallery view</a> will give you many more ways to customize your galleries.', array(
        '!views-link' => url('admin/build/views'),
      ));
    }
    else {

      // The view is enabled: explain why there are no settings here and leave.
      $form['info'] = array(
        '#type' => 'item',
        '#title' => t('Image galleries are being made with the Views module'),
      );
      if (module_exists('views_ui')) {
        $form['info']['#value'] = t('To change the way galleries are displayed, edit the image_gallery view on the <a href="!views-link">Views administration page</a>.', array(
          '!views-link' => url('admin/build/views'),
        ));
      }
      else {
        $form['info']['#value'] = t('To change the way galleries are displayed, enable the <strong>Views UI</strong> module on the <a href="!modules-link">Modules administration page</a>, then override the default image_gallery view.', array(
          '!modules-link' => url('admin/build/modules'),
        ));
      }
      return $form;
    }
  }
  $form['gallery'] = array(
    '#type' => 'fieldset',
    '#title' => t('Gallery settings'),
  );
  $form['gallery']['image_images_per_page'] = array(
    '#type' => 'textfield',
    '#title' => t('Images per page'),
    '#default_value' => variable_get('image_images_per_page', 6),
    '#size' => 3,
    '#description' => t('Sets the number of images to be displayed in a gallery page.'),
  );
  $form['gallery']['image_gallery_node_info'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display node info'),
    '#default_value' => variable_get('image_gallery_node_info', 0),
    '#description' => t("Checking this will display the \"Posted by\" node information on the gallery pages."),
  );
  $form['gallery']['image_gallery_sort_order'] = array(
    '#type' => 'radios',
    '#title' => t('Image display sort order'),
    '#default_value' => variable_get('image_gallery_sort_order', IMAGE_GALLERY_SORT_CREATE_DESC),
    '#options' => array(
      IMAGE_GALLERY_SORT_CREATE_DESC => t('Create date, newest first'),
      IMAGE_GALLERY_SORT_CREATE_ASC => t('Create date, oldest first'),
      IMAGE_GALLERY_SORT_FILENAME => t('File name'),
      IMAGE_GALLERY_SORT_TITLE => t('Image title'),
    ),
  );
  return system_settings_form($form);
}