Author: jablko
Date: Tue Oct 12 17:07:24 2010
New Revision: 8074

Log:
Hard coded parameter names are unnecessary

Modified:
   
trunk/apps/qubit/modules/informationobject/actions/eventFormComponent.class.php

Modified: 
trunk/apps/qubit/modules/informationobject/actions/eventFormComponent.class.php
==============================================================================
--- 
trunk/apps/qubit/modules/informationobject/actions/eventFormComponent.class.php 
    Tue Oct 12 16:46:28 2010        (r8073)
+++ 
trunk/apps/qubit/modules/informationobject/actions/eventFormComponent.class.php 
    Tue Oct 12 17:07:24 2010        (r8074)
@@ -39,80 +39,84 @@
 
     foreach ($updatedEvents as $item)
     {
-      if (0 < strlen($item['actor'])
-          || 0 < strlen($item['dateDisplay'])
-          || 0 < strlen($item['description'])
-          || 0 < strlen($item['endDate'])
-          || 0 < strlen($item['place'])
-          || 0 < strlen($item['startDate'])
-          || 0 < strlen($item['type']))
+      foreach ($item as $value)
       {
-        $event = new QubitEvent;
-        if (isset($item['id']) && !isset($this->request->sourceId))
+        if (0 < strlen($value))
         {
-          $params = 
$this->context->routing->parse(Qubit::pathInfo($item['id']));
-          $event = $params['_sf_route']->resource;
+          break;
         }
+      }
+
+      if (1 > strlen($value))
+      {
+        continue;
+      }
+
+      $event = new QubitEvent;
+      if (isset($item['id']) && !isset($this->request->sourceId))
+      {
+        $params = $this->context->routing->parse(Qubit::pathInfo($item['id']));
+        $event = $params['_sf_route']->resource;
+      }
 
-        $this->form->bind($item);
-        if ($this->form->isValid())
+      $this->form->bind($item);
+      if ($this->form->isValid())
+      {
+        // Use existing actor if one is selected (overrides new actor creation)
+        if (0 < strlen($item['actor']))
         {
-          // Use existing actor if one is selected (overrides new actor 
creation)
-          if (0 < strlen($item['actor']))
-          {
-            $params = 
$this->context->routing->parse(Qubit::pathInfo($item['actor']));
-            $event->actorId = $params['id'];
-          }
+          $params = 
$this->context->routing->parse(Qubit::pathInfo($item['actor']));
+          $event->actorId = $params['id'];
+        }
 
-          $event->startDate = $item['startDate'];
-          $event->endDate = $item['endDate'];
-          $event->dateDisplay = $item['dateDisplay'];
+        $event->startDate = $item['startDate'];
+        $event->endDate = $item['endDate'];
+        $event->dateDisplay = $item['dateDisplay'];
 
-          if (0 < strlen($item['type']))
-          {
-            $params = 
$this->context->routing->parse(Qubit::pathInfo($item['type']));
-            $event->typeId = $params['id'];
-          }
+        if (0 < strlen($item['type']))
+        {
+          $params = 
$this->context->routing->parse(Qubit::pathInfo($item['type']));
+          $event->typeId = $params['id'];
+        }
 
-          if (0 < strlen($item['description']))
-          {
-            $event->description = $item['description'];
-          }
-          else
-          {
-            unset($event->description);
-          }
+        if (0 < strlen($item['description']))
+        {
+          $event->description = $item['description'];
+        }
+        else
+        {
+          unset($event->description);
+        }
 
-          // Save the event if it's valid (has an actor OR date)
-          if (0 < strlen($item['actor'])
-            || 0 < strlen($item['startDate'])
-            || 0 < strlen($item['endDate'])
-            || 0 < strlen($item['dateDisplay']))
+        // Save the event if it's valid (has an actor OR date)
+        if (0 < strlen($item['actor'])
+          || 0 < strlen($item['startDate'])
+          || 0 < strlen($item['endDate'])
+          || 0 < strlen($item['dateDisplay']))
+        {
+          // Update the "place" object term relation object
+          if (0 < strlen($item['place']))
           {
-            // Update the "place" object term relation object
-            if (0 < strlen($item['place']))
+            // If this event didn't exist or didn't have a 'place' associated
+            if (null === $event->id || null === ($place = 
QubitObjectTermRelation::getOneByObjectId($event->id)))
             {
-              // If this event didn't exist or didn't have a 'place' associated
-              if (null === $event->id || null === ($place = 
QubitObjectTermRelation::getOneByObjectId($event->id)))
-              {
-                $place = new QubitObjectTermRelation;
-              }
-
-              $params = 
$this->context->routing->parse(Qubit::pathInfo($item['place']));
-              $place->termId = $params['id'];
-
-              $event->objectTermRelationsRelatedByobjectId[] = $place;
+              $place = new QubitObjectTermRelation;
             }
 
-            // Or delete an existing "place" object term relation, if it's no
-            // longer needed
-            else if (0 < $event->getId() && null !== ($place = 
QubitObjectTermRelation::getOneByObjectId($event->getId())))
-            {
-              $place->delete();
-            }
+            $params = 
$this->context->routing->parse(Qubit::pathInfo($item['place']));
+            $place->termId = $params['id'];
 
-            $this->resource->events[] = $event;
+            $event->objectTermRelationsRelatedByobjectId[] = $place;
           }
+
+          // Or delete an existing "place" object term relation, if it's no
+          // longer needed
+          else if (0 < $event->getId() && null !== ($place = 
QubitObjectTermRelation::getOneByObjectId($event->getId())))
+          {
+            $place->delete();
+          }
+
+          $this->resource->events[] = $event;
         }
       }
     }

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