You are here

function mobile_tools_themes_configuration_form in Mobile Tools 6

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

Configuration form for configuring the mobile context in the theming system

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

File

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

Code

function mobile_tools_themes_configuration_form() {
  $themes = mobile_tools_list_theme_names();
  $prefix = '';
  $warning = '';
  if (count($themes) == 0) {
    $warning = '<div class="message error">You must enable themes in order to use theme switching</div>';
  }
  $form['mobile_tools_theme_configuration'] = array(
    '#type' => 'fieldset',
    '#title' => 'Theming configuration',
    '#collapsible' => TRUE,
    '#description' => t('You can assign a variation of your current theme to all mobile users . this allows you to configure your theme
    specific for mobile users. See !url for more information on this configuration. In order to use this functionality
    you will have to manually create a second *.info file in your theme directory.', array(
      '!url' => l('help', 'help'),
    )),
    '#suffix' => t('If enabled, !configure the settings of your mobile theme and manage the !blocks layout', array(
      '!configure' => l('configure', 'admin/build/themes'),
      '!blocks' => l('blocks', 'admin/build/block'),
    )) . '<br>',
    '#prefix' => $warning,
  );
  $form['mobile_tools_theme_configuration']['mobile-tools-theme-switch'] = array(
    '#type' => 'radios',
    '#title' => t('When do you want to switch themes'),
    '#default_value' => variable_get('mobile-tools-theme-switch', 'mobile-tools-no-switch'),
    '#options' => array(
      'mobile-tools-no-switch' => 'No theme switch',
      'mobile-tools-mobile-device' => 'Switch theme for a mobile device *',
      'mobile-tools-mobile-url' => 'Switch theme based on the URL',
    ),
    '#description' => 'Choose one of these methods. *This is not recommended since using 1 url for both mobile and desktop site disable the drupal caching.',
  );
  if (count($themes) > 0) {
    $form['mobile_tools_theme_configuration']['mobile_tools_theme_name'] = array(
      '#type' => 'select',
      '#title' => 'Mobile theme',
      '#default_value' => variable_get("mobile_tools_theme_name", FALSE),
      '#options' => $themes,
      '#description' => t('Select your default mobile theme. You can specify a different theme for different devices.'),
    );

    // for each group, checkbox and dropdown
    // Mobile
    $mobile_groups = module_invoke(variable_get('mobile-tools-device-detection', 'mobile_tools'), 'device_groups');
    $mobile_detection_module = variable_get('mobile-tools-device-detection', 'mobile_tools');
    foreach ($mobile_groups as $group => $group_title) {
      $form['mobile_tools_theme_configuration'][$mobile_detection_module . '_' . $group] = array(
        '#type' => 'fieldset',
        '#title' => $group_title,
        '#collapsible' => TRUE,
      );
      $form['mobile_tools_theme_configuration'][$mobile_detection_module . '_' . $group][$mobile_detection_module . '_' . $group . '_enable'] = array(
        '#type' => 'checkbox',
        '#title' => t('Enable filter for this device group'),
        '#default_value' => variable_get($mobile_detection_module . '_' . $group . '_enable', ''),
        '#description' => t('Choose a theme for this device group'),
      );
      $form['mobile_tools_theme_configuration'][$mobile_detection_module . '_' . $group][$mobile_detection_module . '_' . $group . '_theme'] = array(
        '#type' => 'select',
        '#title' => 'Mobile theme',
        '#default_value' => variable_get($mobile_detection_module . '_' . $group . '_theme', FALSE),
        '#options' => $themes,
        '#description' => t('Select your mobile theme. See <a href="">help</a> for information on the name'),
      );
    }
  }
  return system_settings_form($form);
}