當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArrayUtility::remapArrayKeys方法代碼示例

本文整理匯總了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;
    }
開發者ID:plan2net,項目名稱:TYPO3.CMS,代碼行數:63,代碼來源:QuicktimeObjectContentObject.php

示例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'];
開發者ID:adrolli,項目名稱:TYPO3.CMS,代碼行數:67,代碼來源:FlowPlayerContentObject.php

示例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);
 }
開發者ID:Gregpl,項目名稱:TYPO3.CMS,代碼行數:12,代碼來源:GeneralUtility.php

示例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);
 }
開發者ID:graurus,項目名稱:testgit_t37,代碼行數:11,代碼來源:ArrayUtilityTest.php

示例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.'])) {
//.........這裏部分代碼省略.........
開發者ID:plan2net,項目名稱:TYPO3.CMS,代碼行數:101,代碼來源:ShockwaveFlashObjectContentObject.php


注:本文中的TYPO3\CMS\Core\Utility\ArrayUtility::remapArrayKeys方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。