You are here

function themekey_ui_form_alter in ThemeKey 6.3

Same name and namespace in other branches
  1. 6.4 themekey_ui.module \themekey_ui_form_alter()
  2. 6 themekey_ui.module \themekey_ui_form_alter()
  3. 6.2 themekey_ui.module \themekey_ui_form_alter()
  4. 7.3 themekey_ui.module \themekey_ui_form_alter()
  5. 7 themekey_ui.module \themekey_ui_form_alter()
  6. 7.2 themekey_ui.module \themekey_ui_form_alter()

Implements hook_form_alter().

File

./themekey_ui.module, line 182
ThemeKey UI is an extension for ThemeKey

Code

function themekey_ui_form_alter(&$form, $form_state, $form_id) {
  if ('path_admin_form' == $form_id) {

    // path aliases form
    if (user_access('assign path alias themes') && variable_get('themekey_ui_pathalias', 0)) {
      module_load_include('inc', 'themekey_ui', 'themekey_ui_admin');
      themekey_ui_pathalias($form);
    }
  }
  elseif ('user_profile_form' == $form_id) {
    if (user_access('assign theme to own nodes') && variable_get('themekey_ui_author', 0)) {
      module_load_include('inc', 'themekey_ui', 'themekey_ui_admin');

      // to avoid a sql query to load his nodes themes every time a user is loaded, we do this query here
      $theme = FALSE;
      if (!empty($form['#uid'])) {
        $theme = db_result(db_query("SELECT theme FROM {themekey_ui_author_theme} WHERE uid = %d", $form['#uid']));
      }
      themekey_ui_theme_select_form($form, t('Theme configuration for my nodes'), t('Every node I create will be shown to other users using this theme.'), $theme ? $theme : 'default', $form['theme_select']['#weight'], FALSE);
    }
  }
  elseif ('themekey_help_tutorials_form' == $form_id) {
    module_load_include('inc', 'themekey_ui', 'themekey_ui_help');
    themekey_ui_help_tutorials($form);
  }
  else {

    // node form?
    if (variable_get('themekey_ui_nodeform', 0) && user_access('assign node themes')) {
      $type = isset($form['type']['#value']) ? $form['type']['#value'] : FALSE;
      if ($form_id == $type . '_node_form' && variable_get('themekey_ui_nodeform|' . $type, 1)) {
        module_load_include('inc', 'themekey_ui', 'themekey_ui_admin');
        $description = t('Theme configuration for this node');
        if (module_exists('og') && !og_is_omitted_type($type)) {
          $description .= '<p><b>' . t('Note:') . '</b> ' . t('This content type is used in organic groups. A Theme you select here will only be used to display this node if you set the theme for the organic group to %theme', array(
            '%theme' => variable_get('theme_default', 'garland') . ' ' . t('(site default theme)'),
          )) . '</p>';
        }
        themekey_ui_theme_select_form($form, t('Theme configuration for this node'), $description, !empty($form['#node']->themekey_ui_theme) ? $form['#node']->themekey_ui_theme : 'default');
      }
    }
  }
}