Author: jablko
Date: Thu Oct 28 02:52:16 2010
New Revision: 8622
Log:
Use $route->resource, fixes issue 1858
Modified:
trunk/apps/qubit/modules/digitalobject/actions/browseAction.class.php
trunk/apps/qubit/modules/digitalobject/actions/deleteAction.class.php
trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php
trunk/apps/qubit/modules/digitalobject/actions/multiFileUploadAction.class.php
trunk/apps/qubit/modules/digitalobject/actions/showVideoComponent.class.php
trunk/apps/qubit/modules/digitalobject/actions/updateAction.class.php
trunk/apps/qubit/modules/digitalobject/actions/uploadAction.class.php
trunk/apps/qubit/modules/digitalobject/templates/_imageflow.php
trunk/apps/qubit/modules/digitalobject/templates/_showAudio.php
trunk/apps/qubit/modules/digitalobject/templates/_showCompound.php
trunk/apps/qubit/modules/digitalobject/templates/_showImage.php
trunk/apps/qubit/modules/digitalobject/templates/_showVideo.php
trunk/apps/qubit/modules/digitalobject/templates/deleteSuccess.php
trunk/apps/qubit/modules/digitalobject/templates/editSuccess.php
trunk/apps/qubit/modules/digitalobject/templates/listSuccess.php
trunk/apps/qubit/modules/digitalobject/templates/multiFileUploadSuccess.php
Modified: trunk/apps/qubit/modules/digitalobject/actions/browseAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/actions/browseAction.class.php
Thu Oct 28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/actions/browseAction.class.php
Thu Oct 28 02:52:16 2010 (r8622)
@@ -29,8 +29,12 @@
{
public function execute($request)
{
- $this->mediaType = QubitTerm::getById($request->mediatype);
+ if (!isset($request->limit))
+ {
+ $request->limit = sfConfig::get('app_hits_per_page');
+ }
+ $this->mediaType = QubitTerm::getById($request->mediatype);
if (!$this->mediaType instanceOf QubitTerm)
{
$this->forward404();
@@ -44,11 +48,6 @@
// Sort by name ascending
$criteria->addAscendingOrderByColumn(QubitDigitalObject::NAME);
- if (!isset($request->limit))
- {
- $request->limit = sfConfig::get('app_hits_per_page');
- }
-
// Filter draft descriptions
$criteria = QubitAcl::addFilterDraftsCriteria($criteria);
Modified: trunk/apps/qubit/modules/digitalobject/actions/deleteAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/actions/deleteAction.class.php
Thu Oct 28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/actions/deleteAction.class.php
Thu Oct 28 02:52:16 2010 (r8622)
@@ -31,22 +31,22 @@
{
$this->form = new sfForm();
- $this->resource = QubitDigitalObject::getById($request->id);
-
- // Check that object exists
- $this->forward404Unless($this->resource);
+ $this->resource = $this->getRoute()->resource;
// Get related information object by first grabbing top-level digital
// object
$parent = $this->resource->parent;
- if (null == $parent)
+ if (isset($parent))
{
- $this->informationObject = $this->resource->informationObject;
- $this->forward404Unless($this->informationObject);
+ $this->informationObject = $parent->informationObject;
}
else
{
- $this->informationObject = $parent->informationObject;
+ $this->informationObject = $this->resource->informationObject;
+ if (!isset($this->informationObject))
+ {
+ $this->forward404();
+ }
}
// Check user authorization
@@ -61,7 +61,7 @@
$this->resource->delete();
// Redirect to edit page for parent Info Object
- if (null !== $parent)
+ if (isset($parent))
{
$this->redirect(array($parent, 'module' => 'digitalobject', 'action'
=> 'edit'));
}
Modified: trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php Thu Oct
28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/actions/editAction.class.php Thu Oct
28 02:52:16 2010 (r8622)
@@ -30,7 +30,7 @@
protected function addFormFields()
{
// Media type field
- $choices = $validChoices = array();
+ $choices = array();
$criteria = new Criteria;
$criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::MEDIA_TYPE_ID);
foreach (QubitTerm::get($criteria) as $item)
@@ -96,20 +96,16 @@
$this->form = new sfForm;
$this->resource = new QubitDigitalObject;
+
$this->informationObject = new QubitInformationObject;
// Get max upload size limits
$this->maxUploadSize = QubitDigitalObject::getMaxUploadSize();
// If digital object already exists (template: edit)
- if (isset($request->id))
+ if (isset($this->getRoute()->resource))
{
- $this->resource = QubitDigitalObject::getById($request->id);
-
- if (!isset($this->resource))
- {
- $this->forward404();
- }
+ $this->resource = $this->getRoute()->resource;
$this->informationObject = $this->resource->informationObject;
@@ -122,8 +118,7 @@
// Get representations
$this->representations = array(
QubitTerm::REFERENCE_ID =>
$this->resource->getChildByUsageId(QubitTerm::REFERENCE_ID),
- QubitTerm::THUMBNAIL_ID =>
$this->resource->getChildByUsageId(QubitTerm::THUMBNAIL_ID)
- );
+ QubitTerm::THUMBNAIL_ID =>
$this->resource->getChildByUsageId(QubitTerm::THUMBNAIL_ID));
$this->addFormFields();
}
@@ -140,7 +135,7 @@
}
// Check if already exists a digital object
- if (null !== ($digitalObject =
$this->informationObject->getDigitalObject()))
+ if (null !== $digitalObject =
$this->informationObject->getDigitalObject())
{
$this->redirect(array($digitalObject, 'module' => 'digitalobject',
'action' => 'edit'));
}
@@ -181,7 +176,6 @@
if ($request->isMethod('post'))
{
$this->form->bind($request->getPostParameters(), $request->getFiles());
-
if ($this->form->isValid())
{
if (null !== $this->form->getValue('file') || null !==
$this->form->getValue('url'))
@@ -220,6 +214,7 @@
}
$this->informationObject->digitalObjects[] = $this->resource;
+
$this->informationObject->save();
$this->redirect(array($this->informationObject, 'module' =>
'informationobject'));
@@ -233,8 +228,7 @@
public function processUpdateForm()
{
// Set property 'displayAsCompound'
- $displayAsCompound = $this->form->getValue('displayAsCompound');
- $this->resource->setDisplayAsCompoundObject($displayAsCompound);
+
$this->resource->setDisplayAsCompoundObject($this->form->getValue('displayAsCompound'));
// Update media type
$this->resource->mediaTypeId = $this->form->getValue('mediaType');
@@ -243,7 +237,7 @@
$uploadedFiles = array();
foreach ($this->representations as $usageId => $representation)
{
- if (null !== ($uf = $this->form->getValue("repFile_$usageId")))
+ if (null !== $uf = $this->form->getValue("repFile_$usageId"))
{
$uploadedFiles[$usageId] = $uf;
}
@@ -278,6 +272,7 @@
$representation->assets[] = new
QubitAsset($uploadFile->getOriginalName(), $content);
$representation->parentId = $this->resource->id;
$representation->createDerivatives = false;
+
$representation->save();
}
Modified:
trunk/apps/qubit/modules/digitalobject/actions/multiFileUploadAction.class.php
==============================================================================
---
trunk/apps/qubit/modules/digitalobject/actions/multiFileUploadAction.class.php
Thu Oct 28 02:33:59 2010 (r8621)
+++
trunk/apps/qubit/modules/digitalobject/actions/multiFileUploadAction.class.php
Thu Oct 28 02:52:16 2010 (r8622)
@@ -104,7 +104,7 @@
if (0 < strlen($title = $file['infoObjectTitle']))
{
- $informationObject->setTitle($title);
+ $informationObject->title = $title;
}
if (0 != intval($levelOfDescriptionId =
$this->form->getValue('level_of_description_id')))
Modified:
trunk/apps/qubit/modules/digitalobject/actions/showVideoComponent.class.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/actions/showVideoComponent.class.php
Thu Oct 28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/actions/showVideoComponent.class.php
Thu Oct 28 02:52:16 2010 (r8622)
@@ -53,7 +53,7 @@
// If this is a reference movie, get the thumbnail representation for the
// place holder image
$this->showFlashPlayer = true;
- if ($this->usageType == QubitTerm::REFERENCE_ID)
+ if (QubitTerm::REFERENCE_ID == $this->usageType)
{
$this->thumbnail =
$this->resource->getRepresentationByUsage(QubitTerm::THUMBNAIL_ID);
}
Modified: trunk/apps/qubit/modules/digitalobject/actions/updateAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/actions/updateAction.class.php
Thu Oct 28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/actions/updateAction.class.php
Thu Oct 28 02:52:16 2010 (r8622)
@@ -30,8 +30,7 @@
{
public function execute($request)
{
- $this->resource = QubitDigitalObject::getById($this->request->id);
- $this->forward404Unless($this->resource);
+ $this->resource = $this->getRoute()->resource;
// Check user authorization
if (!QubitAcl::check($this->resource->informationObject, 'update'))
Modified: trunk/apps/qubit/modules/digitalobject/actions/uploadAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/actions/uploadAction.class.php
Thu Oct 28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/actions/uploadAction.class.php
Thu Oct 28 02:52:16 2010 (r8622)
@@ -47,14 +47,13 @@
$extension = substr($file['name'], strrpos($file['name'], '.'));
// Get a unique file name (to avoid clashing file names)
- $tmpFileName = null;
- $tmpFilePath = null;
- while (file_exists($tmpFilePath) || null === $tmpFileName)
+ do
{
$uniqueString = substr(md5(time().$file['name']), 0, 8);
$tmpFileName = "TMP$uniqueString$extension";
$tmpFilePath = "$tmpDir/$tmpFileName";
}
+ while (file_exists($tmpFilePath))
// Thumbnail name
$thumbName = "THB$uniqueString.jpg";
@@ -74,7 +73,7 @@
if ($canThumbnail =
QubitDigitalObject::canThumbnailMimeType($tmpFileMimeType) ||
QubitDigitalObject::isVideoFile($tmpFilePath))
{
- if (QubitDigitalObject::isImageFile($tmpFilePath) || $tmpFileMimeType
== 'application/pdf')
+ if (QubitDigitalObject::isImageFile($tmpFilePath) || 'application/pdf'
== $tmpFileMimeType)
{
$resizedObject = QubitDigitalObject::resizeImage($tmpFilePath, 150,
150);
}
Modified: trunk/apps/qubit/modules/digitalobject/templates/_imageflow.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/_imageflow.php Thu Oct
28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/templates/_imageflow.php Thu Oct
28 02:52:16 2010 (r8622)
@@ -2,7 +2,7 @@
<div>
<h3><?php echo sfConfig::get('app_ui_label_digitalobject') ?></h3>
- <div id="imageflow" class="imageflow">
+ <div class="imageflow" id="imageflow">
<?php foreach ($thumbnails as $item): ?>
<?php echo image_tag($item->getFullPath(), array('longdesc' =>
url_for(array($item->parent->informationObject, 'module' =>
'informationobject')), 'alt' =>
render_title(truncate_text($item->parent->informationObject, 28)))) ?>
<?php endforeach; ?>
Modified: trunk/apps/qubit/modules/digitalobject/templates/_showAudio.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/_showAudio.php Thu Oct
28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/templates/_showAudio.php Thu Oct
28 02:52:16 2010 (r8622)
@@ -23,12 +23,15 @@
<?php else: ?>
<div class="digitalObject">
+
<div class="digitalObjectRep">
<?php echo link_to(image_tag('play'), $link) ?>
</div>
+
<div class="digitalObjectDesc">
<?php echo wrap_text($digitalObject->name, 18) ?>
</div>
+
</div>
<?php endif; ?>
Modified: trunk/apps/qubit/modules/digitalobject/templates/_showCompound.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/_showCompound.php Thu Oct
28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/templates/_showCompound.php Thu Oct
28 02:52:16 2010 (r8622)
@@ -1,25 +1,27 @@
<table class="compound_digiobj">
+ <tbody>
- <tr>
- <td>
- <?php if (null !== $representation =
$leftObject->getCompoundRepresentation()): ?>
- <?php echo link_to_if(SecurityPriviliges::editCredentials($sf_user,
'informationObject') || QubitTerm::TEXT_ID == $resource->mediaType->id,
image_tag($representation->getFullPath()),
public_path($leftObject->getFullPath(), array('title' => __('View full
size')))) ?>
- <?php endif; ?>
- </td><td>
- <?php if (null !== $rightObject && null !== $representation =
$rightObject->getCompoundRepresentation()): ?>
- <?php echo link_to_if(SecurityPriviliges::editCredentials($sf_user,
'informationObject') || QubitTerm::TEXT_ID == $resource->mediaType->id,
image_tag($representation->getFullPath()),
public_path($rightObject->getFullPath(), array('title' => __('View full
size')))) ?>
- <?php endif; ?>
- </td>
- </tr>
-
- <?php if (SecurityPriviliges::editCredentials($sf_user,
'informationObject')): ?>
<tr>
- <td colspan="2" class="download_link">
- <?php echo link_to(__('Download %1%', array('%1%' => $resource)),
public_path($resource->getFullPath())) ?>
+ <td>
+ <?php if (null !== $representation =
$leftObject->getCompoundRepresentation()): ?>
+ <?php echo link_to_if(SecurityPriviliges::editCredentials($sf_user,
'informationObject') || QubitTerm::TEXT_ID == $resource->mediaType->id,
image_tag($representation->getFullPath()),
public_path($leftObject->getFullPath(), array('title' => __('View full
size')))) ?>
+ <?php endif; ?>
+ </td><td>
+ <?php if (null !== $rightObject && null !== $representation =
$rightObject->getCompoundRepresentation()): ?>
+ <?php echo link_to_if(SecurityPriviliges::editCredentials($sf_user,
'informationObject') || QubitTerm::TEXT_ID == $resource->mediaType->id,
image_tag($representation->getFullPath()),
public_path($rightObject->getFullPath(), array('title' => __('View full
size')))) ?>
+ <?php endif; ?>
</td>
</tr>
- <?php endif; ?>
+ <?php if (SecurityPriviliges::editCredentials($sf_user,
'informationObject')): ?>
+ <tr>
+ <td colspan="2" class="download_link">
+ <?php echo link_to(__('Download %1%', array('%1%' => $resource)),
public_path($resource->getFullPath())) ?>
+ </td>
+ </tr>
+ <?php endif; ?>
+
+ </tbody>
</table>
<?php echo get_partial('default/pager', array('pager' => $pager)) ?>
Modified: trunk/apps/qubit/modules/digitalobject/templates/_showImage.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/_showImage.php Thu Oct
28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/templates/_showImage.php Thu Oct
28 02:52:16 2010 (r8622)
@@ -20,18 +20,21 @@
<?php else: ?>
- <div class="digitalObject">
- <div class="digitalObjectRep">
- <?php if (isset($link)): ?>
- <?php echo link_to(image_tag($representation->getFullPath()), $link) ?>
- <?php else: ?>
- <?php echo image_tag($representation->getFullPath()) ?>
- <?php endif; ?>
- </div>
- <div class="digitalObjectDesc">
- <?php echo wrap_text($resource->name, 18) ?>
+ <div class="digitalObject">
+
+ <div class="digitalObjectRep">
+ <?php if (isset($link)): ?>
+ <?php echo link_to(image_tag($representation->getFullPath()), $link)
?>
+ <?php else: ?>
+ <?php echo image_tag($representation->getFullPath()) ?>
+ <?php endif; ?>
+ </div>
+
+ <div class="digitalObjectDesc">
+ <?php echo wrap_text($resource->name, 18) ?>
+ </div>
+
</div>
- </div>
<?php endif; ?>
Modified: trunk/apps/qubit/modules/digitalobject/templates/_showVideo.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/_showVideo.php Thu Oct
28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/templates/_showVideo.php Thu Oct
28 02:52:16 2010 (r8622)
@@ -23,14 +23,14 @@
<?php echo link_to(__('Download movie'), $link) ?>
<?php endif; ?>
-<?php elseif ($usageType == QubitTerm::THUMBNAIL_ID): ?>
+<?php elseif (QubitTerm::THUMBNAIL_ID == $usageType): ?>
<?php if ($iconOnly): ?>
- <?php if ($link == null): ?>
- <?php echo image_tag($representation->getFullPath()); ?>
- <?php else: ?>
+ <?php if (isset($link)): ?>
<?php echo link_to(image_tag($representation->getFullPath()), $link) ?>
+ <?php else: ?>
+ <?php echo image_tag($representation->getFullPath()); ?>
<?php endif; ?>
<?php else: ?>
Modified: trunk/apps/qubit/modules/digitalobject/templates/deleteSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/deleteSuccess.php Thu Oct
28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/templates/deleteSuccess.php Thu Oct
28 02:52:16 2010 (r8622)
@@ -12,12 +12,15 @@
<div class="content">
<ul class="clearfix links">
+
<?php if (isset($resource->parent)): ?>
<li><?php echo link_to(__('Cancel'), array($resource->parent,
'module' => 'digitalobject', 'action' => 'edit')) ?></li>
<?php else: ?>
<li><?php echo link_to(__('Cancel'), array($resource, 'module' =>
'digitalobject', 'action' => 'edit')) ?></li>
<?php endif; ?>
+
<li><input class="form-submit" type="submit" value="<?php echo
__('Confirm') ?>"/></li>
+
</ul>
</div>
Modified: trunk/apps/qubit/modules/digitalobject/templates/editSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/editSuccess.php Thu Oct
28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/templates/editSuccess.php Thu Oct
28 02:52:16 2010 (r8622)
@@ -38,13 +38,15 @@
<?php if (isset($representation)): ?>
<?php echo get_component('digitalobject', 'editRepresentation',
array('resource' => $resource, 'representation' => $representation)) ?>
<?php else: ?>
- <div class="form-item">
- <table>
+ <table>
+ <thead>
<tr>
<th>
<?php echo __('Add a new %1% representation', array('%1%' =>
QubitTerm::getById($usageId))) ?>
</th>
- </tr><tr>
+ </tr>
+ </thead><tbody>
+ <tr>
<td>
<?php echo __('Select a digital object to upload') ?>
@@ -62,8 +64,8 @@
</td>
</tr>
- </table>
- </div>
+ </tbody>
+ </table>
<?php endif; ?>
<?php endforeach; ?>
Modified: trunk/apps/qubit/modules/digitalobject/templates/listSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/listSuccess.php Thu Oct
28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/templates/listSuccess.php Thu Oct
28 02:52:16 2010 (r8622)
@@ -10,14 +10,14 @@
</th>
</tr>
</thead><tbody>
- <?php foreach ($terms as $term): ?>
+ <?php foreach ($terms as $item): ?>
<tr class="<?php echo 0 == ++$row % 2 ? 'even' : 'odd' ?>">
<td>
<div style="padding-left: 17px;">
- <?php echo link_to($term->getName(array('cultureFallback'=>true)),
array('module' => 'digitalobject', 'action' => 'browse', 'mediatype' =>
$term->id)) ?>
+ <?php echo link_to($item->getName(array('cultureFallback'=>true)),
array('module' => 'digitalobject', 'action' => 'browse', 'mediatype' =>
$item->id)) ?>
</div>
</td><td>
- <?php echo QubitDigitalObject::getCount($term->id); ?>
+ <?php echo QubitDigitalObject::getCount($item->id); ?>
</td>
</tr>
<?php endforeach; ?>
Modified:
trunk/apps/qubit/modules/digitalobject/templates/multiFileUploadSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/digitalobject/templates/multiFileUploadSuccess.php
Thu Oct 28 02:33:59 2010 (r8621)
+++ trunk/apps/qubit/modules/digitalobject/templates/multiFileUploadSuccess.php
Thu Oct 28 02:52:16 2010 (r8622)
@@ -39,11 +39,8 @@
<div id="uiElements" style="display: inline;">
<div id="uploaderContainer">
-
<div id="uploaderOverlay" style="position: absolute; z-index:
2;"></div>
-
<div id="selectFilesLink" style="z-index: 1"><a id="selectLink"
href="#">Select files</a></div>
-
</div>
</div>
@@ -55,11 +52,8 @@
<div class="content">
<ul class="clearfix links">
-
<li><?php echo link_to(__('Cancel'), array($informationObject,
'module' => 'informationobject')) ?></li>
-
<li><input class="form-submit" type="submit" value="<?php echo
__('Import') ?>"/></li>
-
</ul>
</div>
--
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.