From 15d14fbe64453310a34fcca83bdf5ca8153e1d0f Mon Sep 17 00:00:00 2001
From: Dave Reid <dave@davereid.net>
Date: Mon, 23 May 2011 09:49:26 -0500
Subject: [PATCH] Issue #1166140: Added rdf_hook_info() to support modulename.rdf.inc files for RDF hooks.

---
 modules/blog/blog.module          |   15 ----------
 modules/blog/blog.rdf.inc         |   21 ++++++++++++++
 modules/comment/comment.module    |   42 -----------------------------
 modules/comment/comment.rdf.inc   |   48 +++++++++++++++++++++++++++++++++
 modules/forum/forum.module        |   26 ------------------
 modules/forum/forum.rdf.inc       |   32 ++++++++++++++++++++++
 modules/node/node.module          |   47 --------------------------------
 modules/node/node.rdf.inc         |   53 +++++++++++++++++++++++++++++++++++++
 modules/poll/poll.module          |   15 ----------
 modules/poll/poll.rdf.inc         |   21 ++++++++++++++
 modules/rdf/rdf.module            |   29 ++++++++------------
 modules/rdf/rdf.rdf.inc           |   23 ++++++++++++++++
 modules/taxonomy/taxonomy.module  |   45 -------------------------------
 modules/taxonomy/taxonomy.rdf.inc |   51 +++++++++++++++++++++++++++++++++++
 modules/user/user.module          |   22 ---------------
 modules/user/user.rdf.inc         |   28 +++++++++++++++++++
 16 files changed, 289 insertions(+), 229 deletions(-)
 create mode 100644 modules/blog/blog.rdf.inc
 create mode 100644 modules/comment/comment.rdf.inc
 create mode 100644 modules/forum/forum.rdf.inc
 create mode 100644 modules/node/node.rdf.inc
 create mode 100644 modules/poll/poll.rdf.inc
 create mode 100644 modules/rdf/rdf.rdf.inc
 create mode 100644 modules/taxonomy/taxonomy.rdf.inc
 create mode 100644 modules/user/user.rdf.inc

diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index 98ebe51..2c77b76 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -253,18 +253,3 @@ function blog_block_view($delta = '') {
     }
   }
 }
