Author: david
Date: 2008-11-27 15:29:09 -0800 (Thu, 27 Nov 2008)
New Revision: 1635
Modified:
trunk/qubit/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
trunk/qubit/apps/qubit/modules/informationobject/actions/showAction.class.php
trunk/qubit/apps/qubit/modules/informationobject/actions/updateAction.class.php
trunk/qubit/apps/qubit/modules/physicalobject/actions/deleteAction.class.php
trunk/qubit/apps/qubit/modules/physicalobject/actions/editAction.class.php
trunk/qubit/apps/qubit/modules/physicalobject/templates/_edit.php
trunk/qubit/lib/model/QubitRelation.php
Log:
Specify type of object to return from QubitRelation queries that return an
object.
Modified:
trunk/qubit/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
===================================================================
---
trunk/qubit/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
2008-11-27 23:04:58 UTC (rev 1634)
+++
trunk/qubit/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
2008-11-27 23:29:09 UTC (rev 1635)
@@ -114,7 +114,7 @@
$childInformationObjects =
$this->informationObject->getDescendants()->andSelf();
foreach ($childInformationObjects as $informationObject)
{
- $relatedPhysicalObjects =
QubitRelation::getRelatedSubjectsByObjectId($informationObject->getId(),
+ $relatedPhysicalObjects =
QubitRelation::getRelatedSubjectsByObjectId('QubitPhysicalObject',
$informationObject->getId(),
array('typeId'=>QubitTerm::HAS_PHYSICAL_OBJECT_ID));
foreach ($relatedPhysicalObjects as $physicalObject)
Modified:
trunk/qubit/apps/qubit/modules/informationobject/actions/showAction.class.php
===================================================================
---
trunk/qubit/apps/qubit/modules/informationobject/actions/showAction.class.php
2008-11-27 23:04:58 UTC (rev 1634)
+++
trunk/qubit/apps/qubit/modules/informationobject/actions/showAction.class.php
2008-11-27 23:29:09 UTC (rev 1635)
@@ -59,7 +59,7 @@
$this->materialTypes = $this->informationObject->getMaterialTypes();
// Physical objects
- $this->physicalObjects =
QubitRelation::getRelatedSubjectsByObjectId($this->informationObject->getId(),
+ $this->physicalObjects =
QubitRelation::getRelatedSubjectsByObjectId('QubitPhysicalObject',
$this->informationObject->getId(),
array('typeId'=>QubitTerm::HAS_PHYSICAL_OBJECT_ID));
// Determine if user has edit priviliges
Modified:
trunk/qubit/apps/qubit/modules/informationobject/actions/updateAction.class.php
===================================================================
---
trunk/qubit/apps/qubit/modules/informationobject/actions/updateAction.class.php
2008-11-27 23:04:58 UTC (rev 1634)
+++
trunk/qubit/apps/qubit/modules/informationobject/actions/updateAction.class.php
2008-11-27 23:29:09 UTC (rev 1635)
@@ -621,7 +621,7 @@
*/
public function updatePhysicalObjects($informationObject)
{
- $oldPhysicalObjects =
QubitRelation::getRelatedSubjectsByObjectId($informationObject->getId(),
+ $oldPhysicalObjects =
QubitRelation::getRelatedSubjectsByObjectId('QubitPhysicalObject',
$informationObject->getId(),
array('typeId'=>QubitTerm::HAS_PHYSICAL_OBJECT_ID));
// Preferentially use "new container" input data over the selector so that
Modified:
trunk/qubit/apps/qubit/modules/physicalobject/actions/deleteAction.class.php
===================================================================
---
trunk/qubit/apps/qubit/modules/physicalobject/actions/deleteAction.class.php
2008-11-27 23:04:58 UTC (rev 1634)
+++
trunk/qubit/apps/qubit/modules/physicalobject/actions/deleteAction.class.php
2008-11-27 23:29:09 UTC (rev 1635)
@@ -33,20 +33,20 @@
{
$physicalObject =
QubitPhysicalObject::getById($this->getRequestParameter('id'));
$this->forward404Unless($physicalObject);
-
+
$this->forward404Unless($this->hasRequestParameter('next'));
-
+
// Get related information objects (if any)
- $informationObjects =
QubitRelation::getRelatedObjectsBySubjectId($physicalObject->getId(),
+ $informationObjects =
QubitRelation::getRelatedObjectsBySubjectId('QubitInformationObject',
$physicalObject->getId(),
array('typeId'=>QubitTerm::HAS_PHYSICAL_OBJECT_ID));
-
+
// Delete physical object record from the database
$physicalObject->delete();
-
+
// Update Index (if related to an information object)
- if (count($informationObjects) > 0)
+ if (count($informationObjects) > 0)
{
- foreach($informationObjects as $informationObject)
+ foreach ($informationObjects as $informationObject)
{
SearchIndex::updateTranslatedLanguages($informationObject);
}
@@ -54,7 +54,7 @@
// Make the $next parameter into an absolute URL because redirect() expects
// an absolute URL or an array containing module and action
- // (Pre-pend code copied from sfWebController->genUrl() method)
+ // (Pre-pend code copied from sfWebController->genUrl() method)
$next = 'http'.($request->isSecure() ? 's' :
'').'://'.$request->getHost().$this->getRequestParameter('next');
return $this->redirect($next);
}
Modified:
trunk/qubit/apps/qubit/modules/physicalobject/actions/editAction.class.php
===================================================================
--- trunk/qubit/apps/qubit/modules/physicalobject/actions/editAction.class.php
2008-11-27 23:04:58 UTC (rev 1634)
+++ trunk/qubit/apps/qubit/modules/physicalobject/actions/editAction.class.php
2008-11-27 23:29:09 UTC (rev 1635)
@@ -33,13 +33,13 @@
{
$this->physicalObject =
QubitPhysicalObject::getById($this->getRequestParameter('id'));
$this->forward404Unless($this->physicalObject);
-
- $relatedInfoObjects =
QubitRelation::getRelatedObjectsBySubjectId($this->physicalObject->getId(),
+
+ $relatedInfoObjects =
QubitRelation::getRelatedObjectsBySubjectId('QubitInformationObject',
$this->physicalObject->getId(),
array('typeId'=>QubitTerm::HAS_PHYSICAL_OBJECT_ID));
$this->relatedInfoObjectCount = count($relatedInfoObjects);
-
+
$this->relatedInfoObjects = $relatedInfoObjects;
-
+
// If coming here from another page (e.g. informationobject/edit) redirect
// back on update/cancel/delete
$this->nextAction = null;
@@ -47,6 +47,5 @@
{
$this->nextAction = urldecode($this->getRequestParameter('next'));
}
-
}
}
Modified: trunk/qubit/apps/qubit/modules/physicalobject/templates/_edit.php
===================================================================
--- trunk/qubit/apps/qubit/modules/physicalobject/templates/_edit.php
2008-11-27 23:04:58 UTC (rev 1634)
+++ trunk/qubit/apps/qubit/modules/physicalobject/templates/_edit.php
2008-11-27 23:29:09 UTC (rev 1635)
@@ -8,7 +8,7 @@
</td>
</tr>
<?php foreach($relations as $relation): ?>
- <?php $physicalObject = $relation->getSubject(); ?>
+ <?php $physicalObject =
QubitPhysicalObject::getById($relation->getSubjectId()); ?>
<tr>
<td style="width: 90%">
<?php if (strlen($type = $physicalObject->getType())) echo $type.': '; ?>
Modified: trunk/qubit/lib/model/QubitRelation.php
===================================================================
--- trunk/qubit/lib/model/QubitRelation.php 2008-11-27 23:04:58 UTC (rev
1634)
+++ trunk/qubit/lib/model/QubitRelation.php 2008-11-27 23:29:09 UTC (rev
1635)
@@ -126,37 +126,38 @@
/**
* Get related subject objects via QubitRelation many-to-many relationship
*
- * @param QubitObject $objectId primary key of "object" QubitObject
- * @param integer $typeId filter by predicate
- * @param array $options list of options to pass to QubitQuery
+ * @param string $className type of objects to return
+ * @param integer $objectId primary key of "object" QubitObject
+ * @param array $options list of options to pass to QubitQuery
* @return QubitQuery collection of QubitObjects
*/
- public static function getRelatedSubjectsByObjectId($objectId,
$options=array())
+ public static function getRelatedSubjectsByObjectId($className, $objectId,
$options=array())
{
$criteria = new Criteria;
$criteria->add(QubitRelation::OBJECT_ID, $objectId);
$criteria->addJoin(QubitRelation::SUBJECT_ID, QubitObject::ID);
-
+ $criteria->add(QubitObject::CLASS_NAME, $className);
$criteria = self::addTypeIdCriteriaFromOptions($criteria, $options);
- return QubitObject::get($criteria, $options);
+ return call_user_func(array($className, 'get'), $criteria, $options);
}
/**
* Get related "object" (semantic) QubitObjects
*
- * @param QubitObject $subjectId primary key of "subject" QubitObject
- * @param array $options list of options to pass to QubitQuery
+ * @param string $className type of objects to return
+ * @param integer $subjectId primary key of "subject" QubitObject
+ * @param array $options list of options to pass to QubitQuery
* @return QubitQuery collection of QubitObjects
*/
- public static function getRelatedObjectsBySubjectId($subjectId,
$options=array())
+ public static function getRelatedObjectsBySubjectId($className, $subjectId,
$options=array())
{
$criteria = new Criteria;
$criteria->add(QubitRelation::SUBJECT_ID, $subjectId);
$criteria->addJoin(QubitRelation::OBJECT_ID, QubitObject::ID);
-
+ $criteria->add(QubitObject::CLASS_NAME, $className);
$criteria = self::addTypeIdCriteriaFromOptions($criteria, $options);
- return QubitObject::get($criteria, $options);
+ return call_user_func(array($className, 'get'), $criteria, $options);
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---