You are here

function mobile_tools_configuration_form in Mobile Tools 6

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

Configuration form for the mobile device detection, redirection and notification

Return value

The 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 14
Adminstrative pages for Mobile Tools

Code

function mobile_tools_configuration_form() {
  global $base_url;
  $form['mobile_tools_configuration'] = array(
    '#type' => 'fieldset',
    '#title' => 'General configuration',
    '#description' => 'Enter the mobile and desktop url for your site. If both urls are equal there will be no redirection, but only theme switching. Go to "theme switching" to configure the theme',
    '#collapsible' => TRUE,
  );
  $form['mobile_tools_configuration']['mobile_tools_mobile_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Mobile URL'),
    '#required' => TRUE,
    '#description' => t('Give the name of your mobile site. It is recommended to use the convention of m.domain .com or www.domain.mobi'),
    '#default_value' => variable_get('mobile_tools_mobile_url', mobile_tools_create_mobile_url($base_url)),
  );
  $form['mobile_tools_configuration']['mobile_tools_desktop_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Desktop URL'),
    '#required' => TRUE,
    '#description' => t('Give the name of your regular website.'),
    '#collapsible' => TRUE,
    '#default_value' => variable_get('mobile_tools_desktop_url', $base_url),
  );
  $form['mobile_tools_redirection'] = array(
    '#type' => 'fieldset',
    '#title' => t('Redirection options'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['mobile_tools_redirection']['mobile_tools_redirect'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable automatic redirection of the mobile user'),
    '#default_value' => variable_get('mobile_tools_redirect', FALSE),
    '#description' => 'Mobile visitors will automatically be redirected to the mobile site. But mobile users can also -- if they prefer --
    view the desktop version. In order to do so, append ?mobile=false to the URL. The module
    will set a cookie that remembers that the user does not want to be redirected. To undo, send the user to /gomobile. The module will redirect
    the user to the mobile site and reset the cookie!',
  );
  $form['mobile_tools_redirection']['mobile_tools_cookie_session'] = array(
    '#type' => 'textfield',
    '#title' => 'Redirection cookie    (seconds)',
    '#description' => t('This field is only used when using the mobile=false setting. This is the lifetime of the cookie that determines how long the session is remembered. Choose 0 for only the session.'),
    '#default_value' => variable_get('mobile_tools_cookie_session', 3600 * 24 * 30),
  );
  $form['mobile_tools_redirection']['mobile_tools_redirect_exceptions_type'] = array(
    '#type' => 'radios',
    '#title' => 'exception type',
    '#options' => array(
      'not-redirect' => 'Do not redirect from the following pages',
      'only-redirect' => 'Do only redirect from the following pages',
    ),
    '#default_value' => variable_get('mobile_tools_redirect_exceptions_type', 'not-redirect'),
  );
  $form['mobile_tools_redirection']['mobile_tools_redirect_exceptions'] = array(
    '#type' => 'textarea',
    '#title' => 'redirection exceptions',
    '#description' => t('Give the paths to pages that should not be redirected. Put each path on a seperate line. The \'*\' character is a wildcard.'),
    '#default_value' => variable_get('mobile_tools_redirect_exceptions', ''),
  );
  $form['mobile_tools_notification'] = array(
    '#type' => 'fieldset',
    '#title' => t('Mobile Tools block message options'),
    '#collapsed' => TRUE,
    '#collapsible' => 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 (e.g. view Mobile | Desktop)'),
  );
  $form['mobile_tools_notification']['mobile_notification'] = array(
    '#type' => 'textarea',
    '#rows' => 2,
    '#title' => t('On the Mobile site'),
    '#default_value' => variable_get('mobile_notification', MOBILE_NOTIFICATION),
  );
  $form['mobile_tools_notification']['desktop_notification'] = array(
    '#type' => 'textarea',
    '#title' => t('On the desktops site'),
    '#rows' => 2,
    '#default_value' => variable_get('desktop_notification', DESKTOP_NOTIFICATION),
  );
  $form['build_mode'] = array(
    '#type' => 'fieldset',
    '#title' => t('Mobile Tools Build Mode'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => t('Enable a Mobile Build mode'),
  );
  $form['build_mode']['mobile_tools_enable_build_mode'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable a Mobile Tools display mode'),
    '#default_value' => variable_get('mobile_tools_enable_build_mode', 0),
    '#description' => t('Use !ds to configure this build mode', array(
      '!ds' => l('Display Suite', 'http://drupal.org/project/ds'),
    )),
  );
  $form['extra'] = array(
    '#type' => 'fieldset',
    '#title' => 'extra',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['extra']['default_nodes_main_mobile'] = array(
    '#type' => 'select',
    '#title' => t('Number of posts on main page for the mobile version'),
    '#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 main page (on Mobile).'),
  );
  $form['extra']['site_frontpage_mobile'] = array(
    '#type' => 'textfield',
    '#title' => t('Choose another frontpage for mobile visitors.'),
    '#default_value' => variable_get('site_frontpage_mobile', variable_get('site_frontpage', 'node')),
    '#description' => t('If you want a different page as the frontpage of your site for mobile users, specify it here.'),
  );
  return system_settings_form($form);
}