-
-/**
- * Implements hook_rdf_mapping().
- */
-function blog_rdf_mapping() {
-  return array(
-    array(
-      'type' => 'node',
-      'bundle' => 'blog',
-      'mapping' => array(
-        'rdftype' => array('sioc:Post', 'sioct:BlogPost'),
-      ),
-    ),
-  );
-}
diff --git a/modules/blog/blog.rdf.inc b/modules/blog/blog.rdf.inc
new file mode 100644
index 0000000..075db84
--- /dev/null
+++ b/modules/blog/blog.rdf.inc
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * @file
+ * RDF integration for the blog module.
+ */
+
+/**
+ * Implements hook_rdf_mapping().
+ */
+function blog_rdf_mapping() {
+  return array(
+    array(
+      'type' => 'node',
+      'bundle' => 'blog',
+      'mapping' => array(
+        'rdftype' => array('sioc:Post', 'sioct:BlogPost'),
+      ),
+    ),
+  );
+}
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 60a9ca4..cc2d444 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -2632,48 +2632,6 @@ function comment_ranking() {
 }
 
 /**
- * Implements hook_rdf_mapping().
- */
-function comment_rdf_mapping() {
-  return array(
-    array(
-      'type' => 'comment',
-      'bundle' => RDF_DEFAULT_BUNDLE,
-      'mapping' => array(
-        'rdftype' => array('sioc:Post', 'sioct:Comment'),
-        'title' => array(
-          'predicates' => array('dc:title'),
-        ),
-        'created' => array(
-          'predicates' => array('dc:date', 'dc:created'),
-          'datatype' => 'xsd:dateTime',
-          'callback' => 'date_iso8601',
-        ),
-        'changed' => array(
-          'predicates' => array('dc:modified'),
-          'datatype' => 'xsd:dateTime',
-          'callback' => 'date_iso8601',
-        ),
-        'comment_body' => array(
-          'predicates' => array('content:encoded'),
-        ),
-        'pid' => array(
-          'predicates' => array('sioc:reply_of'),
-          'type' => 'rel',
-        ),
-        'uid' => array(
-          'predicates' => array('sioc:has_creator'),
-          'type' => 'rel',
-        ),
-        'name' => array(
-          'predicates' => array('foaf:name'),
-        ),
-      ),
-    ),
-  );
-}
-
-/**
  * Implements hook_file_download_access().
  */
 function comment_file_download_access($field, $entity_type, $entity) {
diff --git a/modules/comment/comment.rdf.inc b/modules/comment/comment.rdf.inc
new file mode 100644
index 0000000..c2cf5e2
--- /dev/null
+++ b/modules/comment/comment.rdf.inc
@@ -0,0 +1,48 @@
+<?php
+
+/**
+ * @file
+ * RDF integration for the comment module.
+ */
+
+/**
+ * Implements hook_rdf_mapping().
+ */
+function comment_rdf_mapping() {
+  return array(
+    array(
+      'type' => 'comment',
+      'bundle' => RDF_DEFAULT_BUNDLE,
+      'mapping' => array(
+        'rdftype' => array('sioc:Post', 'sioct:Comment'),
+        'title' => array(
+          'predicates' => array('dc:title'),
+        ),
+        'created' => array(
+          'predicates' => array('dc:date', 'dc:created'),
+          'datatype' => 'xsd:dateTime',
+          'callback' => 'date_iso8601',
+        ),
+        'changed' => array(
+          'predicates' => array('dc:modified'),
+          'datatype' => 'xsd:dateTime',
+          'callback' => 'date_iso8601',
+        ),
+        'comment_body' => array(
+          'predicates' => array('content:encoded'),
+        ),
+        'pid' => array(
+          'predicates' => array('sioc:reply_of'),
+          'type' => 'rel',
+        ),
+        'uid' => array(
+          'predicates' => array('sioc:has_creator'),
+          'type' => 'rel',
+        ),
+        'name' => array(
+          'predicates' => array('foaf:name'),
+        ),
+      ),
+    ),
+  );
+}
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index c58b5c9..5041aa3 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -1263,29 +1263,3 @@ function _forum_update_forum_index($nid) {
       ->execute();
   }
 }
