Author: david
Date: Wed Sep 23 12:57:36 2009
New Revision: 3476
Log:
Split up and document two different digitalobject/edit form functions to
clarify the difference.
Modified:
trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php
Modified: trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php Wed Sep
23 12:20:33 2009 (r3475)
+++ trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php Wed Sep
23 12:57:36 2009 (r3476)
@@ -64,6 +64,7 @@
$this->form->setWidget('informationObject', new sfWidgetFormInputHidden);
// Get 'show as compound digital object' toggle value
+ /*
$compoundDigitalObject =
QubitProperty::getOneByObjectIdAndName($this->informationObject->getId(),
'display_as_compound_object');
if (!is_null($compoundDigitalObject))
{
@@ -85,9 +86,10 @@
break;
}
}
+ */
// Get related digital object with all representations
- if (count($this->digitalObject))
+ if (null !== $this->digitalObject)
{
$representations[QubitTerm::MASTER_ID] = $this->digitalObject;
$representations[QubitTerm::REFERENCE_ID] =
$this->digitalObject->getChildByUsageId(QubitTerm::REFERENCE_ID);
@@ -102,26 +104,40 @@
if ($this->form->isValid())
{
- $this->digitalObject->assets[] = new
QubitAsset($this->form->getValue('file')->getOriginalName(),
file_get_contents($this->form->getValue('file')->getTempName()));
-
- $this->informationObject->digitalObjects[] = $this->digitalObject;
+ if (null != $this->form->getValue('file'))
+ {
+ $this->uploadNewDigitalObject();
+ }
+ else
+ {
+ $this->updateDigitalObjects();
+ }
+ }
+ }
+ }
- $this->updateDigitalObjects();
+ /**
+ * Upload the asset selected by user and create a digital object with
appropriate
+ * representations.
+ *
+ * @return DigitalObjectEditAction this action
+ */
+ public function uploadNewDigitalObject()
+ {
+ $this->digitalObject->usageId = QubitTerm::MASTER_ID;
+ $this->digitalObject->assets[] = new
QubitAsset($this->form->getValue('file')->getOriginalName(),
file_get_contents($this->form->getValue('file')->getTempName()));
+ $this->informationObject->digitalObjects[] = $this->digitalObject;
+ $this->informationObject->save();
- $this->informationObject->save();
+ $this->redirect(array('module' => 'informationobject', 'action' => 'show',
'id' => $this->informationObject->id));
- $this->redirect(array('module' => 'informationobject', 'action' =>
'show', 'id' => $this->informationObject->id));
- }
- }
+ return $this;
}
/**
- * Add a new digital object to $informationObject, upload a digital asset,
- * and create a representation (thumbnail, icon) of asset.
+ * Update digital object properties, or upload new digital object
derivatives.
*
- * @param sfRequest The current sfRequest object
- * @param informationObject The associated informationObject
- * @return mixed array of file metadata on sucess, false on failure
+ * @return DigitalObjectEditAction this action
*/
public function updateDigitalObjects()
{
@@ -163,12 +179,6 @@
$this->informationObject->digitalObjects[] = $digitalObject;
- // If this is a new information object with no title, set title to name
- // of digital object
- if ($this->request->getParameter('action') == 'update' &&
$this->informationObject->getTitle(array('cultureFallback'=>true)) == null &&
$usageId == QubitTerm::MASTER_ID)
- {
- $this->informationObject->setTitle($digitalObject->getName());
- }
} // endforeach
} // end if
@@ -187,5 +197,7 @@
break;
}
}
- } // end function
+
+ return $this;
+ }
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---