TYPO3 API  SVNRelease
class.tslib_content_quicktimeobject.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003  *  Copyright notice
00004  *
00005  *  (c) 2010-2011 Xavier Perseguers <typo3@perseguers.ch>
00006  *  (c) 2010-2011 Steffen Kamper <steffen@typo3.org>
00007  *  All rights reserved
00008  *
00009  *  This script is part of the TYPO3 project. The TYPO3 project is
00010  *  free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  The GNU General Public License can be found at
00016  *  http://www.gnu.org/copyleft/gpl.html.
00017  *  A copy is found in the textfile GPL.txt and important notices to the license
00018  *  from the author is found in LICENSE.txt distributed with these scripts.
00019  *
00020  *
00021  *  This script is distributed in the hope that it will be useful,
00022  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  *  GNU General Public License for more details.
00025  *
00026  *  This copyright notice MUST APPEAR in all copies of the script!
00027  ***************************************************************/
00028 
00029 /**
00030  * Contains QTOBJECT class object.
00031  *
00032  * $Id: class.tslib_content.php 7905 2010-06-13 14:42:33Z ohader $
00033  * @author Xavier Perseguers <typo3@perseguers.ch>
00034  * @author Steffen Kamper <steffen@typo3.org>
00035  */
00036 class tslib_content_QuicktimeObject extends tslib_content_Abstract {
00037 
00038     /**
00039      * Rendering the cObject, QTOBJECT
00040      *
00041      * @param   array       Array of TypoScript properties
00042      * @return  string      Output
00043      */
00044     public function render($conf = array()) {
00045         $params = $prefix = '';
00046         if ($GLOBALS['TSFE']->baseUrl) {
00047             $prefix = $GLOBALS['TSFE']->baseUrl;
00048         }
00049         if ($GLOBALS['TSFE']->absRefPrefix) {
00050             $prefix = $GLOBALS['TSFE']->absRefPrefix;
00051         }
00052 
00053         $filename = isset( $conf['file.'])
00054             ? $this->cObj->stdWrap($conf['file'], $conf['file.'])
00055             : $conf['file'];
00056 
00057         $type = isset( $conf['type.'])
00058             ? $this->cObj->stdWrap($conf['type'], $conf['type.'])
00059             : $conf['type'];
00060 
00061         $typeConf = $conf[$type . '.'];
00062 
00063             //add QTobject js-file
00064         $GLOBALS['TSFE']->getPageRenderer()->addJsFile(TYPO3_mainDir . 'contrib/flashmedia/qtobject/qtobject.js');
00065         $replaceElementIdString = uniqid('mmqt');
00066         $GLOBALS['TSFE']->register['MMQTID'] = $replaceElementIdString;
00067         $qtObject = 'QTObject' . $replaceElementIdString;
00068 
00069         // merge with default parameters
00070         $conf['params.'] = array_merge((array) $typeConf['default.']['params.'], (array) $conf['params.']);
00071 
00072         if (is_array($conf['params.'])) {
00073             t3lib_div::remapArrayKeys($conf['params.'], $typeConf['mapping.']['params.']);
00074             foreach ($conf['params.'] as $key => $value) {
00075                 $params .= $qtObject . '.addParam("' . $key . '", "' . $value . '");' . LF;
00076             }
00077         }
00078         $params = ($params ? substr($params, 0, -2) : '') . LF . $qtObject . '.write("' . $replaceElementIdString . '");';
00079 
00080         $alternativeContent = isset($conf['alternativeContent.'])
00081             ? $this->cObj->stdWrap($conf['alternativeContent'], $conf['alternativeContent.'])
00082             :  $conf['alternativeContent'];
00083 
00084         $layout = isset($conf['layout.'])
00085             ? $this->cObj->stdWrap($conf['layout'], $conf['layout.'])
00086             : $conf['layout'];
00087         $layout = str_replace('###ID###', $replaceElementIdString, $layout);
00088         $layout = str_replace('###QTOBJECT###', '<div id="' . $replaceElementIdString . '">' . $alternativeContent . '</div>', $layout);
00089 
00090         $width = isset($conf['width.'])
00091             ? $this->cObj->stdWrap($conf['width'], $conf['width.'])
00092             : $conf['width'];
00093         if(!$width) {
00094             $width = $conf[$type . '.']['defaultWidth'];
00095         }
00096 
00097         $height = isset($conf['height.'])
00098             ? $this->cObj->stdWrap($conf['height'], $conf['height.'])
00099             : $conf['height'];
00100         if(!$height) {
00101             $height = $conf[$type . '.']['defaultHeight'];
00102         }
00103 
00104         $embed = 'var ' . $qtObject . ' = new QTObject("' . $prefix . $filename . '", "' .
00105             $replaceElementIdString . '", "' . $width . '", "' . $height . '");';
00106 
00107         $content = $layout . '
00108             <script type="text/javascript">
00109                 ' . $embed . '
00110                 ' . $params . '
00111             </script>';
00112 
00113         if (isset($conf['stdWrap.'])) {
00114             $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
00115         }
00116 
00117         return $content;
00118     }
00119 
00120 }
00121 
00122 
00123 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_quicktimeobject.php'])) {
00124     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_quicktimeobject.php']);
00125 }
00126 
00127 ?>