smiffy's blog

DCD Contact Form Disabled

Due to an enormous deluge of spam through the site contact form, I have had to remove it from the site menu. Anyone wishing to contact me should mail smiffy at this domain without the dcd. Sorry to be so obscure, but I have better things to do than spend all day deleting spam from what should be a trusted source.

Getting Moving - Soon

Ill health and three concurrent client projects started in June have meant that no progress has been made on Dublin Core for Drupal. The last of the client projects should hopefully be finished in about three weeks from now, when I hope to get working on this in earnest.

Finding a Value for DC.creator

No Real Name Field?

Somewhat to my surprise, the Drupal users table does not have a field or fields for a real name. So that we can derive a default value for dc.creator (I don't think that a Drupal user name is really suitable here), I am going work on the basis that the Profile module (part of Drupal core) should be enabled and the following items created:

  • profile_dc_creator
  • profile_dc_rights

The latter item will allow us to set up a per-user value for DC.rights.

I think that putting a bit of SQL to create these into the install script might be a good idea, under a category called Dublin Core Metadata (what else?) [EDIT: SQL has been added as attachment to this post.]

We can then pull the necessary data out from profile_values table, using node.uid and profile_fields.fid, having found the latter from a query like this: SELECT fid from profile_fields where category='Dublin Core Metadata' and title='DC.creator';. Note that we can't just pull out on fid, as other user-defined fields will mean that fid values are arbitrary.

If anyone can think of any other per-user default values that the would like to see used, please leave a comment against this post.

Finding a value for DC.title

Deriving a value for DC.title would appear to be fairly straight-forward, we just need to look at node.title in the database:


SELECT title FROM node WHERE nid='${NID}';

Finding a value for DC.identifier

Preamble

One of my tasks is to look at metadata that can be sourced from existing Drupal code or the Drupal database. This will be used to provide default values for pages which may be over-written by the user, if required. To begin at the beginning, I believe that we need to find a value for DC.identifier, as the URI is the most fundamental piece of data that we have about a page. (Without a URI, there is no way to get to the page in the first place.)

URI Schemes

To work out the URI of a page, we first need to know what URI scheme we are using. These are the things that I think we need to check:

  1. Are we using human (and search-engine) friendly URIs such as http://drupal/node/2 or are do we have a crippled installation only capable of working through the query string like this: http://drupal/?q=node/2 ?
  2. Are we using the default http://drupal/node/[node number] scheme, or have we enabled URI aliases? We can determine this by doing: SELECT status FROM system WHERE filename='modules/path/path.module'; A value of 1 appears to mean that URI aliases are enabled.

The url_alias Table

If an alias has been set for a URI, it will appear in the url_alias table. The Drupal default fragment of the URI, such as node/1 appears in the src column and the alias in the dst column. So, if we call the Drupal default fragment $DURI, we could say (in pseudo-code):


$DURI_LOOKUP=("SELECT dst FROM url_alias where src='${DURI}';");
if (${DURI_LOOKUP})
$DC.identifier=${DURI_LOOKUP};
else
$DC.identifier=${DURI};
endif

Having looked at the code a little closer, it appears that it is possible to add more than one URI alias (yuck!) per node. The above probably needs to be changed so that if ("SELECT count(*) from url_alias where src='${DURI}';") > 1, we just ignore the aliases and go along with ${DURI}. The user can then change the value to whichever alias they want, by hand.

The Rest of the URI

What we put into $DC.identifier, above, is actually missing the domain and possibly part of the path of the URI. This would appear to be available from the global variable $base_url, which is defined for us in our site's settings.php. This variable should lack a trailing slash, so we need to use $base_url, a slash and then the value we put into DC.identifier above, to come up with what we need.

Syndicate content