Metadata

It is often desirable for metadata to be associated with individual items of content. The Continuum CMS API provides generic metadata functionality that allows metadata for different content types to be managed in a unified manner. This includes:

  • jadu/JaduMetadata.php – contains functions for interacting with metadata tables
  • public_html/site/includes/metadata.php – front-end include for printing out generic metadata
  • public_html/jadu/lightboxes/assign_metadata.php and assign_metadata.js – provides a “lightbox” interface for managing the metadata for an item of content

Metadata for each type of content must be stored in a separate database table. For example, the metadata for blogs is stored in JaduBlogsMetadata, blog posts in JaduBlogPostMetadata and news items in JaduNewsMetadata.

All metadata database tables must adhere to the same schema, which can be created using the following SQL statement:

CREATE TABLE IF NOT EXISTS MyContentTypeMetadata (
    id int(10) unsigned NOT NULL AUTO_INCREMENT,
    itemID int(11) DEFAULT NULL,
    creator mediumtext,
    contributor mediumtext,
    publisher mediumtext,
    rights mediumtext,
    source mediumtext,
    status mediumtext,
    coverage mediumtext,
    created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
    modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
    valid timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
    expired timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
    format varchar(255) DEFAULT NULL,
    language varchar(255) DEFAULT NULL,
    subject mediumtext,
    description mediumtext,
    PRIMARY KEY (id),
    KEY itemID (itemID),
    FULLTEXT KEY creator (creator,contributor,publisher,source,subject,description)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

For Microsoft SQL Server based installations this query would need to be converted to the equivalent syntax.

The JaduMetadata.php file includes functions for working with a metadata table such as the one above. Each function takes the name of the database table and a number of other parameters. The most notable functions in JaduMetadata.php are:

/**
 * Add a new metadata item to the database
 * @param string $table The name of the database table to add the record to
 * @param integer $itemID The id of the content item associated with the
 * metadata
 */
newMetadata ($table, $itemID, $creator, $contributor, $publisher, $rights,
$source, $status, $coverage, $created, $modified,
$valid, $expired, $format, $language, $subject, $description)

/**
 * Update a metadata record
 * @param string $table The name of the database table to update
 * @param integer $id The id of the record to update
 * @param integer $itemID The id of the content item associated with the
 * metadata
 */
updateMetadata ($table, $id, $itemID, $creator, $contributor,
$publisher, $rights, $source, $status, $coverage, $created, $modified, $valid,
$expired, $format, $language, $subject, $description)

/**
 * Determine whether the metadata fields are suitable to be added to the
 * database
 */
validateMetadata ($subject, $description, $creator, $contributor, $publisher,
$rights, $status, $coverage, $format, $language, $created, $modified, $valid,
$expired)

/**
 * Retrieve a metadata entry from the database for a particular item
 * @param string $table The name of the table
 * @param integer $itemID The item id
 * @return JaduMetadata Returns an object containing the metadata
 */
getMetadataForItem ($table, $itemID)

/**
 * Delete a metadata record from the database
 * @param string $table The name of the table
 * @param integer $itemID The id of the item
 */
deleteMetadataForItem ($table, $itemID)

/**
 * Prints the metadata
 */
printMetadata ($metadataTable, $categoryTable, $id, $title, $url,
$printOutput = true)

See the comments in the JaduMetadata.php file for details of other parameters.

results matching ""

    No results matching ""