Author: jablko
Date: Mon Oct 18 21:03:25 2010
New Revision: 8268

Log:
Process remaining fields

Modified:
   
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/actions/relatedAuthorityRecordComponent.class.php

Modified: 
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/actions/relatedAuthorityRecordComponent.class.php
==============================================================================
--- 
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/actions/relatedAuthorityRecordComponent.class.php
 Mon Oct 18 20:56:30 2010        (r8267)
+++ 
trunk/plugins/sfIsaarPlugin/modules/sfIsaarPlugin/actions/relatedAuthorityRecordComponent.class.php
 Mon Oct 18 21:03:25 2010        (r8268)
@@ -57,82 +57,55 @@
   {
     switch ($field->getName())
     {
-      default:
+      case 'resource':
 
-        return parent::processField($field);
-    }
-  }
+        // 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);
+        }
 
-  public function processForm()
-  {
-    if (isset($this->request->relatedActors))
-    {
-      // JavaScript (multiple) update
-      $relationsData = $this->request->relatedActors;
-    }
-    else if (isset($this->request->relatedActor))
-    {
-      // Non-JavaScript (single) update
-      $relationsData = array($this->request->relatedActor);
-    }
-    else
-    {
-      return;
-    }
+        $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;
+          }
+        }
 
-    // Loop through related actors
-    foreach ($relationsData as $relationData)
-    {
-      // Get related actor
-      $params = 
$this->context->routing->parse(Qubit::pathInfo($relationData['resource']));
-      $relatedObjectId = (isset($params['id'])) ? $params['id'] : null;
-      if (null === $relatedObject = QubitActor::getById($relatedObjectId))
-      {
-        continue; // If no related object, skip update
-      }
+        break;
 
-      // Get relation
-      if (isset($relationData['id']))
-      {
-        $params = 
$this->context->routing->parse(Qubit::pathInfo($relationData['id']));
+      case 'type':
+        unset($this->relation->type);
 
-        if (null === $relation = QubitRelation::getById($params['id']))
+        $value = $this->form->getValue('type');
+        if (isset($value))
         {
-          // If a relation id is passed, but relation object doesn't exist then
-          // skip this row
-          continue;
+          $params = $this->context->routing->parse(Qubit::pathInfo($value));
+          $this->relation->type = $params['_sf_route']->resource;
         }
-      }
-      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);
+        break;
 
-      // Default to current actor as the subject of the relationship
-      if ($relation->subjectId == $this->resource->id || null == 
$relation->subjectId)
-      {
-        $relation->object = $relatedObject;
-        $this->resource->relationsRelatedBysubjectId[] = $relation;
-      }
-      else
-      {
-        $relation->subject = $relatedObject;
-        $this->resource->relationsRelatedByobjectId[] = $relation;
-      }
+      default:
+
+        return parent::processField($field);
     }
+  }
 
+  public function processForm()
+  {
     if (isset($this->request->deleteRelations))
     {
       foreach ($this->request->deleteRelations as $item)

-- 
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.

Reply via email to