? 303406-domain-theme.patch
? test.patch
Index: domain_source/domain_source.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_source/domain_source.module,v
retrieving revision 1.11
diff -u -p -r1.11 domain_source.module
--- domain_source/domain_source.module	24 Mar 2009 20:09:16 -0000	1.11
+++ domain_source/domain_source.module	28 Apr 2009 16:42:39 -0000
@@ -201,3 +201,12 @@ function domain_source_domainupdate($op,
     db_query("DELETE FROM {domain_source} WHERE domain_id = %d", $domain['domain_id']);
   }
 }
+
+/**
+ * Implements hook_views_api().
+ */
+function domain_source_views_api() {
+  if (module_exists('domain_views')) {
+    return array('api' => 2.0);
+  }
+}
Index: domain_source/domain_source.views.inc
===================================================================
RCS file: domain_source/domain_source.views.inc
diff -N domain_source/domain_source.views.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ domain_source/domain_source.views.inc	28 Apr 2009 16:42:39 -0000
@@ -0,0 +1,63 @@
+<?php
+
+// $Id:$
+
+/**
+ * @file
+ * Views integration for Domain Source.
+ */
+
+/**
+ * Implements hook_views_data().
+ */
+function domain_source_views_data() {
+  // Define the {domain_access} table.
+  $data['domain_source']['table']['group'] = t('Domain Source');
+  // Define the joins.
+  $data['domain_source']['table']['join']['node'] = array(
+    'left_field' => 'nid',
+    'field' => 'nid',
+  );
+  // Define the fields.
+  $data['domain_source']['nid'] = array(
+    'title' => t('Node ID'),
+    'help' => t('The node id.'),
+    'field' => array(
+      'click sortable' => TRUE,
+    ),
+    // Information for accepting a domain_id as a filter
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+    // Information for sorting on a domain_id.
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'relationship' => array(
+      'title' => t('Domain node'),
+      'help' => t("Bring in information about the source domain this node is assigned to."),
+      'base' => 'node',
+      'field' => 'nid',
+      'handler' => 'views_handler_relationship',
+      'label' => t('Domain node'),
+    ),
+  );
+  $data['domain_source']['domain_id'] = array(
+    'title' => t('Domain Source ID'),
+    'help' => t('The unique id key for the source domain.'),
+    'field' => array(
+      'handler' => 'domain_views_handler_field_domain_id',
+      'click sortable' => TRUE,
+    ),
+    // Information for accepting a domain_id as a filter
+    'filter' => array(
+      'handler' => 'domain_views_handler_filter_domain_domain_id',
+    ),
+    // Information for sorting on a domain_id.
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
+
+  return $data;
+}
Index: domain_views/domain_views.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_views/domain_views.views.inc,v
retrieving revision 1.7
diff -u -p -r1.7 domain_views.views.inc
--- domain_views/domain_views.views.inc	23 Apr 2009 21:42:20 -0000	1.7
+++ domain_views/domain_views.views.inc	28 Apr 2009 16:42:40 -0000
@@ -37,6 +37,7 @@ function domain_views_views_data() {
     'help' => t('The unique id key for the active domain.'),
     'field' => array(
       'click sortable' => TRUE,
+      'handler' => 'domain_views_handler_field_domain_id',
     ),
     // Information for accepting a domain_id as a filter
     'filter' => array(
@@ -148,6 +149,7 @@ function domain_views_views_data() {
     'help' => t('The domain id of the record.'),
     'field' => array(
       'click sortable' => TRUE,
+      'handler' => 'domain_views_handler_field_domain_id',
     ),
     // Information for accepting a domain_id as a filter
     'filter' => array(
@@ -221,6 +223,7 @@ function domain_views_views_data() {
     'help' => t('The domain id of the editor record.'),
     'field' => array(
       'click sortable' => TRUE,
+      'handler' => 'domain_views_handler_field_domain_id',
     ),
     // Information for accepting a domain_id as a filter
     'filter' => array(
@@ -267,6 +270,9 @@ function domain_views_views_handlers() {
       'parent' => 'views_handler_argument',
     ),
     // field handlers
+    'domain_views_handler_field_domain_id' => array(
+      'parent' => 'views_handler_field',
+    ),
     'domain_views_handler_field_domain_sitename' => array(
       'parent' => 'views_handler_field',
     ),
Index: domain_views/includes/domain_views_handler_field_domain_id.inc
===================================================================
RCS file: domain_views/includes/domain_views_handler_field_domain_id.inc
diff -N domain_views/includes/domain_views_handler_field_domain_id.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ domain_views/includes/domain_views_handler_field_domain_id.inc	28 Apr 2009 16:42:40 -0000
@@ -0,0 +1,92 @@
+<?php
+// $Id:$
+/**
+ * @file
+ * Interface between domain_views.module and views.module.
+ *
+ * @ingroup domain_views
+ */
+
+/**
+ * Field handler to provide simple renderer that allows linking to a domain.
+ *
+ * @ingroup domain_views
+ */
+class domain_views_handler_field_domain_id extends views_handler_field {
+  /**
+   * Constructor to provide additional field to add.
+   */
+  function construct() {
+    parent::construct();
+    $this->additional_fields['domain_id'] = 'domain_id';
+    $this->additional_fields['nid'] = array('table' => 'node', 'field' => 'nid');
+  }
+
+  function option_definition() {
+    $options = parent::option_definition();
+    $options['link_to_default_domain'] = array('default' => FALSE);
+    $options['link_to_original_domain'] = array('default' => FALSE);
+    $options['list_all_domains'] = array('default' => FALSE);
+    return $options;
+  }
+
+  /**
+   * Provide link to default domain option
+   */
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+    $form['link_to_domain_id'] = array(
+      '#title' => t('Link this field to its domain by domain_id'),
+      '#description' => t('This will override any other link you have set.'),
+      '#type' => 'checkbox',
+      '#default_value' => !empty($this->options['link_to_domain_id']),
+    );
+    $form['link_to_sitename'] = array(
+      '#title' => t('Link this field to its domain by sitename'),
+      '#description' => t('This will override any other link you have set.'),
+      '#type' => 'checkbox',
+      '#default_value' => !empty($this->options['link_to_sitename']),
+    );
+  }
+
+
+  function query() {
+    parent::query();
+    // The {domain_alias} table uses GID instead of DOMAIN_ID.
+    if (isset($this->query->fields['domain_access_gid'])) {
+      $this->query->fields['domain_access_domain_id']['field'] = 'gid';
+    }
+  }
+
+
+  /**
+   * Render sitename is as a link to the domain.
+   *
+   * Data should be made XSS safe prior to calling this function.
+   */
+  function render_link($data, $values) {
+    if (!empty($this->options['link_to_domain_id']) && $data !== NULL && $data !== '') {
+      $this->options['alter']['make_link'] = TRUE;
+      $domain = domain_lookup($data);
+      $node_path = drupal_get_path_alias('node/'. $values->{$this->aliases['nid']});
+      $this->options['alter']['path'] = $domain['scheme'] .'://'. $domain['subdomain'] .'/'. $node_path;
+    }
+    if (!empty($this->options['link_to_sitename']) && $data !== NULL && $data !== '') {
+      $this->options['alter']['make_link'] = TRUE;
+      $domain = domain_lookup($data);
+      $this->aliases['nid'] = 'nid';
+      $node_path = drupal_get_path_alias('node/'. $values->{$this->aliases['nid']});
+      $this->options['alter']['path'] = $domain['scheme'] .'://'. $domain['subdomain'] .'/'. $node_path;
+    }
+    return $data;
+  }
+
+  function render($values) {
+    $text = $values->{$this->field_alias};
+    if (!empty($this->options['link_to_sitename'])) {
+      $domain = domain_lookup($text);
+      $text = $domain['sitename'];
+    }
+    return $this->render_link(check_plain($text), $values);
+  }
+}
