Author: david
Date: Fri Sep 25 16:48:15 2009
New Revision: 3539
Log:
Commit fixes to digitalobject/edit.
Added:
trunk/apps/qubit/modules/digitalobject/templates/uploadFormSuccess.php
(contents, props changed)
- copied, changed from r3535,
trunk/apps/qubit/modules/digitalobject/templates/_upload.php
Deleted:
trunk/apps/qubit/modules/digitalobject/templates/_upload.php
Modified:
trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php
trunk/apps/qubit/modules/digitalobject/config/view.yml
trunk/apps/qubit/modules/digitalobject/templates/_editRepresentation.php
trunk/apps/qubit/modules/digitalobject/templates/editSuccess.php
Modified: trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php Fri Sep
25 15:30:10 2009 (r3538)
+++ trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php Fri Sep
25 16:48:15 2009 (r3539)
@@ -27,12 +27,64 @@
*/
class DigitalObjectEditAction extends sfAction
{
+ protected function addUpdateFormFields()
+ {
+ // Media type field
+ $choices = $validChoices = array();
+ $c = new Criteria;
+ $c->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::MEDIA_TYPE_ID,
Criteria::EQUAL);
+ if (null !== ($mediaTypeTerms = QubitTerm::get($c)))
+ {
+ foreach ($mediaTypeTerms as $mediaTypeTerm)
+ {
+ $choices[$mediaTypeTerm->id] =
$mediaTypeTerm->getName(array('cultureFallback' => true));
+ }
+
+ asort($choices); // Sort media types by name
+ }
+
+ $this->form->setValidator('mediaType', new
sfValidatorChoice(array('choices' => array_keys($choices))));
+ $this->form->setWidget('mediaType', new sfWidgetFormSelect(array('choices'
=> $choices)));
+ $this->form->setDefault('mediaType', $this->digitalObject->mediaTypeId);
+
+ // Only display 'compound digital object' toggle if we have a child with a
+ // digital object
+ $this->showCompoundObjectToggle = false;
+ foreach ($this->informationObject->getChildren() as $child)
+ {
+ if (null !== $child->getDigitalObject())
+ {
+ $this->showCompoundObjectToggle = true;
+ break;
+ }
+ }
+
+ if ($this->showCompoundObjectToggle)
+ {
+ $this->form->setValidator('isCompound', new sfValidatorPass);
+ $this->form->setWidget('isCompound', new sfWidgetFormSelectRadio(
+ array('choices' => array(
+ '1' => $this->getContext()->getI18N()->__('yes'),
+ '0' => $this->getContext()->getI18N()->__('no')
+ ))
+ ));
+ // Set 'isCompound' value from QubitProperty
+ $c = new Criteria;
+ $c->add(QubitProperty::OBJECT_ID, $this->digitalObject->id,
Criteria::EQUAL);
+ $c->add(QubitProperty::NAME, 'is_compound_object', Criteria::EQUAL);
+
+ if (null != ($compoundProperty = QubitProperty::getOne($c)))
+ {
+ $this->form->setDefault('isCompound',
$compoundProperty->getValue(array('sourceCulture' => true)));
+ }
+ }
+ }
+
public function execute($request)
{
$this->form = new sfForm;
$this->digitalObject = new QubitDigitalObject;
-
$this->informationObject = new QubitInformationObject;
if (isset($request->id))
@@ -45,61 +97,37 @@
}
$this->informationObject = $this->digitalObject->informationObject;
- }
- else
- {
- if (isset($request->informationObject))
- {
- $this->informationObject =
QubitInformationObject::getById($request->informationObject);
-
- // Check that object exists and that it is not the root
- if (!isset($this->informationObject) ||
!isset($this->informationObject->parent))
- {
- $this->forward404();
- }
- }
-
- $this->form->bind($request->getGetParameters(), $request->getFiles());
- }
-
- $this->form->setValidator('file', new sfValidatorFile);
- $this->form->setWidget('file', new sfWidgetFormInputFile);
- $this->form->setValidator('informationObject', new sfValidatorString);
- $this->form->setWidget('informationObject', new sfWidgetFormInputHidden);
+ $this->addUpdateFormFields();
- // Get 'show as compound digital object' toggle value
- /*
- $compoundDigitalObject =
QubitProperty::getOneByObjectIdAndName($this->informationObject->getId(),
'display_as_compound_object');
- if (!is_null($compoundDigitalObject))
- {
- $this->isCompoundDigitalObject =
($compoundDigitalObject->getValue(array('sourceCulture' => true))) ? true :
false;
+ // Get related digital object with all representations
+ if (null !== $this->digitalObject)
+ {
+ $representations[QubitTerm::REFERENCE_ID] =
$this->digitalObject->getChildByUsageId(QubitTerm::REFERENCE_ID);
+ $representations[QubitTerm::THUMBNAIL_ID] =
$this->digitalObject->getChildByUsageId(QubitTerm::THUMBNAIL_ID);
+ $this->representations = $representations;
+ }
}
- else
+ else if (isset($request->informationObject))
{
- $this->isCompoundDigitalObject = false;
- }
+ $this->informationObject =
QubitInformationObject::getById($request->informationObject);
- // Only display 'compound digital object' toggle if we have a child with a
- // digital object
- $this->showCompoundObjectToggle = false;
- foreach ($this->informationObject->getChildren() as $child)
- {
- if (null !== $child->getDigitalObject())
+ // Check that object exists and that it is not the root
+ if (!isset($this->informationObject) ||
!isset($this->informationObject->parent))
{
- $this->showCompoundObjectToggle = true;
- break;
+ $this->forward404();
}
- }
- */
- // Get related digital object with all representations
- if (null !== $this->digitalObject)
- {
- $representations[QubitTerm::MASTER_ID] = $this->digitalObject;
- $representations[QubitTerm::REFERENCE_ID] =
$this->digitalObject->getChildByUsageId(QubitTerm::REFERENCE_ID);
- $representations[QubitTerm::THUMBNAIL_ID] =
$this->digitalObject->getChildByUsageId(QubitTerm::THUMBNAIL_ID);
- $this->representations = $representations;
+ $this->form->setValidator('file', new sfValidatorFile);
+ $this->form->setWidget('file', new sfWidgetFormInputFile);
+
+ $this->form->setValidator('informationObject', new sfValidatorPass);
+ $this->form->setWidget('informationObject', new sfWidgetFormInputHidden);
+ $this->form->setDefault('informationObject',
$this->informationObject->id);
+
+ $this->maxUploadSize = QubitDigitalObject::getMaxUploadSize();
+
+ $this->setTemplate('uploadForm');
}
if ($request->isMethod('post'))
@@ -114,7 +142,8 @@
}
else
{
- $this->updateDigitalObjects();
+ $this->processForm();
+ $this->redirect(array('module' => 'informationobject', 'action' =>
'show', 'id' => $this->informationObject->id));
}
}
}
@@ -143,24 +172,19 @@
*
* @return DigitalObjectEditAction this action
*/
- public function updateDigitalObjects()
+ public function processForm()
{
// Set property 'display_as_compound_object'
- if ($this->request->hasParameter('display_as_compound_object'))
+ if ($isCompound = $this->form->getValue('isCompound'))
{
-
$this->informationObject->setDisplayAsCompoundObject($this->request->getParameter('display_as_compound_object'));
+ $this->digital->setDisplayAsCompoundObject($isCompound);
}
// Update media type
- if ($this->request->hasParameter('media_type_id'))
- {
- $digitalObject = $this->informationObject->getDigitalObject();
-
$digitalObject->setMediaTypeId($this->request->getParameter('media_type_id'));
- $digitalObject->save();
- }
+ $this->digitalObject->mediaTypeId = $this->form->getValue('mediaType');
- // Do digital object upload
- if (is_array($uploadedFiles = $this->request->getFile('upload_file')))
+ // Upload new representations
+ if (false && null !== ($uploadedFiles = $this->form->getFiles()))
{
foreach ($uploadedFiles['name'] as $usageId => $filename)
{
@@ -186,12 +210,10 @@
} // endforeach
} // end if
- // Generate a derivative
- if ($this->request->hasParameter('createDerivative'))
+ // Generate new derivatives from existing MASTER
+ if (null != ($createDeriviates =
$this->form->getValue('createDerivative')))
{
- $digitalObject = $this->informationObject->getDigitalObject();
-
- switch ($this->request->getParameter('createDerivative'))
+ switch ($createDerivative)
{
case QubitTerm::REFERENCE_ID:
$digitalObject->createReferenceImage();
@@ -202,6 +224,8 @@
}
}
+ $this->digitalObject->save();
+
return $this;
}
}
Modified: trunk/apps/qubit/modules/digitalobject/config/view.yml
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/config/view.yml Fri Sep 25
15:30:10 2009 (r3538)
+++ trunk/apps/qubit/modules/digitalobject/config/view.yml Fri Sep 25
16:48:15 2009 (r3539)
@@ -1,5 +1,8 @@
+editSuccess:
+ javascripts: [/sfDrupalPlugin/vendor/drupal/misc/collapse]
+
showFullScreenSuccess:
layout: layout_fullscreen
components:
all: []
- bottomBanner: [sfTranslatePlugin, translate]
\ No newline at end of file
+ bottomBanner: [sfTranslatePlugin, translate]
Modified:
trunk/apps/qubit/modules/digitalobject/templates/_editRepresentation.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/_editRepresentation.php
Fri Sep 25 15:30:10 2009 (r3538)
+++ trunk/apps/qubit/modules/digitalobject/templates/_editRepresentation.php
Fri Sep 25 16:48:15 2009 (r3539)
@@ -4,11 +4,9 @@
<tr>
<th colspan="2">
<?php echo __('%1% representation', array('%1%' =>
$representation->getUsage())); ?>
- <?php if (QubitTerm::MASTER_ID != $representation->usageId): ?>
<?php echo link_to(
image_tag('/images/delete.png', array('style'=>'vertical-align:
middle')),
'digitalobject/delete?id='.$representation->getId(),
array('confirm'=>$confirmDeleteString)); ?>
- <?php endif; ?>
</th>
</tr>
<tr>
@@ -24,16 +22,6 @@
</td>
<td style="padding: 0px; margin: 0px;">
<table style="width: 350px; padding: 0px; margin: 0px">
- <?php if ($representation->getUsageId() == QubitTerm::MASTER_ID): ?>
- <tr>
- <td style="border: 0px none">
- <label for="mediatype"><?php echo __('media type'); ?></label>
- <?php echo object_select_tag($digitalObject, 'getMediaTypeId',
- array('related_class' => 'QubitTerm', 'peer_method' =>
'getMediaTypes'
- )) ?>
- </td>
- </tr>
- <?php endif; ?>
<tr>
<td>
<label for="filename"><?php echo __('filename'); ?></label>
Modified: trunk/apps/qubit/modules/digitalobject/templates/editSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/editSuccess.php Fri Sep
25 15:30:10 2009 (r3538)
+++ trunk/apps/qubit/modules/digitalobject/templates/editSuccess.php Fri Sep
25 16:48:15 2009 (r3539)
@@ -1,11 +1,43 @@
<h1><?php echo __('Edit digital object') ?></h1>
+
<div class="headerCell"><?php if (0 < (strlen($label =
$informationObject->getLabel()))): ?><?php echo $label ?><?php endif; ?></div>
-<?php if (isset($sf_request->id)): ?>
+<?php if (null != ($reference =
$digitalObject->getRepresentationByUsage(QubitTerm::REFERENCE_ID))): ?>
+<div class="form-item" style="text-align: center">
+<?php echo image_tag($reference->getFullPath(), array('alt' => __('reference
representation'))) ?>
+<?php endif; ?>
+</div>
- <?php echo $form->renderFormTag(url_for(array('module' => 'digitalobject',
'action' => 'edit', 'id' => $sf_request->id))) ?>
+<?php echo $form->renderFormTag(url_for(array('module' => 'digitalobject',
'action' => 'edit', 'id' => $sf_request->id))) ?>
+<?php echo $form->renderHiddenFields() ?>
+<fieldset class="collapsible">
+ <legend><?php echo __('Master') ?></legend>
+
+ <div class="form-item">
+ <label for="filename"><?php echo __('filename'); ?></label>
+ <?php echo $digitalObject->getName() ?>
+ </div>
+
+ <div class="form-item">
+ <label for="filesize"><?php echo __('filesize'); ?></label>
+ <?php echo hr_filesize($digitalObject->getByteSize()) ?>
+ </div>
+
+ <div class="form-item">
+ <?php echo $form->mediaType->renderRow() ?>
+ </div>
+
+ <?php if ($showCompoundObjectToggle): ?>
+ <div class="form-item">
+ <?php echo $form->isCompound->renderErrors() ?>
+ <?php echo $form->isCompound->label(__('view children as a compound
digital object?'))->renderLabel() ?>
+ <?php echo $form->isCompound->render() ?>
+ </div>
+ <?php endif; ?>
+</fieldset>
- <?php echo $form->renderHiddenFields() ?>
+<fieldset class="collapsible collapsed">
+ <legend><?php echo __('Representations') ?></legend>
<?php foreach ($representations as $usageId => $representation): ?>
<?php if (is_object($representation) && $representation->getId()): ?>
@@ -19,7 +51,10 @@
</tr>
<tr style="border-bottom: 1px solid #CCC">
<td>
- <?php include_component('digitalobject', 'upload',
array('usageId'=>$usageId)); ?><br />
+ <?php echo __('Select a %1% to upload',
array('%1%'=>sfConfig::get('app_ui_label_digitalobject'))) ?>
+ <span class="note"><?php echo __('max. size ~%1%', array('%1%' =>
hr_filesize($maxUploadSize))) ?></span>
+ <?php echo input_file_tag('upload_file['.$usageId.']', 'size=40');
?>
+
<?php if ($digitalObject->canThumbnail()): ?>
<?php echo __('<i>or</i> Auto-generate a new representation from
master image'); ?>
<?php echo checkbox_tag('createDerivative', $usageId, false,
array('class'=>'checkbox')); ?>
@@ -30,35 +65,14 @@
</div>
<?php endif; ?>
<?php endforeach; ?>
-
-<?php else: ?>
-
- <?php echo $form->renderFormTag(url_for(array('module' => 'digitalobject',
'action' => 'create'))) ?>
-
- <?php echo $form->renderHiddenFields() ?>
-
- <?php echo $form->file->label(__('Select a %1% to upload', array('%1%' =>
sfConfig::get('app_ui_label_digitalobject'))))->renderRow() ?>
-
-<?php endif; ?>
-
-<?php if ($showCompoundObjectToggle): ?>
-<div class="form-item">
- <label for="display_as_compound_object"><?php echo __('view children as a
compound digital object?') ?></label>
- <?php echo radiobutton_tag('display_as_compound_object', '1',
$isCompoundDigitalObject); ?> <?php echo __('yes') ?><br />
- <?php echo radiobutton_tag('display_as_compound_object', '0',
!$isCompoundDigitalObject) ?> <?php echo __('no') ?>
-</div>
-<?php endif; ?>
+</fieldset>
<ul class="actions">
<?php if (isset($sf_request->id)): ?>
<li><?php echo link_to(__('Delete'), array('module' => 'digitalobject',
'action' => 'delete', 'id' => $digitalObject->id)) ?></li>
<?php endif; ?>
<li><?php echo link_to(__('Cancel'), array('module' =>
'informationobject', 'action' => 'show', 'id' => $informationObject->id))
?></li>
- <?php if (isset($sf_request->id)): ?>
- <li><?php echo submit_tag(__('Save')) ?></li>
- <?php else: ?>
- <li><?php echo submit_tag(__('Create')) ?></li>
- <?php endif; ?>
+ <li><?php echo submit_tag(__('Save')) ?></li>
</ul>
</form>
Copied and modified:
trunk/apps/qubit/modules/digitalobject/templates/uploadFormSuccess.php (from
r3535, trunk/apps/qubit/modules/digitalobject/templates/_upload.php)
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/_upload.php Fri Sep
25 13:12:31 2009 (r3535, copy source)
+++ trunk/apps/qubit/modules/digitalobject/templates/uploadFormSuccess.php
Fri Sep 25 16:48:15 2009 (r3539)
@@ -1,3 +1,18 @@
-<?php echo __('Select a %1% to upload',
array('%1%'=>sfConfig::get('app_ui_label_digitalobject'))) ?>
-<span class="note"><?php echo __('max. size ~%1%', array('%1%' =>
hr_filesize($maxUploadSize))) ?></span>
-<?php echo input_file_tag('upload_file['.$usageId.']', 'size=40'); ?>
\ No newline at end of file
+<h1><?php echo __('Upload digital object') ?></h1>
+<div class="headerCell"><?php if (0 < (strlen($label =
$informationObject->getLabel()))): ?><?php echo $label ?><?php endif; ?></div>
+
+<?php echo $form->renderFormTag(url_for(array('module' => 'digitalobject',
'action' => 'create'))) ?>
+<input type="hidden" name="informationObject" value="<?php echo
$informationObject->id ?>" />
+
+<div class="form-item"
+<?php echo $form->file->label(__('Select a digital object to
upload'))->renderLabel() ?>
+<?php echo $form->file->render() ?>
+<span class="note"><?php echo __('max. file size ~%1%', array('%1%' =>
hr_filesize($maxUploadSize))) ?></span>
+</div>
+
+<ul class="actions">
+ <li><?php echo link_to(__('Cancel'), array('module' => 'informationobject',
'action' => 'show', 'id' => $informationObject->id)) ?></li>
+ <li><?php echo submit_tag(__('Create')) ?></li>
+</ul>
+
+</form>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---