-
-/**
- * Implements hook_rdf_mapping().
- */
-function forum_rdf_mapping() {
-  return array(
-    array(
-      'type' => 'node',
-      'bundle' => 'forum',
-      'mapping' => array(
-        'rdftype' => array('sioc:Post', 'sioct:BoardPost'),
-        'taxonomy_forums' => array(
-          'predicates' => array('sioc:has_container'),
-          'type' => 'rel',
-        ),
-      ),
-    ),
-    array(
-      'type' => 'taxonomy_term',
-      'bundle' => 'forums',
-      'mapping' => array(
-        'rdftype' => array('sioc:Container', 'sioc:Forum'),
-      ),
-    ),
-  );
-}
diff --git a/modules/forum/forum.rdf.inc b/modules/forum/forum.rdf.inc
new file mode 100644
index 0000000..b7f942e
--- /dev/null
+++ b/modules/forum/forum.rdf.inc
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * @file
+ * RDF integration for the forum module.
+ */
+
+/**
+ * Implements hook_rdf_mapping().
+ */
+function forum_rdf_mapping() {
+  return array(
+    array(
+      'type' => 'node',
+      'bundle' => 'forum',
+      'mapping' => array(
+        'rdftype' => array('sioc:Post', 'sioct:BoardPost'),
+        'taxonomy_forums' => array(
+          'predicates' => array('sioc:has_container'),
+          'type' => 'rel',
+        ),
+      ),
+    ),
+    array(
+      'type' => 'taxonomy_term',
+      'bundle' => 'forums',
+      'mapping' => array(
+        'rdftype' => array('sioc:Container', 'sioc:Forum'),
+      ),
+    ),
+  );
+}
diff --git a/modules/node/node.module b/modules/node/node.module
index 524a57f..8221f81 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -798,53 +798,6 @@ function node_type_set_defaults($info = array()) {
 }
 
 /**
- * Implements hook_rdf_mapping().
- */
-function node_rdf_mapping() {
-  return array(
-    array(
-      'type' => 'node',
-      'bundle' => RDF_DEFAULT_BUNDLE,
-      'mapping' => array(
-        'rdftype' => array('sioc:Item', 'foaf:Document'),
-        'title' => array(
-          'predicates' => array('dc:title'),
-        ),
-        'created' => array(
-          'predicates' => array('dc:date', 'dc:created'),
-          'datatype' => 'xsd:dateTime',
-          'callback' => 'date_iso8601',
-        ),
-        'changed' => array(
-          'predicates' => array('dc:modified'),
-          'datatype' => 'xsd:dateTime',
-          'callback' => 'date_iso8601',
-        ),
-        'body' => array(
-          'predicates' => array('content:encoded'),
-        ),
-        'uid' => array(
-          'predicates' => array('sioc:has_creator'),
-          'type' => 'rel',
-        ),
-        'name' => array(
-          'predicates' => array('foaf:name'),
-        ),
-        'comment_count' => array(
-          'predicates' => array('sioc:num_replies'),
-          'datatype' => 'xsd:integer',
-        ),
-        'last_activity' => array(
-          'predicates' => array('sioc:last_activity_date'),
-          'datatype' => 'xsd:dateTime',
-          'callback' => 'date_iso8601',
-        ),
-      ),
-    ),
-  );
-}
-
-/**
  * Determine whether a node hook exists.
  *
  * @param $node
diff --git a/modules/node/node.rdf.inc b/modules/node/node.rdf.inc
new file mode 100644
index 0000000..9f26712
--- /dev/null
+++ b/modules/node/node.rdf.inc
@@ -0,0 +1,53 @@
+<?php
+
+/**
+ * @file
+ * RDF integration for the node module.
+ */
+
+/**
+ * Implements hook_rdf_mapping().
+ */
+function node_rdf_mapping() {
+  return array(
+    array(
+      'type' => 'node',
+      'bundle' => RDF_DEFAULT_BUNDLE,
+      'mapping' => array(
+        'rdftype' => array('sioc:Item', 'foaf:Document'),
+        'title' => array(
+          'predicates' => array('dc:title'),
+        ),
+        'created' => array(
+          'predicates' => array('dc:date', 'dc:created'),
+          'datatype' => 'xsd:dateTime',
+          'callback' => 'date_iso8601',
+        ),
+        'changed' => array(
+          'predicates' => array('dc:modified'),
+          'datatype' => 'xsd:dateTime',
+          'callback' => 'date_iso8601',
+        ),
+        'body' => array(
+          'predicates' => array('content:encoded'),
+        ),
+        'uid' => array(
+          'predicates' => array('sioc:has_creator'),
+          'type' => 'rel',
+        ),
+        'name' => array(
+          'predicates' => array('foaf:name'),
+        ),
+        'comment_count' => array(
+          'predicates' => array('sioc:num_replies'),
+          'datatype' => 'xsd:integer',
+        ),
+        'last_activity' => array(
+          'predicates' => array('sioc:last_activity_date'),
+          'datatype' => 'xsd:dateTime',
+          'callback' => 'date_iso8601',
+        ),
+      ),
+    ),
+  );
+}
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index f45b8bd..46ecb96 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -984,18 +984,3 @@ function poll_user_delete($account) {
     ->condition('uid', $account->uid)
     ->execute();
 }
