Author: sevein
Date: Tue Dec 8 12:14:08 2009
New Revision: 4118
Log:
Move metadata standard libs to plugins lib directory.
Added:
trunk/plugins/sfDcPlugin/lib/
trunk/plugins/sfDcPlugin/lib/QubitDc.class.php
- copied unchanged from r4117, trunk/lib/QubitDc.class.php
trunk/plugins/sfIsadPlugin/lib/
trunk/plugins/sfIsadPlugin/lib/QubitIsad.class.php
- copied unchanged from r4117, trunk/lib/QubitIsad.class.php
trunk/plugins/sfModsPlugin/lib/
trunk/plugins/sfModsPlugin/lib/QubitMods.class.php
- copied unchanged from r4117, trunk/lib/QubitMods.class.php
trunk/plugins/sfRadPlugin/lib/
trunk/plugins/sfRadPlugin/lib/QubitRad.class.php
- copied unchanged from r4117, trunk/lib/QubitRad.class.php
Deleted:
trunk/lib/QubitDc.class.php
trunk/lib/QubitIsad.class.php
trunk/lib/QubitMods.class.php
trunk/lib/QubitRad.class.php
Copied: trunk/plugins/sfDcPlugin/lib/QubitDc.class.php (from r4117,
trunk/lib/QubitDc.class.php)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/plugins/sfDcPlugin/lib/QubitDc.class.php Tue Dec 8 12:14:08
2009 (r4118, copy of r4117, trunk/lib/QubitDc.class.php)
@@ -0,0 +1,248 @@
+<?php
+
+/*
+ * This file is part of Qubit Toolkit.
+ *
+ * Qubit Toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Qubit Toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * This class is used to provide methods that supplement the core Qubit
information object with behaviour or
+ * presentation features that are specific to the Dublin Core standard
+ *
+ * @package Qubit
+ * @author Peter Van Garderen <[email protected]>
+ * @version svn:$Id$
+ */
+
+class QubitDc
+{
+ public static function getLabel($informationObject, array $options = array())
+ {
+ sfLoader::loadHelpers('Text');
+
+ $label = '';
+
+ if ($informationObject->getIdentifier())
+ {
+ $label = $informationObject->getIdentifier();
+ }
+
+ if (strlen($title = $informationObject->getTitle()) < 1)
+ {
+ $title = $informationObject->getTitle(array('sourceCulture' => true));
+ }
+
+ if ((strlen($title) > 0) & (strlen($label) > 0))
+ {
+ $label .= ' - '.$title;
+ }
+ else
+ {
+ $label .= $title;
+ }
+
+ if (isset($options['truncate']))
+ {
+ $label = truncate_text($label, $options['truncate']);
+ }
+
+ $publicationStatus = $informationObject->getPublicationStatus();
+ if ($publicationStatus->statusId == QubitTerm::PUBLICATION_STATUS_DRAFT_ID)
+ {
+ $label .= ' ('.$publicationStatus->status.')';
+ }
+
+ return $label;
+ }
+
+ public static function getIdentifier($informationObject, array $options =
array())
+ {
+ return QubitIsad::getReferenceCode($informationObject);
+ }
+
+ public static function getDates($informationObject, array $options = array())
+ {
+ // as per DC best practice, only an ISO 8601 normalized (start) date is
returned.
+ // Date ranges (start date - end date) or natural language date strings
are output as dc:coverage values
+ $dcDate = array();
+ foreach (QubitDc::getDcEvents($informationObject) as $event)
+ {
+ if ($date = $event->getStartDate())
+ {
+ $dcDate[] = $date;
+ }
+ }
+
+ return $dcDate;
+ }
+
+ public static function getSubjects($informationObject, array $options =
array())
+ {
+ $dcSubject = array();
+ foreach ($informationObject->getSubjectAccessPoints() as
$subjectAccessPoint)
+ {
+ $dcSubject[] = $subjectAccessPoint->getTerm();
+ }
+
+ // Add name access points
+ $criteria = new Criteria;
+ $criteria =
$informationObject->addrelationsRelatedBysubjectIdCriteria($criteria);
+ $criteria->add(QubitRelation::TYPE_ID, QubitTerm::NAME_ACCESS_POINT_ID);
+
+ if (0 < count($nameAccessPointRelations = QubitRelation::get($criteria)))
+ {
+ foreach ($nameAccessPointRelations as $nameAccessPointRelation)
+ {
+ $dcSubject[] = $nameAccessPointRelation->object;
+ }
+ }
+
+ return $dcSubject;
+ }
+
+ public static function getCoverage($informationObject, array $options =
array())
+ {
+ if (isset($options['temporal']))
+ {
+ $dcCoverage = array();
+ foreach (QubitDc::getDcEvents($informationObject) as $event)
+ {
+ if ($dateDisplay = $event->getDateDisplay())
+ {
+ $dcCoverage[] = $dateDisplay;
+ }
+ }
+
+ return $dcCoverage;
+ }
+
+ if (isset($options['spatial']))
+ {
+ $dcCoverage = array();
+ foreach ($informationObject->getPlaceAccessPoints() as $placeAccessPoint)
+ {
+ $dcCoverage[] = $placeAccessPoint->getTerm();
+ }
+
+ return $dcCoverage;
+ }
+ }
+
+ protected static function getDcEvents($informationObject, array $options =
array())
+ {
+ // Because simple Dublin Core cannot qualify the dc:date or dc:coverage
elements, we only return a limited
+ // set of Events. Just those that are related to creation/origination.
+ $dcEvents = array();
+ foreach ($informationObject->getActorEvents() as $event)
+ {
+ switch ($event->getTypeId())
+ {
+ case QubitTerm::CREATION_ID:
+ $dcEvents[] = $event;
+ break;
+ case QubitTerm::CUSTODY_ID:
+ $dcEvents[] = $event;
+ break;
+ case QubitTerm::PUBLICATION_ID:
+ $dcEvents[] = $event;
+ break;
+ case QubitTerm::COLLECTION_ID:
+ $dcEvents[] = $event;
+ break;
+ case QubitTerm::ACCUMULATION_ID:
+ $dcEvents[] = $event;
+ break;
+ }
+ }
+
+ return $dcEvents;
+ }
+
+ public static function getTypes($informationObject, array $options = array())
+ {
+ $dcType = array();
+ /* disable display of collection type until this option is fully supported
in the UI
+ if ($collectionType = $informationObject->getCollectionType())
+ {
+ $dcType[] = $collectionType;
+ }
+ */
+ if (count(QubitDc::getDcTypes($informationObject)) > 0)
+ {
+ foreach (QubitDc::getDcTypes($informationObject) as $type)
+ {
+ $dcType[] = $type->getTerm();
+ }
+ }
+ if ($digitalObject = $informationObject->getDigitalObject())
+ {
+ $dcType[] = $digitalObject->getMediaType();
+ }
+
+ return $dcType;
+ }
+
+ public static function getDcTypes($informationObject, array $options =
array())
+ {
+ return $informationObject->getTermRelations(QubitTaxonomy::DC_TYPE_ID);
+ }
+
+ public static function getFormats($informationObject, array $options =
array())
+ {
+ $dcFormat = array();
+ if ($digitalObject = $informationObject->getDigitalObject())
+ {
+ if ($digitalObject->getMimeType())
+ {
+ $dcFormat[] = $digitalObject->getMimeType();
+ }
+ }
+ if ($extentAndMedium = $informationObject->getExtentAndMedium())
+ {
+ $dcFormat[] = $extentAndMedium;
+ }
+
+ return $dcFormat;
+ }
+
+ public static function getRelation($informationObject, array $options =
array())
+ {
+ sfLoader::loadHelpers(array('I18N'));
+ $dcRelation = array();
+ $dcRelation['text'] = '';
+ $dcRelation['identifier'] = '';
+ $dcRelation['property'] = '';
+ if ($parent =
QubitInformationObject::getById($informationObject->getParentId()))
+ {
+ $collection = $informationObject->getCollectionRoot();
+ if ($collection->getId() !== $informationObject->getId())
+ {
+ $dcRelation['text'] .= __('is part of').' "'.$parent.'"';
+ if ($collection->getId() !== $parent->getId())
+ {
+ $dcRelation['text'] .= __(' in').' "'.$collection.'"';
+ }
+ $dcRelation['identifier'] = $parent->getOaiIdentifier();
+ }
+ }
+ if ($relation =
$informationObject->getPropertyByName('information_object_relation'))
+ {
+ $dcRelation['property'] = $relation->getValue();
+ }
+
+ return $dcRelation;
+ }
+
+}
Copied: trunk/plugins/sfIsadPlugin/lib/QubitIsad.class.php (from r4117,
trunk/lib/QubitIsad.class.php)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/plugins/sfIsadPlugin/lib/QubitIsad.class.php Tue Dec 8 12:14:08
2009 (r4118, copy of r4117, trunk/lib/QubitIsad.class.php)
@@ -0,0 +1,115 @@
+<?php
+
+/*
+ * This file is part of Qubit Toolkit.
+ *
+ * Qubit Toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Qubit Toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * This class is used to provide methods that supplement the core Qubit
information object with behaviour or
+ * presentation features that are specific to the ICA's International Standard
Archival Description (ISAD)
+ *
+ * @package Qubit
+ * @author Peter Van Garderen <[email protected]>
+ * @version svn:$Id$
+ */
+
+class QubitIsad
+{
+ public static function getLabel($informationObject, array $options = array())
+ {
+ //returns ISAD compliant label
+ sfLoader::loadHelpers('Text');
+
+ $label = $informationObject->getLevelOfDescription();
+
+ if ($informationObject->getIdentifier())
+ {
+ $label .= ' '.$informationObject->getIdentifier();
+ }
+
+ if ($label)
+ {
+ $label .= ' - ';
+ }
+
+ if (strlen($title = $informationObject->getTitle()) < 1)
+ {
+ $title = $informationObject->getTitle(array('sourceCulture' => true));
+ }
+
+ $label .= $title;
+
+ if (isset($options['truncate']))
+ {
+ $label = truncate_text($label, $options['truncate']);
+ }
+
+ $publicationStatus = $informationObject->getPublicationStatus();
+ if ($publicationStatus !== null && $publicationStatus->statusId ==
QubitTerm::PUBLICATION_STATUS_DRAFT_ID)
+ {
+ $label .= ' ('.$publicationStatus->status.')';
+ }
+
+ //TODO: will return an array, only display first one?
+ /*
+ if ($informationObject->getDates($eventType = 'creation'))
+ {
+ $label .= ' ['.$informationObject->getDates($eventType = 'creation').']';
+ }
+ */
+
+ return $label;
+ }
+
+ public static function getReferenceCode($informationObject, array $options =
array())
+ {
+ if (sfConfig::get('app_inherit_code_informationobject'))
+ {
+ $countryCode = null;
+ $repositoryCode = null;
+ $identifiers = array();
+ // if current informationObject is related to a Repository record
+ // get its country and repository code from that related record
+ // otherwise go up the ancestor tree until hitting a node that has a
related
+ // Repository record with country and repository code info
+ foreach ($informationObject->getAncestors()->andSelf()->orderBy('lft')
as $ancestor)
+ {
+ if (null !== $repository = $ancestor->getRepository())
+ {
+ if (null !== $code = $repository->getCountryCode())
+ {
+ $countryCode = $code.' ';
+ }
+ $repositoryCode = $repository->getIdentifier().' ';
+ }
+ // while going up the ancestor tree, build an array of identifiers
that can be output
+ // as one compound identifier string for Reference Code display
+ if ($ancestor->getIdentifier())
+ {
+ $identifiers[] = $ancestor->getIdentifier();
+ }
+ }
+
+ // TODO: This should work in future, without requiring the foreach()
loop above:
+ // return
$informationObject->getAncestors->andSelf->orderBy('rgt')->getRepository()->getPrimaryContact()->getCountryCode().'
'.$informationObject->getAncestors->andSelf()->getRepository()->getIdentifier().'
'.implode('-', $informationObject->getAncestors()->andSelf()->getIdentifier());
+ return $countryCode.$repositoryCode.implode('-', $identifiers);
+ }
+ else
+ {
+ return $informationObject->getIdentifier();
+ }
+ }
+}
Copied: trunk/plugins/sfModsPlugin/lib/QubitMods.class.php (from r4117,
trunk/lib/QubitMods.class.php)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/plugins/sfModsPlugin/lib/QubitMods.class.php Tue Dec 8 12:14:08
2009 (r4118, copy of r4117, trunk/lib/QubitMods.class.php)
@@ -0,0 +1,125 @@
+<?php
+
+/*
+ * This file is part of Qubit Toolkit.
+ *
+ * Qubit Toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Qubit Toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * This class is used to provide methods that supplement the core Qubit
information object with behaviour or
+ * presentation features that are specific to the Metadata Object Description
Schema (MODS) standard
+ *
+ * @package Qubit
+ * @author Peter Van Garderen <[email protected]>
+ * @version svn:$Id$
+ */
+
+class QubitMods
+{
+ public static function getLabel($informationObject, array $options = array())
+ {
+ sfLoader::loadHelpers('Text');
+
+ $label = $informationObject->getLevelOfDescription();
+
+ if ($informationObject->getIdentifier())
+ {
+ $label .= ' '.$informationObject->getIdentifier();
+ }
+
+ if ($label)
+ {
+ $label .= ' - ';
+ }
+
+ if (strlen($title = $informationObject->getTitle()) < 1)
+ {
+ $title = $informationObject->getTitle(array('sourceCulture' => true));
+ }
+
+ $label .= $title;
+
+ if (isset($options['truncate']))
+ {
+ $label = truncate_text($label, $options['truncate']);
+ }
+
+ $publicationStatus = $informationObject->getPublicationStatus();
+ if ($publicationStatus->statusId == QubitTerm::PUBLICATION_STATUS_DRAFT_ID)
+ {
+ $label .= ' ('.$publicationStatus->status.')';
+ }
+
+ return $label;
+ }
+
+ public static function getIdentifier($informationObject, array $options =
array())
+ {
+ return QubitIsad::getReferenceCode($informationObject);
+ }
+
+ public static function getTypes($informationObject, array $options = array())
+ {
+ return
$informationObject->getTermRelations(QubitTaxonomy::MODS_RESOURCE_TYPE_ID);
+ }
+
+ public static function getNames($informationObject, array $options = array())
+ {
+ $nameEvents = array();
+ $actorEvents = $informationObject->getActorEvents();
+ foreach ($actorEvents as $event)
+ {
+ if ($event->getActorId())
+ {
+ $nameEvents[] = $event;
+ }
+ }
+
+ return $nameEvents;
+ }
+
+ public static function getLanguageCodes($informationObject, array $options =
array())
+ {
+ return $informationObject->getProperties($name =
'information_object_language');
+ }
+
+ public static function getDigitalObject($informationObject, array $options =
array())
+ {
+ $digitalObject = $informationObject->getDigitalObject();
+ if (isset($digitalObject))
+ {
+
+ return $digitalObject;
+ }
+ else
+ {
+
+ return null;
+ }
+ }
+
+ public static function getLocationUrl($informationObject, array $options =
array())
+ {
+ if ($digitalObject = $informationObject->getDigitalObject())
+ {
+ return
'http://'.$options['request']->getHost().$options['request']->getRelativeUrlRoot().$digitalObject->getFullPath();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+}
Copied: trunk/plugins/sfRadPlugin/lib/QubitRad.class.php (from r4117,
trunk/lib/QubitRad.class.php)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/plugins/sfRadPlugin/lib/QubitRad.class.php Tue Dec 8 12:14:08
2009 (r4118, copy of r4117, trunk/lib/QubitRad.class.php)
@@ -0,0 +1,109 @@
+<?php
+
+/*
+ * This file is part of Qubit Toolkit.
+ *
+ * Qubit Toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Qubit Toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * This class is used to provide methods that supplement the core Qubit
information object with behaviour or
+ * presentation features that are specific to the Canadian Rules for Archival
Description (RAD) standard
+ *
+ * @package Qubit
+ * @author Peter Van Garderen <[email protected]>
+ * @version svn:$Id$
+ */
+
+class QubitRad
+{
+ public static function getLabel($informationObject, array $options = array())
+ {
+ //returns RAD compliant label
+ sfLoader::loadHelpers('Text');
+
+ $label = $informationObject->getLevelOfDescription();
+
+ if ($informationObject->getIdentifier())
+ {
+ $label .= ' '.$informationObject->getIdentifier();
+ }
+
+ if ($label)
+ {
+ $label .= ' - ';
+ }
+
+ if (strlen($title = $informationObject->getTitle()) < 1)
+ {
+ $title = $informationObject->getTitle(array('sourceCulture' => true));
+ }
+
+ $label .= $title;
+
+ if (isset($options['truncate']))
+ {
+ $label = truncate_text($label, $options['truncate']);
+ }
+
+ $publicationStatus = $informationObject->getPublicationStatus();
+ if ($publicationStatus->statusId == QubitTerm::PUBLICATION_STATUS_DRAFT_ID)
+ {
+ $label .= ' ('.$publicationStatus->status.')';
+ }
+
+ //TODO: will return an array, only display first one?
+ /*
+ if ($informationObject->getDates($eventType = 'creation'))
+ {
+ $label .= ' ['.$informationObject->getDates($eventType = 'creation').']';
+ }
+ */
+
+ return $label;
+ }
+
+ public static function getReferenceCode($informationObject, array $options =
array())
+ {
+ $countryCode = null;
+ $repositoryCode = null;
+ $identifiers = array();
+ // if current informationObject is related to a Repository record
+ // get its country and repository code from that related record
+ // otherwise go up the ancestor tree until hitting a node that has a
related
+ // Repository record with country and repository code info
+ foreach ($informationObject->getAncestors()->andSelf()->orderBy('lft') as
$ancestor)
+ {
+ if (null !== $repository = $ancestor->getRepository())
+ {
+ if (null !== $primaryContact = $repository->getPrimaryContact())
+ {
+ $countryCode = $repository->getPrimaryContact()->getCountryCode().'
';
+ }
+ $repositoryCode = $repository->getIdentifier().' ';
+ }
+ // while going up the ancestor tree, build an array of identifiers that
can be output
+ // as one compound identifier string for Reference Code display
+ if ($ancestor->getIdentifier())
+ {
+ $identifiers[] = $ancestor->getIdentifier();
+ }
+ }
+
+ // TODO: This should work in future, without requiring the foreach() loop
above:
+ // return
$informationObject->getAncestors->andSelf->orderBy('rgt')->getRepository()->getPrimaryContact()->getCountryCode().'
'.$informationObject->getAncestors->andSelf()->getRepository()->getIdentifier().'
'.implode('-', $informationObject->getAncestors()->andSelf()->getIdentifier());
+ return $countryCode.$repositoryCode.implode('-', $identifiers);
+ }
+
+}
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.