|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 /** 00028 * Displays the secondary-options palette for the TCEFORMs wherever they are shown. 00029 * 00030 * $Id: alt_palette.php 10121 2011-01-18 20:15:30Z ohader $ 00031 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj 00032 * XHTML compliant 00033 * 00034 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00035 */ 00036 /** 00037 * [CLASS/FUNCTION INDEX of SCRIPT] 00038 * 00039 * 00040 * 00041 * 81: class formRender extends t3lib_TCEforms 00042 * 91: function printPalette($palArr) 00043 * 00044 * 00045 * 154: class formRender_vert extends t3lib_TCEforms 00046 * 163: function printPalette($palArr) 00047 * 00048 * 00049 * 223: class SC_alt_palette 00050 * 247: function init() 00051 * 301: function main() 00052 * 341: function printContent() 00053 * 00054 * TOTAL FUNCTIONS: 5 00055 * (This index is automatically created/updated by the extension "extdeveval") 00056 * 00057 * @deprecated since TYPO3 4.5, this file will be removed in TYPO3 4.7. The TYPO3 backend is using typo3/backend.php with less frames, which makes this file obsolete. 00058 */ 00059 00060 00061 require('init.php'); 00062 require('template.php'); 00063 $LANG->includeLLFile('EXT:lang/locallang_alt_doc.xml'); 00064 00065 00066 t3lib_div::deprecationLog('alt_palette.php is deprecated since TYPO3 4.5, this file will be removed in TYPO3 4.7. The TYPO3 backend is using typo3/backend.php with less frames, which makes this file obsolete.'); 00067 00068 00069 00070 00071 /** 00072 * Class for rendering the form fields. 00073 * Extending the TCEforms class 00074 * 00075 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00076 * @package TYPO3 00077 * @subpackage core 00078 * @deprecated since TYPO3 4.3, will be removed in TYPO3 4.6 00079 */ 00080 class formRender extends t3lib_TCEforms { 00081 00082 /** 00083 * Creates the HTML content for the palette 00084 * (Horizontally, for display in the top frame) 00085 * (Used if GET var "backRef" IS set) 00086 * 00087 * @deprecated since TYPO3 4.3, will be removed in TYPO3 4.6 00088 * @param array Array of information from which the fields are built. 00089 * @return string HTML output 00090 */ 00091 function printPalette($palArr) { 00092 t3lib_div::logDeprecatedFunction(); 00093 00094 $out=''; 00095 00096 // For each element on the palette, write a few table cells with the field name, content and control images: 00097 foreach($palArr as $content) { 00098 $iRow[]=' 00099 <td>'. 00100 '<img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" class="c-reqIcon" src="clear.gif" width="10" height="10" alt="" />'. 00101 '<img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" class="c-cmIcon" src="clear.gif" width="7" height="10" alt="" />'. 00102 '</td> 00103 <td class="c-label">'. 00104 $content['NAME'].' '. 00105 '</td> 00106 <td class="c-csh">'. 00107 $content['ITEM'].$content['HELP_ICON']. 00108 '</td>'; 00109 } 00110 00111 // Finally, wrap it all in a table: 00112 $out=' 00113 00114 00115 00116 <!-- 00117 TCEforms palette, rendered in top frame. 00118 --> 00119 <table border="0" cellpadding="0" cellspacing="0" id="typo3-TCEforms-palette"> 00120 <tr> 00121 <td class="c-close">'. 00122 '<a href="#" onclick="closePal();return false;">' . t3lib_iconWorks::getSpriteIcon('actions-document-close', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.close', TRUE))) . '</a>'. 00123 '</td>'. 00124 implode('',$iRow).' 00125 </tr> 00126 </table> 00127 00128 '; 00129 00130 // Return the result: 00131 return $out; 00132 } 00133 } 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 /** 00149 * Child class for alternative rendering of form fields (when the secondary fields are shown in a little window rather than the top bar). 00150 * (Used if GET var "backRef" is not set, presuming a window is opened instead.) 00151 * 00152 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00153 * @package TYPO3 00154 * @subpackage core 00155 */ 00156 class formRender_vert extends t3lib_TCEforms { 00157 00158 /** 00159 * Creates the HTML content for the palette. 00160 * (Vertically, for display in a browser window, not top frame) 00161 * 00162 * @param array Array of information from which the fields are built. 00163 * @return string HTML output 00164 */ 00165 function printPalette($palArr) { 00166 $out=''; 00167 $bgColor=' bgcolor="'.$this->colorScheme[2].'"'; 00168 00169 // For each element on the palette, write a few table cells with the field name, content and control images: 00170 foreach($palArr as $content) { 00171 $iRow[]=' 00172 <tr> 00173 <td><img src="clear.gif" width="'.intval($this->paletteMargin).'" height="1" alt="" /></td> 00174 <td'.$bgColor.'> </td> 00175 <td nowrap="nowrap"'.$bgColor.'><font color="'.$this->colorScheme[4].'">'.$content['NAME'].'</font></td> 00176 </tr>'; 00177 $iRow[]=' 00178 <tr> 00179 <td></td> 00180 <td valign="top"><img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="10" height="10" vspace="4" alt="" /><img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" src="clear.gif" width="7" height="10" vspace="4" alt="" /></td> 00181 <td nowrap="nowrap" valign="top">'.$content['ITEM'].$content['HELP_ICON'].'</td> 00182 </tr>'; 00183 } 00184 00185 // Adding the close button: 00186 $iRow[]=' 00187 <tr> 00188 <td></td> 00189 <td></td> 00190 <td nowrap="nowrap" valign="top"> 00191 <br /> 00192 <input type="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.close',1).'" onclick="closePal(); return false;" /> 00193 </td> 00194 </tr>'; 00195 00196 // Finally, wrap it all in a table: 00197 $out=' 00198 <table border="0" cellpadding="0" cellspacing="0" id="typo3-TCEforms-palette-vert"> 00199 '.implode('',$iRow).' 00200 </table>'; 00201 00202 // Return content: 00203 return $out; 00204 } 00205 } 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 /** 00218 * Script Class for rendering the palette form for TCEforms in some other frame (in top frame, horizontally) 00219 * It can also be called in a pop-up window in which case a vertically oriented set of form fields are rendered instead. 00220 * 00221 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00222 * @package TYPO3 00223 * @subpackage core 00224 */ 00225 class SC_alt_palette { 00226 00227 // Internal: 00228 var $content; // Content accumulation 00229 var $backRef; // String, which is the reference back to the window which opened this one. 00230 var $formRef; // String, which is the reference to the form. 00231 var $doc; // Template object. 00232 00233 // Internal, static: GPvar: 00234 var $formName; // Form name 00235 var $GPbackref; // The value of the original backRef GPvar (not necessarily the same as $this->backRef) 00236 var $inData; // Contains tablename, uid and palette number 00237 var $prependFormFieldNames; // Prefix for form fields. 00238 var $rec; // The "record" with the data to display in the form fields. 00239 00240 00241 00242 00243 00244 /** 00245 * Constructor for the class 00246 * 00247 * @return void 00248 */ 00249 function init() { 00250 00251 // Setting GPvars, etc. 00252 $this->formName = $this->sanitizeHtmlName(t3lib_div::_GP('formName')); 00253 $this->GPbackref = $this->sanitizeHtmlName(t3lib_div::_GP('backRef')); 00254 $this->inData = t3lib_div::_GP('inData'); 00255 // safeguards the input with whitelisting 00256 if (!preg_match('/^[a-zA-Z0-9\-_\:]+$/', $this->inData)) { 00257 $this->inData = ''; 00258 } 00259 $this->prependFormFieldNames = 00260 $this->sanitizeHtmlName(t3lib_div::_GP('prependFormFieldNames')); 00261 $this->rec = t3lib_div::_GP('rec'); 00262 00263 // Making references: 00264 $this->backRef = $this->GPbackref ? $this->GPbackref : 'window.opener'; 00265 00266 $this->formRef = $this->backRef.'.document.'.$this->formName; 00267 00268 // Start template object: 00269 $this->doc = t3lib_div::makeInstance('template'); 00270 $this->doc->bodyTagMargins['x']=0; 00271 $this->doc->bodyTagMargins['y']=0; 00272 $this->doc->form='<form action="#" method="post" name="'.htmlspecialchars($this->formName).'" onsubmit="return false;">'; 00273 $this->doc->backPath = ''; 00274 00275 // In case the palette is opened in a SEPARATE window (as the case is with frontend editing) then another body-tag id should be used (so we don't get the background image for the palette shown!) 00276 if (!$this->GPbackref) $this->doc->bodyTagId.= '-vert'; 00277 00278 // Setting JavaScript functions for the header: 00279 $this->doc->JScode = $this->doc->wrapScriptTags(' 00280 var serialNumber = ""; 00281 function timeout_func() { // 00282 if ('.$this->backRef.' && '.$this->backRef.'.document && '.$this->formRef.') { 00283 if ('.$this->formRef.'["_serialNumber"]) { 00284 if (serialNumber) { 00285 if ('.$this->formRef.'["_serialNumber"].value != serialNumber) {closePal(); return false;} 00286 } else { 00287 serialNumber = '.$this->formRef.'["_serialNumber"].value; 00288 } 00289 } 00290 window.setTimeout("timeout_func();",1*1000); 00291 } else closePal(); 00292 } 00293 function closePal() { // 00294 '.($this->GPbackref?'window.location.href="alt_topmenu_dummy.php";':'close();').' 00295 } 00296 timeout_func(); 00297 onBlur="alert();"; 00298 '); 00299 } 00300 00301 /** 00302 * Sanitizes HTML names, IDs, frame names etc. 00303 * 00304 * @param string $input the string to sanitize 00305 * 00306 * @return string the unchanged $input if $input is considered to be harmless, 00307 * an empty string otherwise 00308 */ 00309 protected function sanitizeHtmlName($input) { 00310 $result = $input; 00311 00312 if (!preg_match('/^[a-zA-Z][a-zA-Z0-9_\-\.]*$/', $result)) { 00313 $result = ''; 00314 } 00315 00316 return $result; 00317 } 00318 00319 /** 00320 * Main function, rendering the palette form 00321 * 00322 * @return void 00323 */ 00324 function main() { 00325 00326 $this->content=''; 00327 00328 $inData = explode(':',$this->inData); 00329 00330 // Begin edit: 00331 if (is_array($inData) && count($inData)==3) { 00332 00333 // Create the TCEforms object: 00334 $tceforms = $this->GPbackref ? new formRender() : new formRender_vert(); 00335 $tceforms->initDefaultBEMode(); 00336 $tceforms->palFieldTemplate='###FIELD_PALETTE###'; 00337 $tceforms->palettesCollapsed=0; 00338 $tceforms->isPalettedoc=$this->backRef; 00339 00340 $tceforms->formName = $this->formName; 00341 $tceforms->prependFormFieldNames = $this->prependFormFieldNames; 00342 00343 // Initialize other data: 00344 $table=$inData[0]; 00345 $theUid=$inData[1]; 00346 $thePalNum = $inData[2]; 00347 $this->rec['uid']=$theUid; 00348 00349 // Getting the palette fields rendered: 00350 $panel.=$tceforms->getPaletteFields($table,$this->rec,$thePalNum,'',implode(',',array_keys($this->rec))); 00351 $formContent=$panel; 00352 00353 // Add all the content, including JavaScript as needed. 00354 $this->content.=$tceforms->printNeededJSFunctions_top().$formContent.$tceforms->printNeededJSFunctions(); 00355 } 00356 00357 // Assemble the page: 00358 $tempContent = $this->content; 00359 $this->content = $this->doc->startPage('TYPO3 Edit Palette'); 00360 $this->content.= $tempContent; 00361 } 00362 00363 /** 00364 * Outputting the accumulated content to screen 00365 * 00366 * @return void 00367 */ 00368 function printContent() { 00369 $this->content.= $this->doc->endPage(); 00370 $this->content = $this->doc->insertStylesAndJS($this->content); 00371 echo $this->content; 00372 } 00373 } 00374 00375 00376 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/alt_palette.php'])) { 00377 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/alt_palette.php']); 00378 } 00379 00380 00381 00382 // Make instance: 00383 $SOBE = t3lib_div::makeInstance('SC_alt_palette'); 00384 $SOBE->init(); 00385 $SOBE->main(); 00386 $SOBE->printContent(); 00387 00388 ?>
1.8.0