-
-/**
- * Implements hook_rdf_mapping().
- */
-function poll_rdf_mapping() {
-  return array(
-    array(
-      'type' => 'node',
-      'bundle' => 'poll',
-      'mapping' => array(
-        'rdftype' => array('sioc:Post', 'sioct:Poll'),
-      ),
-    ),
-  );
-}
diff --git a/modules/poll/poll.rdf.inc b/modules/poll/poll.rdf.inc
new file mode 100644
index 0000000..90a7278
--- /dev/null
+++ b/modules/poll/poll.rdf.inc
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * @file
+ * RDF integration for the poll module.
+ */
+
+/**
+ * Implements hook_rdf_mapping().
+ */
+function poll_rdf_mapping() {
+  return array(
+    array(
+      'type' => 'node',
+      'bundle' => 'poll',
+      'mapping' => array(
+        'rdftype' => array('sioc:Post', 'sioct:Poll'),
+      ),
+    ),
+  );
+}
diff --git a/modules/rdf/rdf.module b/modules/rdf/rdf.module
index ebecd42..2ffb7e2 100644
--- a/modules/rdf/rdf.module
+++ b/modules/rdf/rdf.module
@@ -19,6 +19,18 @@ function rdf_help($path, $arg) {
 }
 
 /**
+ * Implements hook_hook_info().
+ */
+function rdf_hook_info() {
+  $hooks = array(
+    'rdf_mapping',
+    'rdf_namespaces',
+  );
+
+  return array_fill_keys($hooks, array('group' => 'rdf'));
+}
+
+/**
  * @defgroup rdf RDF Mapping API
  * @{
  * Functions to describe entities and bundles in RDF.
@@ -74,23 +86,6 @@ function rdf_help($path, $arg) {
 define('RDF_DEFAULT_BUNDLE', '');
 
 /**
- * Implements hook_rdf_namespaces().
- */
-function rdf_rdf_namespaces() {
-  return array(
-    'content'  => 'http://purl.org/rss/1.0/modules/content/',
-    'dc'       => 'http://purl.org/dc/terms/',
-    'foaf'     => 'http://xmlns.com/foaf/0.1/',
-    'og'       => 'http://ogp.me/ns#',
-    'rdfs'     => 'http://www.w3.org/2000/01/rdf-schema#',
-    'sioc'     => 'http://rdfs.org/sioc/ns#',
-    'sioct'    => 'http://rdfs.org/sioc/types#',
-    'skos'     => 'http://www.w3.org/2004/02/skos/core#',
-    'xsd'      => 'http://www.w3.org/2001/XMLSchema#',
-  );
-}
-
-/**
  * Returns an array of RDF namespaces defined in modules that implement
  * hook_rdf_namespaces().
  */
