Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2005 Kasper Skaarhoj (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 ***************************************************************/ 00072 $BACK_PATH=''; 00073 require ('init.php'); 00074 require ('template.php'); 00075 $LANG->includeLLFile('EXT:lang/locallang_wizards.xml'); 00076 require_once (PATH_t3lib.'class.t3lib_parsehtml.php'); 00077 require_once (PATH_t3lib.'class.t3lib_tstemplate.php'); 00078 require_once (PATH_t3lib.'class.t3lib_tsparser_ext.php'); 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00098 class ext_TSparser extends t3lib_tsparser_ext { 00099 00106 function makeHtmlspecialchars($P) { 00107 return $P['_LINK']; 00108 } 00109 } 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00127 class SC_wizard_tsconfig { 00128 00129 // Internal, dynamic: 00130 var $doc; // Document template object 00131 var $content; // Content accumulation for the module. 00132 00133 // Internal, static: GPvars 00134 var $P; // Wizard parameters, coming from TCEforms linking to the wizard. 00135 var $mode; // "page", "tsref" or "beuser" 00136 var $show; // Pointing to an entry in static_tsconfig_help to show. 00137 var $objString; // Object path - for display. 00138 var $onlyProperty; // If set, the "mixed-field" is not shown and you can select only one property at a time. 00139 00140 00141 00142 00143 00149 function init() { 00150 global $LANG,$BACK_PATH; 00151 00152 // Check if the tsconfig_help extension is loaded - which is mandatory for this wizard to work. 00153 t3lib_extMgm::isLoaded('tsconfig_help',1); 00154 00155 // Init GPvars: 00156 $this->P = t3lib_div::_GP('P'); 00157 $this->mode = t3lib_div::_GP('mode'); 00158 $this->show = t3lib_div::_GP('show'); 00159 $this->objString = t3lib_div::_GP('objString'); 00160 $this->onlyProperty = t3lib_div::_GP('onlyProperty'); 00161 // Preparing some JavaScript code: 00162 if (!is_array($this->P['fieldChangeFunc'])) $this->P['fieldChangeFunc']=array(); 00163 unset($this->P['fieldChangeFunc']['alert']); 00164 $update=''; 00165 foreach($this->P['fieldChangeFunc'] as $k=>$v) { 00166 $update.= ' 00167 window.opener.'.$v; 00168 } 00169 00170 // Init the document table object: 00171 $this->doc = t3lib_div::makeInstance('mediumDoc'); 00172 $this->doc->docType = 'xhtml_trans'; 00173 $this->doc->backPath = $BACK_PATH; 00174 $this->doc->form='<form action="" name="editform">'; 00175 00176 // Adding Styles (should go into stylesheet?) 00177 $this->doc->inDocStylesArray[] = ' 00178 A:link {text-decoration: bold; color: '.$this->doc->hoverColor.';} 00179 A:visited {text-decoration: bold; color: '.$this->doc->hoverColor.';} 00180 A:active {text-decoration: bold; color: '.$this->doc->hoverColor.';} 00181 A:hover {color: '.$this->doc->bgColor2.'} 00182 '; 00183 00184 $this->doc->JScode.=$this->doc->wrapScriptTags(' 00185 function checkReference_name() { // Checks if the input field containing the name exists in the document 00186 if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"] ) { 00187 return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"]; 00188 } 00189 } 00190 function checkReference_value() { // Checks if the input field containing the value exists in the document 00191 if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemValue'].'"] ) { 00192 return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemValue'].'"]; 00193 } 00194 } 00195 00202 function setValue(field,value) { 00203 var nameField = checkReference_name(); 00204 var valueField = checkReference_value(); 00205 if (nameField) { 00206 if (valueField) { // This applies to the TS Object Browser module 00207 nameField.value=field; 00208 valueField.value=value; 00209 } else { // This applies to the Info/Modify module and the Page TSconfig field 00210 if (value) { 00211 nameField.value=field+"="+value+"\n"+nameField.value; 00212 } else { 00213 nameField.value=field+"\n"+nameField.value; 00214 } 00215 } 00216 '.$update.' 00217 window.opener.focus(); 00218 } 00219 close(); 00220 } 00221 function getValue() { // This is never used. Remove it? 00222 var field = checkReference_name(); 00223 if (field) { 00224 return field.value; 00225 } else { 00226 close(); 00227 } 00228 } 00229 00236 function mixerField(cmd,objString) { 00237 var temp; 00238 switch(cmd) { 00239 case "Indent": 00240 temp = str_replace("\n","\n ","\n"+document.editform.mixer.value); 00241 document.editform.mixer.value = temp.substr(1); 00242 break; 00243 case "Outdent": 00244 temp = str_replace("\n ","\n","\n"+document.editform.mixer.value); 00245 document.editform.mixer.value = temp.substr(1); 00246 break; 00247 case "Transfer": 00248 setValue(document.editform.mixer.value); 00249 break; 00250 case "Wrap": 00251 document.editform.mixer.value=objString+" {\n"+document.editform.mixer.value+"\n}"; 00252 break; 00253 } 00254 } 00255 00262 function str_replace(match,replace,string) { 00263 var input = ""+string; 00264 var matchStr = ""+match; 00265 if (!matchStr) {return string;} 00266 var output = ""; 00267 var pointer=0; 00268 var pos = input.indexOf(matchStr); 00269 while (pos!=-1) { 00270 output+=""+input.substr(pointer, pos-pointer)+replace; 00271 pointer=pos+matchStr.length; 00272 pos = input.indexOf(match,pos+1); 00273 } 00274 output+=""+input.substr(pointer); 00275 return output; 00276 } 00277 00284 function jump(show,objString) { 00285 window.location.href = "'.t3lib_div::linkThisScript(array('show'=>'','objString'=>'')).'&show="+show+"&objString="+objString; 00286 } 00287 '); 00288 00289 00290 // Start the page: 00291 $this->content.=$this->doc->startPage($LANG->getLL('tsprop')); 00292 } 00293 00299 function main() { 00300 global $LANG; 00301 00302 // Adding module content: 00303 $this->content.=$this->doc->section($LANG->getLL('tsprop'),$this->browseTSprop($this->mode,$this->show),0,1); 00304 00305 // Adding link to TSref: 00306 if ($this->mode=='tsref') { 00307 $this->content.=$this->doc->section($LANG->getLL('tsprop_TSref'),' 00308 <a href="'.htmlspecialchars('http://typo3.org/documentation/document-library/doc_core_tsref/').'" target="_blank">'.$LANG->getLL('tsprop_TSref',1).'</a> 00309 ',0,1); 00310 } 00311 // Adding link to admin guides etc: 00312 if ($this->mode=='page' || $this->mode=='beuser') { 00313 $this->content.=$this->doc->section($LANG->getLL('tsprop_tsconfig'),' 00314 <a href="'.htmlspecialchars('http://typo3.org/documentation/document-library/doc_core_tsconfig/').'" target="_blank">'.$LANG->getLL('tsprop_tsconfig',1).'</a> 00315 ',0,1); 00316 } 00317 } 00318 00324 function printContent() { 00325 $this->content.= $this->doc->endPage(); 00326 $this->content = $this->doc->insertStylesAndJS($this->content); 00327 echo $this->content; 00328 } 00329 00337 function browseTSprop($mode,$show) { 00338 global $LANG; 00339 00340 // Get object tree: 00341 $objTree = $this->getObjTree(); 00342 00343 // Show single element, if show is set. 00344 $out=''; 00345 if ($show) { 00346 // Get the entry data: 00347 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'static_tsconfig_help', 'uid='.intval($show)); 00348 $rec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 00349 $table = unserialize($rec['appdata']); 00350 $obj_string = strtr($this->objString,'()','[]'); // Title: 00351 00352 // Title and description: 00353 $out.='<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('show'=>''))).'" class="typo3-goBack">'. 00354 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/goback.gif','width="14" height="14"').' alt="" />'. 00355 htmlspecialchars($obj_string). 00356 '</a><br />'; 00357 if ($rec['title']) $out.= '<strong>'.htmlspecialchars($rec['title']).': </strong>'; 00358 if ($rec['description']) $out.= nl2br(htmlspecialchars(trim($rec['description']))).'<br />'; 00359 00360 // Printing the content: 00361 $out.= '<br />'.$this->printTable($table, $obj_string, $objTree[$mode.'.']); 00362 $out.='<hr />'; 00363 00364 // Printing the "mixer-field": 00365 if (!$this->onlyProperty) { 00366 $links=array(); 00367 $links[]='<a href="#" onclick="mixerField(\'Indent\');return false;">'.$LANG->getLL('tsprop_mixer_indent',1).'</a>'; 00368 $links[]='<a href="#" onclick="mixerField(\'Outdent\');return false;">'.$LANG->getLL('tsprop_mixer_outdent',1).'</a>'; 00369 $links[]='<a href="#" onclick="mixerField(\'Wrap\',unescape(\''.rawurlencode($obj_string).'\'));return false;">'.$LANG->getLL('tsprop_mixer_wrap',1).'</a>'; 00370 $links[]='<a href="#" onclick="mixerField(\'Transfer\');return false;">'.$LANG->getLL('tsprop_mixer_transfer',1).'</a>'; 00371 $out.='<textarea rows="5" name="mixer" wrap="off"'.$this->doc->formWidthText(48,'','off').' class="fixed-font enable-tab"></textarea>'; 00372 $out.='<br /><strong>'.implode(' | ',$links).'</strong>'; 00373 $out.='<hr />'; 00374 } 00375 } 00376 00377 00378 // SECTION: Showing property tree: 00379 $tmpl = t3lib_div::makeInstance('ext_TSparser'); 00380 $tmpl->tt_track = 0; // Do not log time-performance information 00381 $tmpl->fixedLgd=0; 00382 $tmpl->linkObjects=0; 00383 $tmpl->bType=''; 00384 $tmpl->ext_expandAllNotes=1; 00385 $tmpl->ext_noPMicons=1; 00386 $tmpl->ext_noSpecialCharsOnLabels=1; 00387 00388 if (is_array($objTree[$mode.'.'])) { 00389 $out.=' 00390 00391 00392 <!-- 00393 TSconfig, object tree: 00394 --> 00395 <table border="0" cellpadding="0" cellspacing="0" id="typo3-objtree"> 00396 <tr> 00397 <td nowrap="nowrap">'.$tmpl->ext_getObjTree($this->removePointerObjects($objTree[$mode.'.']),'','').'</td> 00398 </tr> 00399 </table>'; 00400 } 00401 00402 return $out; 00403 } 00404 00405 00406 00407 00408 00409 00410 00411 /*************************** 00412 * 00413 * Module functions 00414 * 00415 ***************************/ 00416 00423 function getObjTree() { 00424 $hash = md5('WIZARD_TSCONFIG-objTree'); 00425 $objTree=array(); 00426 00427 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,obj_string,title', 'static_tsconfig_help', ''); 00428 while($rec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00429 $rec['obj_string'] = $this->revertFromSpecialChars($rec['obj_string']); 00430 $p = explode(';',$rec['obj_string']); 00431 while(list(,$v)=each($p)) { 00432 $p2 = t3lib_div::trimExplode(':',$v,1); 00433 $subp=t3lib_div::trimExplode('/',$p2[1],1); 00434 while(list(,$v2)=each($subp)) { 00435 $this->setObj($objTree,explode('.',$p2[0].'.'.$v2),array($rec,$v2)); 00436 } 00437 } 00438 } 00439 return $objTree; 00440 } 00441 00453 function setObj(&$objTree,$strArr,$params) { 00454 $key = current($strArr); 00455 reset($strArr); 00456 if (count($strArr)>1) { 00457 array_shift($strArr); 00458 if (!isset($objTree[$key.'.'])) $objTree[$key.'.']=array(); 00459 $this->setObj($objTree[$key.'.'],$strArr,$params); 00460 } else { 00461 $objTree[$key]=$params; 00462 $objTree[$key]['_LINK']=$this->doLink($params); 00463 } 00464 } 00465 00473 function revertFromSpecialChars($str) { 00474 $str = str_replace('>','>',$str); 00475 $str = str_replace('<','<',$str); 00476 return $str; 00477 } 00478 00486 function doLink($params) { 00487 $title = trim($params[0]['title'])?trim($params[0]['title']):'[GO]'; 00488 $str = $this->linkToObj($title,$params[0]['uid'],$params[1]); 00489 return $str; 00490 } 00491 00499 function removePointerObjects($objArray) { 00500 reset($objArray); 00501 while(list($k)=each($objArray)) { 00502 if (substr(trim($k),0,2)=="->" && trim($k)!='->.') { 00503 $objArray['->.'][substr(trim($k),2)]=$objArray[$k]; 00504 unset($objArray[$k]); 00505 } 00506 } 00507 return $objArray; 00508 } 00509 00518 function linkToObj($str,$uid,$objString='') { 00519 $aOnClick='jump(\''.rawurlencode($uid).'\',\''.rawurlencode($objString).'\');return false;'; 00520 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.htmlspecialchars($str).'</a>'; 00521 } 00522 00531 function printTable($table,$objString,$objTree) { 00532 if (is_array($table['rows'])) { 00533 00534 // Initialize: 00535 $lines=array(); 00536 00537 // Adding header: 00538 $lines[]=' 00539 <tr> 00540 <td><img src="clear.gif" width="175" height="1" alt="" /></td> 00541 <td><img src="clear.gif" width="100" height="1" alt="" /></td> 00542 <td><img src="clear.gif" width="400" height="1" alt="" /></td> 00543 <td><img src="clear.gif" width="70" height="1" alt="" /></td> 00544 </tr>'; 00545 $lines[]=' 00546 <tr class="bgColor5"> 00547 <td><strong>Property:</strong></td> 00548 <td><strong>Data type:</strong></td> 00549 <td><strong>Description:</strong></td> 00550 <td><strong>Default:</strong></td> 00551 </tr>'; 00552 00553 // Traverse the content of "rows": 00554 foreach($table['rows'] as $row) { 00555 00556 // Linking: 00557 $lP=t3lib_div::trimExplode(chr(10),$row['property'],1); 00558 $lP2=array(); 00559 while(list($k,$lStr)=each($lP)) { 00560 $lP2[$k] = $this->linkProperty($lStr,$lStr,$objString,$row['datatype']); 00561 } 00562 $linkedProperties=implode('<hr />',$lP2); 00563 00564 // Data type: 00565 $dataType = $row['datatype']; 00566 00567 // Generally "->[something]" 00568 $reg=array(); 00569 ereg('->[[:alnum:]_]*',$dataType,$reg); 00570 if ($reg[0] && is_array($objTree[$reg[0]])) { 00571 $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); 00572 } 00573 00574 // stdWrap 00575 if (!strstr($dataType,'->stdWrap') && strstr(strip_tags($dataType),'stdWrap')) { 00576 // 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? 00577 $dataType = str_replace('stdWrap','<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('show'=>$objTree['->stdWrap'][0]['uid'],'objString'=>$objString.'.'.$lP[0]))).'">stdWrap</a>',$dataType); 00578 } 00579 00580 00581 $lines[]=' 00582 <tr class="bgColor4"> 00583 <td valign="top" class="bgColor4-20"><strong>'.$linkedProperties.'</strong></td> 00584 <td valign="top">'.nl2br($dataType.' ').'</td> 00585 <td valign="top">'.nl2br($row['description']).'</td> 00586 <td valign="top">'.nl2br($row['default']).'</td> 00587 </tr>'; 00588 } 00589 // Return it all: 00590 return ' 00591 00592 00593 00594 <!-- 00595 TSconfig, attribute selector: 00596 --> 00597 <table border="0" cellpadding="0" cellspacing="1" width="500" id="typo3-attributes"> 00598 '.implode('',$lines).' 00599 </table>'; 00600 } 00601 } 00602 00612 function linkProperty($str,$propertyName,$prefix,$datatype) { 00613 $out=''; 00614 00615 // Setting preset value: 00616 if (strstr($datatype,'boolean')) { 00617 $propertyVal='1'; // preset "1" to boolean values. 00618 } 00619 00620 // Adding mixer features; The plus icon: 00621 if(!$this->onlyProperty) { 00622 $aOnClick = 'document.editform.mixer.value=unescape(\' '.rawurlencode($propertyName.'='.$propertyVal).'\')+\'\n\'+document.editform.mixer.value; return false;'; 00623 $out.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'. 00624 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('tsprop_addToList',1).'" align="top" alt="" />'. 00625 '</a>'; 00626 $propertyName = $prefix.'.'.$propertyName; 00627 } 00628 00629 // Wrap string: 00630 $aOnClick = 'setValue(unescape(\''.rawurlencode($propertyName).'\'),unescape(\''.rawurlencode($propertyVal).'\')); return false;'; 00631 $out.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$str.'</a>'; 00632 00633 // Return link: 00634 return $out; 00635 } 00636 } 00637 00638 // Include extension? 00639 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_tsconfig.php']) { 00640 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_tsconfig.php']); 00641 } 00642 00643 00644 00645 00646 00647 00648 00649 00650 00651 00652 00653 00654 // Make instance: 00655 $SOBE = t3lib_div::makeInstance('SC_wizard_tsconfig'); 00656 $SOBE->init(); 00657 $SOBE->main(); 00658 $SOBE->printContent(); 00659 ?>