EXTMVC:
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Configuration / Source / TX_EXTMVC_Configuration_Source_FlexForm.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 /**
26 * Configuration source based on FlexForm settings
27 *
28 * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
29 */
30 class TX_EXTMVC_Configuration_Source_FlexForm implements TX_EXTMVC_Configuration_SourceInterface {
31
32 /**
33 * XML FlexForm content
34 *
35 * @var string
36 **/
37 protected $flexFormContent;
38
39 /**
40 * Sets the flex form content
41 *
42 * @param string $flexFormContent Flexform content
43 * @return void
44 */
45 public function setFlexFormContent($flexFormContent) {
46 $this->flexFormContent = $flexFormContent;
47 }
48
49 /**
50 * Loads the specified FlexForm configuration and returns its content in a
51 * configuration container. If the file does not exist or could not be loaded,
52 * the empty configuration container is returned.
53 *
54 * @param string $extensionKey The extension key
55 * @return TX_EXTMVC_Configuration_Container
56 */
57 public function load($extensionKey) {
58 $settings = array();
59 if (is_array($this->flexFormContent)) {
60 $flexFormArray = $this->flexFormContent;
61 } elseif (!empty($this->flexFormContent)) {
62 $flexFormArray = t3lib_div::xml2array($this->flexFormContent);
63 }
64 $sheetArray = $flexFormArray['data']['sDEF']['lDEF'];
65 if (is_array($sheetArray)) {
66 foreach($sheetArray as $key => $value) {
67 $settings[$key] = $value['vDEF'];
68 }
69 }
70 return $settings;
71 }
72
73 }
74 ?>