00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
00108 var $editconf;
00109 var $columnsOnly;
00110 var $defVals;
00111 var $overrideVals;
00112 var $returnUrl;
00113 var $closeDoc;
00114 var $doSave;
00115
00116 var $data;
00117 var $mirror;
00118 var $cacheCmd;
00119 var $redirect;
00120 var $disableRTE;
00121 var $returnNewPageId;
00122 var $vC;
00123
00124 var $popViewId;
00125 var $popViewId_addParams;
00126 var $viewUrl;
00127 var $editRegularContentFromId;
00128 var $recTitle;
00129 var $disHelp;
00130 var $noView;
00131 var $returnEditConf;
00132 var $localizationMode;
00133
00134
00135
00136 var $doc;
00137 var $content;
00138
00139 var $retUrl;
00140 var $R_URL_parts;
00141 var $R_URL_getvars;
00142 var $R_URI;
00143
00144 var $storeTitle;
00145 var $storeArray;
00146 var $storeUrl;
00147 var $storeUrlMd5;
00148
00149 var $docDat;
00150 var $docHandler;
00151
00152
00153
00154 var $elementsData;
00155 var $firstEl;
00156 var $errorC;
00157 var $newC;
00158 var $viewId;
00159 var $viewId_addParams;
00160 var $modTSconfig;
00161 var $tceforms;
00162 var $generalPathOfForm;
00163
00164
00165
00166 var $dontStoreDocumentRef;
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
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
00199 if (!is_array($this->defVals) && is_array($this->overrideVals)) {
00200 $this->defVals = $this->overrideVals;
00201 }
00202
00203
00204 $this->retUrl = $this->returnUrl ? $this->returnUrl : 'dummy.php';
00205
00206
00207 $this->fixWSversioningInEditConf();
00208
00209
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
00215 $this->compileStoreDat();
00216
00217
00218 $this->dontStoreDocumentRef=0;
00219 $this->storeTitle='';
00220
00221
00222 $this->docDat = $BE_USER->getModuleData('alt_doc.php','ses');
00223 $this->docHandler = $this->docDat[0];
00224
00225
00226 if ($this->closeDoc>0) {
00227 $this->closeDocument($this->closeDoc);
00228 }
00229
00230
00231 if (is_array($this->R_URL_getvars) && count($this->R_URL_getvars)<2 && !is_array($this->editconf)) {
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
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
00264
00265 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00266 $tce->stripslashes_values=0;
00267
00268
00269 $TCAdefaultOverride = $BE_USER->getTSConfigProp('TCAdefaults');
00270 if (is_array($TCAdefaultOverride)) {
00271 $tce->setDefaultsFromUserTS($TCAdefaultOverride);
00272 }
00273
00274
00275 if ($BE_USER->uc['neverHideAtCopy']) { $tce->neverHideAtCopy = 1; }
00276 $tce->debug=0;
00277 $tce->disableRTE = $this->disableRTE;
00278
00279
00280 $tce->start($this->data,array());
00281 if (is_array($this->mirror)) { $tce->setMirror($this->mirror); }
00282
00283
00284 if (isset($this->data['pages'])) {
00285 t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
00286 }
00287
00288
00289
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
00298 $tce->process_uploads($_FILES);
00299 $tce->process_datamap();
00300
00301
00302 if (count($tce->substNEWwithIDs_table)) {
00303
00304
00305 $this->editconf = array();
00306
00307
00308 foreach($tce->substNEWwithIDs_table as $nKey => $nTable) {
00309 $editId = $tce->substNEWwithIDs[$nKey];
00310
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
00322 $this->R_URL_getvars['edit']=$this->editconf;
00323
00324
00325 unset($this->R_URL_getvars['defVals']);
00326
00327
00328 $this->compileStoreDat();
00329 }
00330
00331
00332 if (count($tce->autoVersionIdMap)) {
00333 $this->fixWSversioningInEditConf($tce->autoVersionIdMap);
00334 }
00335
00336
00337 if (isset($_POST['_savedoknew_x']) && is_array($this->editconf)) {
00338
00339
00340 reset($this->editconf);
00341 $nTable=key($this->editconf);
00342
00343
00344 reset($this->editconf[$nTable]);
00345 $nUid=key($this->editconf[$nTable]);
00346 $nRec = t3lib_BEfunc::getRecord($nTable,$nUid,'pid,uid');
00347
00348
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
00357 $this->R_URL_getvars['edit']=$this->editconf;
00358
00359
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)
00367 );
00368 }
00369 if (isset($_POST['_saveandclosedok_x']) || $this->closeDoc<0) {
00370 $this->closeDocument(abs($this->closeDoc));
00371 }
00372 }
00373
00379 function init() {
00380 global $BE_USER,$LANG,$BACK_PATH;
00381
00382
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
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
00396
00397
00398
00399 $this->MOD_MENU = array(
00400 'showPalettes' => '',
00401 'showDescriptions' => '',
00402 'disableRTE' => ''
00403 );
00404
00405
00406 $this->MCONF['name']='xMOD_alt_doc.php';
00407
00408
00409 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00410
00411
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
00430 function typoSetup () {
00431 this.uniqueID = "";
00432 }
00433 var TS = new typoSetup();
00434
00435
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
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
00477 $this->content='';
00478 $this->content.=$this->doc->startPage('TYPO3 Edit Document');
00479
00480
00481 if (is_array($this->editconf)) {
00482
00483
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 : '';
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
00495 $this->tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard');
00496 $this->tceforms->clipObj->initializeClipboard();
00497
00498
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
00506 $editForm = $this->makeEditForm();
00507
00508 if ($editForm) {
00509 reset($this->elementsData);
00510 $this->firstEl = current($this->elementsData);
00511
00512
00513
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
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
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
00579
00580
00581
00587 function makeEditForm() {
00588 global $BE_USER,$LANG,$TCA;
00589
00590
00591 $this->elementsData=array();
00592 $this->errorC=0;
00593 $this->newC=0;
00594 $thePrevUid='';
00595 $editForm='';
00596
00597
00598 foreach($this->editconf as $table => $conf) {
00599 if (is_array($conf) && $TCA[$table] && $BE_USER->check('tables_modify',$table)) {
00600
00601
00602 foreach($conf as $cKey => $cmd) {
00603 if ($cmd=='edit' || $cmd=='new') {
00604
00605
00606 $ids = t3lib_div::trimExplode(',',$cKey,1);
00607
00608
00609 foreach($ids as $theUid) {
00610
00611
00612
00613 $hasAccess = 1;
00614 $deniedAccessReason = '';
00615 $deleteAccess = 0;
00616 $this->viewId = 0;
00617
00618
00619 if ($cmd=='new') {
00620 if (intval($theUid)) {
00621
00622
00623 if ($theUid<0) {
00624 $calcPRec=t3lib_BEfunc::getRecord($table,abs($theUid));
00625 $calcPRec=t3lib_BEfunc::getRecord('pages',$calcPRec['pid']);
00626 } else {
00627 $calcPRec=t3lib_BEfunc::getRecord('pages',abs($theUid));
00628 }
00629
00630
00631 if (is_array($calcPRec)) {
00632 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
00633 if ($table=='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;
00643 } else {
00644 $calcPRec = t3lib_BEfunc::getRecord($table,$theUid);
00645 t3lib_BEfunc::fixVersioningPid($table,$calcPRec);
00646 if (is_array($calcPRec)) {
00647 if ($table=='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']));
00654 $hasAccess = $CALC_PERMS&16 ? 1 : 0;
00655 $deleteAccess = $CALC_PERMS&16 ? 1 : 0;
00656 $this->viewId = $calcPRec['pid'];
00657
00658
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
00665 if ($hasAccess) {
00666 $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec);
00667 $deniedAccessReason = $BE_USER->errorMsg;
00668 }
00669 } else $hasAccess = 0;
00670 }
00671
00672
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':'');
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
00698 if (is_array($rec)) {
00699
00700
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
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
00714 $this->tceforms->registerDefaultLanguageData($table,$rec);
00715
00716
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
00730 if ($cmd=='new') {
00731 $panel.= '<input type="hidden" name="data['.$table.']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
00732 $this->newC++;
00733 }
00734
00735
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
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
00781
00782 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly']) {
00783
00784
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
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
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
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
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
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
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
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
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
00858 if (!$this->modTSconfig['properties']['disableDocSelector']) {
00859
00860
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
00867 $docSel='';
00868 if (is_array($this->docHandler)) {
00869 $opt = array();
00870 $opt[] = '<option>[ '.$LANG->getLL('openDocs',1).': ]</option>';
00871
00872
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
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
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
00899 if (!$this->modTSconfig['properties']['disableCacheSelector']) {
00900 $cMenu = $this->doc->clearCacheMenu(intval($this->viewId),!$this->modTSconfig['properties']['disableDocSelector']);
00901
00902
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
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
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
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
01021 if ($this->returnUrl!='close.html') {
01022 $content.='<br /><br />';
01023
01024
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
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
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
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
01104 $langRows = $this->getLanguages($pid);
01105
01106
01107 if (is_array($langRows) && count($langRows)>1) {
01108
01109 $rowsByLang = array();
01110 $fetchFields = 'uid,'.$languageField.','.$transOrigPointerField;
01111
01112
01113 $rowCurrent = t3lib_befunc::getRecord($table, $uid, $fetchFields);
01114 $currentLanguage = $rowCurrent[$languageField];
01115
01116 if ($currentLanguage>-1) {
01117
01118 if ($currentLanguage) {
01119 $rowsByLang[0] = t3lib_befunc::getRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields);
01120 } else {
01121 $rowsByLang[0] = $rowCurrent;
01122 }
01123
01124
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
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'].