You are here

function mobile_tools_configuration_form in Mobile Tools 6.2

Same name and namespace in other branches
  1. 6.3 mobile_tools.admin.inc \mobile_tools_configuration_form()
  2. 6 mobile_tools.admin.inc \mobile_tools_configuration_form()
  3. 7.2 mobile_tools.admin.inc \mobile_tools_configuration_form()

Configuration form.

1 string reference to 'mobile_tools_configuration_form'
mobile_tools_menu in ./mobile_tools.module
Implementation of hook_menu().

File

./mobile_tools.admin.inc, line 11
Generate configuration form and save settings.

Code

function mobile_tools_configuration_form() {

  // Get the base URL of the drupal installation
  global $base_url;
  $form['mobile_tools_site_urls'] = array(
    '#type' => 'fieldset',
    '#title' => t('Site URLs'),
    '#collapsible' => TRUE,
    '#description' => t('Enter a mobile and desktop URL for your website; following the standard practice of naming the mobile site either m.domain.com or www.domain.mobi is recommended. If both URLs are different, site visitors will be redirected to the appropriate site. If both URLs are the same, visitors will not be redirected but <a href="@theme-switching">theme switching</a> will still occur.', array(
      '@theme-switching' => '/admin/settings/mobile-tools/theme-switching',
    )),
  );
  $form['mobile_tools_site_urls']['mobile_tools_mobile_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Mobile URL'),
    '#default_value' => variable_get('mobile_tools_mobile_url', mobile_tools_create_mobile_url($base_url)),
    '#description' => t('Enter the URL of your mobile website.'),
  );
  $form['mobile_tools_site_urls']['mobile_tools_desktop_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Desktop URL'),
    '#default_value' => variable_get('mobile_tools_desktop_url', $base_url),
    '#collapsible' => TRUE,
    '#description' => t('Enter the URL of your desktop website.'),
  );
  $form['mobile_tools_meta_tags'] = array(
    '#type' => 'fieldset',
    '#title' => t('Meta tags'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['mobile_tools_meta_tags']['mobile_tools_add_header'] = array(
    '#type' => 'checkbox',
    '#title' => t('Add mobile meta tags'),
    '#default_value' => variable_get('mobile_tools_add_header', 1),
    '#description' => t('Add mobile-specific meta tags including viewport and HandheldFriendly.'),
  );
  $form['mobile_tools_redirection'] = array(
    '#type' => 'fieldset',
    '#title' => t('Redirection'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['mobile_tools_redirection']['mobile_tools_redirect'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable automatic redirection of site visitors'),
    '#default_value' => variable_get('mobile_tools_redirect', FALSE),
    '#description' => t('Enable this option to automatically detect site visitors using a mobile device and redirect them to the mobile site.'),
  );
  $form['mobile_tools_redirection']['mobile_tools_cookie_session'] = array(
    '#type' => 'textfield',
    '#title' => t('Redirection cookie lifespan'),
    '#size' => 10,
    '#maxlength' => 10,
    '#default_value' => variable_get('mobile_tools_cookie_session', 3600 * 24 * 30),
    '#description' => t("Site visitors who are automatically redirected to the mobile site can, if they prefer, view the desktop version. A cookie will be saved on the visitor's computer to remember their preference. Enter 0 to switch to session cookies which will automatically forget the visitor's preference once they leave the site."),
    '#field_suffix' => t('Seconds'),
  );
  $form['mobile_tools_redirection']['mobile_tools_redirect_exceptions_type'] = array(
    '#type' => 'radios',
    '#title' => t('Redirect on specific pages'),
    '#default_value' => variable_get('mobile_tools_redirect_exceptions_type', 'not-redirect'),
    '#options' => array(
      'not-redirect' => t('Redirect on every page except the listed pages.'),
      'only-redirect' => t('Redirect on only the listed pages.'),
    ),
  );
  $form['mobile_tools_redirection']['mobile_tools_redirect_exceptions'] = array(
    '#type' => 'textarea',
    '#title' => t('Pages'),
    '#default_value' => variable_get('mobile_tools_redirect_exceptions', ''),
    '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
      '%blog' => 'blog',
      '%blog-wildcard' => 'blog/*',
      '%front' => '<front>',
    )),
  );
  $form['mobile_tools_notification'] = array(
    '#type' => 'fieldset',
    '#title' => t('Block message'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => t('You can create a block with a different message on the mobile site than the desktop site. This can be for example used to create a link back to the deskop or mobile site.'),
  );
  $form['mobile_tools_notification']['mobile_notification'] = array(
    '#type' => 'textfield',
    '#title' => t('Mobile message'),
    '#default_value' => variable_get('mobile_notification', 'View full site'),
    '#description' => t('This will create a URL back to the desktop site while maintaining the current path.'),
  );
  $form['mobile_tools_notification']['desktop_notification'] = array(
    '#type' => 'textfield',
    '#title' => t('Desktop message'),
    '#default_value' => variable_get('desktop_notification', 'View mobile site'),
    '#description' => t('This will create a URL back to the mobile site while maintaining the current path.'),
  );
  $form['build_mode'] = array(
    '#type' => 'fieldset',
    '#title' => t('Build mode'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => t("Add a mobile build mode to Drupal's default full, teaser, print and RSS build modes."),
  );
  $form['build_mode']['mobile_tools_enable_build_mode'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable a Mobile Tools build mode.'),
    '#default_value' => variable_get('mobile_tools_enable_build_mode', 0),
    '#description' => t('Use modules such as <a href="@build-modes">Build modes</a> or <a href="@display-suite">Display Suite</a> to configure build modes.', array(
      '@build-modes' => 'http://drupal.org/project/buildmodes',
      '@display-suite' => 'http://drupal.org/project/ds',
    )),
  );
  $form['frontpage'] = array(
    '#type' => 'fieldset',
    '#title' => t('Front page'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => t('Configure unique front page settings for site visitors visiting the mobile site.'),
  );
  $form['frontpage']['site_frontpage_mobile'] = array(
    '#type' => 'textfield',
    '#title' => t('Default mobile front page'),
    '#default_value' => variable_get('site_frontpage_mobile', variable_get('site_frontpage', 'node')),
    '#description' => t('The mobile home page displays content from this relative URL. If unsure, specify "node".'),
  );
  $form['frontpage']['default_nodes_main_mobile'] = array(
    '#type' => 'select',
    '#title' => t('Number of posts on mobile main page'),
    '#default_value' => variable_get('default_nodes_main_mobile', 10),
    '#options' => array(
      1 => 1,
      2 => 2,
      3 => 3,
      4 => 4,
      5 => 5,
      6 => 6,
      7 => 7,
      8 => 8,
      9 => 9,
      10 => 10,
      15 => 15,
      20 => 20,
      25 => 25,
      30 => 30,
    ),
    '#description' => t('The default maximum number of posts to display per page on overview pages such as the mobile main page.'),
  );
  return system_settings_form($form);
}