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
00074 require('init.php');
00075 require('template.php');
00076 $LANG->includeLLFile('EXT:lang/locallang_alt_doc.xml');
00077 require_once (PATH_t3lib.'class.t3lib_tceforms.php');
00078 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
00079
00080
00081 t3lib_BEfunc::lockRecords();
00082
00083
00084
00085
00094 class SC_alt_doc {
00095
00096
00097 var $editconf;
00098 var $columnsOnly;
00099 var $defVals;
00100 var $overrideVals;
00101 var $returnUrl;
00102 var $closeDoc;
00103 var $doSave;
00104
00105 var $data;
00106 var $mirror;
00107 var $cacheCmd;
00108 var $redirect;
00109 var $disableRTE;
00110 var $returnNewPageId;
00111 var $vC;
00112
00113 var $popViewId;
00114 var $popViewId_addParams;
00115 var $viewUrl;
00116 var $editRegularContentFromId;
00117 var $recTitle;
00118 var $disHelp;
00119 var $noView;
00120 var $returnEditConf;
00121
00122
00123
00124 var $doc;
00125 var $content;
00126
00127 var $retUrl;
00128 var $R_URL_parts;
00129 var $R_URL_getvars;
00130 var $R_URI;
00131
00132 var $storeTitle;
00133 var $storeArray;
00134 var $storeUrl;
00135 var $storeUrlMd5;
00136
00137 var $docDat;
00138 var $docHandler;
00139
00140
00141
00142 var $elementsData;
00143 var $firstEl;
00144 var $errorC;
00145 var $newC;
00146 var $viewId;
00147 var $viewId_addParams;
00148 var $modTSconfig;
00149 var $tceforms;
00150 var $generalPathOfForm;
00151
00152
00153
00154 var $dontStoreDocumentRef;
00155
00156
00157
00158
00159
00160
00161
00167 function preInit() {
00168 global $BE_USER;
00169
00170
00171 $this->editconf = t3lib_div::_GP('edit');
00172 $this->defVals = t3lib_div::_GP('defVals');
00173 $this->overrideVals = t3lib_div::_GP('overrideVals');
00174 $this->columnsOnly = t3lib_div::_GP('columnsOnly');
00175 $this->returnUrl = t3lib_div::_GP('returnUrl');
00176 $this->closeDoc = t3lib_div::_GP('closeDoc');
00177 $this->doSave = t3lib_div::_GP('doSave');
00178 $this->returnEditConf = t3lib_div::_GP('returnEditConf');
00179
00180
00181 if (!is_array($this->defVals) && is_array($this->overrideVals)) {
00182 $this->defVals = $this->overrideVals;
00183 }
00184
00185
00186 $this->retUrl = $this->returnUrl ? $this->returnUrl : 'dummy.php';
00187
00188
00189 $this->R_URL_parts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
00190 $this->R_URL_getvars = t3lib_div::_GET();
00191
00192
00193 $this->compileStoreDat();
00194
00195
00196 $this->dontStoreDocumentRef=0;
00197 $this->storeTitle='';
00198
00199
00200 $this->docDat = $BE_USER->getModuleData('alt_doc.php','ses');
00201 $this->docHandler = $this->docDat[0];
00202
00203
00204 if ($this->closeDoc>0) {
00205 $this->closeDocument($this->closeDoc);
00206 }
00207
00208
00209 if (is_array($this->R_URL_getvars) && count($this->R_URL_getvars)<2 && !is_array($this->editconf)) {
00210 $this->setDocument($this->docDat[1]);
00211 }
00212 }
00213
00219 function doProcessData() {
00220 $out = $this->doSave || isset($_POST['_savedok_x']) || isset($_POST['_saveandclosedok_x']) || isset($_POST['_savedokview_x']) || isset($_POST['_savedoknew_x']);
00221 return $out;
00222 }
00223
00229 function processData() {
00230 global $BE_USER,$TYPO3_CONF_VARS;
00231
00232
00233 $this->data = t3lib_div::_GP('data');
00234 $this->mirror = t3lib_div::_GP('mirror');
00235 $this->cacheCmd = t3lib_div::_GP('cacheCmd');
00236 $this->redirect = t3lib_div::_GP('redirect');
00237 $this->disableRTE = t3lib_div::_GP('_disableRTE');
00238 $this->returnNewPageId = t3lib_div::_GP('returnNewPageId');
00239 $this->vC = t3lib_div::_GP('vC');
00240
00241
00242
00243 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
00244 $tce->stripslashes_values=0;
00245
00246
00247 $TCAdefaultOverride = $BE_USER->getTSConfigProp('TCAdefaults');
00248 if (is_array($TCAdefaultOverride)) {
00249 $tce->setDefaultsFromUserTS($TCAdefaultOverride);
00250 }
00251
00252
00253 if ($BE_USER->uc['neverHideAtCopy']) { $tce->neverHideAtCopy = 1; }
00254 $tce->debug=0;
00255 $tce->disableRTE = $this->disableRTE;
00256
00257
00258 $tce->start($this->data,array());
00259 if (is_array($this->mirror)) { $tce->setMirror($this->mirror); }
00260
00261
00262 if (isset($this->data['pages'])) {
00263 t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
00264 }
00265
00266
00267
00268 $refInfo=parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
00269 $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
00270 if ($httpHost!=$refInfo['host'] && $this->vC!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) {
00271 $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));
00272 debug('Error: Referer host did not match with server host.');
00273 } else {
00274
00275
00276 $tce->process_uploads($_FILES);
00277 $tce->process_datamap();
00278
00279
00280 if (count($tce->substNEWwithIDs_table)) {
00281
00282
00283 $this->editconf = array();
00284
00285
00286 foreach($tce->substNEWwithIDs_table as $nKey => $nTable) {
00287 $this->editconf[$nTable][$tce->substNEWwithIDs[$nKey]]='edit';
00288 if ($nTable=='pages' && $this->retUrl!='dummy.php' && $this->returnNewPageId) {
00289 $this->retUrl.='&id='.$tce->substNEWwithIDs[$nKey];
00290 }
00291 }
00292
00293
00294 $this->R_URL_getvars['edit']=$this->editconf;
00295
00296
00297 unset($this->R_URL_getvars['defVals']);
00298
00299
00300 $this->compileStoreDat();
00301 }
00302
00303
00304 if (isset($_POST['_savedoknew_x']) && is_array($this->editconf)) {
00305
00306
00307 reset($this->editconf);
00308 $nTable=key($this->editconf);
00309
00310
00311 reset($this->editconf[$nTable]);
00312 $nUid=key($this->editconf[$nTable]);
00313 $nRec = t3lib_BEfunc::getRecord($nTable,$nUid,'pid,uid');
00314
00315
00316 $this->editconf=array();
00317 if ($this->getNewIconMode($nTable)=='top') {
00318 $this->editconf[$nTable][$nRec['pid']]='new';
00319 } else {
00320 $this->editconf[$nTable][-$nRec['uid']]='new';
00321 }
00322
00323
00324 $this->R_URL_getvars['edit']=$this->editconf;
00325
00326
00327 $this->compileStoreDat();
00328 }
00329
00330 $tce->printLogErrorMessages(
00331 isset($_POST['_saveandclosedok_x']) ?
00332 $this->retUrl :
00333 $this->R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$this->R_URL_getvars)
00334 );
00335 }
00336 if (isset($_POST['_saveandclosedok_x']) || $this->closeDoc<0) {
00337 $this->closeDocument(abs($this->closeDoc));
00338 }
00339 }
00340
00346 function init() {
00347 global $BE_USER,$LANG,$BACK_PATH;
00348
00349
00350 $this->popViewId = t3lib_div::_GP('popViewId');
00351 $this->popViewId_addParams = t3lib_div::_GP('popViewId_addParams');
00352 $this->viewUrl = t3lib_div::_GP('viewUrl');
00353 $this->editRegularContentFromId = t3lib_div::_GP('editRegularContentFromId');
00354 $this->recTitle = t3lib_div::_GP('recTitle');
00355 $this->disHelp = t3lib_div::_GP('disHelp');
00356 $this->noView = t3lib_div::_GP('noView');
00357
00358
00359 $this->R_URL_getvars['returnUrl']=$this->retUrl;
00360 $this->R_URI = $this->R_URL_parts['path'].'?'.t3lib_div::implodeArrayForUrl('',$this->R_URL_getvars);
00361
00362
00363
00364
00365
00366 $this->MOD_MENU = array(
00367 'showPalettes' => '',
00368 'showDescriptions' => '',
00369 'disableRTE' => ''
00370 );
00371
00372
00373 $this->MCONF['name']='xMOD_alt_doc.php';
00374
00375
00376 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00377
00378
00379 $this->doc = t3lib_div::makeInstance('mediumDoc');
00380 $this->doc->bodyTagMargins['x']=5;
00381 $this->doc->bodyTagMargins['y']=5;
00382 $this->doc->backPath = $BACK_PATH;
00383 $this->doc->docType = 'xhtml_trans';
00384
00385 $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);">';
00386
00387 $this->doc->JScode = $this->doc->wrapScriptTags('
00388 function jumpToUrl(URL,formEl) {
00389 if (!TBE_EDITOR_isFormChanged()) {
00390 document.location = URL;
00391 } else if (formEl && formEl.type=="checkbox") {
00392 formEl.checked = formEl.checked ? 0 : 1;
00393 }
00394 }
00395
00396
00397 function typoSetup () {
00398 this.uniqueID = "";
00399 }
00400 var TS = new typoSetup();
00401
00402
00403 function launchView(table,uid,bP) {
00404 var backPath= bP ? bP : "";
00405 var thePreviewWindow="";
00406 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");
00407 if (thePreviewWindow && thePreviewWindow.focus) {
00408 thePreviewWindow.focus();
00409 }
00410 }
00411 function deleteRecord(table,id,url) {
00412 if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning')).')) {
00413 document.location = "tce_db.php?cmd["+table+"]["+id+"][delete]=1&redirect="+escape(url)+"&vC='.$BE_USER->veriCode().'&prErr=1&uPT=1";
00414 }
00415 return false;
00416 }
00417 '.(isset($_POST['_savedokview_x']) && $this->popViewId ?
00418 'if (window.opener) { '.
00419 t3lib_BEfunc::viewOnClick($this->popViewId,'',t3lib_BEfunc::BEgetRootLine($this->popViewId),'',$this->viewUrl,$this->popViewId_addParams,FALSE).
00420 ' } else { '.
00421 t3lib_BEfunc::viewOnClick($this->popViewId,'',t3lib_BEfunc::BEgetRootLine($this->popViewId),'',$this->viewUrl,$this->popViewId_addParams).
00422 ' } '
00423 : '')
00424 ).$this->doc->getDynTabMenuJScode();
00425
00426
00427 $CMparts = $this->doc->getContextMenuCode();
00428 $this->doc->JScode.= $CMparts[0];
00429 $this->doc->bodyTagAdditions = $CMparts[1];
00430 $this->doc->postCode.= $CMparts[2];
00431 }
00432
00438 function main() {
00439 global $BE_USER,$LANG;
00440
00441
00442 $this->content='';
00443 $this->content.=$this->doc->startPage('TYPO3 Edit Document');
00444
00445
00446 if (is_array($this->editconf)) {
00447
00448
00449 $this->tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
00450 $this->tceforms->initDefaultBEMode();
00451 $this->tceforms->doSaveFieldName = 'doSave';
00452 $this->tceforms->returnUrl = $this->R_URI;
00453 $this->tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
00454 $this->tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00455 $this->tceforms->enableClickMenu = TRUE;
00456 $this->tceforms->enableTabMenu = TRUE;
00457
00458
00459 $this->tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard');
00460 $this->tceforms->clipObj->initializeClipboard();
00461
00462
00463 if ($BE_USER->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions']) $this->tceforms->edit_showFieldHelp='text';
00464
00465 if ($this->editRegularContentFromId) {
00466 $this->editRegularContentFromId();
00467 }
00468
00469
00470 $editForm = $this->makeEditForm();
00471 if ($editForm) {
00472 reset($this->elementsData);
00473 $this->firstEl = current($this->elementsData);
00474
00475 if ($this->viewId) {
00476
00477 $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->viewId,'mod.xMOD_alt_doc');
00478 } else $this->modTSconfig=array();
00479
00480 $panel = $this->makeButtonPanel();
00481 $docSel = $this->makeDocSel();
00482 $cMenu = $this->makeCmenu();
00483
00484 $formContent = $this->compileForm($panel,$docSel,$cMenu,$editForm);
00485
00486 $this->content.= $this->tceforms->printNeededJSFunctions_top().
00487 $formContent.
00488 $this->tceforms->printNeededJSFunctions();
00489 $this->content.= $this->functionMenus();
00490
00491
00492 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms', $GLOBALS['BACK_PATH'],'<br/>|',FALSE,'margin-top: 20px;');
00493
00494 $this->content.= $this->shortCutLink();
00495
00496 $this->tceformMessages();
00497 }
00498 }
00499 }
00500
00506 function printContent() {
00507
00508 echo $this->content.$this->doc->endPage();
00509 }
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00541 function makeEditForm() {
00542 global $BE_USER,$LANG,$TCA;
00543
00544
00545 $this->elementsData=array();
00546 $this->errorC=0;
00547 $this->newC=0;
00548 $thePrevUid='';
00549 $editForm='';
00550
00551
00552 foreach($this->editconf as $table => $conf) {
00553 if (is_array($conf) && $TCA[$table] && $BE_USER->check('tables_modify',$table)) {
00554
00555
00556 foreach($conf as $cKey => $cmd) {
00557 if ($cmd=='edit' || $cmd=='new') {
00558
00559
00560 $ids = t3lib_div::trimExplode(',',$cKey,1);
00561
00562
00563 foreach($ids as $theUid) {
00564
00565
00566
00567 $hasAccess = 1;
00568 $deniedAccessReason = '';
00569 $deleteAccess = 0;
00570 $this->viewId = 0;
00571
00572
00573 if ($cmd=='new') {
00574 if (intval($theUid)) {
00575
00576
00577 if ($theUid<0) {
00578 $calcPRec=t3lib_BEfunc::getRecord($table,abs($theUid));
00579 $calcPRec=t3lib_BEfunc::getRecord('pages',$calcPRec['pid']);
00580 } else {
00581 $calcPRec=t3lib_BEfunc::getRecord('pages',abs($theUid));
00582 }
00583
00584
00585 if (is_array($calcPRec)) {
00586 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
00587 if ($table=='pages') {
00588 $hasAccess = $CALC_PERMS&8 ? 1 : 0;
00589 $this->viewId = $calcPRec['pid'];
00590 } else {
00591 $hasAccess = $CALC_PERMS&16 ? 1 : 0;
00592 $this->viewId = $calcPRec['uid'];
00593 }
00594 }
00595 }
00596 $this->dontStoreDocumentRef=1;
00597 } else {
00598 $calcPRec = t3lib_BEfunc::getRecord($table,$theUid);
00599 t3lib_BEfunc::fixVersioningPid($table,$calcPRec);
00600 if (is_array($calcPRec)) {
00601 if ($table=='pages') {
00602 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
00603 $hasAccess = $CALC_PERMS&2 ? 1 : 0;
00604 $deleteAccess = $CALC_PERMS&4 ? 1 : 0;
00605 $this->viewId = $calcPRec['uid'];
00606 } else {
00607 $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid']));
00608 $hasAccess = $CALC_PERMS&16 ? 1 : 0;
00609 $deleteAccess = $CALC_PERMS&16 ? 1 : 0;
00610 $this->viewId = $calcPRec['pid'];
00611
00612
00613 if ($TCA[$table]['ctrl']['languageField'] && $calcPRec[$TCA[$table]['ctrl']['languageField']]>0) {
00614 $this->viewId_addParams = '&L='.$calcPRec[$TCA[$table]['ctrl']['languageField']];
00615 }
00616 }
00617
00618
00619 if ($hasAccess) {
00620 $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec);
00621 $deniedAccessReason = $BE_USER->errorMsg;
00622 }
00623 } else $hasAccess = 0;
00624 }
00625
00626
00627
00628 if ($hasAccess) {
00629 $prevPageID = is_object($trData)?$trData->prevPageID:'';
00630 $trData = t3lib_div::makeInstance('t3lib_transferData');
00631 $trData->addRawData = TRUE;
00632 $trData->defVals = $this->defVals;
00633 $trData->lockRecords=1;
00634 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00635 $trData->prevPageID = $prevPageID;
00636 $trData->fetchRecord($table,$theUid,$cmd=='new'?'new':'');
00637 reset($trData->regTableItems_data);
00638 $rec = current($trData->regTableItems_data);
00639 $rec['uid'] = $cmd=='new'?uniqid('NEW'):$theUid;
00640 $this->elementsData[]=array(
00641 'table' => $table,
00642 'uid' => $rec['uid'],
00643 'cmd' => $cmd,
00644 'deleteAccess' => $deleteAccess
00645 );
00646 if ($cmd=='new') {
00647 $rec['pid'] = $theUid=='prev'?$thePrevUid:$theUid;
00648 }
00649
00650
00651 if (is_array($rec)) {
00652
00653
00654 $this->generalPathOfForm = $this->tceforms->getRecordPath($table,$rec);
00655 if (!$this->storeTitle) {
00656 $this->storeTitle = $this->recTitle ? htmlspecialchars($this->recTitle) : t3lib_BEfunc::getRecordTitle($table,$rec,1);
00657 }
00658
00659
00660 $this->tceforms->hiddenFieldList = '';
00661 $this->tceforms->globalShowHelp = $this->disHelp ? 0 : 1;
00662 if (is_array($this->overrideVals[$table])) {
00663 $this->tceforms->hiddenFieldListArr = array_keys($this->overrideVals[$table]);
00664 }
00665
00666
00667 $this->tceforms->registerDefaultLanguageData($table,$rec);
00668
00669
00670 $panel = '';
00671 if ($this->columnsOnly) {
00672 $panel.= $this->tceforms->getListedFields($table,$rec,$this->columnsOnly);
00673 } else {
00674 $panel.= $this->tceforms->getMainFields($table,$rec);
00675 }
00676 $panel = $this->tceforms->wrapTotal($panel,$rec,$table);
00677
00678
00679 if ($cmd=='new') {
00680 $panel.= '<input type="hidden" name="data['.$table.']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
00681 $this->newC++;
00682 }
00683
00684
00685 if ($lockInfo = t3lib_BEfunc::isRecordLocked($table,$rec['uid'])) {
00686 $lockIcon = '
00687
00688 <!--
00689 Warning box:
00690 -->
00691 <table border="0" cellpadding="0" cellspacing="0" class="warningbox">
00692 <tr>
00693 <td><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' alt="" /></td>
00694 <td>'.htmlspecialchars($lockInfo['msg']).'</td>
00695 </tr>
00696 </table>
00697 ';
00698 } else $lockIcon = '';
00699
00700
00701 $editForm.= $lockIcon.$panel;
00702 }
00703
00704 $thePrevUid = $rec['uid'];
00705 } else {
00706 $this->errorC++;
00707 $editForm.=$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.noEditPermission',1).'<br /><br />'.
00708 ($deniedAccessReason ? 'Reason: '.htmlspecialchars($deniedAccessReason).'<br/><br/>' : '');
00709 }
00710 }
00711 }
00712 }
00713 }
00714 }
00715 return $editForm;
00716 }
00717
00723 function makeButtonPanel() {
00724 global $TCA,$LANG;
00725
00726 $panel='';
00727
00728
00729
00730 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly']) {
00731
00732
00733 $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).'" />';
00734
00735
00736 if ($this->viewId && !$this->noView && t3lib_extMgm::isLoaded('cms')) {
00737 $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).'" />';
00738 }
00739
00740
00741 if (count($this->elementsData)==1 && $this->getNewIconMode($this->firstEl['table'])) {
00742 $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).'" />';
00743 }
00744
00745
00746 $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).'" />';
00747 }
00748
00749
00750 $panel.= '<a href="#" onclick="document.editform.closeDoc.value=1; document.editform.submit(); return false;">'.
00751 '<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="" />'.
00752 '</a>';
00753
00754
00755 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && count($this->elementsData)==1) {
00756 if ($this->firstEl['cmd']!='new' && t3lib_div::testInt($this->firstEl['uid'])) {
00757
00758
00759 if ($this->firstEl['deleteAccess'] && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && !$this->getNewIconMode($this->firstEl['table'],'disableDelete')) {
00760 $aOnClick = 'return deleteRecord(\''.$this->firstEl['table'].'\',\''.$this->firstEl['uid'].'\',unescape(\''.rawurlencode($this->retUrl).'\'));';
00761 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00762 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/deletedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->getLL('deleteItem',1).'" alt="" />'.
00763 '</a>';
00764 }
00765
00766
00767 $undoButton = 0;
00768 $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');
00769 if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
00770 $undoButton = 1;
00771 }
00772 if ($undoButton) {
00773 $aOnClick = 'document.location=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&revert=ALL_FIELDS&sumUp=-1&returnUrl='.rawurlencode($this->R_URI).'\'; return false;';
00774 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00775 '<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="" />'.
00776 '</a>';
00777 }
00778 if ($this->getNewIconMode($this->firstEl['table'],'showHistory')) {
00779 $aOnClick = 'document.location=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&returnUrl='.rawurlencode($this->R_URI).'\'; return false;';
00780 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00781 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/history2.gif','width="13" height="12"').' class="c-inputButton" alt="" />'.
00782 '</a>';
00783 }
00784
00785
00786 if ($this->columnsOnly) {
00787 $panel.= '<a href="'.htmlspecialchars($this->R_URI.'&columnsOnly=').'">'.
00788 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' class="c-inputButton" title="'.$LANG->getLL('editWholeRecord',1).'" alt="" />'.
00789 '</a>';
00790 }
00791 }
00792 }
00793 return $panel;
00794 }
00795
00802 function makeDocSel() {
00803 global $BE_USER,$LANG;
00804
00805
00806 if (!$this->modTSconfig['properties']['disableDocSelector']) {
00807
00808
00809 if ((strcmp($this->docDat[1],$this->storeUrlMd5)||!isset($this->docHandler[$this->storeUrlMd5])) && !$this->dontStoreDocumentRef) {
00810 $this->docHandler[$this->storeUrlMd5]=array($this->storeTitle,$this->storeArray,$this->storeUrl);
00811 $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->storeUrlMd5));
00812 }
00813
00814
00815 $docSel='';
00816 if (is_array($this->docHandler)) {
00817 $opt = array();
00818 $opt[] = '<option>[ '.$LANG->getLL('openDocs',1).': ]</option>';
00819
00820
00821 foreach($this->docHandler as $md5k => $setupArr) {
00822 $theValue = 'alt_doc.php?'.$setupArr[2].'&returnUrl='.rawurlencode($this->retUrl);
00823 $opt[]='<option value="'.htmlspecialchars($theValue).'"'.(!strcmp($md5k,$this->storeUrlMd5)?' selected="selected"':'').'>'.htmlspecialchars(strip_tags(t3lib_div::htmlspecialchars_decode($setupArr[0]))).'</option>';
00824 }
00825
00826
00827 $onChange = 'if(this.options[this.selectedIndex].value && !TBE_EDITOR_isFormChanged()){document.location=(this.options[this.selectedIndex].value);}';
00828 $docSel='<select name="_docSelector" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
00829
00830
00831 $docSel.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_docSelector', $GLOBALS['BACK_PATH'],'', TRUE);
00832 }
00833 } else $docSel='';
00834 return $docSel;
00835 }
00836
00844 function makeCmenu() {
00845
00846
00847 if (!$this->modTSconfig['properties']['disableCacheSelector']) {
00848 $cMenu = $this->doc->clearCacheMenu(intval($this->viewId),!$this->modTSconfig['properties']['disableDocSelector']);
00849
00850
00851 $cMenu.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_cacheSelector', $GLOBALS['BACK_PATH'],'', TRUE);
00852 } else $cMenu ='';
00853 return $cMenu;
00854 }
00855
00865 function compileForm($panel,$docSel,$cMenu,$editForm) {
00866 global $LANG;
00867
00868
00869 $formContent='';
00870 $formContent.='
00871
00872 <!--
00873 Header of the editing page.
00874 Contains the buttons for saving/closing, the document selector and menu selector.
00875 Shows the path of the editing operation as well.
00876 -->
00877 <table border="0" cellpadding="0" cellspacing="1" width="470" id="typo3-altdoc-header">
00878 <tr>
00879 <td nowrap="nowrap" valign="top">'.$panel.'</td>
00880 <td nowrap="nowrap" valign="top" align="right">'.$docSel.$cMenu.'</td>
00881 </tr>
00882 <tr>
00883 <td colspan="2">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '.htmlspecialchars($this->generalPathOfForm).'</td>
00884 </tr>
00885 </table>
00886 <img src="clear.gif" width="1" height="4" alt="" /><br />
00887
00888
00889
00890
00891 <!--
00892 EDITING FORM:
00893 -->
00894
00895 '.$editForm.'
00896
00897
00898
00899 <!--
00900 Saving buttons (same as in top)
00901 -->
00902
00903 '.$panel.
00904 '<input type="hidden" name="returnUrl" value="'.htmlspecialchars($this->retUrl).'" />
00905 <input type="hidden" name="viewUrl" value="'.htmlspecialchars($this->viewUrl).'" />';
00906
00907 if ($this->returnNewPageId) {
00908 $formContent.='<input type="hidden" name="returnNewPageId" value="1" />';
00909 }
00910 $formContent.='<input type="hidden" name="popViewId" value="'.htmlspecialchars($this->viewId).'" />';
00911 if ($this->viewId_addParams) {
00912 $formContent.='<input type="hidden" name="popViewId_addParams" value="'.htmlspecialchars($this->viewId_addParams).'" />';
00913 }
00914 $formContent.='<input type="hidden" name="closeDoc" value="0" />';
00915 $formContent.='<input type="hidden" name="doSave" value="0" />';
00916 $formContent.='<input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
00917 $formContent.='<input type="hidden" name="_disableRTE" value="'.$this->tceforms->disableRTE.'" />';
00918
00919 return $formContent;
00920 }
00921
00927 function functionMenus() {
00928 global $BE_USER,$LANG;
00929
00930 $funcMenus = '';
00931
00932
00933 $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);
00934
00935
00936 if ($BE_USER->uc['edit_showFieldHelp']!='text') {
00937 $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);
00938 }
00939
00940
00941 if ($BE_USER->isRTE()) {
00942 $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);
00943 }
00944
00945 return '
00946
00947 <!--
00948 Function menus (checkboxes for selecting options):
00949 -->
00950 '.$funcMenus;
00951 }
00952
00958 function shortCutLink() {
00959 global $BE_USER,$LANG;
00960
00961
00962 if ($this->returnUrl!='close.html') {
00963 $content.='<br /><br />';
00964
00965
00966 if ($BE_USER->mayMakeShortcut()) {
00967 $content.=$this->doc->makeShortcutIcon('returnUrl,edit,defVals,overrideVals,columnsOnly,returnNewPageId,editRegularContentFromId,disHelp,noView',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name'],1);
00968 }
00969
00970
00971 $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;';
00972 $content.='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00973 '<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="" />'.
00974 '</a>';
00975 }
00976 return '
00977
00978 <!--
00979 Shortcut link:
00980 -->
00981 '.$content;
00982 }
00983
00989 function tceformMessages() {
00990 if (count($this->tceforms->commentMessages)) {
00991 $this->content.='
00992
00993 <!-- TCEFORM messages
00994 '.htmlspecialchars(implode(chr(10),$this->tceforms->commentMessages)).'
00995 -->
00996
00997 ';
00998 }
00999 }
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01027 function editRegularContentFromId() {
01028 if (t3lib_extMgm::isLoaded('cms')) {
01029 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
01030 'uid',
01031 'tt_content',
01032 'pid='.intval($this->editRegularContentFromId).
01033 t3lib_BEfunc::deleteClause('tt_content').
01034 ' AND colPos=0 AND sys_language_uid=0',
01035 '',
01036 'sorting'
01037 );
01038 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
01039 $ecUids=array();
01040 while($ecRec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
01041 $ecUids[]=$ecRec['uid'];
01042 }
01043 $this->editconf['tt_content'][implode(',',$ecUids)]='edit';
01044 }
01045 }
01046 }
01047
01054 function compileStoreDat() {
01055 $this->storeArray = t3lib_div::compileSelectedGetVarsFromArray('edit,defVals,overrideVals,columnsOnly,disHelp,noView,editRegularContentFromId',$this->R_URL_getvars);
01056 $this->storeUrl = t3lib_div::implodeArrayForUrl('',$this->storeArray);
01057 $this->storeUrlMd5 = md5($this->storeUrl);
01058 }
01059
01067 function getNewIconMode($table,$key='saveDocNew') {
01068 global $BE_USER;
01069 $TSconfig = $BE_USER->getTSConfig('options.'.$key);
01070 $output = trim(isset($TSconfig['properties'][$table]) ? $TSconfig['properties'][$table] : $TSconfig['value']);
01071 return $output;
01072 }
01073
01080 function closeDocument($code=0) {
01081 global $BE_USER;
01082
01083
01084 if (isset($this->docHandler[$this->storeUrlMd5])) {
01085 unset($this->docHandler[$this->storeUrlMd5]);
01086 if ($code=='3') $this->docHandler=array();
01087 $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->docDat[1]));
01088 }
01089
01090
01091 if ($this->returnEditConf && $this->retUrl!='dummy.php') {
01092 $this->retUrl.='&returnEditConf='.rawurlencode(serialize($this->editconf));
01093 }
01094
01095
01096 if (!$code || $code==1) {
01097 Header('Location: '.t3lib_div::locationHeaderUrl($this->retUrl));
01098 exit;
01099 } else {
01100 $this->setDocument('',$this->retUrl);
01101 }
01102 }
01103
01112 function setDocument($currentDocFromHandlerMD5='',$retUrl='alt_doc_nodoc.php') {
01113 if (!t3lib_extMgm::isLoaded('cms') && !strcmp($retUrl,'alt_doc_nodoc.php')) return;
01114
01115 if (!$this->modTSconfig['properties']['disableDocSelector'] && is_array($this->docHandler) && count($this->docHandler)) {
01116 if (isset($this->docHandler[$currentDocFromHandlerMD5])) {
01117 $setupArr=$this->docHandler[$currentDocFromHandlerMD5];
01118 } else {
01119 reset($this->docHandler);
01120 $setupArr=current($this->docHandler);
01121 }
01122 if ($setupArr[2]) {
01123 $sParts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
01124 $retUrl = $sParts['path'].'?'.$setupArr[2].'&returnUrl='.rawurlencode($retUrl);
01125 }
01126 }
01127 Header('Location: '.t3lib_div::locationHeaderUrl($retUrl));
01128 exit;
01129 }
01130 }
01131
01132
01133 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php']) {
01134 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php']);
01135 }
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153 $SOBE = t3lib_div::makeInstance('SC_alt_doc');
01154
01155
01156 $SOBE->preInit();
01157 if ($SOBE->doProcessData()) {
01158 require_once (PATH_t3lib.'class.t3lib_tcemain.php');
01159 $SOBE->processData();
01160 }
01161
01162 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
01163 require_once (PATH_t3lib.'class.t3lib_transferdata.php');
01164
01165
01166
01167 $SOBE->init();
01168 $SOBE->main();
01169 $SOBE->printContent();
01170 ?>