Author: peter
Date: 2008-11-04 17:53:19 -0800 (Tue, 04 Nov 2008)
New Revision: 1518
Added:
trunk/qubit/apps/qubit/lib/QubitIsad.class.php
trunk/qubit/apps/qubit/lib/QubitRad.class.php
Removed:
trunk/qubit/apps/qubit/lib/QubitRAD.class.php
Modified:
trunk/qubit/apps/qubit/modules/digitalobject/templates/_imageflow.php
trunk/qubit/lib/model/QubitInformationObject.php
Log:
move the creation of standard specific labels and reference codes out of
QubitInformationObject.php and into QubitRad.class.php and QubitIsad.class.php,
leave a default getLabel method but change it to use the array as per coding
standard. Change _imageflow.php component to use array for getLabel()
Added: trunk/qubit/apps/qubit/lib/QubitIsad.class.php
===================================================================
--- trunk/qubit/apps/qubit/lib/QubitIsad.class.php
(rev 0)
+++ trunk/qubit/apps/qubit/lib/QubitIsad.class.php 2008-11-05 01:53:19 UTC
(rev 1518)
@@ -0,0 +1,104 @@
+<?php
+
+/*
+ * This file is part of the Qubit Toolkit.
+ * Copyright (C) 2006-2008 Peter Van Garderen <[EMAIL PROTECTED]>
+ *
+ * This program 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.
+ *
+ * This program 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 Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * 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 (is_null($title = $informationObject->getTitle()))
+ {
+ $title = $informationObject->getTitle(array('sourceCulture' => true));
+ }
+
+ $label .= $title;
+
+ if (isset($options['truncate']))
+ {
+ $label = truncate_text($label, $options['truncate']);
+ }
+
+ //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);
+ }
+}
\ No newline at end of file
Deleted: trunk/qubit/apps/qubit/lib/QubitRAD.class.php
===================================================================
--- trunk/qubit/apps/qubit/lib/QubitRAD.class.php 2008-11-05 01:43:10 UTC
(rev 1517)
+++ trunk/qubit/apps/qubit/lib/QubitRAD.class.php 2008-11-05 01:53:19 UTC
(rev 1518)
@@ -1,35 +0,0 @@
-<?php
-
-/*
- * This file is part of the Qubit Toolkit.
- * Copyright (C) 2006-2008 Peter Van Garderen <[EMAIL PROTECTED]>
- *
- * This program 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.
- *
- * This program 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 Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-/**
- * @package Qubit
- * @author Peter Van Garderen <[EMAIL PROTECTED]>
- * @version svn:$Id$
- */
-class QubitRAD
-{
- public static function getLabel()
- {
- //returns RAD compliant label
-
- return 'TODO: create RAD label';
- }
-}
Added: trunk/qubit/apps/qubit/lib/QubitRad.class.php
===================================================================
--- trunk/qubit/apps/qubit/lib/QubitRad.class.php
(rev 0)
+++ trunk/qubit/apps/qubit/lib/QubitRad.class.php 2008-11-05 01:53:19 UTC
(rev 1518)
@@ -0,0 +1,104 @@
+<?php
+
+/*
+ * This file is part of the Qubit Toolkit.
+ * Copyright (C) 2006-2008 Peter Van Garderen <[EMAIL PROTECTED]>
+ *
+ * This program 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.
+ *
+ * This program 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 Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * 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 (is_null($title = $informationObject->getTitle()))
+ {
+ $title = $informationObject->getTitle(array('sourceCulture' => true));
+ }
+
+ $label .= $title;
+
+ if (isset($options['truncate']))
+ {
+ $label = truncate_text($label, $options['truncate']);
+ }
+
+ //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);
+ }
+}
\ No newline at end of file
Modified: trunk/qubit/apps/qubit/modules/digitalobject/templates/_imageflow.php
===================================================================
--- trunk/qubit/apps/qubit/modules/digitalobject/templates/_imageflow.php
2008-11-05 01:43:10 UTC (rev 1517)
+++ trunk/qubit/apps/qubit/modules/digitalobject/templates/_imageflow.php
2008-11-05 01:53:19 UTC (rev 1518)
@@ -14,7 +14,7 @@
<?php echo image_tag($thumbnail->getFullPath(), array(
'class'=>'imageflow',
'longdesc'=>url_for('informationobject/show?id='.$informationObjects[$i]->getId()),
- 'alt'=>$informationObjects[$i]->getLabel(30)
+ 'alt'=>$informationObjects[$i]->getLabel(array('truncate' => 30))
)) ?>
<?php endforeach; ?>
</div>
Modified: trunk/qubit/lib/model/QubitInformationObject.php
===================================================================
--- trunk/qubit/lib/model/QubitInformationObject.php 2008-11-05 01:43:10 UTC
(rev 1517)
+++ trunk/qubit/lib/model/QubitInformationObject.php 2008-11-05 01:53:19 UTC
(rev 1518)
@@ -80,7 +80,45 @@
$relation->delete();
}
}
-
+
+ public function getLabel(array $options = array())
+ {
+ sfLoader::loadHelpers('Text');
+
+ $label = $this->getLevelOfDescription();
+
+ if ($this->getIdentifier())
+ {
+ $label .= ' '.$this->getIdentifier();
+ }
+
+ if ($label)
+ {
+ $label .= ' - ';
+ }
+
+ if (is_null($title = $this->getTitle()))
+ {
+ $title = $this->getTitle(array('sourceCulture' => true));
+ }
+
+ $label .= $title;
+
+ if (isset($options['truncate']))
+ {
+ $label = truncate_text($label, $options['truncate']);
+ }
+
+ //TODO: will return an array, only display first one?
+ /*
+ if ($informationObject->getDates($eventType = 'creation'))
+ {
+ $label .= ' ['.$informationObject->getDates($eventType = 'creation').']';
+ }
+ */
+
+ return $label;
+ }
/**
* Get a paginated hitlist information objects
*
@@ -91,28 +129,28 @@
*/
public static function getList($culture, $options = array())
{
- $criteria = new Criteria;
-
+ $criteria = new Criteria;
+
// Only get the top-level info object (collections and orphans)
if (isset($options['parentId']))
{
$criteria->add(QubitInformationObject::PARENT_ID, $options['parentId'],
Criteria::EQUAL);
}
-
+
$cultureFallback = (isset($options['cultureFallback'])) ?
$options['cultureFallback'] : false;
$sort = (isset($options['sort'])) ? $options['sort'] : null;
$page = (isset($options['page'])) ? $options['page'] : 1;
-
+
if (isset($options['repositoryId']))
{
$criteria->add(QubitInformationObject::REPOSITORY_ID,
$options['repositoryId']);
}
-
+
if (isset($options['collectionType']))
{
$criteria->add(QubitInformationObject::COLLECTION_TYPE_ID,
$options['collectionType']);
}
-
+
// Sort results
switch($sort)
{
@@ -135,7 +173,7 @@
$fallbackTable = 'QubitInformationObject';
$criteria->addAscendingOrderByColumn('title');
}
-
+
// Do source culture fallback
if ($cultureFallback === true)
{
@@ -150,56 +188,16 @@
$criteria->addJoin(QubitInformationObject::REPOSITORY_ID,
QubitActorI18n::ID, Criteria::LEFT_JOIN);
$criteria->add(QubitInformationObjectI18n::CULTURE, $culture);
}
-
+
// Page results
$pager = new QubitPager('QubitInformationObject');
$pager->setCriteria($criteria);
$pager->setPage($page);
$pager->init();
-
+
return $pager;
}
- public function getLabel($truncate = null)
- {
- sfLoader::loadHelpers('Text');
-
- $label = $this->getLevelOfDescription();
-
- if ($this->getIdentifier())
- {
- $label .= ' '.$this->getIdentifier();
- }
-
- if ($label)
- {
- $label .= ' - ';
- }
-
- if (is_null($title = $this->getTitle()))
- {
- $title = $this->getTitle(array('sourceCulture' => true));
- }
-
- $label .= $title;
-
- if ($truncate !== null)
- {
- $label = truncate_text($label, $truncate);
- }
-
-
- //TODO: will return an array, only display first one?
- /*
- if ($this->getDates($eventType = 'creation'))
- {
- $label .= ' ['.$this->getDates($eventType = 'creation').']';
- }
- */
-
- return $label;
- }
-
public function getCollectionRoot()
{
return $this->getAncestors()->orderBy('lft')->offsetGet(1,
array('defaultValue' => $this));
@@ -232,8 +230,7 @@
return QubitNote::get($criteria);
}
-
-
+
public function getNotesByTaxonomy(array $options = array())
{
$criteria = new Criteria;
@@ -246,7 +243,6 @@
return QubitNote::get($criteria);
}
-
//Actor-Event Relations
public function getActors($actorRoleTypeId = null)
@@ -269,7 +265,7 @@
$criteria->add(QubitEvent::INFORMATION_OBJECT_ID, $this->getId());
$criteria->add(QubitEvent::ACTOR_ROLE_ID, QubitTerm::CREATOR_ID);
$criteria->addJoin(QubitActor::ID, QubitEvent::ACTOR_ID,
Criteria::INNER_JOIN);
-
+
$actors = QubitActor::get($criteria);
return $actors;
}
@@ -360,7 +356,6 @@
return null;
}
-
/**
* Add a many-to-many Term relation to this information object.
*
@@ -370,9 +365,8 @@
*/
public function addTermRelation($termId, $relationNote = null)
{
-
- // Don't add a term relation to this information object that already
exists.
- if ($this->getTermRelation($termId) === NULL)
+ // Don't add a term relation to this information object that already
exists.
+ if ($this->getTermRelation($termId) === null)
{
$newTermRelation = new QubitObjectTermRelation;
$newTermRelation->setObject($this);
@@ -381,7 +375,7 @@
// $newTermRelation->setRelationNote($relationNote);
$newTermRelation->save();
}
-
+
return $this;
}
@@ -398,7 +392,7 @@
return QubitObjectTermRelation::get($criteria);
}
-
+
/**
* Get related term object by id (should be unique)
*
@@ -409,7 +403,7 @@
$criteria = new Criteria;
$criteria->add(QubitObjectTermRelation::OBJECT_ID, $this->getId());
$criteria->add(QubitObjectTermRelation::TERM_ID, $termId);
-
+
return QubitObjectTermRelation::getOne($criteria);
}
@@ -424,7 +418,8 @@
public function addProperty($name, $value, $scope = null)
{
// Only add this property if an identical one does NOT exist already
- if ($this->getProperty($name, $value, $scope) === null) {
+ if ($this->getProperty($name, $value, $scope) === null)
+ {
$newCode = new QubitProperty;
$newCode->setObjectId($this->getId());
$newCode->setName($name);
@@ -432,10 +427,10 @@
$newCode->setScope($scope);
$newCode->save();
}
-
+
return $this;
}
-
+
/**
* Get an existing property related to this information object.
*
@@ -451,10 +446,10 @@
$criteria->add(QubitProperty::NAME, $name);
$criteria->add(QubitProperty::VALUE, $value);
$criteria->add(QubitProperty::SCOPE, $scope);
-
+
return QubitProperty::getOne($criteria);
}
-
+
/**
* Return all properties related to this information object,
* with option of filtering by name and/or scope
@@ -487,7 +482,7 @@
$newTerm->setTaxonomyId(QubitTaxonomy::SUBJECT_ID);
$newTerm->setName($subject);
$newTerm->save();
-
+
// associate this new subject term with this information object
$this->addTermRelation($newTerm->getId());
}
@@ -501,7 +496,7 @@
{
return $this->getTermRelations(QubitTaxonomy::PLACE_ID);
}
-
+
/**
* Add a name access point to this info object
*
@@ -513,7 +508,7 @@
{
// Only add new related QubitEvent relation if an indentical relationship
// doesn't already exist
- if ($this->getNameAccessPoint($actorId, $actorRoleId) === NULL)
+ if ($this->getNameAccessPoint($actorId, $actorRoleId) === null)
{
$newNameAccessPoint = new QubitEvent;
$newNameAccessPoint->setActorId($actorId);
@@ -521,10 +516,10 @@
$newNameAccessPoint->setInformationObjectId($this->getId());
$newNameAccessPoint->save();
}
-
+
return $this;
}
-
+
/**
* Get an array of name access points related to this InformationObject.
*
@@ -542,7 +537,7 @@
}
}
}
-
+
/**
* Get name access point by $actorId and $actorRoleId (should be unique)
*
@@ -553,11 +548,11 @@
public function getNameAccessPoint($actorId, $actorRoleId)
{
$criteria = new Criteria;
-
+
$criteria->add(QubitEvent::INFORMATION_OBJECT_ID, $this->getId());
$criteria->add(QubitEvent::ACTOR_ID, $actorId);
$criteria->add(QubitEvent::ACTOR_ROLE_ID, $actorRoleId);
-
+
return QubitEvent::getOne($criteria);
}
@@ -565,8 +560,8 @@
{
//TO DO: get via linked digital objects & physical objects
}
-
-
+
+
public function setMaterialType($materialType)
{
// add the materialType to term list (assuming it's a new subject)
@@ -575,7 +570,7 @@
$newTerm->setTaxonomyId(QubitTaxonomy::MATERIAL_TYPE_ID);
$newTerm->setName($materialType);
$newTerm->save();
-
+
// associate this new subject term with this information object
$this->addTermRelation($newTerm->getId());
}
@@ -585,50 +580,6 @@
return $this->getTermRelations(QubitTaxonomy::MATERIAL_TYPE_ID);
}
- public function getReferenceCode(array $options = array())
- {
- // set default value
- $options += array('standard' => 'isad');
-
- $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 ($this->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();
- }
- }
-
- // output a Reference Code according to the rules of a particular standard
- switch ($options['standard'])
- {
- case 'isad':
- // TODO: This should work in future, without requiring the foreach()
loop above:
- // return
$this->getAncestors->andSelf->orderBy('rgt')->getRepository()->getPrimaryContact()->getCountryCode().'
'.$this->getAncestors->andSelf()->getRepository()->getIdentifier().'
'.implode('-', $this->getAncestors()->andSelf()->getIdentifier());
- return $countryCode.$repositoryCode.implode('-', $identifiers);
- case 'dublincore':
- return $identifierString;
- case 'ead':
- return $identifierString;
- }
- }
-
public function getRepositoryCountry()
{
if ($this->getRepositoryId())
@@ -777,7 +728,7 @@
return $this;
}
-
+
/**
* Get a physical object related to this info object
*
@@ -789,7 +740,7 @@
$criteria = new Criteria;
$criteria->add(QubitRelation::OBJECT_ID, $this->getId());
$criteria->add(QubitRelation::SUBJECT_ID, $physicalObjectId);
-
+
return QubitRelation::getOne($criteria);
}
}
--~--~---------~--~----~------------~-------~--~----~
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.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---