From 41b79659db34ccdba43109f99bce93c7f9ffd783 Mon Sep 17 00:00:00 2001
From: Tim Plunkett <git@plnktt.com>
Date: Tue, 5 Apr 2011 18:00:04 -0400
Subject: [PATCH] Issue #1117466 by tim.plunkett: Add basic Views integration.

---
 annotation_text/annotation_text.module             |   10 +++
 annotation_text/includes/annotation_text.views.inc |   70 ++++++++++++++++++++
 2 files changed, 80 insertions(+), 0 deletions(-)
 create mode 100644 annotation_text/includes/annotation_text.views.inc

diff --git a/annotation_text/annotation_text.module b/annotation_text/annotation_text.module
index cb43c88..6773cf7 100644
--- a/annotation_text/annotation_text.module
+++ b/annotation_text/annotation_text.module
@@ -375,3 +375,13 @@ function _annotation_text_closest_match($haystack, $needle, $target, $length) {
 
   return $bestPos;
 }
+
+/**
+ * Implements hook_views_api().
+ */
+function annotation_text_views_api() {
+  return array(
+   'api' => 2,
+   'path' => drupal_get_path('module', 'annotation_text') . '/includes',
+  );
+}
diff --git a/annotation_text/includes/annotation_text.views.inc b/annotation_text/includes/annotation_text.views.inc
new file mode 100644
index 0000000..a43aa8f
--- /dev/null
+++ b/annotation_text/includes/annotation_text.views.inc
@@ -0,0 +1,70 @@
+<?php
+
+/**
+ * @file
+ * Contains Views hooks.
+ */
+
+/**
+ * Implements hook_views_data().
+ */
+function annotation_text_views_data() {
+  $data['annotation_text'] = array(
+    'table' => array(
+      'group' => t('Annotation text'),
+      'join' => array(
+        'node' => array(
+          'left_field' => 'vid',
+          'field' => 'vid',
+        ),
+        'comments' => array(
+          'left_field' => 'cid',
+          'field' => 'cid',
+        ),
+      ),
+    ),
+    'offset' => array(
+      'title' => t('Offset'),
+      'help' => t('The offset of the selected text.'),
+      'field' => array(
+        'handler' => 'views_handler_field_numeric',
+        'click sortable' => TRUE,
+       ),
+      'filter' => array(
+        'handler' => 'views_handler_filter_numeric',
+      ),
+      'sort' => array(
+        'handler' => 'views_handler_sort',
+      ),
+    ),
+    'length' => array(
+      'title' => t('Length'),
+      'help' => t('The length of the selected text.'),
+      'field' => array(
+        'handler' => 'views_handler_field_numeric',
+        'click sortable' => TRUE,
+       ),
+      'filter' => array(
+        'handler' => 'views_handler_filter_numeric',
+      ),
+      'sort' => array(
+        'handler' => 'views_handler_sort',
+      ),
+    ),
+    'string' => array(
+      'title' => t('String'),
+      'help' => t('The selected text.'),
+      'field' => array(
+        'handler' => 'views_handler_field',
+        'click sortable' => TRUE,
+       ),
+      'filter' => array(
+        'handler' => 'views_handler_filter_string',
+      ),
+      'sort' => array(
+        'handler' => 'views_handler_sort',
+      ),
+    ),
+  );
+  return $data;
+}
-- 
1.7.3.2

