Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2004 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 ***************************************************************/ 00068 $BACK_PATH=''; 00069 require ('init.php'); 00070 require ('template.php'); 00071 $LANG->includeLLFile('EXT:lang/locallang_wizards.xml'); 00072 require_once (PATH_t3lib.'class.t3lib_parsehtml.php'); 00073 require_once (PATH_t3lib.'class.t3lib_tstemplate.php'); 00074 require_once (PATH_t3lib.'class.t3lib_tsparser_ext.php'); 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00094 class ext_TSparser extends t3lib_tsparser_ext { 00095 00102 function makeHtmlspecialchars($P) { 00103 return $P['_LINK']; 00104 } 00105 } 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00123 class SC_wizard_tsconfig { 00124 00125 // Internal, dynamic: 00126 var $doc; // Document template object 00127 var $content; // Content accumulation for the module. 00128 00129 // Internal, static: GPvars 00130 var $P; // Wizard parameters, coming from TCEforms linking to the wizard. 00131 var $mode; // "page", "tsref" or "beuser" 00132 var $show; // Pointing to an entry in static_tsconfig_help to show. 00133 var $objString; // Object path - for display. 00134 var $onlyProperty; // If set, the "mixed-field" is not shown and you can select only one property at a time. 00135 00136 00137 00138 00139 00145 function init() { 00146 global $LANG,$BACK_PATH; 00147 00148 // Check if the tsconfig_help extension is loaded - which is mandatory for this wizard to work. 00149 t3lib_extMgm::isLoaded('tsconfig_help',1); 00150 00151 // Init GPvars: 00152 $this->P = t3lib_div::_GP('P'); 00153 $this->mode = t3lib_div::_GP('mode'); 00154 $this->show = t3lib_div::_GP('show'); 00155 $this->objString = t3lib_div::_GP('objString'); 00156 $this->onlyProperty = t3lib_div::_GP('onlyProperty'); 00157 00158 // Preparing some JavaScript code: 00159 if (!is_array($this->P['fieldChangeFunc'])) $this->P['fieldChangeFunc']=array(); 00160 unset($this->P['fieldChangeFunc']['alert']); 00161 reset($this->P['fieldChangeFunc']); 00162 $update=''; 00163 while(list($k,$v)=each($this->P['fieldChangeFunc'])) { 00164 $update.= ' 00165 window.opener.'.$v; 00166 } 00167 00168 // Init the document table object: 00169 $this->doc = t3lib_div::makeInstance('mediumDoc'); 00170 $this->doc->docType = 'xhtml_trans'; 00171 $this->doc->backPath = $BACK_PATH; 00172 $this->doc->form='<form action="" name="editform">'; 00173 00174 // Adding Styles (should go into stylesheet?) 00175 $this->doc->inDocStylesArray[] = ' 00176 A:link {text-decoration: bold; color: '.$this->doc->hoverColor.';} 00177 A:visited {text-decoration: bold; color: '.$this->doc->hoverColor.';} 00178 A:active {text-decoration: bold; color: '.$this->doc->hoverColor.';} 00179 A:hover {color: '.$this->doc->bgColor2.'} 00180 '; 00181 00182 $this->doc->JScode.=$this->doc->wrapScriptTags(' 00183 function checkReference() { // 00184 if (window.opener && window.opener.document && window.opener.document.'.$this->P['formName'].' && window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"] ) { 00185 return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemName'].'"]; 00186 } else { 00187 close(); 00188 } 00189 } 00190 function setValue(input) { // 00191 var field = checkReference(); 00192 if (field) { 00193 field.value=input+"\n"+field.value; 00194 '.$update.' 00195 window.opener.focus(); 00196 } 00197 close(); 00198 } 00199 function getValue() { // 00200 var field = checkReference(); 00201 if (field) return field.value; 00202 } 00203 function mixerField(cmd,objString) { // 00204 var temp; 00205 switch(cmd) { 00206 case "Indent": 00207 temp = str_replace("\n","\n ","\n"+document.editform.mixer.value); 00208 document.editform.mixer.value = temp.substr(1); 00209 break; 00210 case "Outdent": 00211 temp = str_replace("\n ","\n","\n"+document.editform.mixer.value); 00212 document.editform.mixer.value = temp.substr(1); 00213 break; 00214 case "Transfer": 00215 setValue(document.editform.mixer.value); 00216 break; 00217 case "Wrap": 00218 document.editform.mixer.value=objString+" {\n"+document.editform.mixer.value+"\n}"; 00219 break; 00220 } 00221 } 00222 function str_replace(match,replace,string) { // 00223 var input = ""+string; 00224 var matchStr = ""+match; 00225 if (!matchStr) {return string;} 00226 var output = ""; 00227 var pointer=0; 00228 var pos = input.indexOf(matchStr); 00229 while (pos!=-1) { 00230 output+=""+input.substr(pointer, pos-pointer)+replace; 00231 pointer=pos+matchStr.length; 00232 pos = input.indexOf(match,pos+1); 00233 } 00234 output+=""+input.substr(pointer); 00235 return output; 00236 } 00237 function jump(show,objString) { // 00238 document.location = "'.t3lib_div::linkThisScript(array('show'=>'','objString'=>'')).'&show="+show+"&objString="+objString; 00239 } 00240 '); 00241 00242 00243 // Start the page: 00244 $this->content.=$this->doc->startPage($LANG->getLL('tsprop')); 00245 } 00246 00252 function main() { 00253 global $LANG; 00254 00255 // Adding module content: 00256 $this->content.=$this->doc->section($LANG->getLL('tsprop'),$this->browseTSprop($this->mode,$this->show),0,1); 00257 00258 // Adding link to TSref: 00259 if ($this->mode=='tsref') { 00260 $this->content.=$this->doc->section($LANG->getLL('tsprop_TSref'),' 00261 <a href="'.htmlspecialchars('http://typo3.org/documentation/document-library/doc_core_tsref/').'" target="_blank">'.$LANG->getLL('tsprop_TSref',1).'</a> 00262 ',0,1); 00263 } 00264 // Adding link to admin guides etc: 00265 if ($this->mode=='page' || $this->mode=='beuser') { 00266 $this->content.=$this->doc->section($LANG->getLL('tsprop_tsconfig'),' 00267 <a href="'.htmlspecialchars('http://typo3.org/documentation/document-library/doc_core_tsconfig/').'" target="_blank">'.$LANG->getLL('tsprop_tsconfig',1).'</a> 00268 ',0,1); 00269 } 00270 // Ending page: 00271 $this->content.=$this->doc->endPage(); 00272 } 00273 00279 function printContent() { 00280 echo $this->content; 00281 } 00282 00290 function browseTSprop($mode,$show) { 00291 global $LANG; 00292 00293 // Get object tree: 00294 $objTree = $this->getObjTree(); 00295 00296 // Show single element, if show is set. 00297 $out=''; 00298 if ($show) { 00299 // Get the entry data: 00300 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'static_tsconfig_help', 'uid='.intval($show)); 00301 $rec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); 00302 $table = unserialize($rec['appdata']); 00303 $obj_string = strtr($this->objString,'()','[]'); // Title: 00304 00305 // Title and description: 00306 $out.='<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('show'=>''))).'" class="typo3-goBack">'. 00307 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/goback.gif','width="14" height="14"').' alt="" />'. 00308 htmlspecialchars($obj_string). 00309 '</a><br />'; 00310 if ($rec['title']) $out.= '<strong>'.htmlspecialchars($rec['title']).': </strong>'; 00311 if ($rec['description']) $out.= nl2br(htmlspecialchars(trim($rec['description']))).'<br />'; 00312 00313 // Printing the content: 00314 $out.= '<br />'.$this->printTable($table, $obj_string, $objTree[$mode.'.']); 00315 $out.='<hr />'; 00316 00317 // Printing the "mixer-field": 00318 if (!$this->onlyProperty) { 00319 $links=array(); 00320 $links[]='<a href="#" onclick="mixerField(\'Indent\');return false;">'.$LANG->getLL('tsprop_mixer_indent',1).'</a>'; 00321 $links[]='<a href="#" onclick="mixerField(\'Outdent\');return false;">'.$LANG->getLL('tsprop_mixer_outdent',1).'</a>'; 00322 $links[]='<a href="#" onclick="mixerField(\'Wrap\',unescape(\''.rawurlencode($obj_string).'\'));return false;">'.$LANG->getLL('tsprop_mixer_wrap',1).'</a>'; 00323 $links[]='<a href="#" onclick="mixerField(\'Transfer\');return false;">'.$LANG->getLL('tsprop_mixer_transfer',1).'</a>'; 00324 $out.='<textarea rows="5" name="mixer" wrap="off"'.$this->doc->formWidthText(48,'','off').'></textarea>'; 00325 $out.='<br /><strong>'.implode(' | ',$links).'</strong>'; 00326 $out.='<hr />'; 00327 } 00328 } 00329 00330 00331 // SECTION: Showing property tree: 00332 $tmpl = t3lib_div::makeInstance('ext_TSparser'); 00333 $tmpl->tt_track = 0; // Do not log time-performance information 00334 $tmpl->fixedLgd=0; 00335 $tmpl->linkObjects=0; 00336 $tmpl->bType=''; 00337 $tmpl->ext_expandAllNotes=1; 00338 $tmpl->ext_noPMicons=1; 00339 $tmpl->ext_noSpecialCharsOnLabels=1; 00340 00341 if (is_array($objTree[$mode.'.'])) { 00342 $out.=' 00343 00344 00345 <!-- 00346 TSconfig, object tree: 00347 --> 00348 <table border="0" cellpadding="0" cellspacing="0" id="typo3-objtree"> 00349 <tr> 00350 <td nowrap="nowrap">'.$tmpl->ext_getObjTree($this->removePointerObjects($objTree[$mode.'.']),'','').'</td> 00351 </tr> 00352 </table>'; 00353 } 00354 00355 return $out; 00356 } 00357 00358 00359 00360 00361 00362 00363 00364 /*************************** 00365 * 00366 * Module functions 00367 * 00368 ***************************/ 00369 00376 function getObjTree() { 00377 $hash = md5('WIZARD_TSCONFIG-objTree'); 00378 $objTree=array(); 00379 00380 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,obj_string,title', 'static_tsconfig_help', ''); 00381 while($rec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00382 $rec['obj_string'] = $this->revertFromSpecialChars($rec['obj_string']); 00383 $p = explode(';',$rec['obj_string']); 00384 while(list(,$v)=each($p)) { 00385 $p2 = t3lib_div::trimExplode(':',$v,1); 00386 $subp=t3lib_div::trimExplode('/',$p2[1],1); 00387 while(list(,$v2)=each($subp)) { 00388 $this->setObj($objTree,explode('.',$p2[0].'.'.$v2),array($rec,$v2)); 00389 } 00390 } 00391 } 00392 return $objTree; 00393 } 00394 00406 function setObj(&$objTree,$strArr,$params) { 00407 $key = current($strArr); 00408 reset($strArr); 00409 if (count($strArr)>1) { 00410 array_shift($strArr); 00411 if (!isset($objTree[$key.'.'])) $objTree[$key.'.']=array(); 00412 $this->setObj($objTree[$key.'.'],$strArr,$params); 00413 } else { 00414 $objTree[$key]=$params; 00415 $objTree[$key]['_LINK']=$this->doLink($params); 00416 } 00417 } 00418 00426 function revertFromSpecialChars($str) { 00427 $str = str_replace('>','>',$str); 00428 $str = str_replace('<','<',$str); 00429 return $str; 00430 } 00431 00439 function doLink($params) { 00440 $title = trim($params[0]['title'])?trim($params[0]['title']):'[GO]'; 00441 $str = $this->linkToObj($title,$params[0]['uid'],$params[1]); 00442 return $str; 00443 } 00444 00452 function removePointerObjects($objArray) { 00453 reset($objArray); 00454 while(list($k)=each($objArray)) { 00455 if (substr(trim($k),0,2)=="->" && trim($k)!='->.') { 00456 $objArray['->.'][substr(trim($k),2)]=$objArray[$k]; 00457 unset($objArray[$k]); 00458 } 00459 } 00460 return $objArray; 00461 } 00462 00471 function linkToObj($str,$uid,$objString='') { 00472 $aOnClick='jump(\''.rawurlencode($uid).'\',\''.rawurlencode($objString).'\');return false;'; 00473 return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.htmlspecialchars($str).'</a>'; 00474 } 00475 00484 function printTable($table,$objString,$objTree) { 00485 if (is_array($table['rows'])) { 00486 00487 // Initialize: 00488 $lines=array(); 00489 00490 // Adding header: 00491 $lines[]=' 00492 <tr> 00493 <td><img src="clear.gif" width="175" height="1" alt="" /></td> 00494 <td><img src="clear.gif" width="100" height="1" alt="" /></td> 00495 <td><img src="clear.gif" width="400" height="1" alt="" /></td> 00496 <td><img src="clear.gif" width="70" height="1" alt="" /></td> 00497 </tr>'; 00498 $lines[]=' 00499 <tr class="bgColor5"> 00500 <td><strong>Property:</strong></td> 00501 <td><strong>Data type:</strong></td> 00502 <td><strong>Description:</strong></td> 00503 <td><strong>Default:</strong></td> 00504 </tr>'; 00505 00506 // Traverse the content of "rows": 00507 foreach($table['rows'] as $row) { 00508 00509 // Linking: 00510 $lP=t3lib_div::trimExplode(chr(10),$row['property'],1); 00511 $lP2=array(); 00512 while(list($k,$lStr)=each($lP)) { 00513 $lP2[$k] = $this->linkProperty($lStr,$lStr,$objString,$row['datatype']); 00514 } 00515 $linkedProperties=implode('<hr />',$lP2); 00516 00517 // Data type: 00518 $dataType = $row['datatype']; 00519 00520 // Generally "->[something]" 00521 $reg=array(); 00522 ereg('->[[:alnum:]_]*',$dataType,$reg); 00523 if ($reg[0] && is_array($objTree[$reg[0]])) { 00524 $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); 00525 } 00526 00527 // stdWrap 00528 if (!strstr($dataType,'->stdWrap') && strstr(strip_tags($dataType),'stdWrap')) { 00529 // 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? 00530 $dataType = str_replace('stdWrap','<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('show'=>$objTree['->stdWrap'][0]['uid'],'objString'=>$objString.'.'.$lP[0]))).'">stdWrap</a>',$dataType); 00531 } 00532 00533 00534 $lines[]=' 00535 <tr class="bgColor4"> 00536 <td valign="top" class="bgColor4-20"><strong>'.$linkedProperties.'</strong></td> 00537 <td valign="top">'.nl2br($dataType.' ').'</td> 00538 <td valign="top">'.nl2br($row['description']).'</td> 00539 <td valign="top">'.nl2br($row['default']).'</td> 00540 </tr>'; 00541 } 00542 // Return it all: 00543 return ' 00544 00545 00546 00547 <!-- 00548 TSconfig, attribute selector: 00549 --> 00550 <table border="0" cellpadding="0" cellspacing="1" width="500" id="typo3-attributes"> 00551 '.implode('',$lines).' 00552 </table>'; 00553 } 00554 } 00555 00565 function linkProperty($str,$propertyVal,$prefix,$datatype) { 00566 $out=''; 00567 00568 // Setting preset value: 00569 if (strstr($datatype,'boolean')) { 00570 $propertyVal.='=1'; // add preset "=1" to boolean values. 00571 } else { 00572 $propertyVal.='='; // add preset "=" 00573 } 00574 00575 // Adding mixer features; The plus icon: 00576 if(!$this->onlyProperty) { 00577 $aOnClick = 'document.editform.mixer.value=unescape(\' '.rawurlencode($propertyVal).'\')+\'\n\'+document.editform.mixer.value; return false;'; 00578 $out.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'. 00579 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('tsprop_addToList',1).'" align="top" alt="" />'. 00580 '</a>'; 00581 $propertyVal = $prefix.'.'.$propertyVal; 00582 } 00583 00584 // Wrap string: 00585 $aOnClick = 'setValue(unescape(\''.rawurlencode($propertyVal).'\')); return false;'; 00586 $out.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$str.'</a>'; 00587 00588 // Return link: 00589 return $out; 00590 } 00591 } 00592 00593 // Include extension? 00594 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_tsconfig.php']) { 00595 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_tsconfig.php']); 00596 } 00597 00598 00599 00600 00601 00602 00603 00604 00605 00606 00607 00608 00609 // Make instance: 00610 $SOBE = t3lib_div::makeInstance('SC_wizard_tsconfig'); 00611 $SOBE->init(); 00612 $SOBE->main(); 00613 $SOBE->printContent(); 00614 ?>