Author: sevein Date: Mon Sep 21 15:17:57 2009 New Revision: 3462 Log: Add support for audio representation (issue 236). Inspiration from showVideo component.
Added: trunk/apps/qubit/modules/digitalobject/actions/showAudioComponent.class.php (contents, props changed) trunk/apps/qubit/modules/digitalobject/templates/_showAudio.php (contents, props changed) Modified: trunk/apps/qubit/modules/digitalobject/actions/showComponent.class.php Added: trunk/apps/qubit/modules/digitalobject/actions/showAudioComponent.class.php ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/apps/qubit/modules/digitalobject/actions/showAudioComponent.class.php Mon Sep 21 15:17:57 2009 (r3462) @@ -0,0 +1,75 @@ +<?php + +/* + * This file is part of Qubit Toolkit. + * + * Qubit Toolkit is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * Qubit Toolkit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * Digital Object video display component + * + * @package qubit + * @subpackage digitalObject + * @author Jesús García Crespo <[email protected]> + * @version SVN: $Id + */ +class DigitalObjectShowAudioComponent extends sfComponent +{ + /** + * Show a representation of a digital object image. + * + * @param sfWebRequest $request + * + */ + public function execute($request) + { + $this->getResponse()->addJavaScript('/vendor/jquery'); + $this->getResponse()->addJavaScript('/vendor/flowplayer/flashembed.min.js'); + $this->getResponse()->addJavaScript('/vendor/flowplayer/flow.embed.js'); + $this->getResponse()->addStylesheet('flowPlayer'); + + $this->pathToFlowPlayer = public_path('flowplayer/FlowPlayerDark.swf'); + + // Get representation by usage type + $this->representation = $this->digitalObject->getRepresentationByUsage(QubitTerm::MASTER_ID); + + // If we can't find a representation for this object, try their parent + if (!$this->representation && ($parent = $this->digitalObject->getParent())) + { + $this->representation = $parent->getRepresentationByUsage(QubitTerm::MASTER_ID); + } + + // Set up display of video in flowplayer + if ($this->representation) + { + // If this is a reference movie, get the thumbnail representation for the + // place holder image + $this->showFlashPlayer = true; + + if ($this->usageType == QubitTerm::REFERENCE_ID) + { + $this->thumbnail = $this->digitalObject->getRepresentationByUsage(QubitTerm::THUMBNAIL_ID); + } + + list($this->width, $this->height) = QubitDigitalObject::getImageMaxDimensions($this->usageType); + } + // If representation is not a valid digital object, return a generic icon + else + { + $this->showFlashPlayer = false; + $this->representation = QubitDigitalObject::getGenericRepresentation($this->digitalObject->getMimeType(), $this->usageType); + } + } +} \ No newline at end of file Modified: trunk/apps/qubit/modules/digitalobject/actions/showComponent.class.php ============================================================================== --- trunk/apps/qubit/modules/digitalobject/actions/showComponent.class.php Mon Sep 21 15:06:49 2009 (r3461) +++ trunk/apps/qubit/modules/digitalobject/actions/showComponent.class.php Mon Sep 21 15:17:57 2009 (r3462) @@ -56,13 +56,13 @@ $this->showComponent = 'showDownload'; } break; - //case QubitTerm::AUDIO_ID: - //$this->showComponent = 'showAudio'; - //break; + case QubitTerm::AUDIO_ID: + $this->showComponent = 'showAudio'; + break; case QubitTerm::VIDEO_ID: $this->showComponent = 'showVideo'; break; - case (QubitTerm::TEXT_ID): + case QubitTerm::TEXT_ID: $this->showComponent = 'showText'; break; default: Added: trunk/apps/qubit/modules/digitalobject/templates/_showAudio.php ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/apps/qubit/modules/digitalobject/templates/_showAudio.php Mon Sep 21 15:17:57 2009 (r3462) @@ -0,0 +1,27 @@ +<?php use_helper('Javascript') ?> + + <?php if ($showFlashPlayer): ?> + <?php echo javascript_tag(<<<EOF + // select all link tags with "flowplayer" class and "video-enable" them. + $(function() { + $("a.flowplayer").flowembed("$pathToFlowPlayer", { + + }); + }); +EOF + ) ?> + + <a id="flowplayer" class="flowplayer" href="<?php echo public_path($representation->getFullPath()) ?>"> + <?php // echo image_tag($thumbnail->getFullPath()) ?> + <img src="/~jesus/qubit/web/images/generic-icons/blank.png" /> + </a> +<?php else: ?> + <div style="text-align: center"> + <?php echo image_tag($representation->getFullPath(), array('style' => 'border: #999 1px solid')) ?> + </div> +<?php endif;?> + + <!-- link to download master --> + <?php if ($link != null): ?> + <?php echo link_to(__('download audio'),$link) ?> + <?php endif; ?> \ No newline at end of file --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
