Author: sevein
Date: Wed Aug 17 11:56:08 2011
New Revision: 9518
Log:
More progress adding support for multiple editRightComponents in the same form
Modified:
trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php
trunk/apps/qubit/modules/digitalobject/templates/editSuccess.php
trunk/apps/qubit/modules/right/actions/editComponent.class.php
Modified: trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php Wed Aug
17 10:33:22 2011 (r9517)
+++ trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php Wed Aug
17 11:56:08 2011 (r9518)
@@ -76,6 +76,11 @@
}
}
+ // Add rights component
+ $this->rightEditComponent = new RightEditComponent($this->context,
'right', 'edit');
+ $this->rightEditComponent->resource = $this->resource;
+ $this->rightEditComponent->execute($this->request);
+
$maxUploadSize = QubitDigitalObject::getMaxUploadSize();
ProjectConfiguration::getActive()->loadHelpers('Qubit');
@@ -109,6 +114,7 @@
{
$this["rightEditComponent_$usageId"] = new
RightEditComponent($this->context, 'right', 'edit');
$this["rightEditComponent_$usageId"]->resource = $representation;
+ $this["rightEditComponent_$usageId"]->nameFormat =
'editRight'.$usageId.'[%s]';
$this["rightEditComponent_$usageId"]->execute($this->request);
}
}
@@ -246,12 +252,28 @@
*/
public function processUpdateForm()
{
+ /*
+ echo "<pre>";
+ var_dump($_POST);
+ die();
+ */
+
// Set property 'displayAsCompound'
$this->resource->setDisplayAsCompoundObject($this->form->getValue('displayAsCompound'));
// Update media type
$this->resource->mediaTypeId = $this->form->getValue('mediaType');
+ // Process master rights component
+ $this->rightEditComponent->processForm();
+
+ // Process reference/thumbnail rights components
+ foreach ($this->representations as $usageId => $representation)
+ {
+ $this["rightEditComponent_$usageId"]->processForm();
+ $representation->save();
+ }
+
// Upload new representations
$uploadedFiles = array();
foreach ($this->representations as $usageId => $representation)
@@ -260,9 +282,6 @@
{
$uploadedFiles[$usageId] = $uf;
}
-
- $this["rightEditComponent_$usageId"]->processForm();
- $representation->save();
}
foreach ($uploadedFiles as $usageId => $uploadFile)
Modified: trunk/apps/qubit/modules/digitalobject/templates/editSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/editSuccess.php Wed Aug
17 10:33:22 2011 (r9517)
+++ trunk/apps/qubit/modules/digitalobject/templates/editSuccess.php Wed Aug
17 11:56:08 2011 (r9518)
@@ -30,6 +30,8 @@
->renderRow() ?>
<?php endif; ?>
+ <?php echo get_partial('right/edit',
$rightEditComponent->getVarHolder()->getAll()) ?>
+
</fieldset>
<?php foreach ($representations as $usageId => $representation): ?>
Modified: trunk/apps/qubit/modules/right/actions/editComponent.class.php
==============================================================================
--- trunk/apps/qubit/modules/right/actions/editComponent.class.php Wed Aug
17 10:33:22 2011 (r9517)
+++ trunk/apps/qubit/modules/right/actions/editComponent.class.php Wed Aug
17 11:56:08 2011 (r9518)
@@ -161,9 +161,13 @@
public function processForm()
{
- if (isset($this->request->editRights))
+ if (isset($this->nameFormat))
+ {
+ $name = preg_replace('/\[.*\]/', 's', $this->nameFormat);
+ $params = $this->request[$name];
+ }
+ else
{
- // If dialog JavaScript did it's work, then use array of parameters
$params = $this->request->editRights;
}
@@ -237,7 +241,15 @@
{
$this->form = new sfForm;
$this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
- $this->form->getWidgetSchema()->setNameFormat('editRight[%s]');
+
+ if (isset($this->nameFormat))
+ {
+ $this->form->getWidgetSchema()->setNameFormat($this->nameFormat);
+ }
+ else
+ {
+ $this->form->getWidgetSchema()->setNameFormat('editRight[%s]');
+ }
foreach ($this::$NAMES as $name)
{
--
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.