Author: jablko
Date: Mon Oct 18 09:43:23 2010
New Revision: 8224
Log:
Process remaining relation field
Modified:
trunk/apps/qubit/modules/relation/actions/editComponent.class.php
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedAuthorityRecordComponent.class.php
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedFunctionComponent.class.php
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedResourceComponent.class.php
Modified: trunk/apps/qubit/modules/relation/actions/editComponent.class.php
==============================================================================
--- trunk/apps/qubit/modules/relation/actions/editComponent.class.php Mon Oct
18 09:25:02 2010 (r8223)
+++ trunk/apps/qubit/modules/relation/actions/editComponent.class.php Mon Oct
18 09:43:23 2010 (r8224)
@@ -59,6 +59,18 @@
break;
+ case 'resource':
+ unset($this->relation->object);
+
+ $value = $this->form->getValue('resource');
+ if (isset($value))
+ {
+ $params = $this->context->routing->parse(Qubit::pathInfo($value));
+ $this->relation->object = $params['_sf_route']->resource;
+ }
+
+ break;
+
default:
$this->resource[$field->getName()] =
$this->form->getValue($field->getName());
}
@@ -110,6 +122,8 @@
$this->processField($field);
}
}
+
+ $this->resource->relationsRelatedBysubjectId[] = $this->relation;
}
}
}
Modified:
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedAuthorityRecordComponent.class.php
==============================================================================
---
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedAuthorityRecordComponent.class.php
Mon Oct 18 09:25:02 2010 (r8223)
+++
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedAuthorityRecordComponent.class.php
Mon Oct 18 09:43:23 2010 (r8224)
@@ -28,78 +28,6 @@
'endDate',
'dateDisplay');
- protected function processForm()
- {
- if (isset($this->request["{$formName}s"]))
- {
- // JavaScript (multiple) relationship update
- $relationsData = $this->request["{$formName}s"];
- }
- else if (isset($this->request[$formName]))
- {
- // Non-JavaScript (single) relationship update
- $relationsData = array($this->request[$formName]);
- }
- else
- {
- return;
- }
-
- // Loop through relation rows
- foreach ($relationsData as $relationData)
- {
- // Get relation
- if (isset($relationData['id']))
- {
- $params =
$this->context->routing->parse(Qubit::pathInfo($relationData['id']));
-
- if (null === $relation = QubitRelation::getById($params['id']))
- {
- continue; // If we can't find an existing relation, skip this row
- }
- }
- else
- {
- $relation = new QubitRelation;
- }
-
- // Get related information object (resource)
- $params =
$this->context->routing->parse(Qubit::pathInfo($relationData['resource']));
- $objectId = (isset($params['id'])) ? $params['id'] : null;
-
- switch ($formName)
- {
- case 'relatedEntity':
- $object = QubitActor::getById($objectId);
-
- break;
-
- case 'relatedResource':
- $object = QubitInformationObject::getById($objectId);
-
- break;
- }
-
- if (null === $object)
- {
- continue; // If no related object, skip update
- }
- else
- {
- $relation->object = $object;
- }
-
- $relation->startDate = $relationData['startDate'];
- $relation->endDate = $relationData['endDate'];
-
- // Add notes
- $relation->updateNote($relationData['description'],
QubitTerm::RELATION_NOTE_DESCRIPTION_ID);
- $relation->updateNote($relationData['dateDisplay'],
QubitTerm::RELATION_NOTE_DATE_DISPLAY_ID);
-
- $this->resource->relationsRelatedBysubjectId[] = $relation;
- }
- }
-
public function execute($request)
{
parent::execute($request);
Modified:
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedFunctionComponent.class.php
==============================================================================
---
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedFunctionComponent.class.php
Mon Oct 18 09:25:02 2010 (r8223)
+++
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedFunctionComponent.class.php
Mon Oct 18 09:43:23 2010 (r8224)
@@ -57,6 +57,35 @@
{
switch ($field->getName())
{
+ case 'resource':
+
+ // Update the object of the relation, unless the current resource is
+ // the object
+ if ($this->resource->id != $this->relation->objectId)
+ {
+ unset($this->relation->object);
+ }
+ else
+ {
+ unset($this->relation->subject);
+ }
+
+ $value = $this->form->getValue('resource');
+ if (isset($value))
+ {
+ $params = $this->context->routing->parse(Qubit::pathInfo($value));
+ if ($this->resource->id != $this->relation->objectId)
+ {
+ $this->relation->object = $params['_sf_route']->resource;
+ }
+ else
+ {
+ $this->relation->subject = $params['_sf_route']->resource;
+ }
+ }
+
+ break;
+
case 'type':
unset($this->relation->type);
@@ -75,77 +104,6 @@
}
}
- protected function processForm()
- {
- if (isset($this->request->relations))
- {
- // JavaScript (multiple) relationship update
- $relationsData = $this->request->relations;
- }
- else if (isset($this->request->relation))
- {
- // Non-JavaScript (single) relationship update
- $relationsData = array($this->request->relation);
- }
- else
- {
- return;
- }
-
- // Loop through func events
- foreach ($relationsData as $relationData)
- {
- // Get related function
- $params =
$this->context->routing->parse(Qubit::pathInfo($relationData['resource']));
- $relatedFuncId = (isset($params['id'])) ? $params['id'] : null;
- if (null === $relatedFunction = QubitFunction::getById($relatedFuncId))
- {
- continue; // If no related function, skip update
- }
-
- // Get relation
- if (isset($relationData['id']))
- {
- $params =
$this->context->routing->parse(Qubit::pathInfo($relationData['id']));
-
- if (null === $relation = QubitRelation::getById($params['id']))
- {
- // If a relation id is passed, but relation object doesn't exist then
- // skip this row
- continue;
- }
- }
- else
- {
- $relation = new QubitRelation;
- }
-
- // Set category (typeId)
- $params =
$this->context->routing->parse(Qubit::pathInfo($relationData['type']));
- $typeId = (isset($params['id'])) ? $params['id'] : null;
- $relation->typeId = $typeId;
-
- $relation->startDate = $relationData['startDate'];
- $relation->endDate = $relationData['endDate'];
-
- // Add notes
- $relation->updateNote($relationData['description'],
QubitTerm::RELATION_NOTE_DESCRIPTION_ID);
- $relation->updateNote($relationData['dateDisplay'],
QubitTerm::RELATION_NOTE_DATE_DISPLAY_ID);
-
- // Default to current function as subject of relationship
- if ($relation->subjectId == $this->resource->id || null ==
$relation->subjectId)
- {
- $relation->object = $relatedFunction;
- $this->resource->relationsRelatedBysubjectId[] = $relation;
- }
- else
- {
- $relation->subject = $relatedFunction;
- $this->resource->relationsRelatedByobjectId[] = $relation;
- }
- }
- }
-
public function execute($request)
{
parent::execute($request);
Modified:
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedResourceComponent.class.php
==============================================================================
---
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedResourceComponent.class.php
Mon Oct 18 09:25:02 2010 (r8223)
+++
trunk/plugins/sfIsdfPlugin/modules/sfIsdfPlugin/actions/relatedResourceComponent.class.php
Mon Oct 18 09:43:23 2010 (r8224)
@@ -28,78 +28,6 @@
'endDate',
'dateDisplay');
- protected function processForm()
- {
- if (isset($this->request["{$formName}s"]))
- {
- // JavaScript (multiple) relationship update
- $relationsData = $this->request["{$formName}s"];
- }
- else if (isset($this->request[$formName]))
- {
- // Non-JavaScript (single) relationship update
- $relationsData = array($this->request[$formName]);
- }
- else
- {
- return;
- }
-
- // Loop through relation rows
- foreach ($relationsData as $relationData)
- {
- // Get relation
- if (isset($relationData['id']))
- {
- $params =
$this->context->routing->parse(Qubit::pathInfo($relationData['id']));
-
- if (null === $relation = QubitRelation::getById($params['id']))
- {
- continue; // If we can't find an existing relation, skip this row
- }
- }
- else
- {
- $relation = new QubitRelation;
- }
-
- // Get related information object (resource)
- $params =
$this->context->routing->parse(Qubit::pathInfo($relationData['resource']));
- $objectId = (isset($params['id'])) ? $params['id'] : null;
-
- switch ($formName)
- {
- case 'relatedEntity':
- $object = QubitActor::getById($objectId);
-
- break;
-
- case 'relatedResource':
- $object = QubitInformationObject::getById($objectId);
-
- break;
- }
-
- if (null === $object)
- {
- continue; // If no related object, skip update
- }
- else
- {
- $relation->object = $object;
- }
-
- $relation->startDate = $relationData['startDate'];
- $relation->endDate = $relationData['endDate'];
-
- // Add notes
- $relation->updateNote($relationData['description'],
QubitTerm::RELATION_NOTE_DESCRIPTION_ID);
- $relation->updateNote($relationData['dateDisplay'],
QubitTerm::RELATION_NOTE_DATE_DISPLAY_ID);
-
- $this->resource->relationsRelatedBysubjectId[] = $relation;
- }
- }
-
public function execute($request)
{
parent::execute($request);
--
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.