Fixed bug #15383: [Unit tests] Add tests for t3lib_div::validEmail
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tsstyleconfig.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2010 Kasper Skaarhoj (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 * $Id$
31 *
32 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
33 */
34 /**
35 * [CLASS/FUNCTION INDEX of SCRIPT]
36 *
37 *
38 *
39 * 79: class t3lib_tsStyleConfig extends t3lib_tsparser_ext
40 * 98: function ext_initTSstyleConfig($configTemplate,$pathRel,$pathAbs,$backPath)
41 * 118: function ext_setValueArray($theConstants,$valueArray)
42 * 145: function ext_getCategoriesForModMenu()
43 * 155: function ext_makeHelpInformationForCategory($cat)
44 * 168: function ext_getForm($cat,$theConstants,$script="",$addFields="")
45 * 175: function uFormUrl(aname)
46 * 197: function ext_displayExample()
47 * 213: function ext_mergeIncomingWithExisting($arr)
48 * 221: function ext_getKeyImage($key)
49 * 231: function ext_getTSCE_config_image($imgConf)
50 * 244: function ext_fNandV($params)
51 * 262: function ext_loadResources($absPath)
52 * 278: function ext_putValueInConf($key, $var)
53 * 288: function ext_removeValueInConf($key)
54 *
55 * TOTAL FUNCTIONS: 14
56 * (This index is automatically created/updated by the extension "extdeveval")
57 *
58 */
59
60
61
62
63
64
65
66
67
68
69
70
71 /**
72 * Provides a simplified layer for making Constant Editor style configuration forms
73 *
74 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
75 * @package TYPO3
76 * @subpackage t3lib
77 */
78 class t3lib_tsStyleConfig extends t3lib_tsparser_ext {
79 // internal
80 var $categories = array();
81 var $ext_dontCheckIssetValues=1;
82 var $ext_CEformName="tsStyleConfigForm";
83 var $ext_noCEUploadAndCopying=1;
84 var $ext_printAll=1;
85 var $ext_defaultOnlineResourceFlag=1;
86
87 var $ext_incomingValues = array();
88
89
90 /**
91 * @param string pathRel is the path relative to the typo3/ directory
92 * @param string pathAbs is the absolute path from root
93 * @param string backPath is the backReference from current position to typo3/ dir
94 * @param [type] $backPath: ...
95 * @return [type] ...
96 */
97 function ext_initTSstyleConfig($configTemplate,$pathRel,$pathAbs,$backPath) {
98 $this->tt_track = 0; // Do not log time-performance information
99 $this->constants=array($configTemplate,"");
100
101 $theConstants = $this->generateConfig_constants(); // The editable constants are returned in an array.
102
103 $this->ext_localGfxPrefix=$pathAbs;
104 $this->ext_localWebGfxPrefix=$backPath.$pathRel;
105 $this->ext_backPath = $backPath;
106
107 return $theConstants;
108 }
109
110 /**
111 * [Describe function...]
112 *
113 * @param [type] $theConstants: ...
114 * @param [type] $valueArray: ...
115 * @return [type] ...
116 */
117 function ext_setValueArray($theConstants,$valueArray) {
118
119 $temp = $this->flatSetup;
120 $this->flatSetup = Array();
121 $this->flattenSetup($valueArray,"","");
122 $this->objReg = $this->ext_realValues = $this->flatSetup;
123 $this->flatSetup = $temp;
124
125
126 foreach ($theConstants as $k => $p) {
127 if (isset($this->objReg[$k])) {
128 $theConstants[$k]["value"] = $this->ext_realValues[$k];
129 }
130 }
131
132 $this->categories=array(); // Reset the default pool of categories.
133 $this->ext_categorizeEditableConstants($theConstants); // The returned constants are sorted in categories, that goes into the $this->categories array
134
135 return $theConstants;
136 }
137
138 /**
139 * [Describe function...]
140 *
141 * @return [type] ...
142 */
143 function ext_getCategoriesForModMenu() {
144 return $this->ext_getCategoryLabelArray();
145 }
146
147 /**
148 * [Describe function...]
149 *
150 * @param [type] $cat: ...
151 * @return [type] ...
152 */
153 function ext_makeHelpInformationForCategory($cat) {
154 return $this->ext_getTSCE_config($cat);
155 }
156
157 /**
158 * [Describe function...]
159 *
160 * @param [type] $cat: ...
161 * @param [type] $theConstants: ...
162 * @param [type] $script: ...
163 * @param [type] $addFields: ...
164 * @return [type] ...
165 */
166 function ext_getForm($cat,$theConstants,$script="",$addFields="") {
167 $this->ext_makeHelpInformationForCategory($cat);
168 $printFields = trim($this->ext_printFields($theConstants,$cat));
169
170 $content='';
171 $content .= t3lib_div::wrapJS('
172 function uFormUrl(aname) {
173 document.' . $this->ext_CEformName . '.action = "' . t3lib_div::linkThisScript() . '#"+aname;
174 }
175 ');
176 $content .= '<form action="' . htmlspecialchars($script ? $script : t3lib_div::linkThisScript()) . '" name="' . $this->ext_CEformName . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '">';
177 $content.= $addFields;
178 $content.= $printFields;
179 $content.= '<input type="Submit" name="submit" value="Update" />';
180
181 $example = $this->ext_displayExample();
182 $content.= $example?'<hr/>'.$example:"";
183
184 return $content;
185 }
186
187 /**
188 * [Describe function...]
189 *
190 * @return [type] ...
191 */
192 function ext_displayExample() {
193 global $SOBE,$tmpl;
194 if ($this->helpConfig["imagetag"] || $this->helpConfig["description"] || $this->helpConfig["header"]) {
195 $out = '<div align="center">'.$this->helpConfig["imagetag"].'</div><BR>'.
196 ($this->helpConfig["description"] ? implode(explode("//",$this->helpConfig["description"]),"<BR>")."<BR>" : "").
197 ($this->helpConfig["bulletlist"] ? "<ul><li>".implode(explode("//",$this->helpConfig["bulletlist"]),"<li>")."</ul>" : "<BR>");
198 }
199 return $out;
200 }
201
202 /**
203 * [Describe function...]
204 *
205 * @param [type] $arr: ...
206 * @return [type] ...
207 */
208 function ext_mergeIncomingWithExisting($arr) {
209 $parseObj = t3lib_div::makeInstance("t3lib_TSparser");
210 $parseObj->parse(implode(LF,$this->ext_incomingValues));
211 $arr2 = $parseObj->setup;
212 return t3lib_div::array_merge_recursive_overrule($arr,$arr2);
213 }
214
215 // extends:
216 function ext_getKeyImage($key) {
217 return '<img'.t3lib_iconWorks::skinImg($this->ext_backPath,'gfx/rednumbers/'.$key.'.gif','').' hspace="2" align="top" alt="" />';
218 }
219
220 /**
221 * [Describe function...]
222 *
223 * @param [type] $imgConf: ...
224 * @return [type] ...
225 */
226 function ext_getTSCE_config_image($imgConf) {
227 $iFile=$this->ext_localGfxPrefix.$imgConf;
228 $tFile=$this->ext_localWebGfxPrefix.$imgConf;
229 $imageInfo=@getImagesize($iFile);
230 return '<img src="'.$tFile.'" '.$imageInfo[3].'>';
231 }
232
233 /**
234 * [Describe function...]
235 *
236 * @param [type] $params: ...
237 * @return [type] ...
238 */
239 function ext_fNandV($params) {
240 $fN='data['.$params["name"].']';
241 $fV=$params["value"]=isset($this->ext_realValues[$params["name"]]) ? $this->ext_realValues[$params["name"]] : $params["default_value"];
242 $reg = array();
243 if (preg_match('/^\{[\$][a-zA-Z0-9\.]*\}$/',trim($fV),$reg)) { // Values entered from the constantsedit cannot be constants!
244 $fV="";
245 }
246 $fV=htmlspecialchars($fV);
247
248 return array($fN,$fV,$params);
249 }
250
251 /**
252 * [Describe function...]
253 *
254 * @param [type] $absPath: ...
255 * @return [type] ...
256 */
257 function ext_loadResources($absPath) {
258 $this->ext_readDirResources($GLOBALS["TYPO3_CONF_VARS"]["MODS"]["web_ts"]["onlineResourceDir"]);
259 if (is_dir($absPath)) {
260 $absPath = rtrim($absPath, '/');
261 $this->readDirectory($absPath);
262 }
263 $this->ext_resourceDims();
264 }
265
266 /**
267 * [Describe function...]
268 *
269 * @param [type] $key: ...
270 * @param [type] $var: ...
271 * @return [type] ...
272 */
273 function ext_putValueInConf($key, $var) {
274 $this->ext_incomingValues[$key]=$key."=".$var;
275 }
276
277 /**
278 * [Describe function...]
279 *
280 * @param [type] $key: ...
281 * @return [type] ...
282 */
283 function ext_removeValueInConf($key) {
284 // Nothing...
285 }
286 }
287
288
289 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsstyleconfig.php']) {
290 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsstyleconfig.php']);
291 }
292 ?>