You are here

function ad_image_global_settings in Advertisement 6.3

Same name and namespace in other branches
  1. 5.2 image/ad_image.module \ad_image_global_settings()
  2. 5 image/ad_image.module \ad_image_global_settings()
  3. 6 image/ad_image.module \ad_image_global_settings()
  4. 6.2 image/ad_image.module \ad_image_global_settings()
  5. 7 image/ad_image.module \ad_image_global_settings()

Image ad settings form.

File

image/ad_image.module, line 123
Enhances the ad module to support banner ads.

Code

function ad_image_global_settings($edit = array()) {
  $form = array();
  $form['general'] = array(
    '#type' => 'fieldset',
    '#title' => t('General settings'),
    '#collapsible' => TRUE,
  );
  $form['general']['remote_images'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow remote hosted images'),
    '#description' => t('Check this box to add a new field when creating image advertisements allowing you to specify a path to a remotely hosted image rather than locally uploading an image.  This option is disabled by default as it is a confusing field to someone not using it.'),
    '#default_value' => variable_get('ad_image_remote_images', FALSE),
  );
  $groups = module_invoke('ad', 'groups_list', TRUE);
  foreach ($groups as $tid => $group) {
    $form["group-{$tid}"] = array(
      '#type' => 'fieldset',
      '#title' => $group->name,
      '#collapsible' => TRUE,
    );
    $form["group-{$tid}"]["description-{$tid}"] = array(
      '#type' => 'markup',
      '#prefix' => '<div>',
      '#suffix' => '</div>',
      '#value' => theme_placeholder("{$group->description}"),
    );
    $format = db_fetch_object(db_query('SELECT * FROM {ad_image_format} WHERE gid = %d', $tid));
    $form["group-{$tid}"]["max-size-{$tid}"] = array(
      '#type' => 'textfield',
      '#title' => t('Maximum filesize'),
      '#size' => 5,
      '#maxlength' => 15,
      '#default_value' => isset($format->max_size) ? $format->max_size : 0,
      '#description' => t('Optionally specify a maximum filesize in bytes for images in this group.  To specify no maximum filesize, enter <em>0</em>.'),
    );
    $form["group-{$tid}"]["min-height-{$tid}"] = array(
      '#type' => 'textfield',
      '#title' => t('Minimum height'),
      '#size' => 5,
      '#maxlength' => 5,
      '#default_value' => isset($format->min_height) ? $format->min_height : 0,
      '#description' => t('Optionally specify a minimum height in pixels for images in this group.  To specify no minimum height, enter <em>0</em>.'),
    );
    $form["group-{$tid}"]["min-width-{$tid}"] = array(
      '#type' => 'textfield',
      '#title' => t('Minimum width'),
      '#size' => 5,
      '#maxlength' => 5,
      '#default_value' => isset($format->min_width) ? $format->min_width : 0,
      '#description' => t('Optionally specify a minimum width in pixels for images in this group.  To specify no minimum width, enter <em>0</em>.'),
    );
    $form["group-{$tid}"]["max-height-{$tid}"] = array(
      '#type' => 'textfield',
      '#title' => t('Maximum height'),
      '#size' => 5,
      '#maxlength' => 5,
      '#default_value' => isset($format->max_height) ? $format->max_height : 0,
      '#description' => t('Optionally specify a maximum height in pixels for images in this group.  To specify no maximum height, enter <em>0</em>.'),
    );
    $form["group-{$tid}"]["max-width-{$tid}"] = array(
      '#type' => 'textfield',
      '#title' => t('Maximum width'),
      '#size' => 5,
      '#maxlength' => 5,
      '#default_value' => isset($format->max_width) ? $format->max_width : 0,
      '#description' => t('Optionally specify a maximum width in pixels for images in this group.  To specify no maximum width, enter <em>0</em>.'),
    );
  }
  $form['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  $form['#submit'] = array(
    'ad_image_global_settings_submit',
  );
  return $form;
}