Index: context_ui/context_ui.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/context/context_ui/context_ui.module,v
retrieving revision 1.5
diff -u -p -r1.5 context_ui.module
--- context_ui/context_ui.module	17 Jul 2008 16:57:19 -0000	1.5
+++ context_ui/context_ui.module	23 Jul 2008 20:23:21 -0000
@@ -34,11 +34,11 @@ function context_ui_theme() {
 
   $items['context_devel'] = array(
     'arguments' => array('form' => array()),
-    /* 'file' => '', */
+    'file' => 'context_ui_devel.inc',
   );
   $items['context_devel_recurse'] = array(
     'arguments' => array('form' => array()),
-    /* 'file' => '', */
+    'file' => 'context_ui_devel.inc',
   );
 
   return $items;
@@ -71,92 +71,6 @@ function context_ui_block($op = 'list', 
 }
 
 /**
- * hook_context_items().
- */
-function context_ui_context_items() {
-  $items = array();
-
-  // Content Types
-  $nodetypes = array();
-  foreach (node_get_types() as $type) {
-    $nodetypes[$type->type] = t($type->name);  // @todo: this t() is wrong
-  }
-  $items['node'] = array(
-    'title' => t('Content Types'),
-    'description' => t('Set this context when viewing a node page or using the add/edit form of one of these content types.'),
-    'options' => $nodetypes,
-  );
-
-  // Views
-  if (module_exists('views')) {
-    $items['views'] = array(
-      'title' => t('Views'),
-      'description' => t('Set this context when displaying the page of one of these views.'),
-      'options' => _context_ui_get_views(),
-    );
-  }
-
-  // Menu
-  if (module_exists('menu')) {
-    // $item = array('link_title' => '', 'mlid' => 0, 'plid' => 0, 'menu_name' => 'navigation', 'weight' => 0, 'link_path' => '', 'options' => array(), 'module' => 'menu', 'expanded' => 0, 'hidden' => 0, 'has_children' => 0);
-    // @note: NULL value seems to work here, but it is not documented that it should work
-    $menus = menu_parent_options(array_reverse(menu_get_menus()), NULL);
-
-    // this is required because root menu names are displayed inside <> and will not de displayed otherwise
-    foreach ($menus as $key => $name) {
-      if (substr($menus[$key], 0, 1) == '<') {
-        $menus[$key] = '<strong>'. check_plain($menus[$key]) .'</strong>';
-      }
-    }
-
-    $items['menu'] = array(
-      'title' => t('Menus'),
-      'description' => t('Display the selected menu items as active when this context is set.'),
-      'options' => $menus,
-      'widget' => 'select',
-    );
-  }
-
-  $items['user'] = array(
-    'title' => t('User Pages'),
-    'description' => t('Set this context when a user with selected role(s) is viewed'),
-    'options' => user_roles(true),
-    'widget' => 'select',
-  );
-
-  if (module_exists('nodequeue')) {
-    $result = db_query("SELECT qid, title FROM {nodequeue_queue}");
-    $options = array();
-    while ($nq = db_fetch_object($result)) {
-      $options[$nq->qid] = $nq->title;
-    }
-    $items['nodequeue'] = array(
-      'title' => t('Nodequeue'),
-      'description' => t('Set this context when a node in the selected nodequeue(s) is viewed.'),
-      'options' => $options,
-      'widget' => 'select',
-    );
-  }
-
-  // Outline
-  if (module_exists('outline')) {
-    $result = db_query("SELECT volume_id, title FROM {outline_volume}");
-    $options = array();
-    while ($vol = db_fetch_object($result)) {
-      $options[$vol->volume_id] = $vol->title;
-    }
-    $items['outline'] = array(
-      'title' => t('Outline'),
-      'description' => t('Set this context when a node in the selected volumes(s) is viewed.'),
-      'options' => $options,
-      'widget' => 'select',
-    );
-  }
-
-  return $items;
-}
-
-/**
  * Implementation of hook_menu().
  */
 function context_ui_menu() {
@@ -239,60 +153,6 @@ function context_ui_help($path, $arg) {
 }
 
 /**
- * Implementation of hook_nodeapi().
- */
-function context_ui_nodeapi(&$node, $op, $teaser, $page) {
-  if ($op == 'view' && $page && arg(0) == 'node') {
-    // Implementation of context_ui_set for node.
-    context_ui_set('node', $node->type);
-
-    // Implementation of context_ui_set for nodequeue.
-    if (module_exists('nodequeue')) {
-      $result = db_query("SELECT qid FROM {nodequeue_nodes} WHERE nid = %d", $node->nid);
-      while ($qid = db_fetch_object($result)) {
-        context_ui_set('nodequeue', $qid->qid);
-      }
-    }
-
-    // implementation of context_ui_set for outline
-    if (module_exists('outline') && $vol = $node->volume_id) {
-      context_ui_set('outline', $vol);
-    }
-  }
-}
-
-/**
- * Implementation of hook_form_alter().
- */
-function context_ui_form_alter(&$form, $form_state, $form_id) {
-  if (isset($form['#node']) && arg(0) != 'admin') { // Prevent this from firing on admin pages... damn form driven apis...
-    context_ui_set('node', $form['#node']->type);
-  }
-  else if ($form_id == 'comment_form' && $nid = $form['nid']['#value']) {
-    $node = node_load($nid);
-    context_ui_set('node', $node->type);
-  }
-}
-
-/**
- * Implementation of hook_views_pre_query().
- */
-function context_ui_views_pre_view($display_id, $args) {
-  if ($display_id->type == 'Normal') {
-    context_ui_set('views', $display_id->name);
-  }
-}
-
-/**
- * Implementation of hook_user().
- */
-function context_ui_user($op, &$edit, &$account, $category = NULL) {
-  if ($op == 'view') {
-    context_ui_set('user', array_keys($account->roles));
-  }
-}
-
-/**
  * Invokes hook_context_define() to collect all contexts provided in code by modules.
  *
  * @param $space
@@ -473,6 +333,7 @@ function context_ui_form(&$form_state, $
       '#size' => 8,
       '#multiple' => true,
       '#options' => $item['options'],
+      '#display' => isset($item['display']) ? $item['display'] : 'normal',
     );
   }
 
@@ -645,8 +506,18 @@ function theme_context_ui_form($form) {
 
   // Render setters / getters as a two column split
   $header = array(t('Set context'), t('Respond to context'));
-  $getters = drupal_render($form['items']['menu']);
-  $setters = drupal_render($form['items']);
+  $getters = '';
+  $setters = '';
+
+  foreach (context_ui_types() as $type) {
+    if ($form['items'][$type]['#display'] == 'getter') {
+      $getters .= drupal_render($form['items'][$type]);
+    }
+    else {
+      $setters .= drupal_render($form['items'][$type]);
+    }
+  }
+
   $rows = array(
     array(
       array('data' => $setters, 'class' => 'setters left'),
@@ -849,7 +720,10 @@ function context_ui_export(&$form_state,
     // If this context already has a value, don't alter it.
     if (!context_exists($context->space, $context->ckey)) {
       context_set($context->space, $context->ckey, $context->value);
-      context_ui_menu_set_location($context);
+
+      if ($context->cid) {
+        module_invoke_all('context_response', $context);
+      }
 
       // Store the cid of set contexts. Other parts of the stack may be interested.
       $cid = context_get('context_ui', 'cid');
@@ -863,117 +737,6 @@ function context_ui_export(&$form_state,
   return $set;
 }
 
-/**
- * Takes a retrieved context array and returns a themed out tree representation of that context.
- */
-function theme_context_devel($context) {
-  $output = '';
-  foreach ($context as $space => $a) {
-    $output .= "<div class='context-devel-space'>$space</div>";
-    $output .= "<div class='context-devel-tree'>". theme_context_devel_recurse($a) ."</div>";
-  }
-  return $output;
-}
-
-/**
- * Helper function to theme_context_devel that recurses down context arrays and themes accordingly.
- */
-function theme_context_devel_recurse($value) {
-  $output = '';
-  if (is_array($value) || is_object($value)) {
-    if (is_array($value)) {
-      $type = 'array';
-    }
-    else if (is_object($value)) {
-      $type = 'object';
-    }
-    foreach ((array)$value as $key => $a) {
-      $output .= "<div class='context-devel-wrapper'><label><small>$type</small>$key</label>". theme('context_devel_recurse', $a) ."</div>";
-    }
-  }
-  else {
-    if (is_string($value)) {
-      $type = 'string';
-    }
-    else if (is_int($value)) {
-      $type = 'int';
-    }
-    else if (is_bool($value)) {
-      $type = 'bool';
-    }
-    $output .= "<div class='context-devel-wrapper'><label><small>$type</small>$value</label></div>";
-  }
-  return $output;
-}
-
-/**
- * Alters the menu to reflect any active contexts. Called from context_ui_set().
- */
-function context_ui_menu_set_location($context) {
-  // TODO update for Drupal 6
-  return;
-  if ($context->cid) {
-    $result = db_query("
-      SELECT ci.id
-      FROM {context_ui_item} ci
-      WHERE ci.type = '%s' AND ci.cid = %d",
-      'menu', $context->cid);
-    if ($path = db_result($result)) {
-      // Load global menu -- unfortunately we may have to modify it manually
-      global $_menu;
-
-      // Get menu item for active context
-      $context_menu = menu_get_item(null, $path);
-      $items[] = $context_menu;      
-
-      // Grab the menu tree from active context item to the root
-      $mid = $context_menu['pid'];
-      while ($mid && ($item = menu_get_item($mid))) {
-        $items[] = $item;
-        $mid = $item['pid'];
-      }
-      $items = array_reverse($items);
-
-      // Graft the current active page on if it is different
-      $active_mid = menu_get_active_item();
-      if ($active_mid != $_menu['path index'][$path] && !$items[$active_mid]) {
-        $active_menu = menu_get_item($active_mid);        
-        // Due to a bug/feature? of menu_set_location() menu leaves that
-        // are part of the 'visible' portion of the menu tree short-circuit
-        // any further menu grafting. We check here, and make sure the leaf
-        // item is not a visible one.        
-        if (isset($_menu['visible'][$active_mid])) {      
-          unset($_menu['visible'][$active_mid]);
-        }
-
-        // If the active menu item is a local task we need to make sure
-        // to include it's parent.
-        if ($active_menu['type'] & MENU_IS_LOCAL_TASK) {
-          $parent_menu = menu_get_item($active_menu['pid']);
-          $items[] = $parent_menu;
-
-          // Allow for two levels of local tasks.
-          if ($parent_menu['type'] & MENU_IS_LOCAL_TASK) {
-            $items[] = menu_get_item($parent_menu['pid']);
-          }
-        }
-        if ($active_menu['type'] & MENU_DEFAULT_LOCAL_TASK) {
-          $real_q = end($items);
-          $real_q = $real_q['path'];
-        }
-        $items[] = $active_menu;
-      }
-
-      // Push the new location path through
-      menu_set_location($items);
-
-      // Repair query string
-      if ($real_q) {
-        $_GET['q'] = $real_q;
-      }
-    }
-  }
-}
 
 /**
  * In order to add blocks we need to intercept theme_blocks and build the block
Index: context_ui/context_ui_admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/context/context_ui/context_ui_admin.inc,v
retrieving revision 1.4
diff -u -p -r1.4 context_ui_admin.inc
--- context_ui/context_ui_admin.inc	17 Jul 2008 16:57:19 -0000	1.4
+++ context_ui/context_ui_admin.inc	23 Jul 2008 12:00:17 -0000
@@ -305,23 +305,6 @@ function context_ui_form_submit($form, &
   $form_state['redirect'] = 'admin/build/context';
 }
 
-/*
- * Helper function to generate a list of database and module provided views.
- */
-function _context_ui_get_views() {
-  $enabled_views = array();
-  
-  $views = views_get_all_views();
-  
-  foreach ($views as $view) {
-    if (!isset($views[$view->name]->disabled) || !$views[$view->name]->disabled) {
-      $enabled_views[$view->name] = $view->name;
-    }
-  }
-  ksort($enabled_views);
-  return $enabled_views;
-}
-
 /**
  * Helper function to generate a list of blocks from a specified region. If provided a context object,
  * will generate a full list of blocks for that region distinguishing between system blocks and
Index: context_ui/context_ui_devel.inc
===================================================================
RCS file: context_ui/context_ui_devel.inc
diff -N context_ui/context_ui_devel.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ context_ui/context_ui_devel.inc	23 Jul 2008 13:03:16 -0000
@@ -0,0 +1,45 @@
+<?php
+// $Id$
+
+/**
+ * Takes a retrieved context array and returns a themed out tree representation of that context.
+ */
+function theme_context_devel($context) {
+  $output = '';
+  foreach ($context as $space => $a) {
+    $output .= "<div class='context-devel-space'>$space</div>";
+    $output .= "<div class='context-devel-tree'>". theme_context_devel_recurse($a) ."</div>";
+  }
+  return $output;
+}
+
+/**
+ * Helper function to theme_context_devel that recurses down context arrays and themes accordingly.
+ */
+function theme_context_devel_recurse($value) {
+  $output = '';
+  if (is_array($value) || is_object($value)) {
+    if (is_array($value)) {
+      $type = 'array';
+    }
+    else if (is_object($value)) {
+      $type = 'object';
+    }
+    foreach ((array)$value as $key => $a) {
+      $output .= "<div class='context-devel-wrapper'><label><small>$type</small>$key</label>". theme('context_devel_recurse', $a) ."</div>";
+    }
+  }
+  else {
+    if (is_string($value)) {
+      $type = 'string';
+    }
+    else if (is_int($value)) {
+      $type = 'int';
+    }
+    else if (is_bool($value)) {
+      $type = 'bool';
+    }
+    $output .= "<div class='context-devel-wrapper'><label><small>$type</small>$value</label></div>";
+  }
+  return $output;
+}

