[ Index ] |
|
Code source de Typo3 4.1.3 |
1 <?php 2 /*************************************************************** 3 * Copyright notice 4 * 5 * (c) 1999-2005 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 * Displays the secondary-options palette for the TCEFORMs wherever they are shown. 29 * 30 * $Id: alt_palette.php 1421 2006-04-10 09:27:15Z mundaun $ 31 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj 32 * XHTML compliant 33 * 34 * @author Kasper Skaarhoj <kasperYYYY@typo3.com> 35 */ 36 /** 37 * [CLASS/FUNCTION INDEX of SCRIPT] 38 * 39 * 40 * 41 * 81: class formRender extends t3lib_TCEforms 42 * 91: function printPalette($palArr) 43 * 44 * 45 * 154: class formRender_vert extends t3lib_TCEforms 46 * 163: function printPalette($palArr) 47 * 48 * 49 * 223: class SC_alt_palette 50 * 247: function init() 51 * 301: function main() 52 * 341: function printContent() 53 * 54 * TOTAL FUNCTIONS: 5 55 * (This index is automatically created/updated by the extension "extdeveval") 56 * 57 */ 58 59 60 61 require ('init.php'); 62 require ('template.php'); 63 require_once(PATH_t3lib.'class.t3lib_tceforms.php'); 64 require_once(PATH_t3lib.'class.t3lib_transferdata.php'); 65 require_once(PATH_t3lib.'class.t3lib_loaddbgroup.php'); 66 $LANG->includeLLFile('EXT:lang/locallang_alt_doc.xml'); 67 68 69 70 71 72 73 /** 74 * Class for rendering the form fields. 75 * Extending the TCEforms class 76 * 77 * @author Kasper Skaarhoj <kasperYYYY@typo3.com> 78 * @package TYPO3 79 * @subpackage core 80 */ 81 class formRender extends t3lib_TCEforms { 82 83 /** 84 * Creates the HTML content for the palette 85 * (Horizontally, for display in the top frame) 86 * (Used if GET var "backRef" IS set) 87 * 88 * @param array Array of information from which the fields are built. 89 * @return string HTML output 90 */ 91 function printPalette($palArr) { 92 $out=''; 93 94 // For each element on the palette, write a few table cells with the field name, content and control images: 95 foreach($palArr as $content) { 96 $iRow[]=' 97 <td>'. 98 '<img name="req_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" class="c-reqIcon" src="clear.gif" width="10" height="10" alt="" />'. 99 '<img name="cm_'.$content['TABLE'].'_'.$content['ID'].'_'.$content['FIELD'].'" class="c-cmIcon" src="clear.gif" width="7" height="10" alt="" />'. 100 '</td> 101 <td class="c-label">'. 102 $content['NAME'].' '. 103 '</td> 104 <td class="c-csh">'. 105 $content['ITEM'].$content['HELP_ICON']. 106 '</td>'; 107 } 108 109 // Finally, wrap it all in a table: 110 $out=' 111 112 113 114 <!-- 115 TCEforms palette, rendered in top frame. 116 --> 117 <table border="0" cellpadding="0" cellspacing="0" id="typo3-TCEforms-palette"> 118 <tr> 119 <td class="c-close">'. 120 '<a href="#" onclick="closePal();return false;"><img'.t3lib_iconWorks::skinImg('','gfx/close_12h.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.close',1).'" alt="" /></a>'. 121 '</td>'. 122 implode('',$iRow).' 123 </tr> 124 </table> 125 126 '; 127 128 // Return the result: 129 return $out; 130 } 131 } 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 /** 147 * Child class for alternative rendering of form fields (when the secondary fields are shown in a little window rather than the top bar). 148 * (Used if GET var "backRef" is not set, presuming a window is opened instead.) 149 * 150 * @author Kasper Skaarhoj <kasperYYYY@typo3.com> 151 * @package TYPO3 152 * @subpackage core 153 */ 154 class formRender_vert extends t3lib_TCEforms { 155 156 /** 157 * Creates the HTML content for the palette. 158 * (Vertically, for display in a browser window, not top frame) 159 * 160 * @param array Array of information from which the fields are built. 161 * @return string HTML output 162 */ 163 function printPalette($palArr) { 164 $out=''; 165 $bgColor=' bgcolor="'.$this->colorScheme[2].'"'; 166 167 // For each element on the palette, write a few table cells with the field name, content and control images: 168 foreach($palArr as $content) { 169 $iRow[]=' 170 <tr> 171 <td><img src="clear.gif" width="'.intval($this->paletteMargin).'" height="1" alt="" /></td> 172 <td'.$bgColor.'> </td> 173 <td nowrap="nowrap"'.$bgColor.'><font color="'.$this->colorScheme[4].'">'.$content['NAME'].'</font></td> 174 </tr>'; 175 $iRow[]=' 176 <tr> 177 <td></td> 178 <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> 179 <td nowrap="nowrap" valign="top">'.$content['ITEM'].$content['HELP_ICON'].'</td> 180 </tr>'; 181 } 182 183 // Adding the close button: 184 $iRow[]=' 185 <tr> 186 <td></td> 187 <td></td> 188 <td nowrap="nowrap" valign="top"> 189 <br /> 190 <input type="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.close',1).'" onclick="closePal(); return false;" /> 191 </td> 192 </tr>'; 193 194 // Finally, wrap it all in a table: 195 $out=' 196 <table border="0" cellpadding="0" cellspacing="0" id="typo3-TCEforms-palette-vert"> 197 '.implode('',$iRow).' 198 </table>'; 199 200 // Return content: 201 return $out; 202 } 203 } 204 205 206 207 208 209 210 211 212 213 214 215 /** 216 * Script Class for rendering the palette form for TCEforms in some other frame (in top frame, horizontally) 217 * It can also be called in a pop-up window in which case a vertically oriented set of form fields are rendered instead. 218 * 219 * @author Kasper Skaarhoj <kasperYYYY@typo3.com> 220 * @package TYPO3 221 * @subpackage core 222 */ 223 class SC_alt_palette { 224 225 // Internal: 226 var $content; // Content accumulation 227 var $backRef; // String, which is the reference back to the window which opened this one. 228 var $formRef; // String, which is the reference to the form. 229 var $doc; // Template object. 230 231 // Internal, static: GPvar: 232 var $formName; // Form name 233 var $GPbackref; // The value of the original backRef GPvar (not necessarily the same as $this->backRef) 234 var $inData; // Contains tablename, uid and palette number 235 var $prependFormFieldNames; // Prefix for form fields. 236 var $rec; // The "record" with the data to display in the form fields. 237 238 239 240 241 242 /** 243 * Constructor for the class 244 * 245 * @return void 246 */ 247 function init() { 248 249 // Setting GPvars, etc. 250 $this->formName = t3lib_div::_GP('formName'); 251 $this->GPbackref = t3lib_div::_GP('backRef'); 252 $this->inData = t3lib_div::_GP('inData'); 253 $this->prependFormFieldNames = t3lib_div::_GP('prependFormFieldNames'); 254 $this->rec = t3lib_div::_GP('rec'); 255 256 // Making references: 257 $this->backRef = $this->GPbackref ? $this->GPbackref : 'window.opener'; 258 # $this->backRef = 'top.content.list_frame.view_frame'; 259 260 $this->formRef = $this->backRef.'.document.'.$this->formName; 261 262 // Start template object: 263 $this->doc = t3lib_div::makeInstance('template'); 264 $this->doc->bodyTagMargins['x']=0; 265 $this->doc->bodyTagMargins['y']=0; 266 $this->doc->form='<form action="#" method="post" name="'.htmlspecialchars($this->formName).'" onsubmit="return false;">'; 267 $this->doc->docType = 'xhtml_trans'; 268 $this->doc->backPath = ''; 269 270 // 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!) 271 if (!$this->GPbackref) $this->doc->bodyTagId.= '-vert'; 272 273 // Setting JavaScript functions for the header: 274 $this->doc->JScode = $this->doc->wrapScriptTags(' 275 var serialNumber = ""; 276 function timeout_func() { // 277 if ('.$this->backRef.' && '.$this->backRef.'.document && '.$this->formRef.') { 278 if ('.$this->formRef.'["_serialNumber"]) { 279 if (serialNumber) { 280 if ('.$this->formRef.'["_serialNumber"].value != serialNumber) {closePal(); return false;} 281 } else { 282 serialNumber = '.$this->formRef.'["_serialNumber"].value; 283 } 284 } 285 window.setTimeout("timeout_func();",1*1000); 286 } else closePal(); 287 } 288 function closePal() { // 289 '.($this->GPbackref?'window.location.href="alt_topmenu_dummy.php";':'close();').' 290 } 291 timeout_func(); 292 onBlur="alert();"; 293 '); 294 } 295 296 /** 297 * Main function, rendering the palette form 298 * 299 * @return void 300 */ 301 function main() { 302 303 $this->content=''; 304 $this->content.=$this->doc->startPage('TYPO3 Edit Palette'); 305 306 $inData = explode(':',$this->inData); 307 308 // Begin edit: 309 if (is_array($inData) && count($inData)==3) { 310 311 // Create the TCEforms object: 312 $tceforms = $this->GPbackref ? new formRender() : new formRender_vert(); 313 $tceforms->initDefaultBEMode(); 314 $tceforms->palFieldTemplate='###FIELD_PALETTE###'; 315 $tceforms->palettesCollapsed=0; 316 $tceforms->isPalettedoc=$this->backRef; 317 318 $tceforms->formName = $this->formName; 319 $tceforms->prependFormFieldNames = $this->prependFormFieldNames; 320 321 // Initialize other data: 322 $table=$inData[0]; 323 $theUid=$inData[1]; 324 $thePalNum = $inData[2]; 325 $this->rec['uid']=$theUid; 326 327 // Getting the palette fields rendered: 328 $panel.=$tceforms->getPaletteFields($table,$this->rec,$thePalNum,'',implode(',',array_keys($this->rec))); 329 $formContent=$panel; 330 331 // Add all the content, including JavaScript as needed. 332 $this->content.=$tceforms->printNeededJSFunctions_top().$formContent.$tceforms->printNeededJSFunctions(); 333 } 334 } 335 336 /** 337 * Outputting the accumulated content to screen 338 * 339 * @return void 340 */ 341 function printContent() { 342 $this->content.= $this->doc->endPage(); 343 $this->content = $this->doc->insertStylesAndJS($this->content); 344 echo $this->content; 345 } 346 } 347 348 // Include extension? 349 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_palette.php']) { 350 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_palette.php']); 351 } 352 353 354 355 356 357 358 359 360 361 362 363 364 // Make instance: 365 $SOBE = t3lib_div::makeInstance('SC_alt_palette'); 366 $SOBE->init(); 367 $SOBE->main(); 368 $SOBE->printContent(); 369 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Nov 25 17:13:16 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |