You are here

function ad_admin_configure_settings in Advertisement 5

Same name and namespace in other branches
  1. 5.2 ad.module \ad_admin_configure_settings()
  2. 6.3 ad.admin.inc \ad_admin_configure_settings()
  3. 6 ad.admin.inc \ad_admin_configure_settings()
  4. 6.2 ad.admin.inc \ad_admin_configure_settings()
  5. 7 ad.admin.inc \ad_admin_configure_settings()

Display a form for the ad module settings.

1 string reference to 'ad_admin_configure_settings'
ad_menu in ./ad.module
Implementation of hook_menu().

File

./ad.module, line 2193
An advertising system for Drupal powered websites.

Code

function ad_admin_configure_settings($edit = array()) {
  _ad_check_install();
  $edit = $_POST['edit'];
  $adserve = variable_get('adserve', '');
  $adserveinc = variable_get('adserveinc', '');
  $form['configuration'] = array(
    '#type' => 'fieldset',
    '#title' => t('Status'),
  );
  $form['configuration']['adserve'] = array(
    '#type' => 'markup',
    '#value' => t('Using detected adserve scripts: %adserve, %adserveinc', array(
      '%adserve' => $adserve ? $adserve : t('not found'),
      '%adserveinc' => $adserveinc ? $adserveinc : t('not found'),
    )),
  );
  $form['general'] = array(
    '#type' => 'fieldset',
    '#title' => t('General'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );

  // TODO: This needs a per-group over-ride, in case some groups are IFrames,
  // while others are JavaScript, etc.
  $form['general']['ad_link_target'] = array(
    '#type' => 'radios',
    '#title' => t('Click-through target'),
    '#options' => array(
      '_self' => t('same browser window and frame'),
      '_blank' => t('new browser window'),
      '_parent' => t('parent frame'),
      '_top' => t('same browser window, removing all frames'),
    ),
    '#default_value' => variable_get('ad_link_target', '_self'),
    '#description' => t('Select an option above to configure what happens when an ad is clicked.  These options set the <em>a target</em>, and are <em>_self</em>, <em>_blank</em>, <em>_parent</em> and <em>_top</em> respectively.'),
  );
  $form['general']['ad_link_nofollow'] = array(
    '#type' => 'checkbox',
    '#title' => t('nofollow'),
    '#default_value' => variable_get('ad_link_nofollow', 0),
    '#description' => t('If enabled, %tag will be added to advertisement links generated by this module.', array(
      '%tag' => t('rel="nofollow"'),
    )),
  );

  // Provide hook for ad_display_TYPE modules to set display TYPE.
  $display_options = array_merge(array(
    'javascript' => t('JavaScript'),
    'jquery' => t('jQuery'),
    'iframe' => t('IFrame'),
    'raw' => t('Raw'),
  ), module_invoke_all('displayapi', 'display_method'), array());

  // Provide hook for ad_display_TYPE modules to define inline description.
  $description = t('This setting configures the default method for displaying advertisements on your website.  It is possible to override this setting when making direct calls to ad(), as described in the documentation.  Using the JavaScript, jQuery, and IFrame display methods allows you to display random ads and track views even on cached pages.  When using the Raw display method together with Drupal\'s page cache, view statistics will be properly tracked but advertisements will only change when the page cache is updated.');
  $return = module_invoke_all('displayapi', 'display_description', array());
  foreach ($return as $describe) {
    $description .= ' ' . $describe;
  }
  $form['general']['ad_display'] = array(
    '#type' => 'radios',
    '#title' => t('Display type'),
    '#default_value' => variable_get('ad_display', 'javascript'),
    '#options' => $display_options,
    '#description' => $description,
  );
  $form['general']['ad_validate_url'] = array(
    '#type' => 'checkbox',
    '#title' => t('Validate URLs'),
    '#default_value' => variable_get('ad_validate_url', 1),
    '#description' => t('If enabled, any destination URLs entered in ads will be required to be complete URLs (including http:// or https:// at the beginning).  If you wish to include internal urls, you will need to disable this option.'),
  );
  $form['iframe'] = array(
    '#type' => 'fieldset',
    '#title' => t('IFrame'),
    '#collapsible' => TRUE,
    '#collapsed' => variable_get('ad_display', 'javascript') == 'iframe' ? FALSE : TRUE,
  );
  $form['iframe']['ad_iframe_frameborder'] = array(
    '#type' => 'checkbox',
    '#title' => t('Frameborder'),
    '#default_value' => variable_get('ad_iframe_frameborder', 0),
    '#description' => t('If enabled, IFrames used for displaying ads will have a frameborder.'),
  );
  $form['iframe']['ad_iframe_scroll'] = array(
    '#type' => 'radios',
    '#title' => t('Scrolling'),
    '#default_value' => variable_get('ad_iframe_scroll', 'auto'),
    '#options' => array(
      'auto' => 'auto',
      'on' => 'on',
      'off' => 'off',
    ),
    '#description' => t('Define whether or not scroll bars should be enabled for the ad IFrame.'),
  );
  $form['iframe']['ad_iframe_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width'),
    '#default_value' => variable_get('ad_iframe_width', ''),
    '#maxlength' => 8,
    '#size' => 5,
    '#required' => FALSE,
    '#description' => t('The default width for advertisement IFrames'),
  );
  $form['iframe']['ad_iframe_height'] = array(
    '#type' => 'textfield',
    '#title' => t('Height'),
    '#default_value' => variable_get('ad_iframe_height', ''),
    '#maxlength' => 8,
    '#size' => 5,
    '#required' => FALSE,
    '#description' => t('The default height for advertisement IFrames'),
  );
  $form['cache'] = array(
    '#type' => 'fieldset',
    '#title' => t('Cache'),
    '#collapsible' => TRUE,
    '#collapsed' => variable_get('ad_cache', 'none') == 'none' ? TRUE : FALSE,
  );

  // Provide hook for ad_cache_TYPE modules to set cache TYPE.
  $cache_options = array_merge(array(
    'none' => t('None'),
  ), module_invoke_all('adcacheapi', 'method', array()));

  // Provide hook for ad_cache_TYPE modules to define inline description.
  $description = t('A cache can be used to efficiently track how many times advertisements are displayed and clicked.');
  $return = module_invoke_all('adcacheapi', 'description', array());
  foreach ($return as $describe) {
    $description .= ' ' . $describe;
  }
  $form['cache']['ad_cache'] = array(
    '#type' => 'radios',
    '#title' => t('Type'),
    '#default_value' => variable_get('ad_cache', 'none'),
    '#options' => $cache_options,
    '#description' => $description,
  );

  // Provide hook for ad_cache_TYPE modules to add inline settings.
  $form['cache'] = array_merge($form['cache'], module_invoke_all('adcacheapi', 'settings', $edit));
  $form['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}