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 ? t3lib_BEfunc::viewOnClick($this->popViewId,'',t3lib_BEfunc::BEgetRootLine($this->popViewId),'',$this->viewUrl,$this->popViewId_addParams) : '')
00418 ).$this->doc->getDynTabMenuJScode();
00419
00420
00421 $CMparts = $this->doc->getContextMenuCode();
00422 $this->doc->JScode.= $CMparts[0];
00423 $this->doc->bodyTagAdditions = $CMparts[1];
00424 $this->doc->postCode.= $CMparts[2];
00425 }
00426
00432 function main() {
00433 global $BE_USER,$LANG;
00434
00435
00436 $this->content='';
00437 $this->content.=$this->doc->startPage('TYPO3 Edit Document');
00438
00439
00440 if (is_array($this->editconf)) {
00441
00442
00443 $this->tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
00444 $this->tceforms->initDefaultBEMode();
00445 $this->tceforms->doSaveFieldName = 'doSave';
00446 $this->tceforms->returnUrl = $this->R_URI;
00447 $this->tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
00448 $this->tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00449 $this->tceforms->enableClickMenu = TRUE;
00450 $this->tceforms->enableTabMenu = TRUE;
00451
00452
00453 $this->tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard');
00454 $this->tceforms->clipObj->initializeClipboard();
00455
00456
00457 if ($BE_USER->uc['edit_showFieldHelp']!='text' && $this->MOD_SETTINGS['showDescriptions']) $this->tceforms->edit_showFieldHelp='text';
00458
00459 if ($this->editRegularContentFromId) {
00460 $this->editRegularContentFromId();
00461 }
00462
00463
00464 $editForm = $this->makeEditForm();
00465 if ($editForm) {
00466 reset($this->elementsData);
00467 $this->firstEl = current($this->elementsData);
00468
00469 if ($this->viewId) {
00470
00471 $this->modTSconfig = t3lib_BEfunc::getModTSconfig($this->viewId,'mod.xMOD_alt_doc');
00472 } else $this->modTSconfig=array();
00473
00474 $panel = $this->makeButtonPanel();
00475 $docSel = $this->makeDocSel();
00476 $cMenu = $this->makeCmenu();
00477
00478 $formContent = $this->compileForm($panel,$docSel,$cMenu,$editForm);
00479
00480 $this->content.= $this->tceforms->printNeededJSFunctions_top().
00481 $formContent.
00482 $this->tceforms->printNeededJSFunctions();
00483 $this->content.= $this->functionMenus();
00484
00485
00486 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms', $GLOBALS['BACK_PATH'],'<br/>|',FALSE,'margin-top: 20px;');
00487
00488 $this->content.= $this->shortCutLink();
00489
00490 $this->tceformMessages();
00491 }
00492 }
00493 }
00494
00500 function printContent() {
00501
00502 echo $this->content.$this->doc->endPage();
00503 }
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00535 function makeEditForm() {
00536 global $BE_USER,$LANG,$TCA;
00537
00538
00539 $this->elementsData=array();
00540 $this->errorC=0;
00541 $this->newC=0;
00542 $thePrevUid='';
00543 $editForm='';
00544
00545
00546 foreach($this->editconf as $table => $conf) {
00547 if (is_array($conf) && $TCA[$table] && $BE_USER->check('tables_modify',$table)) {
00548
00549
00550 foreach($conf as $cKey => $cmd) {
00551 if ($cmd=='edit' || $cmd=='new') {
00552
00553
00554 $ids = t3lib_div::trimExplode(',',$cKey,1);
00555
00556
00557 foreach($ids as $theUid) {
00558
00559
00560
00561 $hasAccess = 1;
00562 $deniedAccessReason = '';
00563 $deleteAccess = 0;
00564 $this->viewId = 0;
00565
00566
00567 if ($cmd=='new') {
00568 if (intval($theUid)) {
00569
00570
00571 if ($theUid<0) {
00572 $calcPRec=t3lib_BEfunc::getRecord($table,abs($theUid));
00573 $calcPRec=t3lib_BEfunc::getRecord('pages',$calcPRec['pid']);
00574 } else {
00575 $calcPRec=t3lib_BEfunc::getRecord('pages',abs($theUid));
00576 }
00577
00578
00579 if (is_array($calcPRec)) {
00580 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
00581 if ($table=='pages') {
00582 $hasAccess = $CALC_PERMS&8 ? 1 : 0;
00583 $this->viewId = $calcPRec['pid'];
00584 } else {
00585 $hasAccess = $CALC_PERMS&16 ? 1 : 0;
00586 $this->viewId = $calcPRec['uid'];
00587 }
00588 }
00589 }
00590 $this->dontStoreDocumentRef=1;
00591 } else {
00592 $calcPRec = t3lib_BEfunc::getRecord($table,$theUid);
00593 t3lib_BEfunc::fixVersioningPid($table,$calcPRec);
00594 if (is_array($calcPRec)) {
00595 if ($table=='pages') {
00596 $CALC_PERMS = $BE_USER->calcPerms($calcPRec);
00597 $hasAccess = $CALC_PERMS&2 ? 1 : 0;
00598 $deleteAccess = $CALC_PERMS&4 ? 1 : 0;
00599 $this->viewId = $calcPRec['uid'];
00600 } else {
00601 $CALC_PERMS = $BE_USER->calcPerms(t3lib_BEfunc::getRecord('pages',$calcPRec['pid']));
00602 $hasAccess = $CALC_PERMS&16 ? 1 : 0;
00603 $deleteAccess = $CALC_PERMS&16 ? 1 : 0;
00604 $this->viewId = $calcPRec['pid'];
00605
00606
00607 if ($TCA[$table]['ctrl']['languageField'] && $calcPRec[$TCA[$table]['ctrl']['languageField']]>0) {
00608 $this->viewId_addParams = '&L='.$calcPRec[$TCA[$table]['ctrl']['languageField']];
00609 }
00610 }
00611
00612
00613 if ($hasAccess) {
00614 $hasAccess = $BE_USER->recordEditAccessInternals($table, $calcPRec);
00615 $deniedAccessReason = $BE_USER->errorMsg;
00616 }
00617 } else $hasAccess = 0;
00618 }
00619
00620
00621
00622 if ($hasAccess) {
00623 $prevPageID = is_object($trData)?$trData->prevPageID:'';
00624 $trData = t3lib_div::makeInstance('t3lib_transferData');
00625 $trData->addRawData = TRUE;
00626 $trData->defVals = $this->defVals;
00627 $trData->lockRecords=1;
00628 $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
00629 $trData->prevPageID = $prevPageID;
00630 $trData->fetchRecord($table,$theUid,$cmd=='new'?'new':'');
00631 reset($trData->regTableItems_data);
00632 $rec = current($trData->regTableItems_data);
00633 $rec['uid'] = $cmd=='new'?uniqid('NEW'):$theUid;
00634 $this->elementsData[]=array(
00635 'table' => $table,
00636 'uid' => $rec['uid'],
00637 'cmd' => $cmd,
00638 'deleteAccess' => $deleteAccess
00639 );
00640 if ($cmd=='new') {
00641 $rec['pid'] = $theUid=='prev'?$thePrevUid:$theUid;
00642 }
00643
00644
00645 if (is_array($rec)) {
00646
00647
00648 $this->generalPathOfForm = $this->tceforms->getRecordPath($table,$rec);
00649 if (!$this->storeTitle) {
00650 $this->storeTitle = $this->recTitle ? htmlspecialchars($this->recTitle) : t3lib_BEfunc::getRecordTitle($table,$rec,1);
00651 }
00652
00653
00654 $this->tceforms->hiddenFieldList = '';
00655 $this->tceforms->globalShowHelp = $this->disHelp ? 0 : 1;
00656 if (is_array($this->overrideVals[$table])) {
00657 $this->tceforms->hiddenFieldListArr = array_keys($this->overrideVals[$table]);
00658 }
00659
00660
00661 $this->tceforms->registerDefaultLanguageData($table,$rec);
00662
00663
00664 $panel = '';
00665 if ($this->columnsOnly) {
00666 $panel.= $this->tceforms->getListedFields($table,$rec,$this->columnsOnly);
00667 } else {
00668 $panel.= $this->tceforms->getMainFields($table,$rec);
00669 }
00670 $panel = $this->tceforms->wrapTotal($panel,$rec,$table);
00671
00672
00673 if ($cmd=='new') {
00674 $panel.= '<input type="hidden" name="data['.$table.']['.$rec['uid'].'][pid]" value="'.$rec['pid'].'" />';
00675 $this->newC++;
00676 }
00677
00678
00679 if ($lockInfo = t3lib_BEfunc::isRecordLocked($table,$rec['uid'])) {
00680 $lockIcon = '
00681
00682 <!--
00683 Warning box:
00684 -->
00685 <table border="0" cellpadding="0" cellspacing="0" class="warningbox">
00686 <tr>
00687 <td><img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' alt="" /></td>
00688 <td>'.htmlspecialchars($lockInfo['msg']).'</td>
00689 </tr>
00690 </table>
00691 ';
00692 } else $lockIcon = '';
00693
00694
00695 $editForm.= $lockIcon.$panel;
00696 }
00697
00698 $thePrevUid = $rec['uid'];
00699 } else {
00700 $this->errorC++;
00701 $editForm.=$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.noEditPermission',1).'<br /><br />'.
00702 ($deniedAccessReason ? 'Reason: '.htmlspecialchars($deniedAccessReason).'<br/><br/>' : '');
00703 }
00704 }
00705 }
00706 }
00707 }
00708 }
00709 return $editForm;
00710 }
00711
00717 function makeButtonPanel() {
00718 global $TCA,$LANG;
00719
00720 $panel='';
00721
00722
00723
00724 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly']) {
00725
00726
00727 $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).'" />';
00728
00729
00730 if ($this->viewId && !$this->noView && t3lib_extMgm::isLoaded('cms')) {
00731 $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).'" />';
00732 }
00733
00734
00735 if (count($this->elementsData)==1 && $this->getNewIconMode($this->firstEl['table'])) {
00736 $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).'" />';
00737 }
00738
00739
00740 $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).'" />';
00741 }
00742
00743
00744 $panel.= '<a href="#" onclick="document.editform.closeDoc.value=1; document.editform.submit(); return false;">'.
00745 '<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="" />'.
00746 '</a>';
00747
00748
00749 if (!$this->errorC && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && count($this->elementsData)==1) {
00750 if ($this->firstEl['cmd']!='new' && t3lib_div::testInt($this->firstEl['uid'])) {
00751
00752
00753 if ($this->firstEl['deleteAccess'] && !$TCA[$this->firstEl['table']]['ctrl']['readOnly'] && !$this->getNewIconMode($this->firstEl['table'],'disableDelete')) {
00754 $aOnClick = 'return deleteRecord(\''.$this->firstEl['table'].'\',\''.$this->firstEl['uid'].'\',unescape(\''.rawurlencode($this->retUrl).'\'));';
00755 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00756 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/deletedok.gif','width="21" height="16"').' class="c-inputButton" title="'.$LANG->getLL('deleteItem',1).'" alt="" />'.
00757 '</a>';
00758 }
00759
00760
00761 $undoButton = 0;
00762 $undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename="'.$GLOBALS['TYPO3_DB']->quoteStr($this->firstEl['table'], 'sys_history').'" AND recuid="'.intval($this->firstEl['uid']).'"', '', 'tstamp DESC', '1');
00763 if ($undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
00764 $undoButton = 1;
00765 }
00766 if ($undoButton) {
00767 $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;';
00768 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00769 '<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="" />'.
00770 '</a>';
00771 }
00772 if ($this->getNewIconMode($this->firstEl['table'],'showHistory')) {
00773 $aOnClick = 'document.location=\'show_rechis.php?element='.rawurlencode($this->firstEl['table'].':'.$this->firstEl['uid']).'&returnUrl='.rawurlencode($this->R_URI).'\'; return false;';
00774 $panel.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00775 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/history2.gif','width="13" height="12"').' class="c-inputButton" alt="" />'.
00776 '</a>';
00777 }
00778
00779
00780 if ($this->columnsOnly) {
00781 $panel.= '<a href="'.htmlspecialchars($this->R_URI.'&columnsOnly=').'">'.
00782 '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/edit2.gif','width="11" height="12"').' class="c-inputButton" title="'.$LANG->getLL('editWholeRecord',1).'" alt="" />'.
00783 '</a>';
00784 }
00785 }
00786 }
00787 return $panel;
00788 }
00789
00796 function makeDocSel() {
00797 global $BE_USER,$LANG;
00798
00799
00800 if (!$this->modTSconfig['properties']['disableDocSelector']) {
00801
00802
00803 if ((strcmp($this->docDat[1],$this->storeUrlMd5)||!isset($this->docHandler[$this->storeUrlMd5])) && !$this->dontStoreDocumentRef) {
00804 $this->docHandler[$this->storeUrlMd5]=array($this->storeTitle,$this->storeArray,$this->storeUrl);
00805 $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->storeUrlMd5));
00806 }
00807
00808
00809 $docSel='';
00810 if (is_array($this->docHandler)) {
00811 $opt = array();
00812 $opt[] = '<option>[ '.$LANG->getLL('openDocs',1).': ]</option>';
00813
00814
00815 foreach($this->docHandler as $md5k => $setupArr) {
00816 $theValue = 'alt_doc.php?'.$setupArr[2].'&returnUrl='.rawurlencode($this->retUrl);
00817 $opt[]='<option value="'.htmlspecialchars($theValue).'"'.(!strcmp($md5k,$this->storeUrlMd5)?' selected="selected"':'').'>'.htmlspecialchars(strip_tags(t3lib_div::htmlspecialchars_decode($setupArr[0]))).'</option>';
00818 }
00819
00820
00821 $onChange = 'if(this.options[this.selectedIndex].value && !TBE_EDITOR_isFormChanged()){document.location=(this.options[this.selectedIndex].value);}';
00822 $docSel='<select name="_docSelector" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
00823
00824
00825 $docSel.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_docSelector', $GLOBALS['BACK_PATH'],'', TRUE);
00826 }
00827 } else $docSel='';
00828 return $docSel;
00829 }
00830
00838 function makeCmenu() {
00839
00840
00841 if (!$this->modTSconfig['properties']['disableCacheSelector']) {
00842 $cMenu = $this->doc->clearCacheMenu(intval($this->viewId),!$this->modTSconfig['properties']['disableDocSelector']);
00843
00844
00845 $cMenu.=t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'TCEforms_cacheSelector', $GLOBALS['BACK_PATH'],'', TRUE);
00846 } else $cMenu ='';
00847 return $cMenu;
00848 }
00849
00859 function compileForm($panel,$docSel,$cMenu,$editForm) {
00860 global $LANG;
00861
00862
00863 $formContent='';
00864 $formContent.='
00865
00866 <!--
00867 Header of the editing page.
00868 Contains the buttons for saving/closing, the document selector and menu selector.
00869 Shows the path of the editing operation as well.
00870 -->
00871 <table border="0" cellpadding="0" cellspacing="1" width="470" id="typo3-altdoc-header">
00872 <tr>
00873 <td nowrap="nowrap" valign="top">'.$panel.'</td>
00874 <td nowrap="nowrap" valign="top" align="right">'.$docSel.$cMenu.'</td>
00875 </tr>
00876 <tr>
00877 <td colspan="2">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path',1).': '.htmlspecialchars($this->generalPathOfForm).'</td>
00878 </tr>
00879 </table>
00880 <img src="clear.gif" width="1" height="4" alt="" /><br />
00881
00882
00883
00884
00885 <!--
00886 EDITING FORM:
00887 -->
00888
00889 '.$editForm.'
00890
00891
00892
00893 <!--
00894 Saving buttons (same as in top)
00895 -->
00896
00897 '.$panel.
00898 '<input type="hidden" name="returnUrl" value="'.htmlspecialchars($this->retUrl).'" />
00899 <input type="hidden" name="viewUrl" value="'.htmlspecialchars($this->viewUrl).'" />';
00900
00901 if ($this->returnNewPageId) {
00902 $formContent.='<input type="hidden" name="returnNewPageId" value="1" />';
00903 }
00904 $formContent.='<input type="hidden" name="popViewId" value="'.htmlspecialchars($this->viewId).'" />';
00905 if ($this->viewId_addParams) {
00906 $formContent.='<input type="hidden" name="popViewId_addParams" value="'.htmlspecialchars($this->viewId_addParams).'" />';
00907 }
00908 $formContent.='<input type="hidden" name="closeDoc" value="0" />';
00909 $formContent.='<input type="hidden" name="doSave" value="0" />';
00910 $formContent.='<input type="hidden" name="_serialNumber" value="'.md5(microtime()).'" />';
00911 $formContent.='<input type="hidden" name="_disableRTE" value="'.$this->tceforms->disableRTE.'" />';
00912
00913 return $formContent;
00914 }
00915
00921 function functionMenus() {
00922 global $BE_USER,$LANG;
00923
00924 $funcMenus = '';
00925
00926
00927 $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);
00928
00929
00930 if ($BE_USER->uc['edit_showFieldHelp']!='text') {
00931 $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);
00932 }
00933
00934
00935 if ($BE_USER->isRTE()) {
00936 $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);
00937 }
00938
00939 return '
00940
00941 <!--
00942 Function menus (checkboxes for selecting options):
00943 -->
00944 '.$funcMenus;
00945 }
00946
00952 function shortCutLink() {
00953 global $BE_USER,$LANG;
00954
00955
00956 if ($this->returnUrl!='close.html') {
00957 $content.='<br /><br />';
00958
00959
00960 if ($BE_USER->mayMakeShortcut()) {
00961 $content.=$this->doc->makeShortcutIcon('returnUrl,edit,defVals,overrideVals,columnsOnly,returnNewPageId,editRegularContentFromId,disHelp,noView',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name'],1);
00962 }
00963
00964
00965 $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;';
00966 $content.='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
00967 '<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="" />'.
00968 '</a>';
00969 }
00970 return '
00971
00972 <!--
00973 Shortcut link:
00974 -->
00975 '.$content;
00976 }
00977
00983 function tceformMessages() {
00984 if (count($this->tceforms->commentMessages)) {
00985 $this->content.='
00986
00987 <!-- TCEFORM messages
00988 '.htmlspecialchars(implode(chr(10),$this->tceforms->commentMessages)).'
00989 -->
00990
00991 ';
00992 }
00993 }
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01021 function editRegularContentFromId() {
01022 if (t3lib_extMgm::isLoaded('cms')) {
01023 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
01024 'uid',
01025 'tt_content',
01026 'pid='.intval($this->editRegularContentFromId).
01027 t3lib_BEfunc::deleteClause('tt_content').
01028 ' AND colPos=0 AND sys_language_uid=0',
01029 '',
01030 'sorting'
01031 );
01032 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) {
01033 $ecUids=array();
01034 while($ecRec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
01035 $ecUids[]=$ecRec['uid'];
01036 }
01037 $this->editconf['tt_content'][implode(',',$ecUids)]='edit';
01038 }
01039 }
01040 }
01041
01048 function compileStoreDat() {
01049 $this->storeArray = t3lib_div::compileSelectedGetVarsFromArray('edit,defVals,overrideVals,columnsOnly,disHelp,noView,editRegularContentFromId',$this->R_URL_getvars);
01050 $this->storeUrl = t3lib_div::implodeArrayForUrl('',$this->storeArray);
01051 $this->storeUrlMd5 = md5($this->storeUrl);
01052 }
01053
01061 function getNewIconMode($table,$key='saveDocNew') {
01062 global $BE_USER;
01063 $TSconfig = $BE_USER->getTSConfig('options.'.$key);
01064 $output = trim(isset($TSconfig['properties'][$table]) ? $TSconfig['properties'][$table] : $TSconfig['value']);
01065 return $output;
01066 }
01067
01074 function closeDocument($code=0) {
01075 global $BE_USER;
01076
01077
01078 if (isset($this->docHandler[$this->storeUrlMd5])) {
01079 unset($this->docHandler[$this->storeUrlMd5]);
01080 if ($code=='3') $this->docHandler=array();
01081 $BE_USER->pushModuleData('alt_doc.php',array($this->docHandler,$this->docDat[1]));
01082 }
01083
01084
01085 if ($this->returnEditConf && $this->retUrl!='dummy.php') {
01086 $this->retUrl.='&returnEditConf='.rawurlencode(serialize($this->editconf));
01087 }
01088
01089
01090 if (!$code || $code==1) {
01091 Header('Location: '.t3lib_div::locationHeaderUrl($this->retUrl));
01092 exit;
01093 } else {
01094 $this->setDocument('',$this->retUrl);
01095 }
01096 }
01097
01106 function setDocument($currentDocFromHandlerMD5='',$retUrl='alt_doc_nodoc.php') {
01107 if (!t3lib_extMgm::isLoaded('cms') && !strcmp($retUrl,'alt_doc_nodoc.php')) return;
01108
01109 if (!$this->modTSconfig['properties']['disableDocSelector'] && is_array($this->docHandler) && count($this->docHandler)) {
01110 if (isset($this->docHandler[$currentDocFromHandlerMD5])) {
01111 $setupArr=$this->docHandler[$currentDocFromHandlerMD5];
01112 } else {
01113 reset($this->docHandler);
01114 $setupArr=current($this->docHandler);
01115 }
01116 if ($setupArr[2]) {
01117 $sParts = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
01118 $retUrl = $sParts['path'].'?'.$setupArr[2].'&returnUrl='.rawurlencode($retUrl);
01119 }
01120 }
01121 Header('Location: '.t3lib_div::locationHeaderUrl($retUrl));
01122 exit;
01123 }
01124 }
01125
01126
01127 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php']) {
01128 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/alt_doc.php']);
01129 }
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147 $SOBE = t3lib_div::makeInstance('SC_alt_doc');
01148
01149
01150 $SOBE->preInit();
01151 if ($SOBE->doProcessData()) {
01152 require_once (PATH_t3lib.'class.t3lib_tcemain.php');
01153 $SOBE->processData();
01154 }
01155
01156 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
01157 require_once (PATH_t3lib.'class.t3lib_transferdata.php');
01158
01159
01160
01161 $SOBE->init();
01162 $SOBE->main();
01163 $SOBE->printContent();
01164 ?>