[TASK] Disable compression for inlineJs in Backend
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tsstyleconfig.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
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 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Provides a simplified layer for making Constant Editor style configuration forms
29 *
30 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
31 */
32
33
34 /**
35 * Provides a simplified layer for making Constant Editor style configuration forms
36 *
37 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
38 * @package TYPO3
39 * @subpackage t3lib
40 */
41 class t3lib_tsStyleConfig extends t3lib_tsparser_ext {
42 // internal
43 var $categories = array();
44 var $ext_dontCheckIssetValues = 1;
45 var $ext_CEformName = "tsStyleConfigForm";
46 var $ext_noCEUploadAndCopying = 1;
47 var $ext_printAll = 1;
48 var $ext_defaultOnlineResourceFlag = 1;
49
50 var $ext_incomingValues = array();
51
52
53 /**
54 * @param string pathRel is the path relative to the typo3/ directory
55 * @param string pathAbs is the absolute path from root
56 * @param string backPath is the backReference from current position to typo3/ dir
57 * @param [type] $backPath: ...
58 * @return [type] ...
59 */
60 function ext_initTSstyleConfig($configTemplate, $pathRel, $pathAbs, $backPath) {
61 $this->tt_track = 0; // Do not log time-performance information
62 $this->constants = array($configTemplate, "");
63
64 $theConstants = $this->generateConfig_constants(); // The editable constants are returned in an array.
65
66 $this->ext_localGfxPrefix = $pathAbs;
67 $this->ext_localWebGfxPrefix = $backPath . $pathRel;
68 $this->ext_backPath = $backPath;
69
70 return $theConstants;
71 }
72
73 /**
74 * [Describe function...]
75 *
76 * @param [type] $theConstants: ...
77 * @param [type] $valueArray: ...
78 * @return [type] ...
79 */
80 function ext_setValueArray($theConstants, $valueArray) {
81
82 $temp = $this->flatSetup;
83 $this->flatSetup = array();
84 $this->flattenSetup($valueArray, "", "");
85 $this->objReg = $this->ext_realValues = $this->flatSetup;
86 $this->flatSetup = $temp;
87
88
89 foreach ($theConstants as $k => $p) {
90 if (isset($this->objReg[$k])) {
91 $theConstants[$k]["value"] = $this->ext_realValues[$k];
92 }
93 }
94
95 $this->categories = array(); // Reset the default pool of categories.
96 $this->ext_categorizeEditableConstants($theConstants); // The returned constants are sorted in categories, that goes into the $this->categories array
97
98 return $theConstants;
99 }
100
101 /**
102 * [Describe function...]
103 *
104 * @return [type] ...
105 */
106 function ext_getCategoriesForModMenu() {
107 return $this->ext_getCategoryLabelArray();
108 }
109
110 /**
111 * [Describe function...]
112 *
113 * @param [type] $cat: ...
114 * @return [type] ...
115 */
116 function ext_makeHelpInformationForCategory($cat) {
117 return $this->ext_getTSCE_config($cat);
118 }
119
120 /**
121 * Get the form for extension configuration
122 *
123 * @param string $cat
124 * @param array $theConstants
125 * @param string $script
126 * @param string $addFields
127 * @param string $extKey
128 * @param bool Adds opening <form> tag to the ouput, if TRUE
129 * @return string the form
130 */
131 function ext_getForm($cat, $theConstants, $script = "", $addFields = "", $extKey = "", $addFormTag = TRUE) {
132 $this->ext_makeHelpInformationForCategory($cat);
133 $printFields = trim($this->ext_printFields($theConstants, $cat));
134
135 $content = '';
136 $content .= t3lib_div::wrapJS('
137 function uFormUrl(aname) {
138 document.' . $this->ext_CEformName . '.action = "' . t3lib_div::linkThisScript() . '#"+aname;
139 }
140 ');
141
142 if ($addFormTag) {
143 $content .= '<form action="' . htmlspecialchars($script ? $script : t3lib_div::linkThisScript()) . '" name="' . $this->ext_CEformName . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '">';
144 }
145 $content .= $addFields;
146 $content .= $printFields;
147 $content .= '<input type="submit" name="submit" value="' .
148 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tsfe.xml:update', TRUE) . '" id="configuration-submit-' . htmlspecialchars($extKey) . '" />';
149
150 $example = $this->ext_displayExample();
151 $content .= $example ? '<hr/>' . $example : "";
152
153 return $content;
154 }
155
156 /**
157 * [Describe function...]
158 *
159 * @return [type] ...
160 */
161 function ext_displayExample() {
162 if ($this->helpConfig["imagetag"] || $this->helpConfig["description"] || $this->helpConfig["header"]) {
163 $out = '<div align="center">' . $this->helpConfig["imagetag"] . '</div><BR>' .
164 ($this->helpConfig["description"] ? implode(explode("//", $this->helpConfig["description"]), "<BR>") . "<BR>" : "") .
165 ($this->helpConfig["bulletlist"] ? "<ul><li>" . implode(explode("//", $this->helpConfig["bulletlist"]), "<li>") . "</ul>" : "<BR>");
166 }
167 return $out;
168 }
169
170 /**
171 * [Describe function...]
172 *
173 * @param [type] $arr: ...
174 * @return [type] ...
175 */
176 function ext_mergeIncomingWithExisting($arr) {
177 $parseObj = t3lib_div::makeInstance("t3lib_TSparser");
178 $parseObj->parse(implode(LF, $this->ext_incomingValues));
179 $arr2 = $parseObj->setup;
180 return t3lib_div::array_merge_recursive_overrule($arr, $arr2);
181 }
182
183 // extends:
184 function ext_getKeyImage($key) {
185 return '<img' . t3lib_iconWorks::skinImg($this->ext_backPath, 'gfx/rednumbers/' . $key . '.gif', '') . ' hspace="2" align="top" alt="" />';
186 }
187
188 /**
189 * [Describe function...]
190 *
191 * @param [type] $imgConf: ...
192 * @return [type] ...
193 */
194 function ext_getTSCE_config_image($imgConf) {
195 $iFile = $this->ext_localGfxPrefix . $imgConf;
196 $tFile = $this->ext_localWebGfxPrefix . $imgConf;
197 $imageInfo = @getImagesize($iFile);
198 return '<img src="' . $tFile . '" ' . $imageInfo[3] . '>';
199 }
200
201 /**
202 * [Describe function...]
203 *
204 * @param [type] $params: ...
205 * @return [type] ...
206 */
207 function ext_fNandV($params) {
208 $fN = 'data[' . $params["name"] . ']';
209 $fV = $params["value"] = isset($this->ext_realValues[$params["name"]]) ? $this->ext_realValues[$params["name"]] : $params["default_value"];
210 $reg = array();
211 if (preg_match('/^\{[\$][a-zA-Z0-9\.]*\}$/', trim($fV), $reg)) { // Values entered from the constantsedit cannot be constants!
212 $fV = "";
213 }
214 $fV = htmlspecialchars($fV);
215
216 return array($fN, $fV, $params);
217 }
218
219 /**
220 * [Describe function...]
221 *
222 * @param [type] $absPath: ...
223 * @return [type] ...
224 */
225 function ext_loadResources($absPath) {
226 $this->ext_readDirResources($GLOBALS["TYPO3_CONF_VARS"]["MODS"]["web_ts"]["onlineResourceDir"]);
227 if (is_dir($absPath)) {
228 $absPath = rtrim($absPath, '/');
229 $this->readDirectory($absPath);
230 }
231 $this->ext_resourceDims();
232 }
233
234 /**
235 * [Describe function...]
236 *
237 * @param [type] $key: ...
238 * @param [type] $var: ...
239 * @return [type] ...
240 */
241 function ext_putValueInConf($key, $var) {
242 $this->ext_incomingValues[$key] = $key . "=" . $var;
243 }
244
245 /**
246 * [Describe function...]
247 *
248 * @param [type] $key: ...
249 * @return [type] ...
250 */
251 function ext_removeValueInConf($key) {
252 // Nothing...
253 }
254 }
255
256
257 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsstyleconfig.php'])) {
258 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsstyleconfig.php']);
259 }
260 ?>