function themekey_ui_form_alter in ThemeKey 7.3
Same name and namespace in other branches
- 6.4 themekey_ui.module \themekey_ui_form_alter()
- 6 themekey_ui.module \themekey_ui_form_alter()
- 6.2 themekey_ui.module \themekey_ui_form_alter()
- 6.3 themekey_ui.module \themekey_ui_form_alter()
- 7 themekey_ui.module \themekey_ui_form_alter()
- 7.2 themekey_ui.module \themekey_ui_form_alter()
Implements hook_form_alter().
File
- ./
themekey_ui.module, line 248 - 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/her nodes' themes, every time a user is loaded, we do this query here
$theme = FALSE;
if (!empty($form['#user']->uid)) {
$theme = db_select('themekey_ui_author_theme', 'tuat')
->fields('tuat', array(
'theme',
))
->condition('uid', $form['#user']->uid)
->execute()
->fetchField();
}
themekey_ui_theme_select_form($form, t('Theme configuration for my content'), t('Any content I create will be shown to other users using this theme.'), $theme ? $theme : 'default');
$form['#prev_themekey_ui_author_theme'] = $theme;
$form['#submit'][] = 'themekey_ui_user_profile_form_submit';
}
}
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') && variable_get('og_group_type_' . $type, 'omitted') != 'omitted') {
$description .= '<p><b>' . t('Note:') . '</b> ' . t('This content type is used in Organic Groups. By default, the 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', 'bartik') . ' ' . t('(site default theme)'),
)) . '</p>';
$description .= '<p>' . t('This default behaviour could be modified using the !themekey_compat_link module.', array(
'!themekey_compat_link' => l(t('ThemeKey Compatibilty'), module_exists('themekey_compat') ? 'admin/config/user-interface/themekey/settings/compat' : 'admin/modules'),
)) . '</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');
}
}
}
}