Resolves #56038: Language Pack Generator crashes in TYPO3 6.0
[TYPO3CMS/Extensions/static_info_tables.git] / class.tx_staticinfotables_encoding.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2004-2007 René Fritz (r.fritz@colorcube.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 * Functions to convert the character encoding of the static info tables
26 * * DEPRECATED * Used by language packs prior to Static Info Tables version 6
27 *
28 */
29 class tx_staticinfotables_encoding {
30 /**
31 * Returns a selector box with charset encodings
32 *
33 * @deprecated since 6.0, will be removed two versions later - Language pack should be re-created
34 *
35 * @param string $elementName it the form elements name, probably something like "SET[...]"
36 * @param string $currentKey is the key to be selected currently.
37 * @param string $firstEntry is the key to be placed on top as first (default) entry.
38 * @param string $unsetEntries List of keys that should be removed (comma list).
39 * @return string HTML code for selector box
40 */
41 function getEncodingSelect ($elementName, $currentKey, $firstEntry='', $unsetEntries='') {
42 \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
43 $menuItems = array(
44 'utf-8' => 'UTF-8',
45 );
46
47 if ($firstEntry && $menuItems[$firstEntry]) {
48 $entry = array($firstEntry => $menuItems[$firstEntry]);
49 unset($menuItems[$firstEntry]);
50 $menuItems = array_merge($entry, $menuItems);
51 }
52
53 $unsetEntries = explode(',', $unsetEntries);
54 foreach($unsetEntries as $entry) {
55 unset($menuItems[$entry]);
56 }
57
58 $options = array();
59 foreach($menuItems as $value => $label) {
60 $options[] = '<option value="'.htmlspecialchars($value).'"'.(!strcmp($currentKey,$value)?' selected="selected"':'').'>'.
61 \TYPO3\CMS\Core\Utility\GeneralUtility::deHSCentities(htmlspecialchars($label)).
62 '</option>';
63 }
64 if (count($options)) {
65 return '
66
67 <!-- charset encoding menu -->
68 <select name="'.$elementName.'">
69 '.implode('
70 ',$options).'
71 </select>
72 ';
73 }
74 }
75 }
76 ?>