Index: spaces_taxonomy/spaces_taxonomy.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/spaces/spaces_taxonomy/Attic/spaces_taxonomy.module,v
retrieving revision 1.1.2.4.2.4.2.3
diff -u -p -r1.1.2.4.2.4.2.3 spaces_taxonomy.module
--- spaces_taxonomy/spaces_taxonomy.module	17 Dec 2009 22:33:05 -0000	1.1.2.4.2.4.2.3
+++ spaces_taxonomy/spaces_taxonomy.module	12 Apr 2010 23:02:49 -0000
@@ -20,6 +20,15 @@ function spaces_taxonomy_ctools_plugin_a
 }
 
 /**
+ * Implementation of hook_ctools_plugin_directory().
+ */
+function spaces_taxonomy_ctools_plugin_directory($module, $plugin) {
+  if ($module == 'ctools' && $plugin == 'contexts') {
+    return 'plugins/contexts';
+  }
+}
+
+/**
  * Implementation of hook_purl_provider().
  */
 function spaces_taxonomy_purl_provider() {
Index: spaces_taxonomy/plugins/contexts/space_taxonomy_context.inc
===================================================================
RCS file: spaces_taxonomy/plugins/contexts/space_taxonomy_context.inc
diff -N spaces_taxonomy/plugins/contexts/space_taxonomy_context.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ spaces_taxonomy/plugins/contexts/space_taxonomy_context.inc	12 Apr 2010 23:02:49 -0000
@@ -0,0 +1,72 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Ideally we would like this whole thing to be an CTools argument instead of
+ * a context. But we can't do that as "taxonomy/term/%term" must have
+ * additional keywords to be able to pass on additional arguments. Also, spaces
+ * keys aren't necessarily directly accessible in the URL.
+ *
+ * Contexts must always have a data property to be exposed as "usable" in
+ * the admin UI. So because of this, we need to fake the data property as the
+ * space isn't available in the Panels UI. In reality this won't be a problem
+ * as all spaces always exists in them selfs and have data.
+ */
+
+define('SPACES_FAKE_DATA', 0x0001);
+
+$plugin = array(
+  'title' => t("Spaces taxonomy term"),
+  'description' => t('Provides a term from a taxonomy space as a context.'),
+  'keyword' => 'term',
+  'context' => 'spaces_taxonomy_context_create_term',
+  'context name' => 'space_term',
+  'convert list' => array(
+    'tid' => t('Term ID'),
+    'name' => t('Term name'),
+    'vid' => t('Vocabulary ID'),
+  ),
+  'convert' => 'spaces_taxonomy_context_convert',
+);
+
+function spaces_taxonomy_context_create_term($empty, $data = NULL, $conf = FALSE) {
+  $context = new ctools_context('term');
+  $context->plugin = 'term';
+
+  if ($empty) {
+    return $context;
+  }
+
+  $space = spaces_get_space('term');
+
+  if (!empty($space->term)) {
+    $context->data = $space->term;
+    $context->title = $space->term->name;
+    $context->argument = $space->term->tid;
+  }
+  // It's in this case we need to fake some data.
+  else {
+    $context->data->name = SPACES_FAKE_DATA;
+    $context->data->tid = SPACES_FAKE_DATA;
+    $context->data->vid = SPACES_FAKE_DATA;
+    $context->title = SPACES_FAKE_DATA;
+    $context->argument = SPACES_FAKE_DATA;
+  }
+
+  return $context;
+}
+
+/**
+ * Convert a context into a string.
+ */
+function spaces_taxonomy_context_convert($context, $type) {
+  switch ($type) {
+    case 'tid':
+      return $context->data->tid;
+    case 'name':
+      return $context->data->name;
+    case 'vid':
+      return $context->data->vid;
+  }
+}
