Extbase:
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Utility / TypoScript.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Christian Müller <christian@kitsunet.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 * Utilities to manage and convert Typoscript Code
27 *
28 * @package Extbase
29 * @subpackage extbase
30 * @version $ID:$
31 */
32 class Tx_Extbase_Utility_TypoScript {
33
34 /**
35 * Returns an array with Typoscript the old way (with dot).
36 *
37 * Extbase converts the "classical" TypoScript (with trailing dot) to a format without trailing dot,
38 * to be more future-proof and not to have any conflicts with Fluid object accessor syntax.
39 * However, if you want to call legacy TypoScript objects, you somehow need the "old" syntax (because this is what TYPO3 is used to).
40 * With this method, you can convert the extbase TypoScript to classical TYPO3 TypoScript which is understood by the rest of TYPO3.
41 *
42 * @param array $extbaseTS An Typoscript Array with Extbase Syntax (without dot but with _typoscriptNodeValue)
43 * @return array array with Typoscript as usual (with dot)
44 */
45 static public function convertExtbaseToClassicTS($extbaseTS) {
46 $classicTS = array();
47 if (is_array($extbaseTS)) {
48 foreach ($extbaseTS as $key => $value) {
49 if (is_array($value)) {
50 if (isset($value['_typoscriptNodeValue'])) {
51 $classicTS[$key] = $value['_typoscriptNodeValue'];
52 unset($value['_typoscriptNodeValue']);
53 }
54 $classicTS[$key.'.'] = Tx_Extbase_Utility_TypoScript::convertExtbaseToClassicTS($value);
55 } else {
56 $classicTS[$key] = $value;
57 }
58 }
59 }
60 return $classicTS;
61 }
62 }
63 ?>