| [ 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 * Wizard for inserting TSconfig in form fields. (page,user or TS) 29 * 30 * $Id: wizard_tsconfig.php 1991 2007-02-04 22:46:30Z 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 * 98: class ext_TSparser extends t3lib_tsparser_ext 42 * 106: function makeHtmlspecialchars($P) 43 * 44 * 45 * 127: class SC_wizard_tsconfig 46 * 149: function init() 47 * 202: function setValue(field,value) 48 * 232: function mixerField(cmd,objString) 49 * 258: function str_replace(match,replace,string) 50 * 280: function jump(show,objString) 51 * 295: function main() 52 * 320: function printContent() 53 * 333: function browseTSprop($mode,$show) 54 * 55 * SECTION: Module functions 56 * 419: function getObjTree() 57 * 449: function setObj(&$objTree,$strArr,$params) 58 * 469: function revertFromSpecialChars($str) 59 * 482: function doLink($params) 60 * 495: function removePointerObjects($objArray) 61 * 514: function linkToObj($str,$uid,$objString='') 62 * 527: function printTable($table,$objString,$objTree) 63 * 608: function linkProperty($str,$propertyName,$prefix,$datatype) 64 * 65 * TOTAL FUNCTIONS: 17 66 * (This index is automatically created/updated by the extension "extdeveval") 67 * 68 */ 69 70 71 72 $BACK_PATH=''; 73 require ('init.php'); 74 require ('template.php'); 75 $LANG->includeLLFile('EXT:lang/locallang_wizards.xml'); 76 require_once (PATH_t3lib.'class.t3lib_parsehtml.php'); 77 require_once (PATH_t3lib.'class.t3lib_tstemplate.php'); 78 require_once (PATH_t3lib.'class.t3lib_tsparser_ext.php'); 79 80 81 82 83 84 85 86 87 88 89 90 91 /** 92 * TypoScript parser extension class. 93 * 94 * @author Kasper Skaarhoj <kasperYYYY@typo3.com> 95 * @package TYPO3 96 * @subpackage core 97 */ 98 class ext_TSparser extends t3lib_tsparser_ext { 99 100 /** 101 * Pass through of incoming value for link. 102 * 103 * @param array P array 104 * @return string The "_LINK" key value, straight away. 105 */ 106 function makeHtmlspecialchars($P) { 107 return $P['_LINK']; 108 } 109 } 110 111 112 113 114 115 116 117 118 119 120 /** 121 * Script Class for rendering the TSconfig/TypoScript property browser. 122 * 123 * @author Kasper Skaarhoj <kasperYYYY@typo3.com> 124 * @package TYPO3 125 * @subpackage core 126 */ 127 class SC_wizard_tsconfig { 128 129 // Internal, dynamic: 130 var $doc; // Document template object 131 var $content; // Content accumulation for the module. 132 133 // Internal, static: GPvars 134 var $P; // Wizard parameters, coming from TCEforms linking to the wizard. 135 var $mode; // "page", "tsref" or "beuser" 136 var $show; // Pointing to an entry in static_tsconfig_help to show. 137 var $objString; // Object path - for display. 138 var $onlyProperty; // If set, the "mixed-field" is not shown and you can select only one property at a time. 139 140 141 142 143 144 /** 145 * Initialization of the class 146 * 147 * @return void 148 */ 149 function init() { 150 global $LANG,$BACK_PATH; 151 152 // Check if the tsconfig_help extension is loaded - which is mandatory for this wizard to work. 153 t3lib_extMgm::isLoaded('tsconfig_help',1); 154 155 // Init GPvars: 156 $this->P = t3lib_div::_GP('P'); 157 $this->mode = t3lib_div::_GP('mode'); 158 $this->show = t3lib_div::_GP('show'); 159 $this->objString = t3lib_div::_GP('objString'); 160 $this->onlyProperty = t3lib_div::_GP('onlyProperty'); 161 // Preparing some JavaScript code: 162 if (!is_array($this->P['fieldChangeFunc'])) $this->P['fieldChangeFunc']=array(); 163 unset($this->P['fieldChangeFunc']['alert']); 164 $update=''; 165 foreach($this->P['fieldChangeFunc'] as $k=>$v) { 166 $update.= ' 167 window.opener.'.$v; 168 } 169 170 // Init the document table object: 171 $this->doc = t3lib_div::makeInstance('mediumDoc'); 172 $this->doc->docType = 'xhtml_trans'; 173 $this->doc->backPath = $BACK_PATH; 174 $this->doc->form='<form action="" name="editform">'; 175 176 // Adding Styles (should go into stylesheet?) 177 $this->doc->inDocStylesArray[] = ' 178 A:link {text-decoration: bold; color: '.$this->doc->hoverColor.';} 179 A:visited {text-decoration: bold; color: '.$this->doc->hoverColor.';} 180 A:active {text-decoration: bold; color: '.$this->doc->hoverColor.';} 181 A:hover {color: '.$this->doc->bgColor2.'} 182 '; 183 184 $this->doc->JScode.=$this->doc->wrapScriptTags(' 185 function checkReference_name() { // Checks if the input field containing the name exists in the document 186 if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"] ) { 187 return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"]; 188 } 189 } 190 function checkReference_value() { // Checks if the input field containing the value exists in the document 191 if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemValue'].'"] ) { 192 return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemValue'].'"]; 193 } 194 } 195 196 /** 197 * [Describe function...] 198 * 199 * @param [type] $field,value: ... 200 * @return [type] ... 201 */ 202 function setValue(field,value) { 203 var nameField = checkReference_name(); 204 var valueField = checkReference_value(); 205 if (nameField) { 206 if (valueField) { // This applies to the TS Object Browser module 207 nameField.value=field; 208 valueField.value=value; 209 } else { // This applies to the Info/Modify module and the Page TSconfig field 210 if (value) { 211 nameField.value=field+"="+value+"\n"+nameField.value; 212 } else { 213 nameField.value=field+"\n"+nameField.value; 214 } 215 } 216 '.$update.' 217 window.opener.focus(); 218 } 219 close(); 220 } 221 function getValue() { // This is never used. Remove it? 222 var field = checkReference_name(); 223 if (field) { 224 return field.value; 225 } else { 226 close(); 227 } 228 } 229 230 /** 231 * [Describe function...] 232 * 233 * @param [type] $cmd,objString: ... 234 * @return [type] ... 235 */ 236 function mixerField(cmd,objString) { 237 var temp; 238 switch(cmd) { 239 case "Indent": 240 temp = str_replace("\n","\n ","\n"+document.editform.mixer.value); 241 document.editform.mixer.value = temp.substr(1); 242 break; 243 case "Outdent": 244 temp = str_replace("\n ","\n","\n"+document.editform.mixer.value); 245 document.editform.mixer.value = temp.substr(1); 246 break; 247 case "Transfer": 248 setValue(document.editform.mixer.value); 249 break; 250 case "Wrap": 251 document.editform.mixer.value=objString+" {\n"+document.editform.mixer.value+"\n}"; 252 break; 253 } 254 } 255 256 /** 257 * [Describe function...] 258 * 259 * @param [type] $match,replace,string: ... 260 * @return [type] ... 261 */ 262 function str_replace(match,replace,string) { 263 var input = ""+string; 264 var matchStr = ""+match; 265 if (!matchStr) {return string;} 266 var output = ""; 267 var pointer=0; 268 var pos = input.indexOf(matchStr); 269 while (pos!=-1) { 270 output+=""+input.substr(pointer, pos-pointer)+replace; 271 pointer=pos+matchStr.length; 272 pos = input.indexOf(match,pos+1); 273 } 274 output+=""+input.substr(pointer); 275 return output; 276 } 277 278 /** 279 * [Describe function...] 280 * 281 * @param [type] $show,objString: ... 282 * @return [type] ... 283 */ 284 function jump(show,objString) { 285 window.location.href = "'.t3lib_div::linkThisScript(array('show'=>'','objString'=>'')).'&show="+show+"&objString="+objString; 286 } 287 '); 288 289 290 // Start the page: 291 $this->content.=$this->doc->startPage($LANG->getLL('tsprop')); 292 } 293 294 /** 295 * Main function, rendering the content of the TypoScript property browser, including links to online resources 296 * 297 * @return void 298 */ 299 function main() { 300 global $LANG; 301 302 // Adding module content: 303 $this->content.=$this->doc->section($LANG->getLL('tsprop'),$this->browseTSprop($this->mode,$this->show),0,1); 304 305 // Adding link to TSref: 306 if ($this->mode=='tsref') { 307 $this->content.=$this->doc->section($LANG->getLL('tsprop_TSref'),' 308 <a href="'.htmlspecialchars('http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/').'" target="_blank">'.$LANG->getLL('tsprop_TSref',1).'</a> 309 ',0,1); 310 } 311 // Adding link to admin guides etc: 312 if ($this->mode=='page' || $this->mode=='beuser') { 313 $this->content.=$this->doc->section($LANG->getLL('tsprop_tsconfig'),' 314 <a href="'.htmlspecialchars('http://typo3.org/documentation/document-library/references/doc_core_tsconfig/current/view/').'" target="_blank">'.$LANG->getLL('tsprop_tsconfig',1).'</a> 315 ',0,1); 316 } 317 } 318 319 /** 320 * Outputting the accumulated content to screen 321 * 322 * @return void 323 */ 324 function printContent() { 325 $this->content.= $this->doc->endPage(); 326 $this->content = $this->doc->insertStylesAndJS($this->content); 327 echo $this->content; 328 } 329 330 /** 331 * Create the content of the module: 332 * 333 * @param string Object string 334 * @param integer Pointing to an entry in static_tsconfig_help to show. 335 * @return string HTML 336 */ 337 function browseTSprop($mode,$show) { 338 global $LANG; 339 340 // Get object tree: 341 $objTree = $this->getObjTree(); 342 343 // Show single element, if show is set. 344 $out=''; 345 if ($show) { 346 // Get the entry data: 347 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'static_tsconfig_help', 'uid='.intval($show)); 348 $rec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 349 $table = unserialize($rec['appdata']); 350 $obj_string = strtr($this->objString,'()','[]'); // Title: 351 352 // Title and description: 353 $out.='<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('show'=>''))).'" class="typo3-goBack">'. 354 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/goback.gif','width="14" height="14"').' alt="" />'. 355 htmlspecialchars($obj_string). 356 '</a><br />'; 357 if ($rec['title']) $out.= '<strong>'.htmlspecialchars($rec['title']).': </strong>'; 358 if ($rec['description']) $out.= nl2br(htmlspecialchars(trim($rec['description']))).'<br />'; 359 360 // Printing the content: 361 $out.= '<br />'.$this->printTable($table, $obj_string, $objTree[$mode.'.']); 362 $out.='<hr />'; 363 364 // Printing the "mixer-field": 365 if (!$this->onlyProperty) { 366 $links=array(); 367 $links[]='<a href="#" onclick="mixerField(\'Indent\');return false;">'.$LANG->getLL('tsprop_mixer_indent',1).'</a>'; 368 $links[]='<a href="#" onclick="mixerField(\'Outdent\');return false;">'.$LANG->getLL('tsprop_mixer_outdent',1).'</a>'; 369 $links[]='<a href="#" onclick="mixerField(\'Wrap\',unescape(\''.rawurlencode($obj_string).'\'));return false;">'.$LANG->getLL('tsprop_mixer_wrap',1).'</a>'; 370 $links[]='<a href="#" onclick="mixerField(\'Transfer\');return false;">'.$LANG->getLL('tsprop_mixer_transfer',1).'</a>'; 371 $out.='<textarea rows="5" name="mixer" wrap="off"'.$this->doc->formWidthText(48,'','off').' class="fixed-font enable-tab"></textarea>'; 372 $out.='<br /><strong>'.implode(' | ',$links).'</strong>'; 373 $out.='<hr />'; 374 } 375 } 376 377 378 // SECTION: Showing property tree: 379 $tmpl = t3lib_div::makeInstance('ext_TSparser'); 380 $tmpl->tt_track = 0; // Do not log time-performance information 381 $tmpl->fixedLgd=0; 382 $tmpl->linkObjects=0; 383 $tmpl->bType=''; 384 $tmpl->ext_expandAllNotes=1; 385 $tmpl->ext_noPMicons=1; 386 $tmpl->ext_noSpecialCharsOnLabels=1; 387 388 if (is_array($objTree[$mode.'.'])) { 389 $out.=' 390 391 392 <!-- 393 TSconfig, object tree: 394 --> 395 <table border="0" cellpadding="0" cellspacing="0" id="typo3-objtree"> 396 <tr> 397 <td nowrap="nowrap">'.$tmpl->ext_getObjTree($this->removePointerObjects($objTree[$mode.'.']),'','','','','1').'</td> 398 </tr> 399 </table>'; 400 } 401 402 return $out; 403 } 404 405 406 407 408 409 410 411 /*************************** 412 * 413 * Module functions 414 * 415 ***************************/ 416 417 /** 418 * Create object tree from static_tsconfig_help table 419 * 420 * @return array Object tree. 421 * @access private 422 */ 423 function getObjTree() { 424 $objTree=array(); 425 426 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,obj_string,title', 'static_tsconfig_help', ''); 427 while($rec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 428 $rec['obj_string'] = $this->revertFromSpecialChars($rec['obj_string']); 429 $p = explode(';',$rec['obj_string']); 430 while(list(,$v)=each($p)) { 431 $p2 = t3lib_div::trimExplode(':',$v,1); 432 $subp=t3lib_div::trimExplode('/',$p2[1],1); 433 while(list(,$v2)=each($subp)) { 434 $this->setObj($objTree,explode('.',$p2[0].'.'.$v2),array($rec,$v2)); 435 } 436 } 437 } 438 return $objTree; 439 } 440 441 /** 442 * Sets the information from a static_tsconfig_help record in the object array. 443 * Makes recursive calls. 444 * 445 * @param array Object tree array, passed by value! 446 * @param array Array of elements from object path (?) 447 * @param array Array with record and something else (?) 448 * @return void 449 * @access private 450 * @see getObjTree() 451 */ 452 function setObj(&$objTree,$strArr,$params) { 453 $key = current($strArr); 454 reset($strArr); 455 if (count($strArr)>1) { 456 array_shift($strArr); 457 if (!isset($objTree[$key.'.'])) $objTree[$key.'.']=array(); 458 $this->setObj($objTree[$key.'.'],$strArr,$params); 459 } else { 460 $objTree[$key]=$params; 461 $objTree[$key]['_LINK']=$this->doLink($params); 462 } 463 } 464 465 /** 466 * Converts > and < to > and < 467 * 468 * @param string Input string 469 * @return string Output string 470 * @access private 471 */ 472 function revertFromSpecialChars($str) { 473 $str = str_replace('>','>',$str); 474 $str = str_replace('<','<',$str); 475 return $str; 476 } 477 478 /** 479 * Creates a link based on input params array: 480 * 481 * @param array Parameters 482 * @return string The link. 483 * @access private 484 */ 485 function doLink($params) { 486 $title = trim($params[0]['title'])?trim($params[0]['title']):'[GO]'; 487 $str = $this->linkToObj($title,$params[0]['uid'],$params[1]); 488 return $str; 489 } 490 491 /** 492 * Remove pointer strings from an array 493 * 494 * @param array Input array 495 * @return array Modified input array 496 * @access private 497 */ 498 function removePointerObjects($objArray) { 499 reset($objArray); 500 while(list($k)=each($objArray)) { 501 if (substr(trim($k),0,2)=="->" && trim($k)!='->.') { 502 $objArray['->.'][substr(trim($k),2)]=$objArray[$k]; 503 unset($objArray[$k]); 504 } 505 } 506 return $objArray; 507 } 508 509 /** 510 * Linking string to object by UID 511 * 512 * @param string String to link 513 * @param integer UID of a static_tsconfig_help record. 514 * @param string Title string for that record! 515 * @return string Linked string 516 */ 517 function linkToObj($str,$uid,$objString='') { 518 $aOnClick='jump(\''.rawurlencode($uid).'\',\''.rawurlencode($objString).'\');return false;'; 519 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.htmlspecialchars($str).'</a>'; 520 } 521 522 /** 523 * Creates a table of properties: 524 * 525 * @param array Array with properties for the current object path 526 * @param string Object path 527 * @param array Object tree 528 * @return string HTML content. 529 */ 530 function printTable($table,$objString,$objTree) { 531 if (is_array($table['rows'])) { 532 533 // Initialize: 534 $lines=array(); 535 536 // Adding header: 537 $lines[]=' 538 <tr> 539 <td><img src="clear.gif" width="175" height="1" alt="" /></td> 540 <td><img src="clear.gif" width="100" height="1" alt="" /></td> 541 <td><img src="clear.gif" width="400" height="1" alt="" /></td> 542 <td><img src="clear.gif" width="70" height="1" alt="" /></td> 543 </tr>'; 544 $lines[]=' 545 <tr class="bgColor5"> 546 <td><strong>Property:</strong></td> 547 <td><strong>Data type:</strong></td> 548 <td><strong>Description:</strong></td> 549 <td><strong>Default:</strong></td> 550 </tr>'; 551 552 // Traverse the content of "rows": 553 foreach($table['rows'] as $row) { 554 555 // Linking: 556 $lP=t3lib_div::trimExplode(chr(10),$row['property'],1); 557 $lP2=array(); 558 while(list($k,$lStr)=each($lP)) { 559 $lP2[$k] = $this->linkProperty($lStr,$lStr,$objString,$row['datatype']); 560 } 561 $linkedProperties=implode('<hr />',$lP2); 562 563 // Data type: 564 $dataType = $row['datatype']; 565 566 // Generally "->[something]" 567 $reg=array(); 568 ereg('->[[:alnum:]_]*',$dataType,$reg); 569 if ($reg[0] && is_array($objTree[$reg[0]])) { 570 $dataType = str_replace($reg[0],'<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('show'=>$objTree[$reg[0]][0]['uid'],'objString'=>$objString.'.'.$lP[0]))).'">'.htmlspecialchars($reg[0]).'</a>',$dataType); 571 } 572 573 // stdWrap 574 if (!strstr($dataType,'->stdWrap') && strstr(strip_tags($dataType),'stdWrap')) { 575 // Potential problem can be that "stdWrap" is substituted inside another A-tag. So maybe we should even check if there is already a <A>-tag present and if so, not make a substitution? 576 $dataType = str_replace('stdWrap','<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('show'=>$objTree['->stdWrap'][0]['uid'],'objString'=>$objString.'.'.$lP[0]))).'">stdWrap</a>',$dataType); 577 } 578 579 580 $lines[]=' 581 <tr class="bgColor4"> 582 <td valign="top" class="bgColor4-20"><strong>'.$linkedProperties.'</strong></td> 583 <td valign="top">'.nl2br($dataType.' ').'</td> 584 <td valign="top">'.nl2br($row['description']).'</td> 585 <td valign="top">'.nl2br($row['default']).'</td> 586 </tr>'; 587 } 588 // Return it all: 589 return ' 590 591 592 593 <!-- 594 TSconfig, attribute selector: 595 --> 596 <table border="0" cellpadding="0" cellspacing="1" width="500" id="typo3-attributes"> 597 '.implode('',$lines).' 598 </table>'; 599 } 600 } 601 602 /** 603 * Creates a link on a property. 604 * 605 * @param string String to link 606 * @param string Property value. 607 * @param string Object path prefix to value 608 * @param string Data type 609 * @return string Linked $str 610 */ 611 function linkProperty($str,$propertyName,$prefix,$datatype) { 612 $out=''; 613 614 // Setting preset value: 615 if (strstr($datatype,'boolean')) { 616 $propertyVal='1'; // preset "1" to boolean values. 617 } 618 619 // Adding mixer features; The plus icon: 620 if(!$this->onlyProperty) { 621 $aOnClick = 'document.editform.mixer.value=unescape(\' '.rawurlencode($propertyName.'='.$propertyVal).'\')+\'\n\'+document.editform.mixer.value; return false;'; 622 $out.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'. 623 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('tsprop_addToList',1).'" align="top" alt="" />'. 624 '</a>'; 625 $propertyName = $prefix.'.'.$propertyName; 626 } 627 628 // Wrap string: 629 $aOnClick = 'setValue(unescape(\''.rawurlencode($propertyName).'\'),unescape(\''.rawurlencode($propertyVal).'\')); return false;'; 630 $out.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$str.'</a>'; 631 632 // Return link: 633 return $out; 634 } 635 } 636 637 // Include extension? 638 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_tsconfig.php']) { 639 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_tsconfig.php']); 640 } 641 642 643 644 645 646 647 648 649 650 651 652 653 // Make instance: 654 $SOBE = t3lib_div::makeInstance('SC_wizard_tsconfig'); 655 $SOBE->init(); 656 $SOBE->main(); 657 $SOBE->printContent(); 658 ?>
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 |
|