2 /***************************************************************
5 * (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Provides a simplified layer for making Constant Editor style configuration forms
32 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
35 * [CLASS/FUNCTION INDEX of SCRIPT]
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)
56 * (This index is automatically created/updated by the extension "extdeveval")
72 * Provides a simplified layer for making Constant Editor style configuration forms
74 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
78 class t3lib_tsStyleConfig
extends t3lib_tsparser_ext
{
80 var $categories = array();
81 var $ext_dontCheckIssetValues=1;
82 var $ext_CEformName="tsStyleConfigForm";
83 var $ext_noCEUploadAndCopying=1;
85 var $ext_defaultOnlineResourceFlag=1;
87 var $ext_incomingValues = array();
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: ...
97 function ext_initTSstyleConfig($configTemplate,$pathRel,$pathAbs,$backPath) {
98 $this->tt_track
= 0; // Do not log time-performance information
99 $this->constants
=array($configTemplate,"");
101 $theConstants = $this->generateConfig_constants(); // The editable constants are returned in an array.
103 $this->ext_localGfxPrefix
=$pathAbs;
104 $this->ext_localWebGfxPrefix
=$backPath.$pathRel;
105 $this->ext_backPath
= $backPath;
107 return $theConstants;
111 * [Describe function...]
113 * @param [type] $theConstants: ...
114 * @param [type] $valueArray: ...
117 function ext_setValueArray($theConstants,$valueArray) {
119 $temp = $this->flatSetup
;
120 $this->flatSetup
= Array();
121 $this->flattenSetup($valueArray,"","");
122 $this->objReg
= $this->ext_realValues
= $this->flatSetup
;
123 $this->flatSetup
= $temp;
126 reset($theConstants);
127 while(list($k,$p)=each($theConstants)) {
128 if (isset($this->objReg
[$k])) {
129 $theConstants[$k]["value"] = $this->ext_realValues
[$k];
133 $this->categories
=array(); // Reset the default pool of categories.
134 $this->ext_categorizeEditableConstants($theConstants); // The returned constants are sorted in categories, that goes into the $this->categories array
136 return $theConstants;
140 * [Describe function...]
144 function ext_getCategoriesForModMenu() {
145 return $this->ext_getCategoryLabelArray();
149 * [Describe function...]
151 * @param [type] $cat: ...
154 function ext_makeHelpInformationForCategory($cat) {
155 return $this->ext_getTSCE_config($cat);
159 * [Describe function...]
161 * @param [type] $cat: ...
162 * @param [type] $theConstants: ...
163 * @param [type] $script: ...
164 * @param [type] $addFields: ...
167 function ext_getForm($cat,$theConstants,$script="",$addFields="") {
168 $this->ext_makeHelpInformationForCategory($cat);
169 $printFields = trim($this->ext_printFields($theConstants,$cat));
173 <script language="javascript" type="text/javascript">
174 function uFormUrl(aname) {
175 document.'.$this->ext_CEformName
.'.action = "'.t3lib_div
::linkThisScript().'#"+aname;
179 $content .= '<form action="' . ($script ?
$script : t3lib_div
::linkThisScript()) . '" name="' . $this->ext_CEformName
. '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '">';
180 $content.= $addFields;
181 # $content.= '<input type="Submit" name="submit" value="Update"><BR>';
182 $content.= $printFields;
183 $content.= '<input type="Submit" name="submit" value="Update">';
185 $example = $this->ext_displayExample();
186 $content.= $example?
'<HR>'.$example:"";
192 * [Describe function...]
196 function ext_displayExample() {
198 if ($this->helpConfig
["imagetag"] ||
$this->helpConfig
["description"] ||
$this->helpConfig
["header"]) {
199 $out = '<div align="center">'.$this->helpConfig
["imagetag"].'</div><BR>'.
200 ($this->helpConfig
["description"] ?
implode(explode("//",$this->helpConfig
["description"]),"<BR>")."<BR>" : "").
201 ($this->helpConfig
["bulletlist"] ?
"<ul><li>".implode(explode("//",$this->helpConfig
["bulletlist"]),"<li>")."</ul>" : "<BR>");
207 * [Describe function...]
209 * @param [type] $arr: ...
212 function ext_mergeIncomingWithExisting($arr) {
213 $parseObj = t3lib_div
::makeInstance("t3lib_TSparser");
214 $parseObj->parse(implode(chr(10),$this->ext_incomingValues
));
215 $arr2 = $parseObj->setup
;
216 return t3lib_div
::array_merge_recursive_overrule($arr,$arr2);
220 function ext_getKeyImage($key) {
221 return '<img'.t3lib_iconWorks
::skinImg($this->ext_backPath
,'gfx/rednumbers/'.$key.'.gif','').' hspace="2" align="top" alt="" />';
225 * [Describe function...]
227 * @param [type] $imgConf: ...
230 function ext_getTSCE_config_image($imgConf) {
231 $iFile=$this->ext_localGfxPrefix
.$imgConf;
232 $tFile=$this->ext_localWebGfxPrefix
.$imgConf;
233 $imageInfo=@getImagesize
($iFile);
234 return '<img src="'.$tFile.'" '.$imageInfo[3].'>';
238 * [Describe function...]
240 * @param [type] $params: ...
243 function ext_fNandV($params) {
244 $fN='data['.$params["name"].']';
245 $fV=$params["value"]=isset($this->ext_realValues
[$params["name"]]) ?
$this->ext_realValues
[$params["name"]] : $params["default_value"];
247 if (preg_match('/^\{[\$][a-zA-Z0-9\.]*\}$/',trim($fV),$reg)) { // Values entered from the constantsedit cannot be constants!
250 $fV=htmlspecialchars($fV);
252 return array($fN,$fV,$params);
256 * [Describe function...]
258 * @param [type] $absPath: ...
261 function ext_loadResources($absPath) {
262 $this->ext_readDirResources($GLOBALS["TYPO3_CONF_VARS"]["MODS"]["web_ts"]["onlineResourceDir"]);
263 if (is_dir($absPath)) {
264 $absPath = rtrim($absPath, '/');
265 $this->readDirectory($absPath);
267 $this->ext_resourceDims();
271 * [Describe function...]
273 * @param [type] $key: ...
274 * @param [type] $var: ...
277 function ext_putValueInConf($key, $var) {
278 $this->ext_incomingValues
[$key]=$key."=".$var;
282 * [Describe function...]
284 * @param [type] $key: ...
287 function ext_removeValueInConf($key) {
293 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsstyleconfig.php']) {
294 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['t3lib/class.t3lib_tsstyleconfig.php']);