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 ***************************************************************/ 00081 require('init.php'); 00082 require('template.php'); 00083 $LANG->includeLLFile('EXT:lang/locallang_alt_doc.xml'); 00084 require_once (PATH_t3lib.'class.t3lib_tceforms.php'); 00085 require_once (PATH_t3lib.'class.t3lib_clipboard.php'); 00086 00087 require_once (PATH_t3lib.'class.t3lib_tcemain.php'); 00088 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php'); 00089 require_once (PATH_t3lib.'class.t3lib_transferdata.php'); 00090 00091 00092 t3lib_BEfunc::lockRecords(); 00093 00094 00095 00096 00105 class SC_alt_doc { 00106 00107 // Internal, static: GPvars: 00108 var $editconf; // GPvar "edit": Is an array looking approx like [tablename][list-of-ids]=command, eg. "&edit[pages][123]=edit". See t3lib_BEfunc::editOnClick(). Value can be seen modified internally (converting NEW keyword to id, workspace/versioning etc). 00109 var $columnsOnly; // Commalist of fieldnames to edit. The point is IF you specify this list, only those fields will be rendered in the form. Otherwise all (available) fields in the record is shown according to the types configuration in $TCA 00110 var $defVals; // Default values for fields (array with tablenames, fields etc. as keys). Can be seen modified internally. 00111 var $overrideVals; // Array of values to force being set (as hidden fields). Will be set as $this->defVals IF defVals does not exist. 00112 var $returnUrl; // If set, this value will be set in $this->retUrl (which is used quite many places as the return URL). If not set, "dummy.php" will be set in $this->retUrl 00113 var $closeDoc; // Close-document command. Not really sure of all options... 00114 var $doSave; // Quite simply, if this variable is set, then the processing of incoming data will be performed - as if a save-button is pressed. Used in the forms as a hidden field which can be set through JavaScript if the form is somehow submitted by JavaScript). 00115 00116 var $data; // GPvar (for processing only) : The data array from which the data comes... 00117 var $mirror; // GPvar (for processing only) : ? 00118 var $cacheCmd; // GPvar (for processing only) : Clear-cache cmd. 00119 var $redirect; // GPvar (for processing only) : Redirect (not used???) 00120 var $disableRTE; // GPvar (for processing only) : If set, the rich text editor is disabled in the forms. 00121 var $returnNewPageId; // GPvar (for processing only) : Boolean: If set, then the GET var "&id=" will be added to the retUrl string so that the NEW id of something is returned to the script calling the form. 00122 var $vC; // GPvar (for processing only) : Verification code, internal stuff. 00123 00124 var $popViewId; // GPvar (module) : ID for displaying the page in the frontend (used for SAVE/VIEW operations) 00125 var $popViewId_addParams; // GPvar (module) : Additional GET vars for the link, eg. "&L=xxx" 00126 var $viewUrl; // GPvar (module) : Alternative URL for viewing the frontend pages. 00127 var $editRegularContentFromId; // If this is pointing to a page id it will automatically load all content elements (NORMAL column/default language) from that page into the form! 00128 var $recTitle; // Alternative title for the document handler. 00129 var $disHelp; // Disable help... ? 00130 var $noView; // If set, then no SAVE/VIEW button is printed 00131 var $returnEditConf; // If set, the $this->editconf array is returned to the calling script (used by wizard_add.php for instance) 00132 var $localizationMode; // GP var, localization mode for TCEforms (eg. "text") 00133 00134 00135 // Internal, static: 00136 var $doc; // Document template object 00137 var $content; // Content accumulation 00138 00139 var $retUrl; // Return URL script, processed. This contains the script (if any) that we should RETURN TO from the alt_doc.php script IF we press the close button. Thus this variable is normally passed along from the calling script so we can properly return if needed. 00140 var $R_URL_parts; // Contains the parts of the REQUEST_URI (current url). By parts we mean the result of resolving REQUEST_URI (current url) by the parse_url() function. The result is an array where eg. "path" is the script path and "query" is the parameters... 00141 var $R_URL_getvars; // Contains the current GET vars array; More specifically this array is the foundation for creating the R_URI internal var (which becomes the "url of this script" to which we submit the forms etc.) 00142 var $R_URI; // Set to the URL of this script including variables which is needed to re-display the form. See main() 00143 00144 var $storeTitle; // Is loaded with the "title" of the currently "open document" - this is used in the Document Selector box. (see makeDocSel()) 00145 var $storeArray; // Contains an array with key/value pairs of GET parameters needed to reach the current document displayed - used in the Document Selector box. (see compileStoreDat()) 00146 var $storeUrl; // Contains storeArray, but imploded into a GET parameter string (see compileStoreDat()) 00147 var $storeUrlMd5; // Hashed value of storeURL (see compileStoreDat()) 00148 00149 var $docDat; // Module session data 00150 var $docHandler; // An array of the "open documents" - keys are md5 hashes (see $storeUrlMd5) identifying the various documents on the GET parameter list needed to open it. The values are arrays with 0,1,2 keys with information about the document (see compileStoreDat()). The docHandler variable is stored in the $docDat session data, key "0". 00151 00152 00153 // Internal: Related to the form rendering: 00154 var $elementsData; // Array of the elements to create edit forms for. 00155 var $firstEl; // Pointer to the first element in $elementsData 00156 var $errorC; // Counter, used to count the number of errors (when users do not have edit permissions) 00157 var $newC; // Counter, used to count the number of new record forms displayed 00158 var $viewId; // Is set to the pid value of the last shown record - thus indicating which page to show when clicking the SAVE/VIEW button 00159 var $viewId_addParams; // Is set to additional parameters (like "&L=xxx") if the record supports it. 00160 var $modTSconfig; // Module TSconfig, loaded from main() based on the page id value of viewId 00161 var $tceforms; // Contains the instance of TCEforms class. 00162 var $generalPathOfForm; // Contains the root-line path of the currently edited record(s) - for display. 00163 00164 00165 // Internal, dynamic: 00166 var $dontStoreDocumentRef; // Used internally to disable the storage of the document reference (eg. new records) 00167 00168 00169 00170 00171 00172 00173 00179 function preInit() { 00180 global $BE_USER; 00181 00182 if (t3lib_div::_GP('justLocalized')) { 00183 $this->localizationRedirect(t3lib_div::_GP('justLocalized')); 00184 } 00185 00186 // Setting GPvars: 00187 $this->editconf = t3lib_div::_GP('edit'); 00188 $this->defVals = t3lib_div::_GP('defVals'); 00189 $this->overrideVals = t3lib_div::_GP('overrideVals'); 00190 $this->columnsOnly = t3lib_div::_GP('columnsOnly'); 00191 $this->returnUrl = t3lib_div::_GP('returnUrl'); 00192 $this->closeDoc = t3lib_div::_GP('closeDoc'); 00193 $this->doSave = t3lib_div::_GP('doSave'); 00194 $this->returnEditConf = t3lib_div::_GP('returnEditConf'); 00195 $this->localizationMode = t3lib_div::_GP('localizationMode'); 00196 00197 00198 // Setting override values as default if defVals does not exist. 00199 if (!is_array($this->defVals) && is_array($this->overrideVals)) { 00200 $this->defVals = $this->overrideVals; 00201 } 00202 00203 // Setting return URL 00204 $this->retUrl = $this->returnUrl ? $this->returnUrl : 'dummy.php'; 00205 00206 // Fix $this->editconf if versioning applies to any of the records 00207 $this->fixWSversioningInEditConf(); 00208 00209 // Make R_URL (request url) based on input GETvars: 00210 $this->R_URL_parts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI')); 00211 $this->R_URL_getvars = t3lib_div::_GET(); 00212 $this->R_URL_getvars['edit'] = $this->editconf; 00213 00214 // MAKE url for storing 00215 $this->compileStoreDat(); 00216 00217 // Initialize more variables. 00218 $this->dontStoreDocumentRef=0; 00219 $this->storeTitle=''; 00220 00221 // Get session data for the module: 00222 $this->docDat = $BE_USER->getModuleData('alt_doc.php','ses'); 00223 $this->docHandler = $this->docDat[0]; 00224 00225 // If a request for closing the document has been sent, act accordingly: 00226 if ($this->closeDoc>0) { 00227 $this->closeDocument($this->closeDoc); 00228 } 00229 00230 // If NO vars are sent to the script, try to read first document: 00231 if (is_array($this->R_URL_getvars) && count($this->R_URL_getvars)<2 && !is_array($this->editconf)) { // Added !is_array($this->editconf) because editConf must not be set either. Anyways I can't figure out when this situation here will apply... 00232 $this->setDocument($this->docDat[1]); 00233 } 00234 } 00235 00241 function doProcessData() { 00242 $out = $this->doSave || isset($_POST['_savedok_x']) || isset($_POST['_saveandclosedok_x']) || isset($_POST['_savedokview_x']) || isset($_POST['_savedoknew_x']); 00243 return $out; 00244 } 00245 00251 function processData() { 00252 global $BE_USER,$TYPO3_CONF_VARS; 00253 00254 // GPvars specifically for processing: 00255 $this->data = t3lib_div::_GP('data'); 00256 $this->mirror = t3lib_div::_GP('mirror'); 00257 $this->cacheCmd = t3lib_div::_GP('cacheCmd'); 00258 $this->redirect = t3lib_div::_GP('redirect'); 00259 $this->disableRTE = t3lib_div::_GP('_disableRTE'); 00260 $this->returnNewPageId = t3lib_div::_GP('returnNewPageId'); 00261 $this->vC = t3lib_div::_GP('vC'); 00262 00263 // See tce_db.php for relevate options here: 00264 // Only options related to $this->data submission are included here. 00265 $tce = t3lib_div::makeInstance('t3lib_TCEmain'); 00266 $tce->stripslashes_values=0; 00267 00268 // Setting default values specific for the user: 00269 $TCAdefaultOverride = $BE_USER->getTSConfigProp('TCAdefaults'); 00270 if (is_array($TCAdefaultOverride)) { 00271 $tce->setDefaultsFromUserTS($TCAdefaultOverride); 00272 } 00273 00274 // Setting internal vars: 00275 if ($BE_USER->uc['neverHideAtCopy']) { $tce->neverHideAtCopy = 1; } 00276 $tce->debug=0; 00277 $tce->disableRTE = $this->disableRTE; 00278 00279 // Loading TCEmain with data: 00280 $tce->start($this->data,array()); 00281 if (is_array($this->mirror)) { $tce->setMirror($this->mirror); } 00282 00283 // If pages are being edited, we set an instruction about updating the page tree after this operation. 00284 if (isset($this->data['pages'])) { 00285 t3lib_BEfunc::getSetUpdateSignal('updatePageTree'); 00286 } 00287 00288 00289 // Checking referer / executing 00290 $refInfo=parse_url(t3lib_div::getIndpEnv('HTTP_REFERER')); 00291 $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY'); 00292 if ($httpHost!=$refInfo['host'] && $this->vC!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) { 00293 $tce->log('',0,0,0,1,"Referer host '%s' and server host '%s' did not match and veriCode was not valid either!",1,array($refInfo['host'],$httpHost)); 00294 debug('Error: Referer host did not match with server host.'); 00295 } else { 00296 00297 // Perform the saving operation with TCEmain: 00298 $tce->process_uploads($_FILES); 00299 $tce->process_datamap(); 00300 00301 // If there was saved any new items, load them: 00302 if (count($tce->substNEWwithIDs_table)) { 00303 00304 // Resetting editconf: 00305 $this->editconf = array(); 00306 00307 // Traverse all new records and forge the content of ->editconf so we can continue to EDIT these records! 00308 foreach($tce->substNEWwithIDs_table as $nKey => $nTable) { 00309 $editId = $tce->substNEWwithIDs[$nKey]; 00310 // translate new id to the workspace version: 00311 if ($versionRec = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $nTable, $editId,'uid')) { 00312 $editId = $versionRec['uid']; 00313 } 00314 00315 $this->editconf[$nTable][$editId]='edit'; 00316 if ($nTable=='pages' && $this->retUrl!='dummy.php' && $this->returnNewPageId) { 00317 $this->retUrl.='&id='.$tce->substNEWwithIDs[$nKey]; 00318 } 00319 } 00320 00321 // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed. 00322 $this->R_URL_getvars['edit']=$this->editconf; 00323 00324 // Unsetting default values since we don't need them anymore. 00325 unset($this->R_URL_getvars['defVals']); 00326 00327 // Re-compile the store* values since editconf changed... 00328 $this->compileStoreDat(); 00329 } 00330 00331 // See if any records was auto-created as new versions? 00332 if (count($tce->autoVersionIdMap)) { 00333 $this->fixWSversioningInEditConf($tce->autoVersionIdMap); 00334 } 00335 00336 // If a document is saved and a new one is created right after. 00337 if (isset($_POST['_savedoknew_x']) && is_array($this->editconf)) { 00338 00339 // Finding the current table: 00340 reset($this->editconf); 00341 $nTable=key($this->editconf); 00342 00343 // Finding the first id, getting the records pid+uid 00344 reset($this->editconf[$nTable]); 00345 $nUid=key($this->editconf[$nTable]); 00346 $nRec = t3lib_BEfunc::getRecord($nTable,$nUid,'pid,uid'); 00347 00348 // Setting a blank editconf array for a new record: 00349 $this->editconf=array(); 00350 if ($this->getNewIconMode($nTable)=='top') { 00351 $this->editconf[$nTable][$nRec['pid']]='new'; 00352 } else { 00353 $this->editconf[$nTable][-$nRec['uid']]='new'; 00354 } 00355 00356 // Finally, set the editconf array in the "getvars" so they will be passed along in URLs as needed. 00357 $this->R_URL_getvars['edit']=$this->editconf; 00358 00359 // Re-compile the store* values since editconf changed... 00360 $this->compileStoreDat(); 00361 } 00362 00363 $tce->printLogErrorMessages( 00364 isset($_POST['_saveandclosedok_x']) ? 00365 $this->retUrl : 00366 $this->R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$this->R_URL_getvars) // popView will not be invoked here, because the information from the submit button for save/view will be lost .... But does it matter if there is an error anyways? 00367 ); 00368 } 00369 if (isset($_POST['_saveandclosedok_x']) || $this->closeDoc<0) { // || count($tce->substNEWwithIDs)... If any new items has been save, the document is CLOSED because if not, we just get that element re-listed as new. And we don't want that! 00370 $this->closeDocument(abs($this->closeDoc)); 00371 } 00372 } 00373 00379 function init() { 00380 global $BE_USER,$LANG,$BACK_PATH; 00381 00382 // Setting more GPvars: 00383 $this->popViewId = t3lib_div::_GP('popViewId'); 00384 $this->popViewId_addParams = t3lib_div::_GP('popViewId_addParams'); 00385 $this->viewUrl = t3lib_div::_GP('viewUrl'); 00386 $this->editRegularContentFromId = t3lib_div::_GP('editRegularContentFromId'); 00387 $this->recTitle = t3lib_div::_GP('recTitle'); 00388 $this->disHelp = t3lib_div::_GP('disHelp'); 00389 $this->noView = t3lib_div::_GP('noView'); 00390 00391 // Set other internal variables: 00392 $this->R_URL_getvars['returnUrl']=$this->retUrl; 00393 $this->R_URI = $this->R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$this->R_URL_getvars); 00394 00395 // MENU-ITEMS: 00396 // If array, then it's a selector box menu 00397 // If empty string it's just a variable, that'll be saved. 00398 // Values NOT in this array will not be saved in the settings-array for the module. 00399 $this->MOD_MENU = array( 00400 'showPalettes' => '', 00401 'showDescriptions' => '', 00402 'disableRTE' => '' 00403 ); 00404 00405 // Setting virtual document name 00406 $this->MCONF['name']='xMOD_alt_doc.php'; 00407 00408 // CLEANSE SETTINGS 00409 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']); 00410 00411 // Create an instance of the document template object 00412 $this->doc = t3lib_div::makeInstance('mediumDoc'); 00413 $this->doc->bodyTagMargins['x']=5; 00414 $this->doc->bodyTagMargins['y']=5; 00415 $this->doc->backPath = $BACK_PATH; 00416 $this->doc->docType = 'xhtml_trans'; 00417 00418 $this->doc->form='<form action="'.htmlspecialchars($this->R_URI).'" method="post" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" name="editform" onsubmit="return TBE_EDITOR_checkSubmit(1);">'; 00419 00420 $this->doc->JScode = $this->doc->wrapScriptTags(' 00421 function jumpToUrl(URL,formEl) { // 00422 if (!TBE_EDITOR_isFormChanged()) { 00423 window.location.href = URL; 00424 } else if (formEl && formEl.type=="checkbox") { 00425 formEl.checked = formEl.checked ? 0 : 1; 00426 } 00427 } 00428 00429 // Object: TS: 00430 function typoSetup () { // 00431 this.uniqueID = ""; 00432 } 00433 var TS = new typoSetup(); 00434 00435 // Info view: 00436 function launchView(table,uid,bP) { // 00437 var backPath= bP ? bP : ""; 00438 var thePreviewWindow=""; 00439 thePreviewWindow = window.open(backPath+"show_item.php?table="+escape(table)+"&uid="+escape(uid),"ShowItem"+TS.uniqueID,"height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0"); 00440 if (thePreviewWindow && thePreviewWindow.focus) { 00441 thePreviewWindow.focus(); 00442 } 00443 } 00444 function deleteRecord(table,id,url) { // 00445 if ( 00446 '.($GLOBALS['BE_USER']->jsConfirmation(4)?'confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning')).')':'1==1').' 00447 ) { 00448 window.location.href = "tce_db.php?cmd["+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC='.$BE_USER->veriCode().'&prErr=1&uPT=1"; 00449 } 00450 return false; 00451 } 00452 '.(isset($_POST['_savedokview_x']) && $this->popViewId ? 00453 'if (window.opener) { '. 00454 t3lib_BEfunc::viewOnClick($this->popViewId,'',t3lib_BEfunc::BEgetRootLine($this->popViewId),'',$this->viewUrl,$this->popViewId_addParams,FALSE). 00455 ' } else { '. 00456 t3lib_BEfunc::viewOnClick($this->popViewId,'',t3lib_BEfunc::BEgetRootLine($this->popViewId),'',$this->viewUrl,$this->popViewId_addParams). 00457 ' } ' 00458 : '') 00459 ).$this->doc->getDynTabMenuJScode(); 00460 00461 // Setting up the context sensitive menu: 00462 $CMparts = $this->doc->getContextMenuCode(); 00463 $this->doc->JScode.= $CMparts[0]; 00464 $this->doc->bodyTagAdditions = $CMparts[1]; 00465 $this->doc->postCode.= $CMparts[2]; 00466 } 00467 00473 function main() { 00474 global $BE_USER,$LANG; 00475 00476 // Starting content accumulation: 00477 $this->content=''; 00478 $this->content.=$this->doc->startPage('TYPO3 Edit Document'); 00479 00480 // Begin edit: 00481 if (is_array($this->editconf)) { 00482 00483 // Initialize TCEforms (rendering the forms) 00484 $this->tceforms = t3lib_div::makeInstance('t3lib_TCEforms'); 00485 $this->tceforms->initDefaultBEMode(); 00486 $this->tceforms->doSaveFieldName = 'doSave'; 00487 $this->tceforms->localizationMode = t3lib_div::inList('text,media',$this->localizationMode) ? $this->localizationMode : ''; // text,media is keywords defined in TYPO3 Core API..., see "l10n_cat" 00488 $this->tceforms->returnUrl = $this->R_URI; 00489 $this->tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes']; 00490 $this->tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE']; 00491 $this->tceforms->enableClickMenu = TRUE; 00492 $this->tceforms->enableTabMenu = TRUE; 00493 00494 // Clipboard is initialized: 00495 $this->tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard'); // Start clipboard 00496 $this->tceforms->clipObj->initializeClipboard(); // Initialize - reads the clipboard content from the user session 00497 00498 // Setting external variables: 00499 if ($BE_USER->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions']) $this->tceforms->edit_showFieldHelp='text'; 00500 00501 if ($this->editRegularContentFromId) { 00502 $this->editRegularContentFromId(); 00503 } 00504 00505 // Creating the editing form, wrap it with buttons, document selector etc. 00506 $editForm = $this->makeEditForm(); 00507 00508 if ($editForm) { 00509 reset($this->elementsData); 00510 $this->firstEl = current($this->elementsData); 00511 00512 // language switch/selector for editing 00513 // show only when a single record is edited - multiple records are too confusing 00514 if (count($this->elementsData)==1) { 00515 $languageSwitch = $this->languageSwitch($this->firstEl['table'], $this->firstEl['uid'], $this->firstEl['pid']); 00516 } 00517 00518 00519 if ($this->viewId) { 00520 // Module configuration: 00521 $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->viewId,'mod.xMOD_alt_doc'); 00522 } else $this->modTSconfig=array(); 00523 00524 $panel = $this->makeButtonPanel(); 00525 $docSel = $this->makeDocSel(); 00526 $cMenu = $this->makeCmenu(); 00527 00528 $formContent = $this->compileForm($panel,$docSel,$cMenu,$editForm,$languageSwitch); 00529 00530 $this->content.= $this->tceforms->printNeededJSFunctions_top(). 00531 $formContent. 00532 $this->tceforms->printNeededJSFunctions(); 00533 $this->content.= $this->functionMenus(); 00534 00535 // Add CSH: 00536 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms', $GLOBALS['BACK_PATH'],'<br/>|',FALSE,'margin-top: 20px;'); 00537 00538 $this->content.= $this->shortCutLink(); 00539 00540 $this->tceformMessages(); 00541 } 00542 } 00543 } 00544 00545 00551 function printContent() { 00552 $this->content.= $this->doc->endPage(); 00553 $this->content = $this->doc->insertStylesAndJS($this->content); 00554 echo $this->content; 00555 } 00556 00557 00558 00559 00560 00561 00562 00563 00564 00565 00566 00567 00568 00569 00570 00571 00572 00573 00574 00575 00576 /*************************** 00577 * 00578 * Sub-content functions, rendering specific parts of the module content. 00579 * 00580 ***************************/ 00581 00587 function makeEditForm() { 00588 global $BE_USER,$LANG,$TCA; 00589 00590 // Initialize variables: 00591 $this->elementsData=array(); 00592 $this->errorC=0; 00593 $this->newC=0; 00594 $thePrevUid=''; 00595 $editForm=''; 00596 00597 // Traverse the GPvar edit array 00598 foreach($this->editconf as $table => $conf) { // Tables: 00599 if (is_array($conf) && $TCA[$table] && $BE_USER->check('tables_modify',$table)) { 00600 00601 // Traverse the keys/comments of each table (keys can be a commalist of uids) 00602 foreach($conf as $cKey => $cmd) { 00603 if ($cmd=='edit' || $cmd=='new') { 00604 00605 // Get the ids: 00606 $ids = t3lib_div::trimExplode(',',$cKey,1); 00607 00608 // Traverse the ids: 00609 foreach($ids as $theUid) { 00610 00611 // Checking if the user has permissions? (Only working as a precaution, because the final permission check is always down in TCE. But it's good to notify the user on beforehand...) 00612 // First, resetting flags. 00613 $hasAccess = 1; 00614 $deniedAccessReason = ''; 00615 $deleteAccess = 0; 00616 $this->viewId = 0; 00617 00618 // If the command is to create a NEW record...: 00619 if ($cmd=='new') { 00620 if (intval($theUid)) { // NOTICE: the id values in this case points to the page uid onto which the record should be create OR (if the id is negativ) to a record from the same table AFTER which to create the record. 00621 00622 // Find parent page on which the new record reside 00623 if ($theUid<0) { // Less than zero - find parent page 00624 $calcPRec=t3lib_BEfunc::getRecord($table,abs($theUid)); 00625 $calcPRec=t3lib_BEfunc::getRecord('pages',$calcPRec['pid']); 00626 } else { // always a page 00627 $calcPRec=t3lib_BEfunc::getRecord('pages',abs($theUid)); 00628 } 00629 00630 // Now, calculate whether the user has access to creating new records on this position: 00631 if (is_array($calcPRec)) { 00632 $CALC_PERMS = $BE_USER->calcPerms($calcPRec); // Permissions for the parent page 00633 if ($table=='pages') { // If pages: 00634 $hasAccess = $CALC_PERMS&8 ? 1 : 0; 00635 $this->viewId = $calcPRec['pid']; 00636 } else { 00637 $hasAccess = $CALC_PERMS&16 ? 1 : 0; 00638 $this->viewId = $calcPRec['uid']; 00639 } 00640 } 00641 } 00642 $this->dontStoreDocumentRef=1; // Don't save this document title in the document selector if the document is new. 00643 } else { // Edit: 00644 $calcPRec = t3lib_BEfunc::getRecord($table,$theUid); 00645 t3lib_BEfunc::fixVersioningPid($table,$calcPRec); 00646 if (is_array($calcPRec)) { 00647 if ($table=='pages') { // If pages: 00648 $CALC_PERMS = $BE_USER->calcPerms($calcPRec); 00649 $hasAccess = $CALC_PERMS&2 ? 1 : 0; 00650 $deleteAccess = $CALC_PERMS&4 ? 1 : 0; 00651 $this->viewId = $calcPRec['uid']; 00652 } else { 00653 $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid'])); // Fetching pid-record first. 00654 $hasAccess = $CALC_PERMS&16 ? 1 : 0; 00655 $deleteAccess = $CALC_PERMS&16 ? 1 : 0; 00656 $this->viewId = $calcPRec['pid']; 00657 00658 // Adding "&L=xx" if the record being edited has a languageField with a value larger than zero! 00659 if ($TCA[$table]['ctrl']['languageField'] && $calcPRec[$TCA[$table]['ctrl']['languageField']]>0) { 00660 $this->viewId_addParams = '&L='.$calcPRec[$TCA[$table]['ctrl']['languageField']]; 00661 } 00662 } 00663 00664 // Check internals regarding access: 00665 if ($hasAccess) { 00666 $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec); 00667 $deniedAccessReason = $BE_USER->errorMsg; 00668 } 00669 } else $hasAccess = 0; 00670 } 00671 00672 // AT THIS POINT we have checked the access status of the editing/creation of records and we can now proceed with creating the form elements: 00673 00674 if ($hasAccess) { 00675 $prevPageID = is_object($trData)?$trData->prevPageID:''; 00676 $trData = t3lib_div::makeInstance('t3lib_transferData'); 00677 $trData->addRawData = TRUE; 00678 $trData->defVals = $this->defVals; 00679 $trData->lockRecords=1; 00680 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE']; 00681 $trData->prevPageID = $prevPageID; 00682 $trData->fetchRecord($table,$theUid,$cmd=='new'?'new':''); // 'new' 00683 reset($trData->regTableItems_data); 00684 $rec = current($trData->regTableItems_data); 00685 $rec['uid'] = $cmd=='new' ? uniqid('NEW') : $theUid; 00686 if ($cmd=='new') { 00687 $rec['pid'] = $theUid=='prev'?$thePrevUid:$theUid; 00688 } 00689 $this->elementsData[]=array( 00690 'table' => $table, 00691 'uid' => $rec['uid'], 00692 'pid' => $rec['pid'], 00693 'cmd' => $cmd, 00694 'deleteAccess' => $deleteAccess 00695 ); 00696 00697 // Now, render the form: 00698 if (is_array($rec)) { 00699 00700 // Setting visual path / title of form: 00701 $this->generalPathOfForm = $this->tceforms->getRecordPath($table,$rec); 00702 if (!$this->storeTitle) { 00703 $this->storeTitle = $this->recTitle ? htmlspecialchars($this->recTitle) : t3lib_BEfunc::getRecordTitle($table,$rec,1); 00704 } 00705 00706 // Setting variables in TCEforms object: 00707 $this->tceforms->hiddenFieldList = ''; 00708 $this->tceforms->globalShowHelp = $this->disHelp ? 0 : 1; 00709 if (is_array($this->overrideVals[$table])) { 00710 $this->tceforms->hiddenFieldListArr = array_keys($this->overrideVals[$table]); 00711 } 00712 00713 // Register default language labels, if any: 00714 $this->tceforms->registerDefaultLanguageData($table,$rec); 00715 00716 // Create form for the record (either specific list of fields or the whole record): 00717 $panel = ''; 00718 if ($this->columnsOnly) { 00719 if(is_array($this->columnsOnly)){ 00720 $panel.= $this->tceforms->getListedFields($table,$rec,$this->columnsOnly[$table]); 00721 } else { 00722 $panel.= $this->tceforms->getListedFields($table,$rec,$this->columnsOnly); 00723 } 00724 } else { 00725 $panel.= $this->tceforms->getMainFields($table,$rec); 00726 } 00727 $panel = $this->tceforms->wrapTotal($panel,$rec,$table); 00728 00729 // Setting the pid value for new records: 00730 if ($cmd=='new') { 00731 $panel.= '<input type="hidden" name="data['.$table.']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />'; 00732 $this->newC++; 00733 } 00734 00735 // Display "is-locked" message: 00736 if ($lockInfo = t3lib_BEfunc::isRecordLocked($table,$rec['uid'])) { 00737 $lockIcon = ' 00738 00739 <!-- 00740 Warning box: 00741 --> 00742 <table border="0" cellpadding="0" cellspacing="0" class="warningbox"> 00743 <tr> 00744 <td><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' alt="" /></td> 00745 <td>'.htmlspecialchars($lockInfo['msg']).'</td> 00746 </tr> 00747 </table> 00748 '; 00749 } else $lockIcon = ''; 00750 00751 // Combine it all: 00752 $editForm.= $lockIcon.$panel; 00753 } 00754 00755 $thePrevUid = $rec['uid']; 00756 } else { 00757 $this->errorC++; 00758 $editForm.=$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.noEditPermission',1).'<br /><br />'. 00759 ($deniedAccessReason ? 'Reason: '.htmlspecialchars($deniedAccessReason).'<br/><br/>' : ''); 00760 } 00761 } 00762 } 00763 } 00764 } 00765 } 00766 00767 return $editForm; 00768 } 00769 00775 function makeButtonPanel() { 00776 global $TCA,$LANG; 00777 00778 $panel=''; 00779 00780 // Render SAVE type buttons: 00781 // The action of each button is decided by its name attribute. (See doProcessData()) 00782 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly']) { 00783 00784 // SAVE button: 00785 $panel.= '<input type="image" class="c-inputButton" name="_savedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/savedok.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'" />'; 00786 00787 // SAVE / VIEW button: 00788 if ($this->viewId && !$this->noView && t3lib_extMgm::isLoaded('cms')) { 00789 $panel.= '<input type="image" class="c-inputButton" name="_savedokview"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/savedokshow.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveDocShow',1).'" />'; 00790 } 00791 00792 // SAVE / NEW button: 00793 if (count($this->elementsData)==1 && $this->getNewIconMode($this->firstEl['table'])) { 00794 $panel.= '<input type="image" class="c-inputButton" name="_savedoknew"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/savedoknew.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveNewDoc',1).'" />'; 00795 } 00796 00797 // SAVE / CLOSE 00798 $panel.= '<input type="image" class="c-inputButton" name="_saveandclosedok"'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/saveandclosedok.gif','').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc',1).'" />'; 00799 } 00800 00801 // CLOSE button: 00802 $panel.= '<a href="#" onclick="document.editform.closeDoc.value=1; document.editform.submit(); return false;">'. 00803 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/closedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'" alt="" />'. 00804 '</a>'; 00805 00806 // DELETE + UNDO buttons: 00807 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && count($this->elementsData)==1) { 00808 if ($this->firstEl['cmd']!='new' && t3lib_div::testInt($this->firstEl['uid'])) { 00809 00810 // Delete: 00811 if ($this->firstEl['deleteAccess'] && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && !$this->getNewIconMode($this->firstEl['table'],'disableDelete')) { 00812 $aOnClick = 'return deleteRecord(\''.$this->firstEl['table'].'\',\''.$this->firstEl['uid'].'\',unescape(\''.rawurlencode($this->retUrl).'\'));'; 00813 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'. 00814 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/deletedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->getLL('deleteItem',1).'" alt="" />'. 00815 '</a>'; 00816 } 00817 00818 // Undo: 00819 $undoButton = 0; 00820 $undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->firstEl['table'], 'sys_history').' AND recuid='.intval($this->firstEl['uid']), '', 'tstamp DESC', '1'); 00821 if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) { 00822 $undoButton = 1; 00823 } 00824 if ($undoButton) { 00825 $aOnClick = 'window.location.href=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&revert=ALL_FIELDS&sumUp=-1&returnUrl='.rawurlencode($this->R_URI).'\'; return false;'; 00826 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'. 00827 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/undo.gif','width="21" height="16"').' class="c-inputButton" title="'.htmlspecialchars(sprintf($LANG->getLL('undoLastChange'),t3lib_BEfunc::calcAge(time()-$undoButtonR['tstamp'],$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears')))).'" alt="" />'. 00828 '</a>'; 00829 } 00830 if ($this->getNewIconMode($this->firstEl['table'],'showHistory')) { 00831 $aOnClick = 'window.location.href=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&returnUrl='.rawurlencode($this->R_URI).'\'; return false;'; 00832 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'. 00833 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/history2.gif','width="13" height="12"').' class="c-inputButton" alt="" />'. 00834 '</a>'; 00835 } 00836 00837 // If only SOME fields are shown in the form, this will link the user to the FULL form: 00838 if ($this->columnsOnly) { 00839 $panel.= '<a href="'.htmlspecialchars($this->R_URI.'&columnsOnly=').'">'. 00840 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' class="c-inputButton" title="'.$LANG->getLL('editWholeRecord',1).'" alt="" />'. 00841 '</a>'; 00842 } 00843 } 00844 } 00845 return $panel; 00846 } 00847 00854 function makeDocSel() { 00855 global $BE_USER,$LANG; 00856 00857 // Render the selector ONLY if it has not been disabled: 00858 if (!$this->modTSconfig['properties']['disableDocSelector']) { 00859 00860 // Checking if the currently open document is stored in the list of "open documents" - if not, then add it: 00861 if ((strcmp($this->docDat[1],$this->storeUrlMd5)||!isset($this->docHandler[$this->storeUrlMd5])) && !$this->dontStoreDocumentRef) { 00862 $this->docHandler[$this->storeUrlMd5]=array($this->storeTitle,$this->storeArray,$this->storeUrl); 00863 $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->storeUrlMd5)); 00864 } 00865 00866 // Now, create the document selector box: 00867 $docSel=''; 00868 if (is_array($this->docHandler)) { 00869 $opt = array(); 00870 $opt[] = '<option>[ '.$LANG->getLL('openDocs',1).': ]</option>'; 00871 00872 // Traverse the list of open documents: 00873 foreach($this->docHandler as $md5k => $setupArr) { 00874 $theValue = 'alt_doc.php?'.$setupArr[2].'&returnUrl='.rawurlencode($this->retUrl); 00875 $opt[]='<option value="'.htmlspecialchars($theValue).'"'.(!strcmp($md5k,$this->storeUrlMd5)?' selected="selected"':'').'>'.htmlspecialchars(strip_tags(t3lib_div::htmlspecialchars_decode($setupArr[0]))).'</option>'; 00876 } 00877 00878 // Compile the selector box finally: 00879 $onChange = 'if(this.options[this.selectedIndex].value && !TBE_EDITOR_isFormChanged()){window.location.href=(this.options[this.selectedIndex].value);}'; 00880 $docSel='<select name="_docSelector" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>'; 00881 00882 // Add CSH: 00883 $docSel.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_docSelector', $GLOBALS['BACK_PATH'],'', TRUE); 00884 } 00885 } else $docSel=''; 00886 return $docSel; 00887 } 00888 00896 function makeCmenu() { 00897 00898 // Generate the menu if NOT disabled: 00899 if (!$this->modTSconfig['properties']['disableCacheSelector']) { 00900 $cMenu = $this->doc->clearCacheMenu(intval($this->viewId),!$this->modTSconfig['properties']['disableDocSelector']); 00901 00902 // Add CSH: 00903 $cMenu.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_cacheSelector', $GLOBALS['BACK_PATH'],'', TRUE); 00904 } else $cMenu =''; 00905 return $cMenu; 00906 } 00907 00918 function compileForm($panel,$docSel,$cMenu,$editForm, $langSelector='') { 00919 global $LANG; 00920 00921 00922 $formContent=''; 00923 $formContent.=' 00924 00925 <!-- 00926 Header of the editing page. 00927 Contains the buttons for saving/closing, the document selector and menu selector. 00928 Shows the path of the editing operation as well. 00929 --> 00930 <table border="0" cellpadding="0" cellspacing="1" width="470" id="typo3-altdoc-header"> 00931 <tr> 00932 <td nowrap="nowrap" valign="top">'.$panel.'</td> 00933 <td nowrap="nowrap" valign="top" align="right">'.$docSel.$cMenu.'</td> 00934 </tr>'; 00935 00936 if ($langSelector) { 00937 $langSelector ='<div id="typo3-altdoc-lang-selector">'.$langSelector.'</div>'; 00938 } 00939 $pagePath = '<div id="typo3-altdoc-page-path">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '.htmlspecialchars($this->generalPathOfForm).'</div>'; 00940 00941 $formContent.=' 00942 <tr> 00943 <td colspan="2"><div id="typo3-altdoc-header-info-options">'.$pagePath.$langSelector.'<div></td> 00944 </tr> 00945 </table> 00946 00947 00948 00949 00950 <!-- 00951 EDITING FORM: 00952 --> 00953 00954 '.$editForm.' 00955 00956 00957 00958 <!-- 00959 Saving buttons (same as in top) 00960 --> 00961 00962 '.$panel. 00963 '<input type="hidden" name="returnUrl" value="'.htmlspecialchars($this->retUrl).'" /> 00964 <input type="hidden" name="viewUrl" value="'.htmlspecialchars($this->viewUrl).'" />'; 00965 00966 if ($this->returnNewPageId) { 00967 $formContent.='<input type="hidden" name="returnNewPageId" value="1" />'; 00968 } 00969 $formContent.='<input type="hidden" name="popViewId" value="'.htmlspecialchars($this->viewId).'" />'; 00970 if ($this->viewId_addParams) { 00971 $formContent.='<input type="hidden" name="popViewId_addParams" value="'.htmlspecialchars($this->viewId_addParams).'" />'; 00972 } 00973 $formContent.='<input type="hidden" name="closeDoc" value="0" />'; 00974 $formContent.='<input type="hidden" name="doSave" value="0" />'; 00975 $formContent.='<input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />'; 00976 $formContent.='<input type="hidden" name="_disableRTE" value="'.$this->tceforms->disableRTE.'" />'; 00977 00978 return $formContent; 00979 } 00980 00986 function functionMenus() { 00987 global $BE_USER,$LANG; 00988 00989 $funcMenus = ''; 00990 00991 // Show palettes: 00992 $funcMenus.= '<br /><br />'.t3lib_BEfunc::getFuncCheck('','SET[showPalettes]',$this->MOD_SETTINGS['showPalettes'],'alt_doc.php',t3lib_div::implodeArrayForUrl('',array_merge($this->R_URL_getvars,array('SET'=>'')))).$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPalettes',1); 00993 00994 // Show descriptions/help texts: 00995 if ($BE_USER->uc['edit_showFieldHelp']!='text') { 00996 $funcMenus.= '<br />'.t3lib_BEfunc::getFuncCheck('','SET[showDescriptions]',$this->MOD_SETTINGS['showDescriptions'],'alt_doc.php',t3lib_div::implodeArrayForUrl('',array_merge($this->R_URL_getvars,array('SET'=>'')))).$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showDescriptions',1); 00997 } 00998 00999 // Show disable RTE checkbox: 01000 if ($BE_USER->isRTE()) { 01001 $funcMenus.= '<br />'.t3lib_BEfunc::getFuncCheck('','SET[disableRTE]',$this->MOD_SETTINGS['disableRTE'],'alt_doc.php',t3lib_div::implodeArrayForUrl('',array_merge($this->R_URL_getvars,array('SET'=>'')))).$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.disableRTE',1); 01002 } 01003 01004 return ' 01005 01006 <!-- 01007 Function menus (checkboxes for selecting options): 01008 --> 01009 '.$funcMenus; 01010 } 01011 01017 function shortCutLink() { 01018 global $BE_USER,$LANG; 01019 01020 // ShortCut 01021 if ($this->returnUrl!='close.html') { 01022 $content.='<br /><br />'; 01023 01024 // Shortcut: 01025 if ($BE_USER->mayMakeShortcut()) { 01026 $content.=$this->doc->makeShortcutIcon('returnUrl,edit,defVals,overrideVals,columnsOnly,returnNewPageId,editRegularContentFromId,disHelp,noView',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name'],1); 01027 } 01028 01029 // Open in new window: 01030 $aOnClick = 'vHWin=window.open(\''.t3lib_div::linkThisScript(array('returnUrl'=>'close.html')).'\',\''.md5($this->R_URI).'\',\''.($BE_USER->uc['edit_wideDocument']?'width=670,height=500':'width=600,height=400').',status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;'; 01031 $content.='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'. 01032 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/open_in_new_window.gif','width="19" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.openInNewWindow',1).'" alt="" />'. 01033 '</a>'; 01034 } 01035 return ' 01036 01037 <!-- 01038 Shortcut link: 01039 --> 01040 '.$content; 01041 } 01042 01048 function tceformMessages() { 01049 if (count($this->tceforms->commentMessages)) { 01050 $this->content.=' 01051 01052 <!-- TCEFORM messages 01053 '.htmlspecialchars(implode(chr(10),$this->tceforms->commentMessages)).' 01054 --> 01055 01056 '; 01057 } 01058 } 01059 01060 01061 01062 01063 01064 01065 01066 01067 01068 01069 01070 01071 01072 /*************************** 01073 * 01074 * Localization stuff 01075 * 01076 ***************************/ 01077 01087 function languageSwitch($table, $uid, $pid=NULL) { 01088 global $TCA; 01089 01090 $content = ''; 01091 01092 $languageField = $TCA[$table]['ctrl']['languageField']; 01093 $transOrigPointerField = $TCA[$table]['ctrl']['transOrigPointerField']; 01094 01095 // table editable and activated for languages? 01096 if ($GLOBALS['BE_USER']->check('tables_modify',$table) && $languageField && $transOrigPointerField && !$TCA[$table]['ctrl']['transOrigPointerTable']) { 01097 01098 if(is_null($pid)) { 01099 $row = t3lib_befunc::getRecord($table, $uid, 'pid'); 01100 $pid = $row['pid']; 01101 } 01102 01103 // get all avalibale languages for the page 01104 $langRows = $this->getLanguages($pid); 01105 01106 // page available in other languages than default language? 01107 if (is_array($langRows) && count($langRows)>1) { 01108 01109 $rowsByLang = array(); 01110 $fetchFields = 'uid,'.$languageField.','.$transOrigPointerField; 01111 01112 // get record in current language 01113 $rowCurrent = t3lib_befunc::getRecord($table, $uid, $fetchFields); 01114 $currentLanguage = $rowCurrent[$languageField]; 01115 01116 if ($currentLanguage>-1) { // Disabled for records with [all] language! 01117 // get record in default language if needed 01118 if ($currentLanguage) { 01119 $rowsByLang[0] = t3lib_befunc::getRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields); 01120 } else { 01121 $rowsByLang[0] = $rowCurrent; 01122 } 01123 01124 // get record in other languages to see what's already available 01125 $translations = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 01126 $fetchFields, 01127 $table, 01128 'pid='.intval($pid). 01129 ' AND '.$languageField.'>0'. 01130 ' AND '.$transOrigPointerField.'='.intval($rowsByLang[0]['uid']). 01131 t3lib_BEfunc::deleteClause($table). 01132 t3lib_BEfunc::versioningPlaceholderClause($table) 01133 ); 01134 foreach ($translations as $row) { 01135 $rowsByLang[$row[$languageField]] = $row; 01136 } 01137 01138 $langSelItems=array(); 01139 foreach ($langRows as $lang) { 01140 if ($GLOBALS['BE_USER']->checkLanguageAccess($lang['uid'])) { 01141 01142 $newTranslation = isset($rowsByLang[$lang['uid']]) ? '' : ' ['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.new',1).']'; 01143 01144 // create url for creating a localized record 01145 if($newTranslation) { 01146 $href = $this->doc->issueCommand( 01147 '&cmd['.$table.']['.$rowsByLang[0]['uid'].'][localize]='.$lang['uid'], 01148 $this->backPath.'alt_doc.php?justLocalized='.rawurlencode($table.':'.$rowsByLang[0]['uid'].':'.$lang['uid']).'&returnUrl='.rawurlencode($this->retUrl) 01149 ); 01150 01151 // create edit url 01152 } else { 01153 $href = $this->backPath.'alt_doc.php?'; 01154 $href .= '&edit['.$table.']['.$rowsByLang[$lang['uid']]['uid'].']=edit'; 01155 $href .= '&returnUrl='.rawurlencode($this->retUrl); 01156 } 01157 01158 $langSelItems[$lang['uid']]=' 01159 <option value="'.htmlspecialchars($href).'"'.($currentLanguage==$lang['uid']?' selected="selected"':'').'>'.htmlspecialchars($lang['title'].$newTranslation).'</option>'; 01160 } 01161 } 01162 01163 // If any languages are left, make selector: 01164 if (count($langSelItems)>1) { 01165 $onChange = 'if(this.options[this.selectedIndex].value){window.location.href=(this.options[this.selectedIndex].value);}'; 01166 $content = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.language',1).' <select name="_langSelector" onchange="'.htmlspecialchars($onChange).'"> 01167 '.implode('',$langSelItems).' 01168 </select>'; 01169 } 01170 } 01171 } 01172 } 01173 return $content; 01174 } 01175 01176 01183 function localizationRedirect($justLocalized) { 01184 global $TCA; 01185 01186 list($table,$orig_uid,$language) = explode(':',$justLocalized); 01187 01188 if ($TCA[$table] && $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField']) { 01189 list($localizedRecord) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 01190 'uid', 01191 $table, 01192 $TCA[$table]['ctrl']['languageField'].'='.intval($language).' AND '. 01193 $TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($orig_uid). 01194 t3lib_BEfunc::deleteClause($table). 01195 t3lib_BEfunc::versioningPlaceholderClause($table) 01196 ); 01197 01198 if (is_array($localizedRecord)) { 01199 // Create parameters and finally run the classic page module for creating a new page translation 01200 $params = '&edit['.$table.']['.$localizedRecord['uid'].']=edit'; 01201 $returnUrl = '&returnUrl='.rawurlencode(t3lib_div::_GP('returnUrl')); 01202 $location = $GLOBALS['BACK_PATH'].'alt_doc.php?'.$params.$returnUrl; 01203 01204 header('Location: '.t3lib_div::locationHeaderUrl($location)); 01205 exit; 01206 } 01207 } 01208 } 01209 01210 01217 function getLanguages($id) { 01218 global $LANG; 01219 01220 $modSharedTSconfig = t3lib_BEfunc::getModTSconfig($id, 'mod.SHARED'); 01221 01222 $languages = array( 01223 0 => array( 01224 'uid' => 0, 01225 'pid' => 0, 01226 'hidden' => 0, 01227 'title' => strlen($modSharedTSconfig['properties']['defaultLanguageLabel']) ? $modSharedTSconfig['properties']['defaultLanguageLabel'].' ('.$GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xml:defaultLanguage').')' : $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xml:defaultLanguage'), 01228 'flag' => $modSharedTSconfig['properties']['defaultLanguageFlag'], 01229 ) 01230 ); 01231 01232 $exQ = $GLOBALS['BE_USER']->isAdmin() ? '' : ' AND sys_language.hidden=0'; 01233 if ($id) { 01234 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 01235 'sys_language.*', 01236 'pages_language_overlay,sys_language', 01237 'pages_language_overlay.sys_language_uid=sys_language.uid AND pages_language_overlay.pid='.intval($id).$exQ, 01238 'pages_language_overlay.sys_language_uid,sys_language.uid,sys_language.pid,sys_language.tstamp,sys_language.hidden,sys_language.title,sys_language.static_lang_isocode,sys_language.flag', 01239 'sys_language.title' 01240 ); 01241 } else { 01242 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 01243 'sys_language.*', 01244 'sys_language', 01245 'sys_language.hidden=0', 01246 '', 01247 'sys_language.title' 01248 ); 01249 } 01250 if ($rows) { 01251 foreach ($rows as $row) { 01252 $languages[$row['uid']] = $row; 01253 } 01254 } 01255 return $languages; 01256 } 01257 01258 01259 01260 01261 01262 01263 01264 01265 01266 01267 /*************************** 01268 * 01269 * Other functions 01270 * 01271 ***************************/ 01272 01279 function fixWSversioningInEditConf($mapArray=FALSE) { 01280 global $TCA,$BE_USER; 01281 01282 // Traverse the editConf array 01283 if (is_array($this->editconf)) { 01284 foreach($this->editconf as $table => $conf) { // Tables: 01285 if (is_array($conf) && $TCA[$table]) { 01286 01287 // Traverse the keys/comments of each table (keys can be a commalist of uids) 01288 $newConf = array(); 01289 foreach($conf as $cKey => $cmd) { 01290 if ($cmd=='edit') { 01291 // Traverse the ids: 01292 $ids = t3lib_div::trimExplode(',', $cKey, 1); 01293 foreach($ids as $idKey => $theUid) { 01294 if (is_array($mapArray)) { 01295 if ($mapArray[$table][$theUid]) { 01296 $ids[$idKey] = $mapArray[$table][$theUid]; 01297 } 01298 } else { // Default, look for versions in workspace for record: 01299 $calcPRec = $this->getRecordForEdit($table,$theUid); 01300 if (is_array($calcPRec)) { 01301 // Setting UID again if it had changed, eg. due to workspace versioning. 01302 $ids[$idKey] = $calcPRec['uid']; 01303 } 01304 } 01305 #else unset($ids[$idKey]); 01306 } 01307 01308 // Add the possibly manipulated IDs to the new-build newConf array: 01309 $newConf[implode(',',$ids)] = $cmd; 01310 } else { 01311 $newConf[$cKey] = $cmd; 01312 } 01313 } 01314 // Store the new conf array: 01315 $this->editconf[$table] = $newConf; 01316 } 01317 } 01318 } 01319 } 01320 01328 function getRecordForEdit($table,$theUid) { 01329 global $TCA; 01330 01331 // Fetch requested record: 01332 $reqRecord = t3lib_BEfunc::getRecord($table,$theUid,'uid,pid'); 01333 01334 if (is_array($reqRecord)) { 01335 // If workspace is OFFLINE: 01336 if ($GLOBALS['BE_USER']->workspace!=0) { 01337 01338 // Check for versioning support of the table: 01339 if ($TCA[$table] && $TCA[$table]['ctrl']['versioningWS']) { 01340 01341 // If the record is already a version of "something" pass it by. 01342 if ($reqRecord['pid']==-1) { 01343 01344 // (If it turns out not to be a version of the current workspace there will be trouble, but that is handled inside TCEmain then and in the interface it would clearly be an error of links if the user accesses such a scenario) 01345 return $reqRecord; 01346 } else { // The input record was online and an offline version must be found or made: 01347 01348 // Look for version of this workspace: 01349 $versionRec = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $table, $reqRecord['uid'],'uid,pid,t3ver_oid'); 01350 return is_array($versionRec) ? $versionRec : $reqRecord; 01351 } 01352 } else return FALSE; // This means that editing cannot occur on this record because it was not supporting versioning which is required inside an offline workspace. 01353 } else return $reqRecord; // In ONLINE workspace, just return the originally requested record: 01354 } else return FALSE; // Return false because the table/uid was not found anyway. 01355 } 01356 01362 function editRegularContentFromId() { 01363 if (t3lib_extMgm::isLoaded('cms')) { 01364 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 01365 'uid', 01366 'tt_content', 01367 'pid='.intval($this->editRegularContentFromId). 01368 t3lib_BEfunc::deleteClause('tt_content'). 01369 t3lib_BEfunc::versioningPlaceholderClause('tt_content'). 01370 ' AND colPos=0 AND sys_language_uid=0', 01371 '', 01372 'sorting' 01373 ); 01374 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 01375 $ecUids=array(); 01376 while($ecRec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01377 $ecUids[]=$ecRec['uid']; 01378 } 01379 $this->editconf['tt_content'][implode(',',$ecUids)]='edit'; 01380 } 01381 } 01382 } 01383 01390 function compileStoreDat() { 01391 $this->storeArray = t3lib_div::compileSelectedGetVarsFromArray('edit,defVals,overrideVals,columnsOnly,disHelp,noView,editRegularContentFromId',$this->R_URL_getvars); 01392 $this->storeUrl = t3lib_div::implodeArrayForUrl('',$this->storeArray); 01393 $this->storeUrlMd5 = md5($this->storeUrl); 01394 } 01395 01403 function getNewIconMode($table,$key='saveDocNew') { 01404 global $BE_USER; 01405 $TSconfig = $BE_USER->getTSConfig('options.'.$key); 01406 $output = trim(isset($TSconfig['properties'][$table]) ? $TSconfig['properties'][$table] : $TSconfig['value']); 01407 return $output; 01408 } 01409 01416 function closeDocument($code=0) { 01417 global $BE_USER; 01418 01419 // If current document is found in docHandler, then unset it, possibly unset it ALL and finally, write it to the session data: 01420 if (isset($this->docHandler[$this->storeUrlMd5])) { 01421 unset($this->docHandler[$this->storeUrlMd5]); 01422 if ($code=='3') $this->docHandler=array(); 01423 $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->docDat[1])); 01424 } 01425 01426 // If ->returnEditConf is set, then add the current content of editconf to the ->retUrl variable: (used by other scripts, like wizard_add, to know which records was created or so...) 01427 if ($this->returnEditConf && $this->retUrl!='dummy.php') { 01428 $this->retUrl.='&returnEditConf='.rawurlencode(serialize($this->editconf)); 01429 } 01430 01431 // If code is NOT set OR set to 1, then make a header location redirect to $this->retUrl 01432 if (!$code || $code==1) { 01433 Header('Location: '.t3lib_div::locationHeaderUrl($this->retUrl)); 01434 exit; 01435 } else { 01436 $this->setDocument('',$this->retUrl); 01437 } 01438 } 01439 01448 function setDocument($currentDocFromHandlerMD5='',$retUrl='alt_doc_nodoc.php') { 01449 if (!t3lib_extMgm::isLoaded('cms') && !strcmp($retUrl,'alt_doc_nodoc.php')) return; 01450 01451 if (!$this->modTSconfig['properties']['disableDocSelector'] && is_array($this->docHandler) && count($this->docHandler)) { 01452 if (isset($this->docHandler[$currentDocFromHandlerMD5])) { 01453 $setupArr=$this->docHandler[$currentDocFromHandlerMD5]; 01454 } else { 01455 reset($this->docHandler); 01456 $setupArr=current($this->docHandler); 01457 } 01458 if ($setupArr[2]) { 01459 $sParts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI')); 01460 $retUrl = $sParts['path'].'?'.$setupArr[2].'&returnUrl='.rawurlencode($retUrl); 01461 } 01462 } 01463 Header('Location: '.t3lib_div::locationHeaderUrl($retUrl)); 01464 exit; 01465 } 01466 } 01467 01468 // Include extension? 01469 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php']) { 01470 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php']); 01471 } 01472 01473 01474 01475 01476 01477 01478 01479 01480 01481 01482 01483 01484 01485 01486 01487 01488 // Make instance: 01489 $SOBE = t3lib_div::makeInstance('SC_alt_doc'); 01490 01491 // Preprocessing, storing data if submitted to 01492 $SOBE->preInit(); 01493 if ($SOBE->doProcessData()) { // Checks, if a save button has been clicked (or the doSave variable is sent) 01494 $SOBE->processData(); 01495 } 01496 01497 01498 // Main: 01499 $SOBE->init(); 01500 $SOBE->main(); 01501 $SOBE->printContent(); 01502 ?>