=== modified file 'includes/bootstrap.inc'
--- includes/bootstrap.inc 2009-09-05 13:05:30 +0000
+++ includes/bootstrap.inc 2009-08-31 19:13:39 +0000
@@ -1,5 +1,5 @@
2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
ini_set('session.cookie_domain', $cookie_domain);
}
- // To prevent session cookies from being hijacked, a user can configure the
- // SSL version of their website to only transfer session cookies via SSL by
- // using PHP's session.cookie_secure setting. The browser will then use two
- // separate session cookies for the HTTPS and HTTP versions of the site. So we
- // must use different session identifiers for HTTPS and HTTP to prevent a
- // cookie collision.
- if ($is_https) {
- ini_set('session.cookie_secure', TRUE);
- }
- $prefix = ini_get('session.cookie_secure') ? 'SSESS' : 'SESS';
- session_name($prefix . md5($session_name));
+ session_name('SESS' . md5($session_name));
}
/**
=== modified file 'includes/common.inc'
--- includes/common.inc 2009-09-05 13:05:30 +0000
+++ includes/common.inc 2009-09-05 14:19:11 +0000
@@ -1,5 +1,5 @@
$uri) {
$xml_rdf_namespaces[] = 'xmlns:' . $prefix . '="' . $uri . '"';
}
- return implode("\n ", $xml_rdf_namespaces);
+ //allow altering of this namespaces
+ drupal_alter('rdf_namespaces', $xml_rdf_namespaces);
+
+ //we are returning an array of namespaces to allow themers to alter how it shows up
+ return $xml_rdf_namespaces;
}
/**
@@ -423,14 +427,6 @@ function drupal_goto($path = '', $query
extract(parse_url(urldecode($_REQUEST['destination'])));
}
- $args = array(
- 'path' => &$path,
- 'query' => &$query,
- 'fragment' => &$fragment,
- 'http_response_code' => &$http_response_code,
- );
- drupal_alter('drupal_goto', $args);
-
$url = url($path, array('query' => $query, 'fragment' => $fragment, 'absolute' => TRUE));
// Allow modules to react to the end of the page request before redirecting.
@@ -2155,11 +2151,6 @@ function _format_date_callback(array $ma
* - 'language'
* An optional language object. Used to build the URL to link to and
* look up the proper alias for the link.
- * - 'https'
- * Whether this URL should point to a secure location. If not specified,
- * the current scheme is used, so the user stays on http or https
- * respectively. TRUE enforces HTTPS and FALSE enforces HTTP, but HTTPS
- * can only be enforced when the variable 'https' is set to TRUE.
* - 'base_url'
* Only used internally, to modify the base URL when a language dependent
* URL requires so.
@@ -2179,7 +2170,6 @@ function url($path = NULL, array $option
'query' => '',
'absolute' => FALSE,
'alias' => FALSE,
- 'https' => FALSE,
'prefix' => ''
);
if (!isset($options['external'])) {
@@ -2217,7 +2207,7 @@ function url($path = NULL, array $option
return $path . $options['fragment'];
}
- global $base_url, $base_secure_url, $base_insecure_url;
+ global $base_url;
$script = &drupal_static(__FUNCTION__);
if (!isset($script)) {
@@ -2227,21 +2217,9 @@ function url($path = NULL, array $option
$script = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === FALSE) ? 'index.php' : '';
}
- // The base_url might be rewritten from the language rewrite in domain mode.
if (!isset($options['base_url'])) {
- if (isset($options['https']) && variable_get('https', FALSE)) {
- if ($options['https'] === TRUE) {
- $options['base_url'] = $base_secure_url;
- $options['absolute'] = TRUE;
- }
- elseif ($options['https'] === FALSE) {
- $options['base_url'] = $base_insecure_url;
- $options['absolute'] = TRUE;
- }
- }
- else {
- $options['base_url'] = $base_url;
- }
+ // The base_url might be rewritten from the language rewrite in domain mode.
+ $options['base_url'] = $base_url;
}
// Preserve the original path before aliasing.
@@ -3183,7 +3161,7 @@ function drupal_get_js($scope = 'header'
case 'external':
// Preprocessing for external JavaScript files is ignored.
- $output .= '\n";
+ $output .= '\n";
break;
}
}
@@ -4238,7 +4216,7 @@ function show(&$element) {
*
* @see drupal_render()
* @see drupal_render_cache_set()
- *
+ *
* @param $elements
* A renderable array.
* @return
@@ -4278,7 +4256,7 @@ function drupal_render_cache_get($elemen
* A renderable array.
*/
function drupal_render_cache_set($markup, $elements) {
- // Create the cache ID for the element
+ // Create the cache ID for the element
if (!in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) || !$cid = drupal_render_cid_create($elements)) {
return FALSE;
}
@@ -4561,7 +4539,7 @@ function drupal_common_theme() {
'arguments' => array('region' => NULL),
),
'username' => array(
- 'arguments' => array('object' => NULL),
+ 'arguments' => array('object' => NULL, 'link_attributes' => array()),
),
'progress_bar' => array(
'arguments' => array('percent' => NULL, 'message' => NULL),
=== modified file 'includes/form.inc'
--- includes/form.inc 2009-09-05 13:05:30 +0000
+++ includes/form.inc 2009-08-31 19:13:40 +0000
@@ -1,5 +1,5 @@
$sid))->fetchObject();
- if (!$user) {
- if (isset($_COOKIE[$insecure_session_name])) {
- $user = db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid AND s.uid = 0", array(
- ':sid' => $_COOKIE[$insecure_session_name]))
- ->fetchObject();
- }
- }
- }
- else {
- $user = db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid", array(':sid' => $sid))->fetchObject();
- }
+ // client's session in the database.
+ $user = db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid", array(':sid' => $sid))->fetchObject();
// We found the client's session record and they are an authenticated user.
if ($user && $user->uid > 0) {
@@ -137,27 +122,22 @@ function _drupal_session_read($sid) {
* This function will always return TRUE.
*/
function _drupal_session_write($sid, $value) {
- global $user, $is_https;
+ global $user;
if (!drupal_save_session()) {
// We don't have anything to do if we are not allowed to save the session.
return;
}
- $fields = array(
- 'uid' => $user->uid,
- 'cache' => isset($user->cache) ? $user->cache : 0,
- 'hostname' => ip_address(),
- 'session' => $value,
- 'timestamp' => REQUEST_TIME,
- );
- $insecure_session_name = substr(session_name(), 1);
- if ($is_https && isset($_COOKIE[$insecure_session_name])) {
- $fields['sid'] = $_COOKIE[$insecure_session_name];
- }
db_merge('sessions')
- ->key(array($is_https ? 'ssid' : 'sid' => $sid))
- ->fields($fields)
+ ->key(array('sid' => $sid))
+ ->fields(array(
+ 'uid' => $user->uid,
+ 'cache' => isset($user->cache) ? $user->cache : 0,
+ 'hostname' => ip_address(),
+ 'session' => $value,
+ 'timestamp' => REQUEST_TIME,
+ ))
->execute();
// Last access time is updated no more frequently than once every 180 seconds.
@@ -266,14 +246,7 @@ function drupal_session_started($set = N
* Called when an anonymous user becomes authenticated or vice-versa.
*/
function drupal_session_regenerate() {
- global $user, $is_https;
- if ($is_https && variable_get('https', FALSE)) {
- $insecure_session_name = substr(session_name(), 1);
- $params = session_get_cookie_params();
- $session_id = md5(uniqid(mt_rand(), TRUE));
- setcookie($insecure_session_name, $session_id, REQUEST_TIME + $params['lifetime'], $params['path'], $params['domain'], FALSE, $params['httponly']);
- $_COOKIE[$insecure_session_name] = $session_id;
- }
+ global $user;
if (drupal_session_started()) {
$old_session_id = session_id();
@@ -291,7 +264,7 @@ function drupal_session_regenerate() {
if (isset($old_session_id)) {
db_update('sessions')
->fields(array(
- $is_https ? 'ssid' : 'sid' => session_id()
+ 'sid' => session_id()
))
->condition('sid', $old_session_id)
->execute();
@@ -331,11 +304,11 @@ function drupal_session_count($timestamp
* Session ID.
*/
function _drupal_session_destroy($sid) {
- global $user, $is_https;
+ global $user;
// Delete session data.
db_delete('sessions')
- ->condition($is_https ? 'ssid' : 'sid', $sid)
+ ->condition('sid', $sid)
->execute();
// Reset $_SESSION and $user to prevent a new session from being started
@@ -343,26 +316,11 @@ function _drupal_session_destroy($sid) {
$_SESSION = array();
$user = drupal_anonymous_user();
- // Unset the session cookies.
- _drupal_session_delete_cookie(session_name());
- if ($is_https) {
- _drupal_session_delete_cookie(substr(session_name(), 1), TRUE);
- }
-}
-
-/**
- * Deletes the session cookie.
- *
- * @param $name
- * Name of session cookie to delete.
- * @param $force_insecure
- * Fornce cookie to be insecure.
- */
-function _drupal_session_delete_cookie($name, $force_insecure = FALSE) {
- if (isset($_COOKIE[$name])) {
+ // Unset the session cookie.
+ if (isset($_COOKIE[session_name()])) {
$params = session_get_cookie_params();
- setcookie($name, '', REQUEST_TIME - 3600, $params['path'], $params['domain'], !$force_insecure && $params['secure'], $params['httponly']);
- unset($_COOKIE[$name]);
+ setcookie(session_name(), '', REQUEST_TIME - 3600, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
+ unset($_COOKIE[session_name()]);
}
}
=== modified file 'includes/theme.inc'
--- includes/theme.inc 2009-08-31 19:50:17 +0000
+++ includes/theme.inc 2009-09-05 14:19:11 +0000
@@ -1863,11 +1863,13 @@ function theme_more_link($url, $title) {
* A string containing an HTML link to the user's page if the passed object
* suggests that this is a site user. Otherwise, only the username is returned.
*/
-function theme_username($object) {
+function theme_username($object, $link_attributes = array()) {
+ // Insist that HTML is false when it's not passed in.
+ $link_attributes += array('html' => FALSE);
if ($object->uid && $object->name) {
- // Shorten the name when it is too long or it will break many tables.
- if (drupal_strlen($object->name) > 20) {
+ if (!$link_attributes['html'] && drupal_strlen($object->name) > 20) {
+ // Shorten the name when it is too long or it will break many tables.
$name = drupal_substr($object->name, 0, 15) . '...';
}
else {
@@ -1875,10 +1877,11 @@ function theme_username($object) {
}
if (user_access('access user profiles')) {
- $output = l($name, 'user/' . $object->uid, array('attributes' => array('title' => t('View user profile.'))));
+ $link_attributes += array('attributes' => array('title' => t('View user profile.')));
+ $output = l($name, 'user/' . $object->uid, $link_attributes);
}
else {
- $output = check_plain($name);
+ $output = $link_attributes['html'] ? $name : check_plain($name);
}
}
elseif ($object->name) {
@@ -1887,10 +1890,11 @@ function theme_username($object) {
// aggregator modules). This clause enables modules to display
// the true author of the content.
if (!empty($object->homepage)) {
- $output = l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow')));
+ $link_attributes += array('attributes' => array('rel' => t('View nofollow profile.')));
+ $output = l($object->name, $object->homepage, $link_attributes);
}
else {
- $output = check_plain($object->name);
+ $output = $link_attributes['html'] ? $object->name : check_plain($object->name);
}
if (theme_get_setting('toggle_comment_user_verification')) {
@@ -2079,10 +2083,11 @@ function template_preprocess_page(&$vari
$variables['site_slogan'] = (theme_get_setting('toggle_slogan') ? filter_xss_admin(variable_get('site_slogan', '')) : '');
$variables['tabs'] = theme('menu_local_tasks');
$variables['title'] = drupal_get_title();
+
// RDFa allows annotation of XHTML pages with RDF data, while GRDDL provides
// mechanisms for extraction of this RDF content via XSLT transformation
// using an associated GRDDL profile.
- $variables['rdf_namespaces'] = drupal_get_rdf_namespaces();
+ $variables['rdf_namespaces'] = implode("\n ", drupal_get_rdf_namespaces());
$variables['grddl_profile'] = 'http://ns.inria.fr/grddl/rdfa/';
if ($node = menu_get_object()) {
=== added directory 'modules/rdf'
=== added file 'modules/rdf/rdf.api.php'
--- modules/rdf/rdf.api.php 1970-01-01 00:00:00 +0000
+++ modules/rdf/rdf.api.php 2009-08-17 14:25:35 +0000
@@ -0,0 +1,69 @@
+ array(
+ 'rdftype' => array('sioc:Post'),
+ 'title' => array('dc:title'),
+ 'created' => array(
+ 'properties' => array('dc:date', 'dc:created'),
+ 'datatype' => 'xsd:dateTime',
+ 'callback' => 'date_iso8601',
+ ),
+ 'name' => array('foaf:name'),
+ 'uid' => array('sioc:has_creator', 'foaf:maker'),
+ )
+ );
+}
+
+/**
+ * Allow modules to override existing mappings.
+ *
+ * @param &$mappings
+ * An associative array of mappings
+ */
+function hook_rdf_mapping_alter(&$mapping) {
+ return array(
+ 'blog' => array(
+ 'rdftype' => array('sioc:Post','myvoc:BlogPost'),
+ 'title' => array('dc:title', 'myvoc:title'),
+ 'created' => array(
+ 'properties' => array('dc:date', 'dc:created'),
+ 'datatype' => 'xsd:dateTime',
+ 'callback' => 'date_iso8601',
+ ),
+ 'name' => array('foaf:name'),
+ 'uid' => array('sioc:has_creator', 'foaf:maker'),
+ )
+ );
+}
+
+/**
+ * @} End of "addtogroup hooks".
+ */
=== added file 'modules/rdf/rdf.info'
--- modules/rdf/rdf.info 1970-01-01 00:00:00 +0000
+++ modules/rdf/rdf.info 2009-06-19 20:48:47 +0000
@@ -0,0 +1,7 @@
+; $Id$
+name = RDF
+description = Supports RDF mappings.
+package = Core
+core = 7.x
+files[] = rdf.module
+files[] = rdf.test
=== added file 'modules/rdf/rdf.module'
--- modules/rdf/rdf.module 1970-01-01 00:00:00 +0000
+++ modules/rdf/rdf.module 2009-09-05 14:19:11 +0000
@@ -0,0 +1,256 @@
+ 'foaf:Document',
+ 'title' => array(
+ 'property' => array('dc:title'),
+ )
+ );
+ $stored_mapping = &drupal_static(__FUNCTION__, $default_mapping);
+
+ if (isset($mapping)) {
+ $stored_mapping = $mapping;
+ }
+
+ return $stored_mapping;
+}
+
+/**
+ * Returns the page level RDF mapping from the dictionary.
+ *
+ * @return array
+ * The page level RDF mapping.
+ */
+function drupal_get_rdf_page_mapping() {
+ return drupal_set_rdf_page_mapping();
+}
+
+/**
+ * Returns RDFa attributes to render.
+ *
+ * @param $mapping
+ * An array containing a mandatory property key and optional
+ * datatype and callback keys.
+ * Example:
+ * array(
+ * 'property' => array('dc:created'),
+ * 'datatype' => 'xsd:dateTime',
+ * 'callback' => 'date_iso8601',
+ * )
+ * @param $data
+ * @return string
+ * An XHTML string containing RDFa attributes ready for insertion into a tag.
+ */
+function drupal_rdfa_attributes($mapping, $data = NULL) {
+ $attributes['property'] = $mapping['property'];
+
+ if (isset($mapping['callback']) && isset($data)) {
+ $callback = $mapping['callback'];
+
+ if (function_exists($callback)) {
+ $attributes['content'] = call_user_func($callback, $data);
+ }
+ if (isset($mapping['datatype'])) {
+ $attributes['datatype'] = $mapping['datatype'];
+ }
+ }
+
+ return $attributes;
+}
+
+/**
+ * Implementation of hook_node_load().
+ */
+function rdf_node_load($nodes, $types) {
+ foreach ($nodes as $node) {
+ $node->rdf_mapping = rdf_get_mapping($node->type);
+
+ // The node_load function does not reuse user_load(), so we need to regenerate
+ // the URI of the author of the node.
+ $node->rdf['user'] = array('uri' => _rdf_generate_user_uri($node->uid));
+ }
+}
+
+/**
+ * Implement hook_user_load().
+ */
+function rdf_user_load($users) {
+ // Generate an RDF resource URI for each user account.
+ foreach ($users as $user) {
+ $user->rdf = array('uri' => _rdf_generate_user_uri($user->uid));
+ }
+}
+
+/**
+ * Helper function to create a URI for the user object.
+ *
+ * @param $uid
+ * The user id the URI should be generated from.
+ * @return
+ * A URI including the base path of the site, e.g. '/subdomain/user/1#user'.
+ */
+function _rdf_generate_user_uri($uid) {
+ return base_path() . 'user/' . $uid . '#user';
+}
+
+/**
+ * Returns an ISO8601 formatted date based on the given date.
+ *
+ * Can be used as a callback for mappings.
+ *
+ * @param $date
+ * A date in a format parseable by strtotime.
+ * @return string
+ * An ISO8601 formatted date.
+ */
+function date_iso8601($date) {
+ return date(DATE_ISO8601, strtotime($date));
+}
+
+/**
+ * Implement MODULE_preprocess_HOOK().
+ */
+function rdf_preprocess_node(&$variables) {
+ // The about and typeof attributes are required when a node is displayed in teaser mode.
+ if (!$variables['page']) {
+ $variables['attributes_array']['about'] = $variables['node_uri'];
+ $variables['attributes_array']['typeof'] = implode(' ', $variables['node']->rdf_mapping['rdftype']);
+ }
+
+ // The title is only displayed on teaser mode.
+ $variables['title_raw'] = $variables['title'];
+ $variables['title'] = !$variables['page'] ? ' implode($variables['node']->rdf_mapping['title']))) . '>' . $variables['title_raw'] . '' : '';
+}
+
+/**
+ * Implements MODULE_preprocess_HOOK().
+ */
+function rdf_preprocess_page(&$variables) {
+ // The variable rdfa_page_about contains the HTML attributes which define
+ // what resource a page is about and optionally its RDF type.
+ $variables['rdfa_page_about'] = '';
+ // The variable rdfa_page_title contains the HTML attributes which define
+ // which property should be used for the title of a page.
+ $variables['rdfa_page_title'] = '';
+
+ // Contruct the RDFa markup.
+ $rdf_page_mapping = drupal_get_rdf_page_mapping();
+ if (!empty($rdf_page_mapping['rdftype'])) {
+ $variables['rdfa_page_about'] = ' about="#this" typeof="' . implode(' ', (array)$rdf_page_mapping['rdftype']) . '"';
+ }
+ else {
+ // Even if we don't have an RDF type for the resource described on the page
+ // we create a URI for it.
+ $variables['rdfa_page_about'] = ' about="#this"';
+ }
+ if (!empty($rdf_page_mapping['title'])) {
+ $variables['rdfa_page_title_attributes'] = ' property="' . implode(' ', $rdf_page_mapping['title']['property']) . '"';
+ }
+}
+
+/**
+ * Adds RDFa attributes to the template variables.
+ *
+ * @param $variables
+ */
+function rdf_preprocess_field(&$variables) {
+ $instance = $variables['instance'];
+ $value = $variables['items'][0]['#item']['value'];
+
+ if (isset($instance['rdf_mapping'])) {
+ $variables['#attributes'] = drupal_rdfa_attributes($instance['rdf_mapping'], $value);
+ }
+}
+
+/**
+ * Implements MODULE_preprocess_HOOK().
+ */
+function rdf_preprocess_username(&$variables) {
+ $object = $variables['object'] = clone($variables['object']);
+
+ if (!empty($object->rdf_mapping['name'])) {
+ $object->name = '' . check_plain($object->name) . '';
+ $variables['link_attributes']['html'] = TRUE;
+ }
+
+ if (user_access('access user profiles') && !empty($object->rdf_mapping['uid']) && !empty($object->rdf['user']['uri'])) {
+ $variables['link_attributes']['attributes']['about'] = $object->rdf['user']['uri'];
+ }
+}
+
+/**
+ * Implements MODULE_postprocess_HOOK().
+ */
+function rdf_postprocess_username(&$output, $hook, $variables) {
+ $object = $variables['object'];
+ if (user_access('access user profiles') && !empty($object->rdf_mapping['uid']) && !empty($object->rdf['user']['uri'])) {
+ $output = ''. $output .'';
+ }
+}
+
+/**
+ * @todo
+ * all this can and should be cut if issue #553038 patch lands.
+ */
+function rdf_theme_registry_alter(&$theme_registry) {
+ if ($theme_registry['username']['function'] == 'theme_username') {
+ $theme_registry['username']['function'] = 'rdf_theme_username';
+ unset($theme_registry['username']['postprocess functions']);
+ }
+}
+
+function rdf_theme_username($object, $link_attributes) {
+ $output = theme_username($object, $link_attributes);
+ if (user_access('access user profiles') && !empty($object->rdf_mapping['uid']) && !empty($object->rdf['user']['uri'])) {
+ $output = ''. $output .'';
+ }
+ return $output;
+}
=== added file 'modules/rdf/rdf.test'
--- modules/rdf/rdf.test 1970-01-01 00:00:00 +0000
+++ modules/rdf/rdf.test 2009-09-05 14:18:16 +0000
@@ -0,0 +1,218 @@
+ t('RDF mappings'),
+ 'description' => t('Test RDF mapping hooks.'),
+ 'group' => t('RDF'),
+ );
+ }
+
+ function setUp() {
+ // Enable RDF and RDF test in the test environment.
+ parent::setUp('rdf', 'rdf_test');
+ }
+
+ /**
+ * Test that the mappings are correctly returned and processed by the hooks.
+ */
+ function testMappings() {
+ // Test that the mapping is returned correctly by the hook.
+ $mapping = rdf_get_mapping('rdf_test_container');
+ $this->assertIdentical($mapping['rdftype'], array('sioc:Post'), t('Mapping for rdftype is sioc:Post.'));
+ $this->assertIdentical($mapping['title'], array('property' => array('dc:title')), t('Mapping for title is dc:title.'));
+ $this->assertIdentical($mapping['created'], array('property' => array('dc:created')), t('Mapping for created is dc:created.'));
+ $this->assertTrue(in_array('sioc:has-creator', $mapping['uid']['property']), t('Mapping for uid contains sioc:has-creator'));
+ $this->assertTrue(in_array('dc:creator', $mapping['uid']['property']), t('Mapping for uid contains dc:creator'));
+
+ // Test that an empty array is returned when a container has no mappings.
+ $mapping = rdf_get_mapping('rdf_test_nonexistent_container');
+ $this->assertTrue(is_array($mapping) && empty($mapping), t('Empty array returned for container with no mappings'));
+
+ // Test that the mappings are altered correctly.
+ $mapping = rdf_get_mapping('rdf_test_another');
+ $this->assertTrue(in_array('dc:title', $mapping['title']['property']), t('Mapping for title contains dc:title'));
+ $this->assertTrue(in_array('sioc:title', $mapping['title']['property']), t('Mapping for title contains sioc:title'));
+ $this->assertTrue(in_array('sioc:has-creator', $mapping['uid']['property']), t('Mapping for uid contains sioc:has-creator'));
+ $this->assertTrue(in_array('foo:bar', $mapping['uid']['property']), t('Mapping for uid contains foo:bar'));
+ $this->assertFalse(in_array('dc:creator', $mapping['uid']['property']), t('Mapping for uid does not contain dc:creator'));
+ $this->assertTrue(in_array('foaf:name', $mapping['name']['property']), t('Mapping for name contains foaf:name'));
+ $this->assertFalse(in_array('dc:creator', $mapping['name']['property']), t('Mapping for name does not contain dc:creator'));
+ $this->assertIdentical($mapping['rdftype'], array('foaf:Person'), t('Mapping for rdftype was changed'));
+ $this->assertFalse(isset($mapping['foobar']), t('Mapping for foobar was removed.'));
+ }
+
+ /**
+ * Test manually setting and getting the page mapping.
+ */
+ function testPageMapping() {
+ // Default value should be returned if nothing was explicitly set.
+ $this->assertEqual(drupal_get_rdf_page_mapping(), array('title' => array('property' => array('dc:title')), 'rdftype' => 'foaf:Document'), t('Default mapping is set correctly.'));
+
+ // If we manually set a mapping, that should replace the default.
+ drupal_set_rdf_page_mapping(array('foobar' => array('property' => array('foo:bar'))));
+ $this->assertEqual(drupal_get_rdf_page_mapping(), array('foobar' => array('property' => array('foo:bar'))), t('Custom mapping overrides default mapping.'));
+ }
+}
+
+/**
+ * RDFa markup generation tests.
+ */
+class RdfaMarkupTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => t('RDFa markup'),
+ 'description' => t('Test RDF markup generation.'),
+ 'group' => t('RDF'),
+ );
+ }
+
+ function setUp() {
+ // Enable RDF and RDF test in the test environment.
+ parent::setUp('rdf', 'rdf_test');
+ }
+
+ /**
+ * Test drupal_rdfa_attributes().
+ */
+ function testDrupalRdfaAtributes() {
+ $date = '2009-05-14';
+ $isoDate = date(DATE_ISO8601, strtotime($date));
+
+ $expectedType = 'datatype="xsd:dateTime"';
+ $expectedProperty = 'property="dc:created"';
+ $expectedValue = "content=\"$isoDate\"";
+ $mapping = rdf_get_mapping('rdf_complex_test');
+ $attributes = drupal_rdfa_attributes($mapping['date'], $date);
+
+ $this->assertNotEqual(FALSE, strpos($attributes, $expectedType));
+ $this->assertNotEqual(FALSE, strpos($attributes, $expectedProperty));
+ $this->assertNotEqual(FALSE, strpos($attributes, $expectedValue));
+
+ $expectedProperty = 'property="dc:title"';
+ $mapping = rdf_get_mapping('rdf_test_container');
+ $attributes = drupal_rdfa_attributes($mapping['title']);
+
+ $this->assertNotEqual(FALSE, strpos($attributes, $expectedProperty));
+ }
+
+}
+
+class RdfaFieldTestCase extends DrupalWebTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => t('RDFa field markup'),
+ 'description' => t('Test RDFa markup in fields.'),
+ 'group' => t('RDF'),
+ );
+ }
+
+ function setUp() {
+ parent::setUp('field_test', 'rdf');
+
+ $this->field_name = drupal_strtolower($this->randomName() . '_field_name');
+ $this->field = array('field_name' => $this->field_name, 'type' => 'test_field', 'cardinality' => 4);
+ $this->field = field_create_field($this->field);
+ $this->field_id = $this->field['id'];
+ $this->instance = array(
+ 'field_name' => $this->field_name,
+ 'bundle' => 'test_bundle',
+ 'label' => $this->randomName() . '_label',
+ 'description' => $this->randomName() . '_description',
+ 'weight' => mt_rand(0, 127),
+ 'settings' => array(
+ 'test_instance_setting' => $this->randomName(),
+ ),
+ 'widget' => array(
+ 'type' => 'test_field_widget',
+ 'label' => 'Test Field',
+ 'settings' => array(
+ 'test_widget_setting' => $this->randomName(),
+ )
+ ),
+ 'rdf_mapping' => array(
+ 'property' => array('dc:created'),
+ 'datatype' => 'xsd:dateTime',
+ 'callback' => 'date_iso8601',
+ )
+ );
+ field_create_instance($this->instance);
+ }
+
+ function testAttributesInMarkup() {
+ $entity_type = 'test_entity';
+ $entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']);
+ $langcode = FIELD_LANGUAGE_NONE;
+
+ // Populate values to be displayed.
+ $date = '2009-09-05';
+ $values = array(0 => array('value' => $date));
+ $entity->{$this->field_name}[$langcode] = $values;
+
+ // Simple formatter, label displayed.
+ $formatter_setting = $this->randomName();
+ $this->field['display'] = array(
+ 'full' => array(
+ 'label' => 'above',
+ 'type' => 'field_test_default',
+ 'settings' => array(
+ 'test_formatter_setting' => $formatter_setting,
+ )
+ ),
+ );
+
+ field_update_instance($this->instance);
+ $this->content = drupal_render(field_attach_view($entity_type, $entity));
+ $this->assertPattern('/property="dc:created"/');
+ $this->assertPattern('/datatype="xsd:dateTime"/');
+ $date_iso8601 = preg_quote(date(DATE_ISO8601, strtotime($date)));
+ $this->assertPattern("/content=\"$date_iso8601\"/");
+ }
+
+}
+
+/**
+ * Test the generation of the user RDF URI.
+ */
+class RdfUserLoadUnitTest extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'User RDF URI generation',
+ 'description' => 'Test the loading of a user and a node and make sure the user RDF URI is added to the respective object.',
+ 'group' => 'RDF',
+ );
+ }
+
+ function setUp() {
+ // Enable RDF in the test environment.
+ parent::setUp('rdf');
+ $web_user = $this->drupalCreateUser(array('create article content'));
+ $this->drupalLogin($web_user);
+ }
+
+ /**
+ * Create a user and ensure it has an RDF URI.
+ */
+ function testUserLoad() {
+ // Create a user.
+ $account = $this->drupalCreateUser(array());
+ // Load real user object.
+ $account = user_load($account->uid, TRUE);
+ $this->assertIdentical($account->rdf, array('uri' => base_path() . 'user/' . $account->uid . '#user'), t('The user RDF URI is present in the user object.'));
+ }
+
+ /**
+ * Create a node and ensure it has an RDF URI for the author of the node.
+ */
+ function testNodeLoad() {
+ $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
+ $node = node_load($node->nid);
+ $this->assertIdentical($node->rdf['user'], array('uri' => base_path() . 'user/' . $node->uid . '#user'), t('The user RDF URI is present in the node object.'));
+ }
+}
=== added directory 'modules/rdf/tests'
=== added file 'modules/rdf/tests/rdf_test.info'
--- modules/rdf/tests/rdf_test.info 1970-01-01 00:00:00 +0000
+++ modules/rdf/tests/rdf_test.info 2009-05-12 13:42:35 +0000
@@ -0,0 +1,8 @@
+; $Id$
+name = "RDF module tests"
+description = "Support module for RDF module testing."
+package = Testing
+version = VERSION
+core = 7.x
+files[] = rdf_test.module
+hidden = TRUE
=== added file 'modules/rdf/tests/rdf_test.module'
--- modules/rdf/tests/rdf_test.module 1970-01-01 00:00:00 +0000
+++ modules/rdf/tests/rdf_test.module 2009-09-01 14:21:06 +0000
@@ -0,0 +1,99 @@
+ array(
+ 'rdftype' => array('sioc:Post'),
+ 'title' => array(
+ 'property' => array(
+ 'dc:title'
+ ),
+ ),
+ 'created' => array('property' => array('dc:created')),
+ 'uid' => array(
+ 'property' => array(
+ 'sioc:has-creator',
+ 'dc:creator',
+ ),
+ ),
+ 'foobar' => array(
+ 'property' => array(
+ 'foo:bar'
+ ),
+ ),
+ ),
+ 'rdf_test_another' => array(
+ 'rdftype' => array('sioc:User'),
+ 'title' => array(
+ 'property' => array('dc:title'),
+ ),
+ 'name' => array(
+ 'property' => array('dc:creator'),
+ ),
+ 'uid' => array(
+ 'property' => array(
+ 'sioc:has-creator',
+ 'dc:creator',
+ ),
+ ),
+ 'foobar' => array(
+ 'property' => array('foo:bar'),
+ ),
+ ),
+ 'rdf_complex_test' => array(
+ 'date' => array(
+ 'property' => array('dc:created'),
+ 'datatype' => 'xsd:dateTime',
+ 'callback' => 'date_iso8601',
+ ),
+ )
+ );
+}
+
+/**
+ * Implementation of hook_rdf_mapping_alter().
+ */
+function rdf_test_rdf_mapping_alter(&$mapping) {
+ // Add a single mapping without overriding anything.
+ $mapping['rdf_test_another']['name']['property'][] = 'foaf:name';
+
+ // Add a multi-value mapping without overwriting anything.
+ $mapping_addition = array(
+ 'rdf_test_another' => array(
+ 'title' => array(
+ 'property' => array('sioc:title'),
+ ),
+ ),
+ );
+ $mapping = array_merge_recursive($mapping, $mapping_addition);
+
+ // @TODO - in both above examples, what happens if we declare the same
+ // property more than once-- so that 'title' equals for instance
+ // array('foaf:Person', 'dc:title', 'foaf:Person')
+ // should/could we force values to unique at some point?
+
+ // Override (replace) a single property.
+ if (isset($mapping['rdf_test_another']['uid'])) {
+ $mapping['rdf_test_another']['uid']['property'] = array_diff($mapping['rdf_test_another']['uid']['property'], array('dc:creator'));
+ $mapping['rdf_test_another']['uid']['property'][] = 'foo:bar';
+ }
+
+ // Delete a specific property.
+ $mapping['rdf_test_another']['name']['property'] = array_diff($mapping['rdf_test_another']['name']['property'], array('dc:creator'));
+
+ // Delete all mappings for an attribute.
+ unset($mapping['rdf_test_another']['foobar']);
+
+ // Replace a mapping.
+ $mapping['rdf_test_another']['rdftype'] = array('foaf:Person');
+}
=== modified file 'modules/system/page.tpl.php'
--- modules/system/page.tpl.php 2009-08-31 19:50:17 +0000
+++ modules/system/page.tpl.php 2009-09-01 11:53:14 +0000
@@ -168,9 +168,9 @@
-
+
>
-
+
>
=== modified file 'modules/system/system.api.php'
--- modules/system/system.api.php 2009-09-05 13:05:30 +0000
+++ modules/system/system.api.php 2009-09-01 23:00:50 +0000
@@ -1,5 +1,5 @@
array(
),
);
- return $tasks;
-}
-
-/**
- * Change the page the user is sent to by drupal_goto().
- *
- * @param $args
- * The array keys are the same as drupal_goto() arguments and the array can
- * be changed.
- *
- * $args = array(
- * 'path' => &$path,
- * 'query' => &$query,
- * 'fragment' => &$fragment,
- * 'http_response_code' => &$http_response_code,
- * );
- *
- */
-function hook_drupal_goto_alter(array $args) {
- // A good addition to misery module.
- $args['http_response_code'] = 500;
+ return $tasks;
}
/**
=== modified file 'modules/system/system.install'
--- modules/system/system.install 2009-09-05 13:05:30 +0000
+++ modules/system/system.install 2009-08-31 19:13:43 +0000
@@ -1,5 +1,5 @@
TRUE,
'default' => '',
),
- 'ssid' => array(
- 'description' => "Unique key: Secure session ID. The value is generated by PHP's Session API.",
- 'type' => 'varchar',
- 'length' => 64,
- 'not null' => FALSE,
- 'default' => NULL,
- ),
'hostname' => array(
'description' => 'The IP address that last used this session ID (sid).',
'type' => 'varchar',
@@ -1354,9 +1347,6 @@ function system_schema() {
'timestamp' => array('timestamp'),
'uid' => array('uid'),
),
- 'unique keys' => array(
- 'ssid' => array('ssid'),
- ),
'foreign keys' => array(
'uid' => array('users' => 'uid'),
),
=== modified file 'modules/system/system.module'
--- modules/system/system.module 2009-09-01 16:50:11 +0000
+++ modules/system/system.module 2009-09-01 23:00:50 +0000
@@ -257,7 +257,9 @@ function system_rdf_namespaces() {
'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
'rss' => 'http://purl.org/rss/1.0/',
+ 'tags' => 'http://www.holygoat.co.uk/owl/redwood/0.1/tags/',
'sioc' => 'http://rdfs.org/sioc/ns#',
+ 'skos' => 'http://www.w3.org/2004/02/skos/core#',
'xsd' => 'http://www.w3.org/2001/XMLSchema',
);
}