You are here

function mobile_tools_configuration_form in Mobile Tools 7.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. 6.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
Implements hook_menu().

File

./mobile_tools.admin.inc, line 14
Adminstrative pages for Mobile Tools

Code

function mobile_tools_configuration_form() {
  global $base_url;
  $form['general'] = array(
    '#type' => 'vertical_tabs',
    '#title' => t('General'),
  );
  $form['general']['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['general']['mobile_tools_configuration']['mobile_tools_mobile_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Mobile URL'),
    '#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['general']['mobile_tools_configuration']['mobile_tools_desktop_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Desktop URL'),
    '#description' => t('Give the name of your regular website.'),
    '#collapsible' => TRUE,
    '#default_value' => variable_get('mobile_tools_desktop_url', $base_url),
  );
  $form['general']['mobile_tools_redirection'] = array(
    '#type' => 'fieldset',
    '#title' => t('Redirection options'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );

  // @todo add detection for aggressive caching and disable redirection field
  // @todo add form alter on caching form to disable the redirection flag
  // @todo change options for redirect to the following:
  //  - none
  //  - first page (redirect the user when they view their first page, i.e. when they create their session)
  //  - automatic (redirect on all pages)
  $form['general']['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 ?device=desktop to the URL. The module
    will set a cookie that remembers that the user does not want to be redirected. To undo, add ?device=auto',
  );
  $form['general']['mobile_tools_redirection']['mobile_tools_cookie_session'] = array(
    '#type' => 'textfield',
    '#title' => 'Redirection cookie    (seconds)',
    '#description' => t('This field is only used when using the "?device=" 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['general']['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['general']['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 separate line. The \'*\' character is a wildcard.'),
    '#default_value' => variable_get('mobile_tools_redirect_exceptions', ''),
  );
  $form['general']['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['general']['mobile_tools_notification']['mobile_tools_switch_link_text'] = array(
    '#type' => 'textarea',
    '#rows' => 2,
    '#title' => t('Block text'),
    '#description' => t('If you would like to include the name of the device group in your text, add @device to your text. It will be replaced by the name of the device group.'),
    '#default_value' => variable_get('mobile_tools_switch_link_text', MOBILE_TOOLS_SWITCH_LINK_TEXT),
  );
  $form['general']['build_mode'] = array(
    '#type' => 'fieldset',
    '#title' => t('Mobile Tools Build Mode'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => t('Enable a Mobile Build mode'),
  );
  $form['general']['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('New build modes will be available in the Content Types configuration page (see Manage Display)'),
  );
  $form['general']['extra'] = array(
    '#type' => 'fieldset',
    '#title' => 'Other Options',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['general']['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['general']['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);
}