|
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 MEDIA 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_Media extends tslib_content_Abstract { 00037 00038 /** 00039 * Rendering the cObject, MEDIA 00040 * 00041 * @param array Array of TypoScript properties 00042 * @return string Output 00043 */ 00044 public function render($conf = array()) { 00045 $content = ''; 00046 $flexParams = isset($conf['flexParams.']) 00047 ? $this->cObj->stdWrap($conf['flexParams'], $conf['flexParams.']) 00048 : $conf['flexParams']; 00049 if (substr($flexParams, 0, 1) === '<') { 00050 // it is a content element 00051 $this->cObj->readFlexformIntoConf($flexParams, $conf['parameter.']); 00052 $url = isset($conf['file.']) 00053 ? $this->cObj->stdWrap($conf['parameter.']['mmFile'], $conf['file.']) 00054 : $conf['parameter.']['mmFile']; 00055 $mmFile = $url; 00056 } else { 00057 // it is a TS object 00058 $url = isset($conf['file.']) 00059 ? $this->cObj->stdWrap($conf['file'], $conf['file.']) 00060 : $conf['file']; 00061 } 00062 00063 $mode = is_file(PATH_site . $url) ? 'file' : 'url'; 00064 if ($mode === 'file') { 00065 // render FILE 00066 $filename = $GLOBALS['TSFE']->tmpl->getFileName($url); 00067 $fileinfo = t3lib_div::split_fileref($filename); 00068 $conf['file'] = $filename; 00069 } else { 00070 // render URL 00071 // use media wizard to extract video from URL 00072 $mediaWizard = tslib_mediaWizardManager::getValidMediaWizardProvider($url); 00073 if ($mediaWizard !== NULL) { 00074 $url = $mediaWizard->rewriteUrl($url); 00075 } 00076 $conf['file'] = $this->cObj->typoLink_URL(array( 00077 'parameter' => $url 00078 )); 00079 } 00080 00081 $renderType = isset($conf['renderType.']) 00082 ? $this->cObj->stdWrap($conf['renderType'], $conf['renderType.']) 00083 : $conf['renderType']; 00084 $mmRenderType = isset($conf['parameter.']['mmRenderType.']) 00085 ? $this->cObj->stdWrap($conf['parameter.']['mmRenderType'], $conf['parameter.']['mmRenderType.']) 00086 : $conf['parameter.']['mmRenderType']; 00087 if ($mmRenderType) { 00088 $renderType = $mmRenderType; 00089 } 00090 if ($renderType === 'auto') { 00091 // default renderType is swf 00092 $renderType = 'swf'; 00093 $handler = array_keys($conf['fileExtHandler.']); 00094 if (in_array($fileinfo['fileext'], $handler)) { 00095 $renderType = strtolower($conf['fileExtHandler.'][$fileinfo['fileext']]); 00096 } 00097 } 00098 00099 $mmForcePlayer = isset($conf['parameter.']['mmforcePlayer.']) 00100 ? $this->cObj->stdWrap($conf['parameter.']['mmforcePlayer'], $conf['parameter.']['mmforcePlayer.']) 00101 : $conf['parameter.']['mmforcePlayer']; 00102 00103 $forcePlayer = $mmFile ? intval($mmForcePlayer) : $conf['forcePlayer']; 00104 $conf['forcePlayer'] = isset($conf['forcePlayer.']) 00105 ? $this->cObj->stdWrap($forcePlayer, $conf['forcePlayer.']) 00106 : $forcePlayer; 00107 00108 $mmType = isset($conf['parameter.']['mmType.']) 00109 ? $this->cObj->stdWrap($conf['parameter.']['mmType'], $conf['parameter.']['mmType.']) 00110 : $conf['parameter.']['mmType']; 00111 00112 $type = isset($conf['type.']) 00113 ? $this->cObj->stdWrap($conf['type'], $conf['type.']) 00114 : $conf['type']; 00115 00116 $conf['type'] = $mmType ? $mmType : $type; 00117 $mime = $renderType . 'object'; 00118 $typeConf = $conf['mimeConf.'][$mime . '.'][$conf['type'] . '.'] ? $conf['mimeConf.'][$mime . '.'][$conf['type'] . '.'] : array(); 00119 $conf['predefined'] = array(); 00120 00121 $width = isset($conf['parameter.']['mmWidth.']) 00122 ? intval($this->cObj->stdWrap($conf['parameter.']['mmWidth'], $conf['parameter.']['mmWidth.'])) 00123 : intval($conf['parameter.']['mmWidth']); 00124 $height = isset($conf['parameter.']['mmHeight.']) 00125 ? intval($this->cObj->stdWrap($conf['parameter.']['mmHeight'], $conf['parameter.']['mmHeight.'])) 00126 : intval($conf['parameter.']['mmHeight']); 00127 if ($width) { 00128 $conf['width'] = $width; 00129 } else { 00130 $width = isset($conf['width.']) 00131 ? intval($this->cObj->stdWrap($conf['width'], $conf['width.'])) 00132 : intval($conf['width']); 00133 $conf['width'] = $width ? $width : $typeConf['defaultWidth']; 00134 } 00135 if ($height) { 00136 $conf['height'] = $height; 00137 } else { 00138 $height = isset($conf['height.']) 00139 ? intval($this->cObj->stdWrap($conf['height'], $conf['height.'])) 00140 : intval($conf['height']); 00141 $conf['height'] = $height ? $height : $typeConf['defaultHeight']; 00142 } 00143 00144 if (is_array($conf['parameter.']['mmMediaOptions'])) { 00145 $params = array(); 00146 foreach ($conf['parameter.']['mmMediaOptions'] as $key => $value) { 00147 if ($key == 'mmMediaCustomParameterContainer') { 00148 foreach ($value as $val) { 00149 //custom parameter entry 00150 $rawTS = $val['mmParamCustomEntry']; 00151 //read and merge 00152 $tmp = t3lib_div::trimExplode(LF, $rawTS); 00153 if (count($tmp)) { 00154 foreach ($tmp as $tsLine) { 00155 if (substr($tsLine, 0, 1) != '#' && $pos = strpos($tsLine, '.')) { 00156 $parts[0] = substr($tsLine, 0, $pos); 00157 $parts[1] = substr($tsLine, $pos + 1); 00158 $valueParts = t3lib_div::trimExplode('=', $parts[1], TRUE); 00159 00160 switch (strtolower($parts[0])) { 00161 case 'flashvars' : 00162 $conf['flashvars.'][$valueParts[0]] = $valueParts[1]; 00163 break; 00164 case 'params' : 00165 $conf['params.'][$valueParts[0]] = $valueParts[1]; 00166 break; 00167 case 'attributes' : 00168 $conf['attributes.'][$valueParts[0]] = $valueParts[1]; 00169 break; 00170 } 00171 } 00172 } 00173 } 00174 } 00175 } elseif ($key == 'mmMediaOptionsContainer') { 00176 foreach ($value as $val) { 00177 if (isset($val['mmParamSet'])) { 00178 $pName = $val['mmParamName']; 00179 $pSet = $val['mmParamSet']; 00180 $pValue = $pSet == 2 ? $val['mmParamValue'] : ($pSet == 0 ? 'false' : 'true'); 00181 $conf['predefined'][$pName] = $pValue; 00182 } 00183 } 00184 } 00185 } 00186 } 00187 00188 // render MEDIA 00189 if ($mode == 'url' && !$forcePlayer) { 00190 // url is called direct, not with player 00191 if ($url == '' && !$conf['allowEmptyUrl']) { 00192 return '<p style="background-color: yellow;">' . $GLOBALS['TSFE']->sL('LLL:EXT:cms/locallang_ttc.xml:media.noFile', TRUE) . '</p>'; 00193 } 00194 $conf = array_merge((array) $conf['mimeConf.']['swfobject.'], $conf); 00195 $conf[$conf['type'] . '.']['player'] = strpos($url, '://') === FALSE ? 'http://' . $url : $url; 00196 $conf['installUrl'] = 'null'; 00197 $conf['flashvars'] = array_merge((array) $conf['flashvars'], $conf['predefined']); 00198 } 00199 00200 switch ($renderType) { 00201 case 'swf' : 00202 $conf[$conf['type'] . '.'] = array_merge((array) $conf['mimeConf.']['swfobject.'][$conf['type'] . '.'], $typeConf); 00203 $conf = array_merge((array) $conf['mimeConf.']['swfobject.'], $conf); 00204 unset($conf['mimeConf.']); 00205 $conf['flashvars.'] = array_merge((array) $conf['flashvars.'], $conf['predefined']); 00206 $content = $this->cObj->SWFOBJECT($conf); 00207 break; 00208 case 'qt' : 00209 $conf[$conf['type'] . '.'] = array_merge($conf['mimeConf.']['swfobject.'][$conf['type'] . '.'], $typeConf); 00210 $conf = array_merge($conf['mimeConf.']['qtobject.'], $conf); 00211 unset($conf['mimeConf.']); 00212 $conf['params.'] = array_merge((array) $conf['params.'], $conf['predefined']); 00213 $content = $this->cObj->QTOBJECT($conf); 00214 break; 00215 case 'embed' : 00216 $paramsArray = array_merge((array) $typeConf['default.']['params.'], (array) $conf['params.'], $conf['predefined']); 00217 $conf['params'] = ''; 00218 foreach ($paramsArray as $key => $value) { 00219 $conf['params'] .= $key . '=' . $value . LF; 00220 } 00221 $content = $this->cObj->MULTIMEDIA($conf); 00222 break; 00223 default : 00224 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/hooks/class.tx_cms_mediaitems.php']['customMediaRender'])) { 00225 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/hooks/class.tx_cms_mediaitems.php']['customMediaRender'] as $classRef) { 00226 $hookObj = t3lib_div::getUserObj($classRef); 00227 $conf['file'] = $url; 00228 $conf['mode'] = $mode; 00229 $content = $hookObj->customMediaRender($renderType, $conf, $this); 00230 } 00231 } 00232 } 00233 00234 if (isset($conf['stdWrap.'])) { 00235 $content = $this->cObj->stdWrap($content, $conf['stdWrap.']); 00236 } 00237 00238 return $content; 00239 } 00240 00241 } 00242 00243 00244 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_media.php'])) { 00245 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_media.php']); 00246 } 00247 00248 ?>
1.8.0