|
TYPO3 API
SVNRelease
|
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 SWFOBJECT 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_ShockwaveFlashObject extends tslib_content_Abstract { 00037 00038 /** 00039 * Rendering the cObject, SWFOBJECT 00040 * 00041 * @param array Array of TypoScript properties 00042 * @return string Output 00043 */ 00044 public function render($conf = array()) { 00045 $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 00054 $type = isset($conf['type.']) 00055 ? $this->cObj->stdWrap($conf['type'], $conf['type.']) 00056 : $conf['type']; 00057 $typeConf = $conf[$type . '.']; 00058 00059 //add SWFobject js-file 00060 $GLOBALS['TSFE']->getPageRenderer()->addJsFile(TYPO3_mainDir . 'contrib/flashmedia/swfobject/swfobject.js'); 00061 00062 $player = isset($typeConf['player.']) 00063 ? $this->cObj->stdWrap($typeConf['player'], $typeConf['player.']) 00064 : $typeConf['player']; 00065 00066 $installUrl = isset($conf['installUrl.']) 00067 ? $this->cObj->stdWrap($conf['installUrl'], $conf['installUrl.']) 00068 : $conf['installUrl']; 00069 if(!$installUrl) { 00070 $installUrl = $prefix . TYPO3_mainDir . 'contrib/flashmedia/swfobject/expressInstall.swf'; 00071 } 00072 00073 $filename = isset($conf['file.']) 00074 ? $this->cObj->stdWrap($conf['file'], $conf['file.']) 00075 : $conf['file']; 00076 $forcePlayer = isset($conf['forcePlayer.']) 00077 ? $this->cObj->stdWrap($conf['forcePlayer'], $conf['forcePlayer.']) 00078 : $conf['forcePlayer']; 00079 00080 if ($filename && $forcePlayer) { 00081 if (strpos($filename, '://') !== FALSE) { 00082 $conf['flashvars.']['file'] = $filename; 00083 } else { 00084 if ($prefix) { 00085 $conf['flashvars.']['file'] = $prefix . $filename; 00086 } else { 00087 $conf['flashvars.']['file'] = str_repeat('../', substr_count($player, '/')) . $filename; 00088 } 00089 00090 } 00091 } else { 00092 $player = $filename; 00093 } 00094 // Write calculated values in conf for the hook 00095 $conf['player'] = $player; 00096 $conf['installUrl'] = $installUrl; 00097 $conf['filename'] = $filename; 00098 $conf['prefix'] = $prefix; 00099 00100 // merge with default parameters 00101 $conf['flashvars.'] = array_merge((array) $typeConf['default.']['flashvars.'], (array) $conf['flashvars.']); 00102 $conf['params.'] = array_merge((array) $typeConf['default.']['params.'], (array) $conf['params.']); 00103 $conf['attributes.'] = array_merge((array) $typeConf['default.']['attributes.'], (array) $conf['attributes.']); 00104 $conf['embedParams'] = 'flashvars, params, attributes'; 00105 00106 // Hook for manipulating the conf array, it's needed for some players like flowplayer 00107 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/hooks/class.tx_cms_mediaitems.php']['swfParamTransform'])) { 00108 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/hooks/class.tx_cms_mediaitems.php']['swfParamTransform'] as $classRef) { 00109 t3lib_div::callUserFunction($classRef, $conf, $this); 00110 } 00111 } 00112 if (is_array($conf['flashvars.'])) { 00113 t3lib_div::remapArrayKeys($conf['flashvars.'], $typeConf['mapping.']['flashvars.']); 00114 } 00115 $flashvars = 'var flashvars = ' . (count($conf['flashvars.']) ? json_encode($conf['flashvars.']) : '{}') . ';'; 00116 00117 if (is_array($conf['params.'])) { 00118 t3lib_div::remapArrayKeys($conf['params.'], $typeConf['mapping.']['params.']); 00119 } 00120 $params = 'var params = ' . (count($conf['params.']) ? json_encode($conf['params.']) : '{}') . ';'; 00121 00122 if (is_array($conf['attributes.'])) { 00123 t3lib_div::remapArrayKeys($conf['attributes.'], $typeConf['attributes.']['params.']); 00124 } 00125 $attributes = 'var attributes = ' . (count($conf['attributes.']) ? json_encode($conf['attributes.']) : '{}') . ';'; 00126 00127 $flashVersion = isset($conf['flashVersion.']) 00128 ? $this->cObj->stdWrap($conf['flashVersion'], $conf['flashVersion.']) 00129 : $conf['flashVersion']; 00130 00131 if (!$flashVersion) { 00132 $flashVersion = '9'; 00133 } 00134 00135 $replaceElementIdString = uniqid('mmswf'); 00136 $GLOBALS['TSFE']->register['MMSWFID'] = $replaceElementIdString; 00137 00138 $alternativeContent = isset($conf['alternativeContent.']) 00139 ? $this->cObj->stdWrap($conf['alternativeContent'], $conf['alternativeContent.']) 00140 : $conf['alternativeContent']; 00141 00142 $layout = isset($conf['layout.']) 00143 ? $this->cObj->stdWrap($conf['layout'], $conf['layout.']) 00144 : $conf['layout']; 00145 $layout = str_replace('###ID###', $replaceElementIdString, $layout); 00146 $layout = str_replace('###SWFOBJECT###', '<div id="' . $replaceElementIdString . '">' . $alternativeContent . '</div>', $layout); 00147 00148 $width = isset($conf['width.']) 00149 ? $this->cObj->stdWrap($conf['width'], $conf['width.']) 00150 : $conf['width']; 00151 if(!$width) { 00152 $width = $conf[$type . '.']['defaultWidth']; 00153 } 00154 00155 $height = isset($conf['height.']) 00156 ? $this->cObj->stdWrap($conf['height'], $conf['height.']) 00157 : $conf['height']; 00158 if(!$height) { 00159 $height = $conf[$type . '.']['defaultHeight']; 00160 } 00161 00162 00163 $embed = 'swfobject.embedSWF("' . $conf['player'] . '", "' . $replaceElementIdString . '", "' . $width . '", "' . $height . '", 00164 "' . $flashVersion . '", "' . $installUrl . '", ' . $conf['embedParams'] . ');'; 00165 00166 $content = $layout . ' 00167 <script type="text/javascript"> 00168 ' . $flashvars . ' 00169 ' . $params . ' 00170 ' . $attributes . ' 00171 ' . $embed . ' 00172 </script>'; 00173 00174 if (isset($conf['stdWrap.'])) { 00175 $content = $this->cObj->stdWrap($content, $conf['stdWrap.']); 00176 } 00177 00178 return $content; 00179 } 00180 00181 } 00182 00183 00184 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_shockwaveflashobject.php'])) { 00185 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_shockwaveflashobject.php']); 00186 } 00187 00188 ?>
1.8.0