? .cvsignore
? cvs-release-notes.php
? views_category2.patch
? views_fixes_backport.patch
Index: userpoints.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/userpoints/userpoints.views.inc,v
retrieving revision 1.1.2.11
diff -u -p -r1.1.2.11 userpoints.views.inc
--- userpoints.views.inc	2 Jan 2011 12:15:01 -0000	1.1.2.11
+++ userpoints.views.inc	16 Feb 2011 08:33:43 -0000
@@ -71,15 +71,15 @@ function userpoints_views_data() {
     'title' => t('Userpoints Category', userpoints_translation()),
     'help' => t('The categories (terms) of userpoints used', userpoints_translation()), // The help that appears on the UI,
     'field' => array(
-      'handler' => 'views_handler_field_term_node_tid',
+      'handler' => 'userpoints_views_handler_field_category',
     ),
     'argument' => array(
-      'handler' => 'views_handler_argument_term_node_tid',
+      'handler' => 'userpoints_views_handler_argument_category',
       'numeric' => TRUE,
       'name field' => 'category', // display this field in the summary
     ),
     'filter' => array(
-      'handler' => 'views_handler_filter_term_node_tid',
+      'handler' => 'userpoints_views_handler_filter_category',
     ),
     'sort' => array(
       'handler' => 'views_handler_sort',
@@ -191,15 +191,15 @@ function userpoints_views_data() {
     'title' => t('Userpoints Category', userpoints_translation()),
     'help' => t('The categories (terms) of userpoints used for this transaction', userpoints_translation()), // The help that appears on the UI,
     'field' => array(
-      'handler' => 'views_handler_field_term_node_tid',
+      'handler' => 'userpoints_views_handler_field_category',
     ),
     'argument' => array(
-      'handler' => 'views_handler_argument_term_node_tid',
+      'handler' => 'userpoints_views_handler_argument_category',
       'numeric' => TRUE,
       'name field' => 'category', // display this field in the summary
     ),
     'filter' => array(
-      'handler' => 'views_handler_filter_term_node_tid',
+      'handler' => 'userpoints_views_handler_filter_category',
     ),
     'sort' => array(
       'handler' => 'views_handler_sort',
@@ -362,3 +362,25 @@ function userpoints_views_data() {
 
   return $data;
 }
+
+/**
+ * Implements hook_views_handlers().
+ */
+function userpoints_views_handlers() {
+  return array(
+    'info' => array(
+      'path' => drupal_get_path('module', 'userpoints') . '/views',
+    ),
+    'handlers' => array(
+      'userpoints_views_handler_field_category' => array(
+        'parent' => 'views_handler_field',
+      ),
+      'userpoints_views_handler_filter_category' => array(
+        'parent' => 'views_handler_filter_in_operator',
+      ),
+      'userpoints_views_handler_argument_category' => array(
+        'parent' => 'views_handler_argument',
+      ),
+    ),
+  );
+}
\ No newline at end of file
Index: views/userpoints_views_handler_argument_category.inc
===================================================================
RCS file: views/userpoints_views_handler_argument_category.inc
diff -N views/userpoints_views_handler_argument_category.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views/userpoints_views_handler_argument_category.inc	16 Feb 2011 08:33:43 -0000
@@ -0,0 +1,35 @@
+<?php
+// $Id$
+
+/**
+ * Argument handler to accept a userpoints category.
+ */
+class userpoints_views_handler_argument_category extends views_handler_argument {
+  function construct() {
+    parent::construct('category');
+  }
+
+  /**
+   * Override the behavior of summary_name(). Get the user friendly version
+   * of the node type.
+   */
+  function summary_name($data) {
+    return $this->category($data->{$this->name_alias});
+  }
+
+  /**
+   * Override the behavior of title(). Get the user friendly version of the
+   * node type.
+   */
+  function title() {
+    return $this->category($this->argument);
+  }
+
+  function category($id) {
+    $output = userpoints_get_categories();
+    if (empty($output[$id])) {
+      $output = t('Unknown category');
+    }
+    return check_plain($output[$id]);
+  }
+}
Index: views/userpoints_views_handler_field_category.inc
===================================================================
RCS file: views/userpoints_views_handler_field_category.inc
diff -N views/userpoints_views_handler_field_category.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views/userpoints_views_handler_field_category.inc	16 Feb 2011 08:33:43 -0000
@@ -0,0 +1,49 @@
+<?php
+// $Id$
+
+/**
+ * Field handler for categories.
+ *
+ * Copied from views_handler_field_term_node_tid.inc
+ */
+class userpoints_views_handler_field_category extends views_handler_field {
+
+  function init(&$view, $options) {
+    parent::init($view, $options);
+
+    $this->additional_fields['name'] = array('table' => 'term_data', 'field' => 'name');
+  }
+
+  /**
+   * Add this term to the query
+   */
+  function query() {
+    $this->ensure_my_table();
+    $this->add_additional_fields();
+  }
+
+  function pre_render($values) {
+    $this->field_alias = $this->aliases['name'];
+  }
+
+  function render($values) {
+    if (!empty($values->{$this->field_alias})) {
+      return $values->{$this->field_alias};
+    }
+    return t('!Uncategorized', userpoints_translation());
+  }
+
+  function document_self_tokens(&$tokens) {
+    $tokens['[' . $this->options['id'] . '-tid' . ']'] = t('The taxonomy term ID for the term.');
+    $tokens['[' . $this->options['id'] . '-name' . ']'] = t('The taxonomy term name for the term.');
+    $tokens['[' . $this->options['id'] . '-vid' . ']'] = t('The vocabulary ID for the vocabulary the term belongs to.');
+    $tokens['[' . $this->options['id'] . '-vocabulary' . ']'] = t('The name for the vocabulary the term belongs to.');
+  }
+
+  function add_self_tokens(&$tokens, $item) {
+    $tokens['[' . $this->options['id'] . '-tid' . ']'] = $item['tid'];
+    $tokens['[' . $this->options['id'] . '-name' . ']'] = $item['name'];
+    $tokens['[' . $this->options['id'] . '-vid' . ']'] = $item['vid'];
+    $tokens['[' . $this->options['id'] . '-vocabulary' . ']'] = $item['vocabulary'];
+  }
+}
Index: views/userpoints_views_handler_filter_category.inc
===================================================================
RCS file: views/userpoints_views_handler_filter_category.inc
diff -N views/userpoints_views_handler_filter_category.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views/userpoints_views_handler_filter_category.inc	16 Feb 2011 08:33:43 -0000
@@ -0,0 +1,13 @@
+<?php
+// $Id$
+/**
+ * Filter by category
+ */
+class userpoints_views_handler_filter_category extends views_handler_filter_in_operator {
+  function get_value_options() {
+    if (!isset($this->value_options)) {
+      $this->value_title = t('Category');
+      $this->value_options = userpoints_get_categories();
+    }
+  }
+}
