DrupalBin
Submit Code
About
Recent Posts
TwitterFeed for D4D review
text
rewrite
Module to overrule the save settings of the "new node" form
Code
apidoc
Empty DateTime Object
Fix for listcars_manufacturer.module
listcars_manufacturer.info
listcars_manufacturer.module
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
test
theme
user
views
more tags
Home
›
RDF in core idea
Fix for RDF in core idea
View
Fix
Fixes are not saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
<?php /** * Implementation of hook_rdf_schema(). */ function node_rdf_schema() { $rdf = array(); $rdf['node'] = array( 'label' => t('content'), 'class' => 'sioc:post' ); $rdf['node']['properties'] = array( 'nid' => array( 'label' => t('internal content id'), 'type' => 'literal', // default, so it can be omitted. 'datatype' => 'integer', // If no callback is given the API should automatically use the key 'nid' // for retrieving the data and make sure the data is in the right format, // e.g. by using intval(). ), 'uid' => array( 'label' => t("author's internal user id"), 'property' => 'node:uid', // Should we use something like this as default if none is specified? 'datatype' => 'integer', ), 'author' => array( 'label' => t('author'), 'type' => 'uri', 'property' => 'dc:creator', 'class' => 'user', 'callback' => 'node_rdf_get_author', ), 'title' => array( 'label' => t('content title'), 'datatype' => 'string', ), 'created' => array( 'label' => t('creation date'), 'datatype' => 'date', // Timestamps could be automatically converted right, if not we would need // a callback here. ), ); return $rdf; } /** * Implementation of hook_rdf_schema(). */ function mymodule_rdf_schema_alter($schema) { //Customize properties, classes, .. } /** * Callback for getting the uri */ function node_rdf_get_author($node, $key, $info) { return new RDFClassLocal('user', $node->uid); } /** * A generic reference to an rdf class + it's properties. * For actually getting the RDF data lazy loading should be used. */ abstract class RDFClass { /** * Returns the types of this class. */ abstract function getRdfTypes() { } } abstract class RDFClassLocal extends RDFClass { var $entity; public function __construct($class, $id) { } function getRdfTypes() { return array('user'); } // Returns another RDFClass or a literal. function getPropertyValue($property_name) { // First load the entity if necesarry. return rdf_get_property('user', $property_name, $entity); } /** * Lazy load the entity. */ abstract function loadEntity() { } function getRdfaAttributes($property_name, $content = FALSE) { // Return an array of attributes needed for RDFa, suited for drupal_attributes(). // Add in the content attribute if requested. } function getRdfaTags() { // Retrieve the property and return some span tags for RDFa output. } } class RDFClassLocalUser extends RDFClassLocal { /** * Lazy load the entity. */ function loadEntity() { $this->entity = user_load($this->id); } } /** * Not really required, but could be implemented for handling remote data. */ class RDFClassRemote extends RDFClass { function __construct($class, $url) { // Retrieve rdf data from $url if requested. } function getRdfTypes() { return array($class); } function getPropertyValue($property_name) { //TODO } } /** * Actually retrieves the value for the given property. */ function rdf_get_property($entity_name, $property_name, $entity) { $schema = rdf_get_schema(); if (isset($schema[$entity_name]['properties'][$property_name]['callback'])) { return $schema[$entity_name]['properties'][$property_name]['callback'](); } else { if ($schema[$entity_name]['properties'][$property_name]['type'] == 'uri') { return new RDFClassRemote($entity->$entity_name); } else { // Literal return rdf_ensure_datatype($schema[$entity_name]['properties'][$property_name]['datatype'], $entity->$entity_name); } } } function rdf_ensure_datatype($datatype, $value) { //ensure the datatype fits! }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp
.