本文整理汇总了PHP中TYPO3\CMS\Core\Utility\ArrayUtility::remapArrayKeys方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtility::remapArrayKeys方法的具体用法?PHP ArrayUtility::remapArrayKeys怎么用?PHP ArrayUtility::remapArrayKeys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\ArrayUtility
的用法示例。
在下文中一共展示了ArrayUtility::remapArrayKeys方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Rendering the cObject, QTOBJECT
*
* @param array $conf Array of TypoScript properties
* @return string Output
*/
public function render($conf = array())
{
$params = $prefix = '';
if ($GLOBALS['TSFE']->baseUrl) {
$prefix = $GLOBALS['TSFE']->baseUrl;
}
if ($GLOBALS['TSFE']->absRefPrefix) {
$prefix = $GLOBALS['TSFE']->absRefPrefix;
}
$type = isset($conf['type.']) ? $this->cObj->stdWrap($conf['type'], $conf['type.']) : $conf['type'];
// If file is audio and an explicit path has not been set,
// take path from audio fallback property
if ($type == 'audio' && empty($conf['file'])) {
$conf['file'] = $conf['audioFallback'];
}
$filename = isset($conf['file.']) ? $this->cObj->stdWrap($conf['file'], $conf['file.']) : $conf['file'];
$typeConf = $conf[$type . '.'];
// Add QTobject js-file
$GLOBALS['TSFE']->getPageRenderer()->addJsFile($this->getPathToLibrary('flashmedia/qtobject/qtobject.js'));
$replaceElementIdString = str_replace('.', '', uniqid('mmqt', TRUE));
$GLOBALS['TSFE']->register['MMQTID'] = $replaceElementIdString;
$qtObject = 'QTObject' . $replaceElementIdString;
// Merge with default parameters
$conf['params.'] = array_merge((array) $typeConf['default.']['params.'], (array) $conf['params.']);
if (is_array($conf['params.']) && is_array($typeConf['mapping.']['params.'])) {
ArrayUtility::remapArrayKeys($conf['params.'], $typeConf['mapping.']['params.']);
foreach ($conf['params.'] as $key => $value) {
$params .= $qtObject . '.addParam("' . $key . '", "' . $value . '");' . LF;
}
}
$params = ($params ? substr($params, 0, -2) : '') . LF . $qtObject . '.write("' . $replaceElementIdString . '");';
$alternativeContent = isset($conf['alternativeContent.']) ? $this->cObj->stdWrap($conf['alternativeContent'], $conf['alternativeContent.']) : $conf['alternativeContent'];
$layout = str_replace(array('###ID###', '###QTOBJECT###'), array($replaceElementIdString, '<div id="' . $replaceElementIdString . '">' . $alternativeContent . '</div>'), isset($conf['layout.']) ? $this->cObj->stdWrap($conf['layout'], $conf['layout.']) : $conf['layout']);
$width = isset($conf['width.']) ? $this->cObj->stdWrap($conf['width'], $conf['width.']) : $conf['width'];
if (!$width) {
$width = $conf[$type . '.']['defaultWidth'];
}
$height = isset($conf['height.']) ? $this->cObj->stdWrap($conf['height'], $conf['height.']) : $conf['height'];
if (!$height) {
$height = $conf[$type . '.']['defaultHeight'];
}
$fullFilename = $filename;
// If the file name doesn't contain a scheme, prefix with appropriate data
if (strpos($filename, '://') === FALSE && !empty($prefix)) {
$fullFilename = $prefix . $filename;
}
$embed = 'var ' . $qtObject . ' = new QTObject("' . $fullFilename . '", "' . $replaceElementIdString . '", "' . $width . '", "' . $height . '");';
$content = $layout . '
<script type="text/javascript">
' . $embed . '
' . $params . '
</script>';
if (isset($conf['stdWrap.'])) {
$content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
}
return $content;
}
示例2: render
//.........这里部分代码省略.........
if (is_array($conf['audioSources'])) {
foreach ($conf['audioSources'] as $key => $source) {
if (strpos($source, '://') === FALSE) {
$conf['audioSources'][$key] = $prefix . $source;
}
}
}
if (isset($conf['audioFallback']) && strpos($conf['audioFallback'], '://') === FALSE) {
$conf['audioFallback'] = $prefix . $conf['audioFallback'];
}
if (isset($conf['caption']) && strpos($conf['caption'], '://') === FALSE) {
$conf['caption'] = $prefix . $conf['caption'];
}
// Write calculated values in conf for the hook
$conf['player'] = $player ?: $filename;
$conf['installUrl'] = $installUrl;
$conf['filename'] = $conf['flashvars.']['url'];
$conf['prefix'] = $prefix;
// merge with default parameters
$conf['flashvars.'] = array_merge((array) $typeConf['default.']['flashvars.'], (array) $conf['flashvars.']);
$conf['params.'] = array_merge((array) $typeConf['default.']['params.'], (array) $conf['params.']);
$conf['attributes.'] = array_merge((array) $typeConf['default.']['attributes.'], (array) $conf['attributes.']);
$conf['embedParams'] = 'flashvars, params, attributes';
// Hook for manipulating the conf array, it's needed for some players like flowplayer
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/hooks/class.tx_cms_mediaitems.php']['swfParamTransform'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/hooks/class.tx_cms_mediaitems.php']['swfParamTransform'] as $classRef) {
\TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($classRef, $conf, $this);
}
}
// Flowplayer config
$flowplayerVideoConfig = array();
$flowplayerAudioConfig = array();
if (is_array($conf['flashvars.']) && is_array($typeConf['mapping.']['flashvars.'])) {
ArrayUtility::remapArrayKeys($conf['flashvars.'], $typeConf['mapping.']['flashvars.']);
} else {
$conf['flashvars.'] = array();
}
$conf['videoflashvars'] = $conf['flashvars.'];
$conf['audioflashvars'] = $conf['flashvars.'];
$conf['audioflashvars']['url'] = $conf['audioFallback'];
// Render video sources
$videoSources = '';
if (is_array($conf['sources'])) {
foreach ($conf['sources'] as $source) {
$fileinfo = \TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($source);
$mimeType = $this->mimeTypes[$fileinfo['fileext']]['video'];
$videoSources .= '<source src="' . $source . '"' . ($mimeType ? ' type="' . $mimeType . '"' : '') . ' />' . LF;
}
}
// Render audio sources
$audioSources = '';
if (is_array($conf['audioSources'])) {
foreach ($conf['audioSources'] as $source) {
$fileinfo = \TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($source);
$mimeType = $this->mimeTypes[$fileinfo['fileext']]['audio'];
$audioSources .= '<source src="' . $source . '"' . ($mimeType ? ' type="' . $mimeType . '"' : '') . ' />' . LF;
}
}
// Configure captions
if ($conf['type'] === 'video' && isset($conf['caption'])) {
// Assemble captions track tag
$videoCaptions = '<track id="' . $replaceElementIdString . '_captions_track" kind="captions" src="' . $conf['caption'] . '" default>' . LF;
// Add videoJS extension for captions
$pageRenderer->addJsFile($this->getPathToLibrary('videojs/video-js/controls/captions.js'));
// Flowplayer captions
$conf['videoflashvars']['captionUrl'] = $conf['caption'];
示例3: remapArrayKeys
/**
* Rename Array keys with a given mapping table
*
* @param array $array Array by reference which should be remapped
* @param array $mappingTable Array with remap information, array/$oldKey => $newKey)
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8 - use ArrayUtility::remapArrayKeys() instead
*/
public static function remapArrayKeys(&$array, $mappingTable)
{
static::logDeprecatedFunction();
ArrayUtility::remapArrayKeys($array, $mappingTable);
}
示例4: remapArrayKeysExchangesKeysWithGivenMapping
/**
* @test
*/
public function remapArrayKeysExchangesKeysWithGivenMapping()
{
$array = array('one' => 'one', 'two' => 'two', 'three' => 'three');
$keyMapping = array('one' => '1', 'two' => '2');
$expected = array('1' => 'one', '2' => 'two', 'three' => 'three');
ArrayUtility::remapArrayKeys($array, $keyMapping);
$this->assertEquals($expected, $array);
}
示例5: render
/**
* Rendering the cObject, SWFOBJECT
*
* @param array $conf Array of TypoScript properties
* @return string Output
*/
public function render($conf = array())
{
$prefix = '';
if ($GLOBALS['TSFE']->baseUrl) {
$prefix = $GLOBALS['TSFE']->baseUrl;
}
if ($GLOBALS['TSFE']->absRefPrefix) {
$prefix = $GLOBALS['TSFE']->absRefPrefix;
}
$type = isset($conf['type.']) ? $this->cObj->stdWrap($conf['type'], $conf['type.']) : $conf['type'];
$typeConf = $conf[$type . '.'];
/** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
$pageRenderer = $GLOBALS['TSFE']->getPageRenderer();
// Add SWFobject js-file
$pageRenderer->addJsFile($this->getPathToLibrary('flashmedia/swfobject/swfobject.js'));
$player = isset($typeConf['player.']) ? $this->cObj->stdWrap($typeConf['player'], $typeConf['player.']) : $typeConf['player'];
if (strpos($player, 'EXT:') === 0) {
$player = $prefix . $GLOBALS['TSFE']->tmpl->getFileName($player);
}
$installUrl = isset($conf['installUrl.']) ? $this->cObj->stdWrap($conf['installUrl'], $conf['installUrl.']) : $conf['installUrl'];
if (!$installUrl) {
$installUrl = $prefix . $this->getPathToLibrary('flashmedia/swfobject/expressInstall.swf');
}
// If file is audio and an explicit path has not been set,
// take path from audio fallback property
if ($type == 'audio' && empty($conf['file'])) {
$conf['file'] = $conf['audioFallback'];
}
$filename = isset($conf['file.']) ? $this->cObj->stdWrap($conf['file'], $conf['file.']) : $conf['file'];
$forcePlayer = isset($conf['forcePlayer.']) ? $this->cObj->stdWrap($conf['forcePlayer'], $conf['forcePlayer.']) : $conf['forcePlayer'];
if ($filename && $forcePlayer) {
if (strpos($filename, '://') !== FALSE) {
$conf['flashvars.']['file'] = $filename;
} else {
if ($prefix) {
$conf['flashvars.']['file'] = $prefix . $filename;
} else {
$conf['flashvars.']['file'] = str_repeat('../', substr_count($player, '/')) . $filename;
}
}
} else {
$player = $filename;
}
// Write calculated values in conf for the hook
$conf['player'] = $player;
$conf['installUrl'] = $installUrl;
$conf['filename'] = $filename;
$conf['prefix'] = $prefix;
// Merge with default parameters
$conf['flashvars.'] = array_merge((array) $typeConf['default.']['flashvars.'], (array) $conf['flashvars.']);
$conf['params.'] = array_merge((array) $typeConf['default.']['params.'], (array) $conf['params.']);
$conf['attributes.'] = array_merge((array) $typeConf['default.']['attributes.'], (array) $conf['attributes.']);
$conf['embedParams'] = 'flashvars, params, attributes';
// Hook for manipulating the conf array, it's needed for some players like flowplayer
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/hooks/class.tx_cms_mediaitems.php']['swfParamTransform'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/hooks/class.tx_cms_mediaitems.php']['swfParamTransform'] as $classRef) {
\TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($classRef, $conf, $this);
}
}
if (is_array($conf['flashvars.']) && is_array($typeConf['mapping.']['flashvars.'])) {
ArrayUtility::remapArrayKeys($conf['flashvars.'], $typeConf['mapping.']['flashvars.']);
}
$flashvars = 'var flashvars = ' . (!empty($conf['flashvars.']) ? json_encode($conf['flashvars.']) : '{}') . ';';
if (is_array($conf['params.']) && is_array($typeConf['mapping.']['params.'])) {
ArrayUtility::remapArrayKeys($conf['params.'], $typeConf['mapping.']['params.']);
}
$params = 'var params = ' . (!empty($conf['params.']) ? json_encode($conf['params.']) : '{}') . ';';
if (is_array($conf['attributes.']) && is_array($typeConf['attributes.']['params.'])) {
ArrayUtility::remapArrayKeys($conf['attributes.'], $typeConf['attributes.']['params.']);
}
$attributes = 'var attributes = ' . (!empty($conf['attributes.']) ? json_encode($conf['attributes.']) : '{}') . ';';
$flashVersion = isset($conf['flashVersion.']) ? $this->cObj->stdWrap($conf['flashVersion'], $conf['flashVersion.']) : $conf['flashVersion'];
if (!$flashVersion) {
$flashVersion = '9';
}
$replaceElementIdString = str_replace('.', '', uniqid('mmswf', TRUE));
$GLOBALS['TSFE']->register['MMSWFID'] = $replaceElementIdString;
$alternativeContent = isset($conf['alternativeContent.']) ? $this->cObj->stdWrap($conf['alternativeContent'], $conf['alternativeContent.']) : $conf['alternativeContent'];
$layout = isset($conf['layout.']) ? $this->cObj->stdWrap($conf['layout'], $conf['layout.']) : $conf['layout'];
$content = str_replace('###ID###', $replaceElementIdString, $layout);
$content = str_replace('###SWFOBJECT###', '<div id="' . $replaceElementIdString . '">' . $alternativeContent . '</div>', $content);
$width = isset($conf['width.']) ? $this->cObj->stdWrap($conf['width'], $conf['width.']) : $conf['width'];
if (!$width) {
$width = $conf[$type . '.']['defaultWidth'];
}
$height = isset($conf['height.']) ? $this->cObj->stdWrap($conf['height'], $conf['height.']) : $conf['height'];
if (!$height) {
$height = $conf[$type . '.']['defaultHeight'];
}
$embed = 'swfobject.embedSWF("' . $conf['player'] . '", "' . $replaceElementIdString . '", "' . $width . '", "' . $height . '",
"' . $flashVersion . '", "' . $installUrl . '", ' . $conf['embedParams'] . ');';
$script = $flashvars . $params . $attributes . $embed;
$pageRenderer->addJsInlineCode($replaceElementIdString, $script);
if (isset($conf['stdWrap.'])) {
//.........这里部分代码省略.........