You are here

function ad_admin_configure_settings in Advertisement 6.3

Same name and namespace in other branches
  1. 5.2 ad.module \ad_admin_configure_settings()
  2. 5 ad.module \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.admin.inc, line 483
Advertisement admin pages and functions.

Code

function ad_admin_configure_settings($form_state) {
  _ad_check_installation();
  $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 impressions even on cached pages.  When using the Raw display method together with Drupal\'s page cache, impressions 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['search'] = array(
    '#type' => 'fieldset',
    '#title' => t('Search'),
    '#collapsible' => TRUE,
  );
  $form['search']['ad_no_search'] = array(
    '#type' => 'checkbox',
    '#title' => t('Remove ads from local search results'),
    '#default_value' => variable_get('ad_no_search', 1),
    '#description' => t('If enabled, all advertisements will be removed from local search results.  Users with %perm1 or %perm2 permissions will still see advertisements in the search results.', array(
      '%perm1' => t('administer advertisements'),
      '%perm2' => t('edit any advertisement'),
    )),
  );
  $form['search']['ad_meta_noindex'] = array(
    '#type' => 'checkbox',
    '#title' => t('Remove ads from remote search engines'),
    '#default_value' => variable_get('ad_meta_noindex', 0),
    '#description' => t('If enabled, advertisement nodes will include the !noindex, telling remote search engines to not include these nodes in their search index.  This meta tag will appear on any page that an advertisement node is displayed on, even if a page is comprised of both ad nodes and other site content.  It will not be displayed when advertisements are displayed via blocks, calls to ad(), or other display methods when the page is comprised of non-ad content. This option is disabled by default as users with this option enabled and custom home pages have accidentally caused important pages such as their front page to not be indexed by popular search engines.', array(
      '!noindex' => l(t('noindex meta tag'), 'http://en.wikipedia.org/wiki/Noindex'),
    )),
  );
  $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' => t('auto'),
      'yes' => t('on'),
      'no' => t('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'));
  $form['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}