You are here

function mostpopular_settings_form in Drupal Most Popular 7

Same name and namespace in other branches
  1. 6 mostpopular.admin.inc \mostpopular_settings_form()
1 string reference to 'mostpopular_settings_form'
mostpopular_menu in ./mostpopular.module
Implements hook_menu().

File

./mostpopular.admin.inc, line 20
Defines the main administration forms for the Most Popular module.

Code

function mostpopular_settings_form() {
  $form = array();
  $form['block'] = array(
    '#type' => 'fieldset',
    '#collapsible' => true,
    '#title' => t('Style settings'),
    '#description' => t('Configure the look and feel of the Most Popular block.'),
  );
  $form['block']['mostpopular_styling'] = array(
    '#type' => 'radios',
    '#title' => t('Stylesheet'),
    '#description' => '<p>' . t("Choose how much styling to apply to the Most Popular block.\nYou can add additional styling in your own theme.") . '</p>' . '<p>' . t("For help, look at the <a href='@basic'>basic stylesheet</a>, which turns the\nservice and interval links into tabs, and the <a href='@full'>full stylesheet</a>,\nwhich adds fonts, colors, formatting, and layouts.", array(
      '@basic' => url(drupal_get_path('module', 'mostpopular') . '/css/mostpopular-basic.css'),
      '@full' => url(drupal_get_path('module', 'mostpopular') . '/css/mostpopular-full.css'),
    )) . '</p>' . '<p>' . t("When creating your own styles for the Most Popular block, we recommend you\nstart with our full stylesheet and override it using drupal_set_css().") . '</p>',
    '#options' => array(
      MOSTPOPULAR_STYLE_NONE => t('No styling'),
      MOSTPOPULAR_STYLE_BASIC => t('Basic styling'),
      MOSTPOPULAR_STYLE_FULL => t('Full styling'),
    ),
    '#default_value' => variable_get('mostpopular_styling', MOSTPOPULAR_STYLE_FULL),
  );

  // Add a fieldset for configuring Drupal paths
  $form['paths'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#title' => t('Drupal Paths'),
  );

  // Get the configured base paths
  $site_base = url('', array(
    'absolute' => TRUE,
  ));
  $path_base = url('');
  $basepaths = variable_get('mostpopular_basepaths', array(
    $site_base,
    $path_base,
  ));
  $form['paths']['mostpopular_basepaths'] = array(
    '#type' => 'textarea',
    '#rows' => 6,
    '#title' => t('Base Paths'),
    '#default_value' => implode("\n", $basepaths),
    '#description' => t(<<<EOT
<p>These base URLs will be stripped from the beginning of any full page URLs returned
by the various services. This allows the most popular content to work across several
site configurations.  This will only work, however, if the node nids are shared
between all sites.</p>
<p>Put each base URL on a separate line. Each must end with a slash.</p>
EOT
),
  );

  // Get the configured exclude paths
  $excludepaths = variable_get('mostpopular_exclude_paths', MOSTPOPULAR_DEFAULT_EXCLUDES);
  $form['paths']['mostpopular_exclude_paths'] = array(
    '#type' => 'textarea',
    '#rows' => 10,
    '#title' => t('Paths to exclude'),
    '#default_value' => $excludepaths,
    '#description' => t(<<<EOT
<p>These Drupal pages will be excluded from the most popular results for any
services that return nodes.  The homepage will automatically be excluded, but
you can use this field to hide landing pages or other non-content pages.</p>
<p>Each URL should be an internal Drupal path with no leading slash, and can
point either to node/%d or to an alias. Put each path on a separate line and
use '*' to denote wildcards.</p>
EOT
),
  );
  $form['mostpopular_debug'] = array(
    '#type' => 'checkbox',
    '#title' => t('Log debug messages from the services?'),
    '#default_value' => variable_get('mostpopular_debug', FALSE),
  );
  $form['#validate'][] = 'mostpopular_settings_form_validate';
  $form = system_settings_form($form);
  return $form;
}