本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::xml2array方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::xml2array方法的具体用法?PHP GeneralUtility::xml2array怎么用?PHP GeneralUtility::xml2array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\GeneralUtility
的用法示例。
在下文中一共展示了GeneralUtility::xml2array方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sanitize
/**
* Parses a flexForm node recursively and takes care of sections etc
*
* @param array|string $flexForm
* @return array
*/
protected function sanitize($flexForm)
{
if (is_string($flexForm)) {
$flexForm = GeneralUtility::xml2array($flexForm);
}
return $flexForm;
}
示例2: getExtensionSummary
/**
* @param array $params
*
* @return string
*/
public function getExtensionSummary(array $params)
{
$LL = $this->includeLocalLang();
$result = '<strong><cite>→ ' . $this->getLanguage()->getLLL('list_title_' . $params['row']['list_type'], $LL) . ' </cite></strong>';
$this->flexformData = GeneralUtility::xml2array($params['row']['pi_flexform']);
if ($this->getFieldFromFlexform('settings.videoWidth')) {
$result .= '<br /><strong>Width:</strong>: ' . $this->getFieldFromFlexform('settings.videoWidth');
}
if ($this->getFieldFromFlexform('settings.videoHeight')) {
$result .= '<br /><strong>Height</strong>: ' . $this->getFieldFromFlexform('settings.videoHeight');
}
if ($this->getFieldFromFlexform('settings.templateFile')) {
$result .= '<br /><strong>Template</strong>: ' . $this->getFieldFromFlexform('settings.templateFile');
}
if ($this->getFieldFromFlexform('settings.addMediaElementJsInitializationFile')) {
$result .= '<br /><strong>MediaelementInit</strong>: ' . basename($this->getFieldFromFlexform('settings.addMediaElementJsInitializationFile'));
}
if ($this->getFieldFromFlexform('settings.skin')) {
$result .= '<br /><strong>Skin</strong>: ' . $this->getFieldFromFlexform('settings.skin');
}
if ($this->getFieldFromFlexform('settings.videoSelection')) {
$this->addItemsToResult($this->getItemsByTableAndUids($this->getFieldFromFlexform('settings.videoSelection')), $result);
}
if ($this->getFieldFromFlexform('settings.audioSelection')) {
$this->addItemsToResult($this->getItemsByTableAndUids($this->getFieldFromFlexform('settings.audioSelection'), 'tx_sschhtml5videoplayer_domain_model_audio'), $result);
}
return $result;
}
示例3: addFields_predefinedJS
/**
* Adds onchange listener on the drop down menu "predefined".
* If the event is fired and old value was ".default", then empty some fields.
*
* @param array $config
* @return string the javascript
* @author Fabien Udriot
*/
function addFields_predefinedJS($config)
{
$newRecord = 'true';
if ($config['row']['pi_flexform'] != '') {
$flexData = \TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($config['row']['pi_flexform']);
if (isset($flexData['data']['sDEF']['lDEF']['predefined'])) {
$newRecord = 'false';
}
}
$uid = NULL;
if (is_array($GLOBALS['SOBE']->editconf['tt_content'])) {
$uid = key($GLOBALS['SOBE']->editconf['tt_content']);
}
if ($uid < 0 || empty($uid) || !strstr($uid, 'NEW')) {
$uid = $GLOBALS['SOBE']->elementsData[0]['uid'];
}
//print_r($GLOBALS['SOBE']->elementsData[0]);
$js = "<script>\n";
$js .= "/*<![CDATA[*/\n";
$divId = $GLOBALS['SOBE']->tceforms->dynNestedStack[0][1];
if (!$divId) {
//$divId = 'DTM-' . $uid;
$divId = "DIV.c-tablayer";
} else {
$divId .= "-DIV";
}
$js .= "var uid = '" . $uid . "'\n";
$js .= "var flexformBoxId = '" . $divId . "'\n";
//$js .= "var flexformBoxId = 'DIV.c-tablayer'\n";
$js .= "var newRecord = " . $newRecord . "\n";
$js .= file_get_contents(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('formhandler') . 'Resources/JS/addFields_predefinedJS.js');
$js .= "/*]]>*/\n";
$js .= "</script>\n";
return $js;
}
示例4: convertFlexFormContentToArray
/**
* Parses the flexForm content and converts it to an array
* The resulting array will be multi-dimensional, as a value "bla.blubb"
* results in two levels, and a value "bla.blubb.bla" results in three levels.
*
* Note: multi-language flexForms are not supported yet
*
* @param string $flexFormContent flexForm xml string
* @param string $languagePointer language pointer used in the flexForm
* @param string $valuePointer value pointer used in the flexForm
* @return array the processed array
*/
public function convertFlexFormContentToArray($flexFormContent, $languagePointer = 'lDEF', $valuePointer = 'vDEF')
{
$settings = array();
$flexFormArray = \TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($flexFormContent);
$flexFormArray = isset($flexFormArray['data']) ? $flexFormArray['data'] : array();
foreach (array_values($flexFormArray) as $languages) {
if (!is_array($languages[$languagePointer])) {
continue;
}
foreach ($languages[$languagePointer] as $valueKey => $valueDefinition) {
if (strpos($valueKey, '.') === FALSE) {
$settings[$valueKey] = $this->walkFlexFormNode($valueDefinition, $valuePointer);
} else {
$valueKeyParts = explode('.', $valueKey);
$currentNode =& $settings;
foreach ($valueKeyParts as $valueKeyPart) {
$currentNode =& $currentNode[$valueKeyPart];
}
if (is_array($valueDefinition)) {
if (array_key_exists($valuePointer, $valueDefinition)) {
$currentNode = $valueDefinition[$valuePointer];
} else {
$currentNode = $this->walkFlexFormNode($valueDefinition, $valuePointer);
}
} else {
$currentNode = $valueDefinition;
}
}
}
}
return $settings;
}
示例5: getExtensionSummary
/**
* @param array $params
*
* @return string
*/
public function getExtensionSummary(array $params)
{
$result = '<strong><cite>→ HTML5 Video Player</cite></strong>';
$this->flexformData = GeneralUtility::xml2array($params['row']['pi_flexform']);
if ($this->getFieldFromFlexform('settings.ff.videowidth')) {
$result .= '<br /><strong>Width:</strong>: ' . $this->getFieldFromFlexform('settings.ff.videowidth');
}
if ($this->getFieldFromFlexform('settings.ff.videoheight')) {
$result .= '<br /><strong>Height</strong>: ' . $this->getFieldFromFlexform('settings.ff.videoheight');
}
if ($this->getFieldFromFlexform('switchableControllerActions')) {
$result .= '<br /><strong>Mode</strong>:';
if ($this->getFieldFromFlexform('switchableControllerActions') == 'Videoplayer->list') {
$result .= 'Movies';
} else {
$result .= 'Gallery';
}
}
$result .= '<br /><ul style="margin-bottom: 0;">';
$videos = $this->getVideosByContentUid($params['row']['uid']);
foreach ($videos as $video) {
$result .= '<li>' . $video['title'] . '</li>';
}
$result .= '</ul>';
return $result;
}
示例6: getExtensionSummary
/**
* Render the Plugin Info
*
* @param unknown_type $params
* @param unknown_type $pObj
*/
public function getExtensionSummary($params, &$pObj)
{
$data = GeneralUtility::xml2array($params['row']['pi_flexform']);
$this->init($data);
if (is_array($data)) {
// PluginMode
$firstControllerAction = array_shift(explode(';', $data['data']['sDefault']['lDEF']['switchableControllerActions']['vDEF']));
$this->pluginMode = str_replace('->', '_', $firstControllerAction);
// List
$listIdentifier = $data['data']['sDefault']['lDEF']['settings.listIdentifier']['vDEF'];
// Filter
$filterBoxIdentifier = $data['data']['sDefault']['lDEF']['settings.filterboxIdentifier']['vDEF'];
// Export
$exportType = array_pop(explode('.', $data['data']['sDefault']['lDEF']['settings.controller.List.export.view']['vDEF']));
$exportFileName = $data['data']['sDefault']['lDEF']['settings.prototype.export.fileName']['vDEF'];
$exportFileName .= $data['data']['sDefault']['lDEF']['settings.prototype.export.addDateToFilename']['vDEF'] ? '[DATE]' : '';
$exportFileName .= '.' . $data['data']['sDefault']['lDEF']['settings.prototype.export.fileExtension']['vDEF'];
$exportDownloadType = 'tx_ptextlist_flexform_export.downloadtype.' . $data['data']['sDefault']['lDEF']['settings.prototype.export.downloadType']['vDEF'];
$exportListIdentifier = $data['data']['sDefault']['lDEF']['settings.exportListIdentifier']['vDEF'];
}
$this->fluidRenderer->assign($this->pluginMode, true);
$this->fluidRenderer->assign('listIdentifier', $listIdentifier);
$this->fluidRenderer->assign('filterBoxIdentifier', $filterBoxIdentifier);
$this->fluidRenderer->assign('exportType', $exportType);
$this->fluidRenderer->assign('exportFileName', $exportFileName);
$this->fluidRenderer->assign('exportDownloadType', $exportDownloadType);
$this->fluidRenderer->assign('exportListIdentifier', $exportListIdentifier);
$this->fluidRenderer->assign('caLabel', 'LLL:EXT:pt_extlist/Resources/Private/Language/locallang.xml:tx_ptextlist_flexform_controllerAction.' . $this->pluginMode);
return $this->fluidRenderer->render();
}
示例7: getExtensionSummary
/**
* Returns information about this extension's pi1 plugin
*
* @param array $params Parameters to the hook
* @param object $pObj A reference to calling object
* @return string Information about pi1 plugin
*/
function getExtensionSummary($params, &$pObj)
{
$languageService = $this->getLanguageService();
$result = '';
if ($params['row']['list_type'] == 'irfaq_pi1') {
$data = GeneralUtility::xml2array($params['row']['pi_flexform']);
if (is_array($data)) {
$modes = array();
foreach (GeneralUtility::trimExplode(',', $data['data']['sDEF']['lDEF']['what_to_display']['vDEF'], true) as $mode) {
switch ($mode) {
case 'DYNAMIC':
$modes[] = $languageService->sL('LLL:EXT:irfaq/lang/locallang_db.xml:tx_irfaq.pi_flexform.view_dynamic');
break;
case 'STATIC':
$modes[] = $languageService->sL('LLL:EXT:irfaq/lang/locallang_db.xml:tx_irfaq.pi_flexform.view_static');
break;
case 'STATIC_SEPARATE':
$modes[] = $languageService->sL('LLL:EXT:irfaq/lang/locallang_db.xml:tx_irfaq.pi_flexform.view_static_separate');
break;
case 'SEARCH':
$modes[] = $languageService->sL('LLL:EXT:irfaq/lang/locallang_db.xml:tx_irfaq.pi_flexform.view_search');
break;
}
}
$result = implode(', ', $modes);
}
if (!$result) {
$result = $languageService->sL('LLL:EXT:irfaq/lang/locallang_db.xml:tx_irfaq.pi_flexform.no_view');
}
}
return $result;
}
示例8: getFlexFormDS_postProcessDS
/**
* Overwrites the data structure of a given tt_content::pi_flexform by
* by the one matching the gridelements layout.
*
* @param array $dataStructArray The incoming data structure. This might be the default one.
* @param array $conf
* @param array $row
* @param string $table
* @param string $fieldName
*
* @return void
*
*/
public function getFlexFormDS_postProcessDS(&$dataStructArray, $conf, $row, $table, $fieldName)
{
if ($table === 'tt_content' && $fieldName === 'pi_flexform' && $row['CType'] === 'gridelements_pi1' && $row['tx_gridelements_backend_layout']) {
$this->init($row['pid']);
$dataStructArray = GeneralUtility::xml2array($this->layoutSetup->getFlexformConfiguration($row['tx_gridelements_backend_layout']));
}
}
示例9: init
/**
* Init the extbase Context and the configurationBuilder
*
* @throws \Exception
*/
protected function init(&$PA)
{
$this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
if (is_array($PA['row']['pi_flexform'])) {
// TYPO3 7.5 and newer delivers an array
$this->apiServerToken = $PA['row']['pi_flexform']['data']['sDefault']['lDEF']['settings.apiServerToken']['vDEF'];
$this->ytChannelId = $PA['row']['pi_flexform']['data']['sDefault']['lDEF']['settings.channelId']['vDEF'];
} else {
// TYPO3 7.4 or older delivers a string
$flexForm = GeneralUtility::xml2array($PA['row']['pi_flexform']);
if (is_array($flexForm) && isset($flexForm['data']['sDefault']['lDEF']['settings.apiServerToken']['vDEF'])) {
$this->apiServerToken = $flexForm['data']['sDefault']['lDEF']['settings.apiServerToken']['vDEF'];
}
if (is_array($flexForm) && isset($flexForm['data']['sDefault']['lDEF']['settings.channelId']['vDEF'])) {
$this->ytChannelId = $flexForm['data']['sDefault']['lDEF']['settings.channelId']['vDEF'];
}
}
if (!isset($this->apiServerToken)) {
error_log("YouTube Playlist - PlaylistSelector: API Server Token could not be accessed.");
}
if (!isset($this->ytChannelId)) {
error_log("YouTube Playlist - PlaylistSelector: YouTube Channel ID could not be accessed.");
}
$this->youTubeApi = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Powrup\\YoutubePlaylist\\Utility\\YouTubeApi', $this->apiServerToken);
// Set Channel ID
$this->youTubeApi->setChannelId($this->ytChannelId);
}
示例10: renderPreviewContent_preProcess
/**
* renders the templavoila preview
*
* @param pointer $row: affected record
* @param pointer $table: affected table
* @param pointer $alreadyRendered: is the preview already rendered by another extension?
* @param pointer $reference: pointer to the parent class
* @return string preview content
*/
function renderPreviewContent_preProcess($row, $table, &$alreadyRendered, &$reference)
{
if ($row['CType'] == 'list' && $row['list_type'] == 'piwikintegration_pi1') {
$content = '<strong>Piwik in FE</strong>';
$content = $reference->link_edit($content, $table, $row['uid']);
$piFlexForm = \TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($row['pi_flexform']);
foreach ($piFlexForm['data'] as $sheet => $data) {
foreach ($data as $lang => $value) {
foreach ($value as $key => $val) {
$conf[$key] = $piFlexForm['data'][$sheet]['lDEF'][$key]['vDEF'];
}
}
}
$this->extConf = array('widget' => json_decode(base64_decode($conf['widget']), true), 'height' => $conf['div_height']);
$this->extConf['widget']['idSite'] = $conf['idsite'];
$this->extConf['widget']['period'] = $conf['period'];
$this->extConf['widget']['date'] = 'yesterday';
$this->extConf['widget']['viewDataTable'] = $conf['viewDataTable'];
$this->extConf['widget']['moduleToWidgetize'] = $this->extConf['widget']['module'];
$this->extConf['widget']['actionToWidgetize'] = $this->extConf['widget']['action'];
unset($this->extConf['widget']['module']);
unset($this->extConf['widget']['action']);
#$helper = new tx_piwikintegration_helper();
$obj .= '<div style="width:' . $this->extConf['height'] . 'px;"><object width="100%" type="text/html" height="' . intval($this->extConf['height']) . '" data="';
$obj .= '../../../../typo3conf/piwik/piwik/index.php?module=Widgetize&action=iframe' . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', $this->extConf['widget']);
$obj .= '&disableLink=1"></object></div>';
$content .= $obj;
$alreadyRendered = true;
return $content;
}
}
开发者ID:heiko-hardt,项目名称:TYPO3.piwikintegration,代码行数:40,代码来源:class.tx_piwikintegration_pi1_templavoila_preview.php
示例11: renderFlexFormSelectDropdown
/**
* User function for to render a dropdown for selecting a folder
* of a selected storage
* todo: https://review.typo3.org/#/c/27119/2
*
* @param array $PA the array with additional configuration options.
* @param \TYPO3\CMS\Backend\Form\FormEngine $tceformsObj Parent object
* @return string The HTML code for the TCEform field
*/
public function renderFlexFormSelectDropdown(&$PA, &$tceformsObj)
{
$storageUid = 0;
// get storageUid from flexform
$flexform_data = GeneralUtility::xml2array($PA['row']['pi_flexform']);
if (is_array($flexform_data) && isset($flexform_data['data']['sDEF']['lDEF']['settings.storage']['vDEF'])) {
$storageUid = (int) $flexform_data['data']['sDEF']['lDEF']['settings.storage']['vDEF'];
}
// if storageUid found get folders
if ($storageUid > 0) {
// reset items
$PA['items'] = array();
/** @var $storageRepository \TYPO3\CMS\Core\Resource\StorageRepository */
$storageRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\StorageRepository');
/** @var $storage \TYPO3\CMS\Core\Resource\ResourceStorage */
$storage = $storageRepository->findByUid($storageUid);
if ($storage->isBrowsable()) {
$rootLevelFolder = $storage->getRootLevelFolder();
$folderItems = $this->getSubfoldersForOptionList($rootLevelFolder);
foreach ($folderItems as $item) {
$PA['items'][] = array($item->getIdentifier(), $item->getIdentifier());
}
} else {
/** @var \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService */
$flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
$queue = $flashMessageService->getMessageQueueByIdentifier();
$queue->enqueue(new FlashMessage('Storage "' . $storage->getName() . '" is not browsable. No folder is currently selectable.', '', FlashMessage::WARNING));
if (!count($PA['items'])) {
$PA['items'][] = array('', '');
}
}
}
}
示例12: renderWizard
/**
* Renders the slider value wizard
*
* @param array $params
* @return string
*/
public function renderWizard($params)
{
$field = $params['field'];
if (is_array($params['row'][$field])) {
$value = $params['row'][$field][0];
} else {
$value = $params['row'][$field];
}
// If Slider is used in a flexform
if (!empty($params['flexFormPath'])) {
$flexFormTools = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::class);
$flexFormValue = $flexFormTools->getArrayValueByPath($params['flexFormPath'], GeneralUtility::xml2array($value));
if ($flexFormValue !== null) {
$value = $flexFormValue;
}
}
$itemName = $params['itemName'];
// Set default values (which correspond to those of the JS component)
$min = 0;
$max = 10000;
// Use the range property, if defined, to set min and max values
if (isset($params['fieldConfig']['range'])) {
$min = isset($params['fieldConfig']['range']['lower']) ? (int) $params['fieldConfig']['range']['lower'] : 0;
$max = isset($params['fieldConfig']['range']['upper']) ? (int) $params['fieldConfig']['range']['upper'] : 10000;
}
$elementType = $params['fieldConfig']['type'];
$step = $params['wConf']['step'] ?: 1;
$width = (int) $params['wConf']['width'] ?: 400;
$type = 'null';
if (isset($params['fieldConfig']['eval'])) {
$eval = GeneralUtility::trimExplode(',', $params['fieldConfig']['eval'], true);
if (in_array('int', $eval, true)) {
$type = 'int';
$value = (int) $value;
} elseif (in_array('double2', $eval, true)) {
$type = 'double';
$value = (double) $value;
}
}
if (isset($params['fieldConfig']['items'])) {
$type = 'array';
$index = 0;
$itemAmount = count($params['fieldConfig']['items']);
for (; $index < $itemAmount; ++$index) {
$item = $params['fieldConfig']['items'][$index];
if ((string) $item[1] === $value) {
break;
}
}
$min = 0;
$max = $itemAmount - 1;
$step = 1;
$value = $index;
}
$callbackParams = [$params['table'], $params['row']['uid'], $params['field'], $params['itemName']];
$id = 'slider-' . $params['md5ID'];
$content = '<div' . ' id="' . $id . '"' . ' data-slider-id="' . $id . '"' . ' data-slider-min="' . $min . '"' . ' data-slider-max="' . $max . '"' . ' data-slider-step="' . htmlspecialchars($step) . '"' . ' data-slider-value="' . htmlspecialchars($value) . '"' . ' data-slider-value-type="' . htmlspecialchars($type) . '"' . ' data-slider-item-name="' . htmlspecialchars($itemName) . '"' . ' data-slider-element-type="' . htmlspecialchars($elementType) . '"' . ' data-slider-callback-params="' . htmlspecialchars(json_encode($callbackParams)) . '"' . ' style="width: ' . $width . 'px;"' . '></div>';
return $content;
}
示例13: getFormUidFromTtContentUid
/**
* Return Form Uid from content element
*
* @param int $ttContentUid
* @return int
*/
protected function getFormUidFromTtContentUid($ttContentUid)
{
$row = $this->databaseConnection->exec_SELECTgetSingleRow('pi_flexform', 'tt_content', 'uid=' . (int) $ttContentUid);
$flexform = GeneralUtility::xml2array($row['pi_flexform']);
if (is_array($flexform) && isset($flexform['data']['main']['lDEF']['settings.flexform.main.form']['vDEF'])) {
return (int) $flexform['data']['main']['lDEF']['settings.flexform.main.form']['vDEF'];
}
return 0;
}
示例14: render
/**
* @param Form $form
* @return string
*/
public function render(Form $form)
{
$record = $form->getOption(Form::OPTION_RECORD);
$table = $form->getOption(Form::OPTION_RECORD_TABLE);
$field = $form->getOption(Form::OPTION_RECORD_FIELD);
$node = $this->getNodeFactory()->create(array('type' => 'flex', 'renderType' => 'flex', 'flexFormDataStructureArray' => $form->build(), 'tableName' => $table, 'fieldName' => $field, 'databaseRow' => $record, 'inlineStructure' => array(), 'parameterArray' => array('itemFormElName' => sprintf('data[%s][%d][%s]', $table, (int) $record['uid'], $field), 'itemFormElValue' => GeneralUtility::xml2array($record[$field]), 'fieldChangeFunc' => array(), 'fieldConf' => array('config' => array('ds' => $form->build())))));
$output = $node->render();
return $output['html'];
}
示例15: getFormFromFlexform
/**
* Return Form Uid from Flexform settings
*
* @param array $params
* @return int
*/
protected function getFormFromFlexform($params)
{
$xml = $params['row']['pi_flexform'];
$flexform = GeneralUtility::xml2array($xml);
if (is_array($flexform) && isset($flexform['data']['main']['lDEF']['settings.flexform.main.form']['vDEF'])) {
return $flexform['data']['main']['lDEF']['settings.flexform.main.form']['vDEF'];
}
return 0;
}