Index: fasttoggle.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fasttoggle/Attic/fasttoggle.module,v
retrieving revision 1.8.2.8
diff -u -p -r1.8.2.8 fasttoggle.module
--- fasttoggle.module	8 Nov 2008 11:38:19 -0000	1.8.2.8
+++ fasttoggle.module	29 Jan 2009 08:15:42 -0000
@@ -297,47 +297,6 @@ function fasttoggle_link($type, $obj = n
 
 
 /**
- * Implementation of hook_views_tables().
- */
-function fasttoggle_views_tables() {
-  $tables['fasttoggle'] = array(
-    'fields' => array(
-      'fasttoggle' => array(
-        'name' => t('Node: Fasttoggle'),
-        'handler' => 'fasttoggle_handler_field',
-        'query_handler' => 'fasttoggle_node_query_handler',
-        'sortable' => false,
-        'option' => array(
-          '#type' => 'select',
-          '#options' => array(
-            'status' => t('Status'),
-            'promote' => t('Promoted'),
-            'sticky' => t('Sticky'),
-            'comment' => t('Comment settings'),
-          ),
-        ),
-        'notafield' => 'true',
-        'help' => t('This field contains a fasttoggle link for the selected action for the current node.'),
-      ),
-    ),
-  );
-
-  return $tables;
-}
-
-/**
- * Views query callback.
- */
-function fasttoggle_node_query_handler($fielddata, $fieldinfo, &$query) {
-  foreach (array('status', 'comment', 'promote', 'sticky') as $field) {
-    if (!in_array('node.'. $field, $query->fields)) {
-      $query->fields[] = 'node.'. $field;
-    }
-  }
-}
-
-
-/**
  * Implementation of hook_fasttoggle_labels().
  */
 function fasttoggle_fasttoggle_labels($style) {
@@ -391,14 +350,6 @@ function _fasttoggle_get_label($label, $
 }
 
 
-/**
- * Views handler callback.
- */
-function fasttoggle_handler_field($fieldinfo, $fielddata, $value, $data) {
-  $options = fasttoggle_get_options('node', $data);
-  $key = $fielddata['options'];
-
-  if (isset($options[$key]) && isset($data->$key)) {
-    return fasttoggle($options[$key][intval($data->$key)], 'node/'. $data->nid .'/toggle/'. $key, true, $key .'_'. $data->nid);
-  }
+function fasttoggle_views_api() {
+  return array('api' => 2, 'path' => drupal_get_path('module', 'fasttoggle') . '/views');
 }
Index: views/fasttoggle.views.inc
===================================================================
RCS file: views/fasttoggle.views.inc
diff -N views/fasttoggle.views.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views/fasttoggle.views.inc	29 Jan 2009 08:15:42 -0000
@@ -0,0 +1,55 @@
+<?php
+
+/**
+ * Implementation of hook_views_data_alter()
+ */
+
+function fasttoggle_views_data_alter() {
+
+  $data['node']['publish_node'] = array(
+    'field' => array(
+    'title' => t('Publish Link'),
+    'help' => t('Provide a simple link to publish the node.'),
+    'handler' => 'fasttoggle_handler_field_node_link_publish',
+    ),
+  );
+  $data['node']['promote_node'] = array(
+    'field' => array(
+    'title' => t('Promote Link'),
+    'help' => t('Provide a simple link to promote the node.'),
+    'handler' => 'fasttoggle_handler_field_node_link_promote',
+    ),
+  );
+  $data['node']['sticky_node'] = array(
+    'field' => array(
+    'title' => t('Make Sticky Link'),
+    'help' => t('Provide a simple link to make the node sticky.'),
+    'handler' => 'fasttoggle_handler_field_node_link_sticky',
+    ),
+  );
+  return $data;
+}
+
+/**
+ * Field handler to present a link toggle status.
+ */
+
+function fasttoggle_views_handlers() {
+  return array(
+      'info' => array(
+      'path' => drupal_get_path('module', 'fasttoggle') . '/views',
+    ),
+    'handlers' => array(
+      // field handlers
+      'fasttoggle_handler_field_node_link_publish' => array(
+        'parent' => 'views_handler_field_node_link',
+      ),
+      'fasttoggle_handler_field_node_link_promote' => array(
+        'parent' => 'fasttoggle_handler_field_node_link_publish',
+      ),
+      'fasttoggle_handler_field_node_link_sticky' => array(
+        'parent' => 'fasttoggle_handler_field_node_link_publish',
+      ),
+    ),
+  );
+}
Index: views/fasttoggle_handler_field_node_link_promote.inc
===================================================================
RCS file: views/fasttoggle_handler_field_node_link_promote.inc
diff -N views/fasttoggle_handler_field_node_link_promote.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views/fasttoggle_handler_field_node_link_promote.inc	29 Jan 2009 08:15:42 -0000
@@ -0,0 +1,8 @@
+<?php
+class fasttoggle_handler_field_node_link_promote extends fasttoggle_handler_field_node_link_publish {
+  function construct() {
+    parent::construct();
+    $this->additional_fields['promote'] = 'promote';
+    $this->fasttoggle_key = 'promote';
+  }
+}
Index: views/fasttoggle_handler_field_node_link_publish.inc
===================================================================
RCS file: views/fasttoggle_handler_field_node_link_publish.inc
diff -N views/fasttoggle_handler_field_node_link_publish.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views/fasttoggle_handler_field_node_link_publish.inc	29 Jan 2009 08:15:42 -0000
@@ -0,0 +1,42 @@
+<?php
+class fasttoggle_handler_field_node_link_publish extends views_handler_field_node_link {
+  var $fasttoggle_key = 'status';
+
+  function construct() {
+    parent::construct();
+    $this->additional_fields['uid'] = 'uid';
+    $this->additional_fields['status'] = 'status';
+    $this->additional_fields['type'] = 'type';
+    $this->additional_fields['format'] = array('table' => 'node_revisions', 'field' => 'format');
+  }
+
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+    unset($form['text']);
+  }
+
+
+  function render($values) {
+    // ensure user has access to edit this node.
+    $node = new stdClass();
+    $node->nid = $values->{$this->aliases['nid']};
+    $node->uid = $values->{$this->aliases['uid']};
+    $node->type = $values->{$this->aliases['type']};
+    $node->format = $values->{$this->aliases['format']};
+
+    $node->status = 1; // unpublished nodes ignore access control
+    if (!node_access('update', $node)) {
+      return;
+    }
+
+    $node->status = $values->{$this->aliases['status']};
+    $options = fasttoggle_get_options('node', $obj);
+
+    $key = $this->fasttoggle_key;
+
+    if (!empty($options[$key])) {
+      $node->$key = $values->{$this->aliases[$key]};
+      return fasttoggle($options[$key][intval($node->$key)], 'node/'. $node->nid .'/toggle/'. $key, TRUE, $key .'_'. $node->nid);
+    }
+  }
+}
Index: views/fasttoggle_handler_field_node_link_sticky.inc
===================================================================
RCS file: views/fasttoggle_handler_field_node_link_sticky.inc
diff -N views/fasttoggle_handler_field_node_link_sticky.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ views/fasttoggle_handler_field_node_link_sticky.inc	29 Jan 2009 08:15:42 -0000
@@ -0,0 +1,8 @@
+<?php
+class fasttoggle_handler_field_node_link_sticky extends fasttoggle_handler_field_node_link_publish {
+  function construct() {
+    parent::construct();
+    $this->additional_fields['sticky'] = 'sticky';
+    $this->fasttoggle_key = 'sticky';
+  }
+}
