You are here

function mobile_tools_form_alter in Mobile Tools 5

Same name and namespace in other branches
  1. 6.3 mobile_tools.module \mobile_tools_form_alter()
  2. 6 mobile_tools.module \mobile_tools_form_alter()
  3. 7.2 mobile_tools.module \mobile_tools_form_alter()

Altering the form for theme configuration to indicate that the theme is being used as a mobile theme.

File

./mobile_tools.module, line 859
Mobile Tools provides a range of functionality assisting in creating a mobile drupal site . this functionality contains:

Code

function mobile_tools_form_alter($form_id, &$form) {
  switch ($form_id) {
    case 'system_theme_settings':
      if (variable_get('mobile_tools_theme', FALSE) && arg(4) == variable_get('mobile_tools_theme_name', '')) {
        drupal_set_message(t('This theme will be used by Siruna when your site is being transcoded. Configure this for a mobile device'));
      }
      break;
    case 'user_admin_role':
      $query = "SELECT COUNT(*) as count FROM {mobile_tools_roles_relations} WHERE mrid = %d";
      $result = db_query($query, arg(4));
      $item = db_fetch_object($result);
      if ($item->count == 0) {
        $form['mobile_tools_configure_role_' . arg(4)] = array(
          '#type' => 'checkbox',
          '#title' => t('Create a mobile context for this user role'),
          '#default_value' => TRUE,
          '#description' => t('check if you want to add a mobile context to this role. Adding a mobile context will result in the creation of a new role that will be assigned to the user when the site is beeing mobilized. When unchecking all configurations will be lost for that role.'),
        );
        $form['mobile_tools_role_type'] = array(
          '#type' => 'hidden',
          '#value' => 'desktop',
        );
      }
      else {
        $form['mobile_tools_role_type'] = array(
          '#type' => 'hidden',
          '#value' => 'mobile',
        );
      }
      $form['#submit']['mobile_tools_roles_configuration_submit'] = array();
      break;
    case 'user_profile_form':
      unset($form['account']['roles']['#options']);
      $form['account']['roles']['#options'] = mobile_tools_user_roles();
      break;
    case 'node_configure':
      $form['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['#submit']['mobile_tools_node_configuration_submit'] = array();
  }
}