diff --git a/modules/rdf/rdf.rdf.inc b/modules/rdf/rdf.rdf.inc
new file mode 100644
index 0000000..3b34cec
--- /dev/null
+++ b/modules/rdf/rdf.rdf.inc
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * @file
+ * RDF integration for the rdf module.
+ */
+
+/**
+ * Implements hook_rdf_namespaces().
+ */
+function rdf_rdf_namespaces() {
+  return array(
+    'content'  => 'http://purl.org/rss/1.0/modules/content/',
+    'dc'       => 'http://purl.org/dc/terms/',
+    'foaf'     => 'http://xmlns.com/foaf/0.1/',
+    'og'       => 'http://ogp.me/ns#',
+    'rdfs'     => 'http://www.w3.org/2000/01/rdf-schema#',
+    'sioc'     => 'http://rdfs.org/sioc/ns#',
+    'sioct'    => 'http://rdfs.org/sioc/types#',
+    'skos'     => 'http://www.w3.org/2004/02/skos/core#',
+    'xsd'      => 'http://www.w3.org/2001/XMLSchema#',
+  );
+}
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 50d2fd6..a6d897a 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -1580,51 +1580,6 @@ function taxonomy_field_settings_form($field, $instance, $has_data) {
 }
 
 /**
- * Implements hook_rdf_mapping().
- *
- * @return array
- *   The rdf mapping for vocabularies and terms.
- */
-function taxonomy_rdf_mapping() {
-  return array(
-    array(
-      'type' => 'taxonomy_term',
-      'bundle' => RDF_DEFAULT_BUNDLE,
-      'mapping' => array(
-        'rdftype' => array('skos:Concept'),
-        'name'   => array(
-          'predicates' => array('rdfs:label', 'skos:prefLabel'),
-        ),
-        'description'   => array(
-          'predicates' => array('skos:definition'),
-        ),
-        'vid'   => array(
-          'predicates' => array('skos:inScheme'),
-          'type' => 'rel',
-        ),
-        'parent'   => array(
-          'predicates' => array('skos:broader'),
-          'type' => 'rel',
-        ),
-      ),
-    ),
-    array(
-      'type' => 'taxonomy_vocabulary',
-      'bundle' => RDF_DEFAULT_BUNDLE,
-      'mapping' => array(
-        'rdftype' => array('skos:ConceptScheme'),
-        'name'   => array(
-          'predicates' => array('dc:title'),
-        ),
-        'description'   => array(
-          'predicates' => array('rdfs:comment'),
-        ),
-      ),
-    ),
-  );
-}
-
-/**
  * @defgroup taxonomy_index Taxonomy indexing
  * @{
  * Functions to maintain taxonomy indexing.
diff --git a/modules/taxonomy/taxonomy.rdf.inc b/modules/taxonomy/taxonomy.rdf.inc
new file mode 100644
index 0000000..98deae1
--- /dev/null
+++ b/modules/taxonomy/taxonomy.rdf.inc
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * @file
+ * RDF integration for the taxonomy module.
+ */
+
+/**
+ * Implements hook_rdf_mapping().
+ *
+ * @return array
+ *   The rdf mapping for vocabularies and terms.
+ */
+function taxonomy_rdf_mapping() {
+  return array(
+    array(
+      'type' => 'taxonomy_term',
+      'bundle' => RDF_DEFAULT_BUNDLE,
+      'mapping' => array(
+        'rdftype' => array('skos:Concept'),
+        'name'   => array(
+          'predicates' => array('rdfs:label', 'skos:prefLabel'),
+        ),
+        'description'   => array(
+          'predicates' => array('skos:definition'),
+        ),
+        'vid'   => array(
+          'predicates' => array('skos:inScheme'),
+          'type' => 'rel',
+        ),
+        'parent'   => array(
+          'predicates' => array('skos:broader'),
+          'type' => 'rel',
+        ),
+      ),
+    ),
+    array(
+      'type' => 'taxonomy_vocabulary',
+      'bundle' => RDF_DEFAULT_BUNDLE,
+      'mapping' => array(
+        'rdftype' => array('skos:ConceptScheme'),
+        'name'   => array(
+          'predicates' => array('dc:title'),
+        ),
+        'description'   => array(
+          'predicates' => array('rdfs:comment'),
+        ),
+      ),
+    ),
+  );
+}
diff --git a/modules/user/user.module b/modules/user/user.module
index de72baf..b9c4038 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -3816,28 +3816,6 @@ function user_cookie_delete($cookie_name) {
 }
 
 /**
- * Implements hook_rdf_mapping().
- */
-function user_rdf_mapping() {
-  return array(
-    array(
-      'type' => 'user',
-      'bundle' => RDF_DEFAULT_BUNDLE,
-      'mapping' => array(
-        'rdftype' => array('sioc:UserAccount'),
-        'name' => array(
-          'predicates' => array('foaf:name'),
-        ),
-        'homepage' => array(
-          'predicates' => array('foaf:page'),
-          'type' => 'rel',
-        ),
-      ),
-    ),
-  );
-}
-
-/**
  * Implements hook_file_download_access().
  */
 function user_file_download_access($field, $entity_type, $entity) {
diff --git a/modules/user/user.rdf.inc b/modules/user/user.rdf.inc
new file mode 100644
index 0000000..2e3ae40
--- /dev/null
+++ b/modules/user/user.rdf.inc
@@ -0,0 +1,28 @@
+<?php
+
+/**
+ * @file
+ * RDF integration for the user module.
+ */
+
+/**
+ * Implements hook_rdf_mapping().
+ */
+function user_rdf_mapping() {
+  return array(
+    array(
+      'type' => 'user',
+      'bundle' => RDF_DEFAULT_BUNDLE,
+      'mapping' => array(
+        'rdftype' => array('sioc:UserAccount'),
+        'name' => array(
+          'predicates' => array('foaf:name'),
+        ),
+        'homepage' => array(
+          'predicates' => array('foaf:page'),
+          'type' => 'rel',
+        ),
+      ),
+    ),
+  );
+}
-- 
1.7.1

