array( 'arguments' => array('form' => NULL), ) ); } /** * Implementation of hook_perm(). */ function themekey_ui_perm() { return array('assign node themes'); } /** * Implementation of hook_menu(). */ function themekey_ui_menu() { $items = array(); $items['admin/settings/themekey/settings/ui'] = array( 'title' => 'User Interface', 'access callback' => 'user_access', 'access arguments' => array('administer themekey settings'), 'file' => 'themekey_ui_admin.inc', 'page callback' => 'drupal_get_form', 'page arguments' => array('_themekey_ui_settings_form'), 'type' => MENU_LOCAL_TASK, 'weight' => 1 ); return $items; } /** * Implementation of hook_form_alter(). */ function themekey_ui_form_alter(&$form, $form_state, $form_id) { // 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)) { require_once(drupal_get_path('module', 'themekey_ui') .'/themekey_ui_admin.inc'); _themekey_ui_nodeform($form, $form_state); } } // Path aliases if ($form_id == 'path_admin_form' && variable_get('themekey_ui_pathalias', 0)) { require_once(drupal_get_path('module', 'themekey_ui') .'/themekey_ui_admin.inc'); _themekey_ui_pathalias($form, $form_state); } // REVIEW seems to be dead code // // Views // if ($form_id == 'views_ui_edit_display_form' && $form_state['#section'] == 'page-path' // && variable_get('themekey_ui_views', 0) && user_access('administer views')) { // require_once(drupal_get_path('module', 'themekey_ui') .'/themekey_ui_admin.inc'); // _themekey_ui_views($form, $form_state); // } } /** * Implementation of hook_nodeapi(). */ function themekey_ui_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { switch ($op) { case 'load': if (variable_get('themekey_ui_nodeform', 0) && variable_get('themekey_ui_nodeform|'. $node->type, 1)) { if (!empty($node->vid)) { $theme = db_result(db_query('SELECT theme FROM {themekey_ui_node_theme} WHERE nid = %d AND vid = %d', $node->nid, $node->vid)); if ($theme) { $node->theme = $theme; } else { $node->theme = 'default'; } } } break; case 'insert': if (!empty($node->theme)) { $item = array('nid' => $node->nid, 'vid' => $node->vid, 'theme' => $node->theme); if (drupal_write_record('themekey_ui_node_theme', $item)) { $themes[$node->vid] = $node->theme; } } break; case 'update': if (!empty($node->theme)) { $item = array('nid' => $node->nid, 'vid' => $node->vid, 'theme' => $node->theme); if (drupal_write_record('themekey_ui_node_theme', $item, array('nid', 'vid'))) { $themes[$node->vid] = $node->theme; } } break; case 'delete': db_query('DELETE FROM {themekey_ui_node_theme} WHERE nid = %d', $node->nid); break; } } /** * Function themekey_ui_form_submit(). */ function themekey_ui_form_submit($form, &$form_state) { if (isset($form_state['values']['themekey_ui_submit'])) { require_once(drupal_get_path('module', 'themekey_ui') .'/themekey_ui_admin.inc'); $handler = $form_state['values']['themekey_ui_submit']; if (function_exists($handler)) { $handler($form, $form_state); } } }