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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 class t3lib_clipboard {
00098 var $numberTabs = 3;
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 var $clipData=array();
00120
00121 var $changed=0;
00122 var $current='';
00123 var $backPath='';
00124 var $lockToNormal=0;
00125 var $fileMode=0;
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 function initializeClipboard() {
00151 global $BE_USER;
00152
00153 $this->backPath = $GLOBALS['BACK_PATH'];
00154
00155
00156 $clipData = $BE_USER->getModuleData('clipboard',$BE_USER->getTSConfigVal('options.saveClipboard')?'':'ses');
00157
00158
00159 $clNP = $BE_USER->getTSConfigVal('options.clipboardNumberPads');
00160 if (t3lib_div::testInt($clNP) && $clNP>=0) {
00161 $this->numberTabs = t3lib_div::intInRange($clNP,0,20);
00162 }
00163
00164
00165 $this->clipData['normal'] = is_array($clipData['normal']) ? $clipData['normal'] : array();
00166 for ($a=1;$a<=$this->numberTabs;$a++) {
00167 $this->clipData['tab_'.$a] = is_array($clipData['tab_'.$a]) ? $clipData['tab_'.$a] : array();
00168 }
00169
00170
00171 $this->clipData['current'] = $this->current = isset($this->clipData[$clipData['current']]) ? $clipData['current'] : 'normal';
00172 $this->clipData['_setThumb'] = $clipData['_setThumb'];
00173 }
00174
00175
00176
00177
00178
00179
00180
00181 function lockToNormal() {
00182 $this->lockToNormal = 1;
00183 $this->current = 'normal';
00184 }
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 function setCmd($cmd) {
00199 if (is_array($cmd['el'])) {
00200 foreach ($cmd['el'] as $k => $v) {
00201 if ($this->current=='normal') {
00202 unset($this->clipData['normal']);
00203 }
00204 if ($v) {
00205 $this->clipData[$this->current]['el'][$k]=$v;
00206 } else {
00207 $this->removeElement($k);
00208 }
00209 $this->changed=1;
00210 }
00211 }
00212
00213 if ($cmd['setP']) {
00214 $this->setCurrentPad($cmd['setP']);
00215 }
00216
00217 if ($cmd['remove']) {
00218 $this->removeElement($cmd['remove']);
00219 $this->changed=1;
00220 }
00221
00222 if ($cmd['removeAll']) {
00223 $this->clipData[$cmd['removeAll']]=array();
00224 $this->changed=1;
00225 }
00226
00227 if (isset($cmd['setCopyMode'])) {
00228 $this->clipData[$this->current]['mode']=$this->isElements()?($cmd['setCopyMode']?'copy':''):'';
00229 $this->changed=1;
00230 }
00231
00232 if (isset($cmd['setThumb'])) {
00233 $this->clipData['_setThumb']=$cmd['setThumb'];
00234 $this->changed=1;
00235 }
00236 }
00237
00238
00239
00240
00241
00242
00243
00244 function setCurrentPad($padIdent) {
00245
00246 if (!$this->lockToNormal && $this->current!=$padIdent) {
00247 if (isset($this->clipData[$padIdent])) $this->clipData['current'] = $this->current = $padIdent;
00248 if ($this->current!='normal' || !$this->isElements()) $this->clipData[$this->current]['mode']='';
00249 $this->changed=1;
00250 }
00251 }
00252
00253
00254
00255
00256
00257
00258
00259 function endClipboard() {
00260 if ($this->changed) $this->saveClipboard();
00261 $this->changed=0;
00262 }
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 function cleanUpCBC($CBarr,$table,$removeDeselected=0) {
00273 if (is_array($CBarr)) {
00274 foreach ($CBarr as $k => $v) {
00275 $p=explode('|',$k);
00276 if ((string)$p[0]!=(string)$table || ($removeDeselected && !$v)) {
00277 unset($CBarr[$k]);
00278 }
00279 }
00280 }
00281 return $CBarr;
00282 }
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306 function printClipboard() {
00307 global $TBE_TEMPLATE,$LANG;
00308
00309 $out=array();
00310 $elCount = count($this->elFromTable($this->fileMode?'_FILE':''));
00311
00312
00313 $out[]='
00314 <tr class="t3-row-header">
00315 <td colspan="3" nowrap="nowrap" align="center"><strong>' . $this->clLabel('clipboard', 'buttons') . '</strong></td>
00316 </tr>';
00317
00318
00319 $thumb_url = t3lib_div::linkThisScript(array('CB'=>array('setThumb'=>$this->clipData['_setThumb']?0:1)));
00320 $rmall_url = t3lib_div::linkThisScript(array('CB'=>array('removeAll'=>$this->current)));
00321
00322
00323 $copymode_url = t3lib_div::linkThisScript();
00324 $moveLabel = htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.php:moveElements'));
00325 $copyLabel = htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.php:copyElements'));
00326 $opt=array();
00327 $opt[]='<option style="padding-left: 20px; background-image: url(\''.t3lib_iconWorks::skinImg($this->backPath, 'gfx/clip_cut.gif', '', 1).'\'); background-repeat: no-repeat;" value="" '.(($this->currentMode()=='copy')?'':'selected="selected"').'>'.$moveLabel .'</option>';
00328 $opt[]='<option style="padding-left: 20px; background-image: url(\''.t3lib_iconWorks::skinImg($this->backPath, 'gfx/clip_copy.gif', '', 1).'\'); background-repeat: no-repeat;" value="1" '.(($this->currentMode()=='copy')?'selected="selected"':'').'>'.$copyLabel .'</option>';
00329
00330 $copymode_selector = ' <select name="CB[setCopyMode]" onchange="this.form.method=\'POST\'; this.form.action=\''.htmlspecialchars($copymode_url.'&CB[setCopyMode]=').'\'+(this.options[this.selectedIndex].value); this.form.submit(); return true;" >'.implode('',$opt).'</select>';
00331
00332
00333 $opt=array();
00334 $opt[]='<option value="" selected="selected">'.$this->clLabel('menu','rm').'</option>';
00335
00336 if ($elCount && t3lib_extMgm::isLoaded('impexp')) {
00337 $opt[] = '<option value="'.htmlspecialchars("window.location.href='".$this->backPath.t3lib_extMgm::extRelPath('impexp').'app/index.php'.$this->exportClipElementParameters().'\';').'">'.$this->clLabel('export','rm').'</option>';
00338 }
00339
00340 if (!$this->fileMode && $elCount) {
00341 $opt[]='<option value="' . htmlspecialchars("window.location.href='" . $this->editUrl() . "&returnUrl='+top.rawurlencode(window.location.href);") . '">' . $this->clLabel('edit', 'rm') . '</option>';
00342 }
00343
00344 if ($elCount) {
00345 if($GLOBALS['BE_USER']->jsConfirmation(4)) {
00346 $js = "
00347 if(confirm(".$GLOBALS['LANG']->JScharCode(sprintf($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.deleteClip'),$elCount)).")){
00348 window.location.href='" . $this->deleteUrl(0, $this->fileMode ? 1 : 0) . "&redirect='+top.rawurlencode(window.location.href);
00349 }
00350 ";
00351 } else {
00352 $js = " window.location.href='" . $this->deleteUrl(0, $this->fileMode ? 1 : 0) . "&redirect='+top.rawurlencode(window.location.href); ";
00353 }
00354 $opt[]='<option value="'.htmlspecialchars($js).'">'.$this->clLabel('delete','rm').'</option>';
00355 }
00356 $selector_menu = '<select name="_clipMenu" onchange="eval(this.options[this.selectedIndex].value);this.selectedIndex=0;">'.implode('',$opt).'</select>';
00357
00358 $out[]='
00359 <tr class="typo3-clipboard-head">
00360 <td nowrap="nowrap">'.
00361 '<a href="'.htmlspecialchars($thumb_url).'#clip_head">'.
00362 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/thumb_'.($this->clipData['_setThumb']?'s':'n').'.gif','width="21" height="16"').' vspace="2" border="0" title="'.$this->clLabel('thumbmode_clip').'" alt="" />'.
00363 '</a>'.
00364 '</td>
00365 <td width="95%" nowrap="nowrap">'.
00366 $copymode_selector.' '.
00367 $selector_menu.
00368 '</td>
00369 <td>'.
00370 '<a href="'.htmlspecialchars($rmall_url).'#clip_head">'.
00371 t3lib_iconWorks::getSpriteIcon('actions-document-close', array('title' => $LANG->sL('LLL:EXT:lang/locallang_core.php:buttons.clear', TRUE))) .
00372 '</a></td>
00373 </tr>';
00374
00375
00376
00377 $out[]='
00378 <tr class="bgColor5">
00379 <td colspan="3"><a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('CB'=>array('setP'=>'normal')))).'#clip_head">'.
00380 t3lib_iconWorks::getSpriteIcon('actions-view-table-' . (($this->current == 'normal') ? 'collapse' : 'expand')) .
00381 $this->padTitleWrap('Normal','normal').
00382 '</a></td>
00383 </tr>';
00384 if ($this->current=='normal') $out=array_merge($out,$this->printContentFromTab('normal'));
00385
00386
00387 for ($a=1;$a<=$this->numberTabs;$a++) {
00388 $out[]='
00389 <tr class="bgColor5">
00390 <td colspan="3"><a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('CB'=>array('setP'=>'tab_'.$a)))).'#clip_head">'.
00391 t3lib_iconWorks::getSpriteIcon('actions-view-table-' . (($this->current == 'tab_' . $a) ? 'collapse' : 'expand')) .
00392 $this->padTitleWrap($this->clLabel('cliptabs').$a,'tab_'.$a).
00393 '</a></td>
00394 </tr>';
00395 if ($this->current=='tab_'.$a) $out=array_merge($out,$this->printContentFromTab('tab_'.$a));
00396 }
00397
00398
00399 $output = '<a name="clip_head"></a>
00400
00401 <!--
00402 TYPO3 Clipboard:
00403 -->
00404 <table cellpadding="0" cellspacing="1" border="0" width="290" id="typo3-clipboard">
00405 '.implode('',$out).'
00406 </table>';
00407
00408
00409 $output = '<form action="">'.$output.'</form>';
00410
00411
00412 return $output;
00413 }
00414
00415
00416
00417
00418
00419
00420
00421
00422 function printContentFromTab($pad) {
00423 global $TBE_TEMPLATE;
00424
00425 $lines=array();
00426 if (is_array($this->clipData[$pad]['el'])) {
00427 foreach ($this->clipData[$pad]['el'] as $k => $v) {
00428 if ($v) {
00429 list($table,$uid) = explode('|',$k);
00430 $bgColClass = ($table=='_FILE'&&$this->fileMode)||($table!='_FILE'&&!$this->fileMode) ? 'bgColor4-20' : 'bgColor4';
00431
00432 if ($table=='_FILE') {
00433 if (file_exists($v) && t3lib_div::isAllowedAbsPath($v)) {
00434 $fI = pathinfo($v);
00435 $icon = is_dir($v) ? 'folder.gif' : t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
00436 $size = ' ('.t3lib_div::formatSize(filesize($v)).'bytes)';
00437 $icon = t3lib_iconWorks::getSpriteIconForFile(is_dir($v) ? 'folder' : strtolower($fI['extension']), array('style' => 'margin: 0 20px;', 'title' => htmlspecialchars($fI['basename'] . $size)));
00438 $thumb = $this->clipData['_setThumb'] ? (t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],$fI['extension']) ? t3lib_BEfunc::getThumbNail($this->backPath.'thumbs.php',$v,' vspace="4"') : '') :'';
00439
00440 $lines[]='
00441 <tr>
00442 <td class="'.$bgColClass.'">'.$icon.'</td>
00443 <td class="'.$bgColClass.'" nowrap="nowrap" width="95%"> '.$this->linkItemText(htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($v),$GLOBALS['BE_USER']->uc['titleLen'])),$v).
00444 ($pad=='normal'?(' <strong>('.($this->clipData['normal']['mode']=='copy'?$this->clLabel('copy','cm'):$this->clLabel('cut','cm')).')</strong>'):'').' '.($thumb?'<br />'.$thumb:'').'</td>
00445 <td class="'.$bgColClass.'" align="center" nowrap="nowrap">'.
00446 '<a href="#" onclick="' . htmlspecialchars('top.launchView(\'' . $v . '\', \'\'); return false;') . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-info', array('title' => $this->clLabel('info', 'cm'))) . '</a>'.
00447 '<a href="' . htmlspecialchars($this->removeUrl('_FILE', t3lib_div::shortmd5($v))) . '#clip_head">' . t3lib_iconWorks::getSpriteIcon('actions-selection-delete', array('title' => $this->clLabel('removeItem'))) . '</a>'.
00448 '</td>
00449 </tr>';
00450 } else {
00451
00452 unset($this->clipData[$pad]['el'][$k]);
00453 $this->changed=1;
00454 }
00455 } else {
00456 $rec=t3lib_BEfunc::getRecordWSOL($table,$uid);
00457 if (is_array($rec)) {
00458 $lines[]='
00459 <tr>
00460 <td class="' . $bgColClass . '">' . $this->linkItemText(t3lib_iconWorks::getSpriteIconForRecord($table, $rec, array('style' => 'margin: 0 20px;', 'title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($rec, $table)))), $rec, $table) . '</td>
00461 <td class="'.$bgColClass.'" nowrap="nowrap" width="95%"> '.$this->linkItemText(htmlspecialchars(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$rec),$GLOBALS['BE_USER']->uc['titleLen'])),$rec,$table).
00462 ($pad=='normal'?(' <strong>('.($this->clipData['normal']['mode']=='copy'?$this->clLabel('copy','cm'):$this->clLabel('cut','cm')).')</strong>'):'').' </td>
00463 <td class="'.$bgColClass.'" align="center" nowrap="nowrap">'.
00464 '<a href="#" onclick="' . htmlspecialchars('top.launchView(\'' . $table . '\', \'' . intval($uid) . '\'); return false;') . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-info', array('title' => $this->clLabel('info','cm'))) . '</a>'.
00465 '<a href="' . htmlspecialchars($this->removeUrl($table, $uid)) . '#clip_head">' . t3lib_iconWorks::getSpriteIcon('actions-selection-delete', array('title' => $this->clLabel('removeItem'))) . '</a>'.
00466 '</td>
00467 </tr>';
00468
00469 $localizationData = $this->getLocalizations($table, $rec, $bgColClass, $pad);
00470 if ($localizationData) {
00471 $lines[] = $localizationData;
00472 }
00473
00474 } else {
00475 unset($this->clipData[$pad]['el'][$k]);
00476 $this->changed=1;
00477 }
00478 }
00479 }
00480 }
00481 }
00482 if (!count($lines)) {
00483 $lines[]='
00484 <tr>
00485 <td class="bgColor4"><img src="clear.gif" width="56" height="1" alt="" /></td>
00486 <td colspan="2" class="bgColor4" nowrap="nowrap" width="95%"> <em>('.$this->clLabel('clipNoEl').')</em> </td>
00487 </tr>';
00488 }
00489
00490 $this->endClipboard();
00491 return $lines;
00492 }
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502 function getLocalizations($table, $parentRec, $bgColClass, $pad) {
00503 $lines = array();
00504 $tcaCtrl = $GLOBALS['TCA'][$table]['ctrl'];
00505
00506 if ($table != 'pages' && t3lib_BEfunc::isTableLocalizable($table) && !$tcaCtrl['transOrigPointerTable']) {
00507 $where = array();
00508 $where[] = $tcaCtrl['transOrigPointerField'] . '=' . intval($parentRec['uid']);
00509 $where[] = $tcaCtrl['languageField'] . '!=0';
00510
00511 if (isset($tcaCtrl['delete']) && $tcaCtrl['delete']) {
00512 $where[] = $tcaCtrl['delete'] . '=0';
00513 }
00514
00515 if (isset($tcaCtrl['versioningWS']) && $tcaCtrl['versioningWS']) {
00516 $where[] = 't3ver_wsid=' . $parentRec['t3ver_wsid'];
00517 }
00518
00519 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $table, implode(' AND ', $where));
00520
00521 if (is_array($rows)) {
00522 $modeData = '';
00523 if ($pad == 'normal') {
00524 $mode = ($this->clipData['normal']['mode'] == 'copy' ? 'copy' : 'cut');
00525 $modeData = ' <strong>(' . $this->clLabel($mode, 'cm') . ')</strong>';
00526 }
00527
00528 foreach ($rows as $rec) {
00529 $lines[]='
00530 <tr>
00531 <td class="' . $bgColClass . '">' .
00532 t3lib_iconWorks::getSpriteIconForRecord($table, $rec, array('style' => "margin-left: 38px;")) . '</td>
00533 <td class="' . $bgColClass . '" nowrap="nowrap" width="95%"> ' . htmlspecialchars(
00534 t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table, $rec), $GLOBALS['BE_USER']->uc['titleLen'])) .
00535 $modeData . ' </td>
00536 <td class="' . $bgColClass . '" align="center" nowrap="nowrap"> </td>
00537 </tr>';
00538 }
00539 }
00540 }
00541 return implode('',$lines);
00542 }
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553 function padTitleWrap($str,$pad) {
00554 $el = count($this->elFromTable($this->fileMode?'_FILE':'',$pad));
00555 if ($el) {
00556 return '<strong>'.$str.'</strong> ('.($pad=='normal'?($this->clipData['normal']['mode']=='copy'?$this->clLabel('copy','cm'):$this->clLabel('cut','cm')):htmlspecialchars($el)).')';
00557 } else {
00558 return $GLOBALS['TBE_TEMPLATE']->dfw($str);
00559 }
00560 }
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570 function linkItemText($str,$rec,$table='') {
00571 if (is_array($rec) && $table) {
00572 if ($this->fileMode) {
00573 $str=$GLOBALS['TBE_TEMPLATE']->dfw($str);
00574 } else {
00575 if (t3lib_extMgm::isLoaded('list')) {
00576 $str = '<a href="' . htmlspecialchars(
00577 $this->backPath . t3lib_extMgm::extRelPath('list') . 'mod1/db_list.php?id=' . $rec['pid']
00578 ) . '">' . $str . '</a>';
00579 }
00580 }
00581 } elseif (file_exists($rec)) {
00582 if (!$this->fileMode) {
00583 $str=$GLOBALS['TBE_TEMPLATE']->dfw($str);
00584 } else {
00585 if (t3lib_extMgm::isLoaded('filelist')) {
00586 $str = '<a href="' . htmlspecialchars(
00587 $this->backPath . t3lib_extMgm::extRelPath('filelist') . 'mod1/file_list.php?id=' . dirname($rec)
00588 ) . '">' . $str . '</a>';
00589 }
00590 }
00591 }
00592 return $str;
00593 }
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605 function selUrlDB($table,$uid,$copy=0,$deselect=0,$baseArray=array()) {
00606 $CB = array('el'=>array(rawurlencode($table.'|'.$uid)=>$deselect?0:1));
00607 if ($copy) $CB['setCopyMode'] = 1;
00608 $baseArray['CB'] = $CB;
00609 return t3lib_div::linkThisScript($baseArray);
00610 }
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621 function selUrlFile($path,$copy=0,$deselect=0,$baseArray=array()) {
00622 $CB=array('el'=>array(rawurlencode('_FILE|'.t3lib_div::shortmd5($path))=>$deselect?'':$path));
00623 if ($copy) $CB['setCopyMode']=1;
00624 $baseArray['CB']=$CB;
00625 return t3lib_div::linkThisScript($baseArray);
00626 }
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638 function pasteUrl($table,$uid,$setRedirect=1) {
00639 $rU = $this->backPath.($table=='_FILE'?'tce_file.php':'tce_db.php').'?'.
00640 ($setRedirect ? 'redirect='.rawurlencode(t3lib_div::linkThisScript(array('CB'=>''))) : '').
00641 '&vC='.$GLOBALS['BE_USER']->veriCode().
00642 '&prErr=1&uPT=1'.
00643 '&CB[paste]='.rawurlencode($table.'|'.$uid).
00644 '&CB[pad]='.$this->current;
00645 return $rU;
00646 }
00647
00648
00649
00650
00651
00652
00653
00654
00655 function deleteUrl($setRedirect=1,$file=0) {
00656 $rU = $this->backPath.($file?'tce_file.php':'tce_db.php').'?'.
00657 ($setRedirect ? 'redirect='.rawurlencode(t3lib_div::linkThisScript(array('CB'=>''))) : '').
00658 '&vC='.$GLOBALS['BE_USER']->veriCode().
00659 '&prErr=1&uPT=1'.
00660 '&CB[delete]=1'.
00661 '&CB[pad]='.$this->current;
00662 return $rU;
00663 }
00664
00665
00666
00667
00668
00669
00670
00671
00672 function editUrl() {
00673 $elements = $this->elFromTable('');
00674 $editCMDArray=array();
00675 foreach ($elements as $tP => $value) {
00676 list($table,$uid) = explode('|',$tP);
00677 $editCMDArray[] = '&edit['.$table.']['.$uid.']=edit';
00678 }
00679
00680 $rU = $this->backPath.'alt_doc.php?'.implode('',$editCMDArray);
00681 return $rU;
00682 }
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692 function removeUrl($table,$uid) {
00693 return t3lib_div::linkThisScript(array('CB'=>array('remove'=>$table.'|'.$uid)));
00694 }
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705 function confirmMsg($table,$rec,$type,$clElements) {
00706 if($GLOBALS['BE_USER']->jsConfirmation(2)) {
00707 $labelKey = 'LLL:EXT:lang/locallang_core.php:mess.'.($this->currentMode()=='copy'?'copy':'move').($this->current=='normal'?'':'cb').'_'.$type;
00708 $msg = $GLOBALS['LANG']->sL($labelKey);
00709
00710 if ($table=='_FILE') {
00711 $thisRecTitle = basename($rec);
00712 if ($this->current=='normal') {
00713 reset($clElements);
00714 $selItem = current($clElements);
00715 $selRecTitle = basename($selItem);
00716 } else {
00717 $selRecTitle=count($clElements);
00718 }
00719 } else {
00720 $thisRecTitle = (
00721 $table=='pages' && !is_array($rec) ?
00722 $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] :
00723 t3lib_BEfunc::getRecordTitle($table,$rec)
00724 );
00725
00726 if ($this->current=='normal') {
00727 $selItem = $this->getSelectedRecord();
00728 $selRecTitle=$selItem['_RECORD_TITLE'];
00729 } else {
00730 $selRecTitle=count($clElements);
00731 }
00732 }
00733
00734
00735 $conf='confirm('.$GLOBALS['LANG']->JScharCode(sprintf(
00736 $msg,
00737 t3lib_div::fixed_lgd_cs($selRecTitle,30),
00738 t3lib_div::fixed_lgd_cs($thisRecTitle,30)
00739 )).')';
00740 } else {
00741 $conf = '';
00742 }
00743 return $conf;
00744 }
00745
00746
00747
00748
00749
00750
00751
00752
00753 function clLabel($key,$Akey='labels') {
00754 return htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:'.$Akey.'.'.$key));
00755 }
00756
00757
00758
00759
00760
00761
00762 function exportClipElementParameters() {
00763
00764
00765 $pad = $this->current;
00766 $params = array();
00767 $params[] = 'tx_impexp[action]=export';
00768
00769
00770 if (is_array($this->clipData[$pad]['el'])) {
00771 foreach ($this->clipData[$pad]['el'] as $k => $v) {
00772 if ($v) {
00773 list($table,$uid) = explode('|',$k);
00774
00775 if ($table=='_FILE') {
00776 if (file_exists($v) && t3lib_div::isAllowedAbsPath($v)) {
00777 $params[] = 'tx_impexp['.(is_dir($v) ? 'dir' : 'file').'][]='.rawurlencode($v);
00778 }
00779 } else {
00780 $rec = t3lib_BEfunc::getRecord($table,$uid);
00781 if (is_array($rec)) {
00782 $params[] = 'tx_impexp[record][]='.rawurlencode($table.':'.$uid);
00783 }
00784 }
00785 }
00786 }
00787 }
00788
00789 return '?'.implode('&', $params);
00790 }
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811 function removeElement($el) {
00812 unset($this->clipData[$this->current]['el'][$el]);
00813 $this->changed=1;
00814 }
00815
00816
00817
00818
00819
00820
00821
00822
00823 function saveClipboard() {
00824 global $BE_USER;
00825 $BE_USER->pushModuleData('clipboard',$this->clipData);
00826 }
00827
00828
00829
00830
00831
00832
00833 function currentMode() {
00834 return $this->clipData[$this->current]['mode']=='copy' ? 'copy' : 'cut';
00835 }
00836
00837
00838
00839
00840
00841
00842
00843 function cleanCurrent() {
00844 if (is_array($this->clipData[$this->current]['el'])) {
00845 foreach ($this->clipData[$this->current]['el'] as $k => $v) {
00846 list($table,$uid) = explode('|',$k);
00847 if ($table!='_FILE') {
00848 if (!$v || !is_array(t3lib_BEfunc::getRecord($table,$uid,'uid'))) {
00849 unset($this->clipData[$this->current]['el'][$k]);
00850 $this->changed=1;
00851 }
00852 } else {
00853 if (!$v || !file_exists($v)) {
00854 unset($this->clipData[$this->current]['el'][$k]);
00855 $this->changed=1;
00856 }
00857 }
00858 }
00859 }
00860 }
00861
00862
00863
00864
00865
00866
00867
00868
00869 function elFromTable($matchTable='',$pad='') {
00870 $pad = $pad ? $pad : $this->current;
00871 $list=array();
00872 if (is_array($this->clipData[$pad]['el'])) {
00873 foreach ($this->clipData[$pad]['el'] as $k => $v) {
00874 if ($v) {
00875 list($table,$uid) = explode('|',$k);
00876 if ($table!='_FILE') {
00877 if ((!$matchTable || (string)$table==(string)$matchTable) && $GLOBALS['TCA'][$table]) {
00878 $list[$k]= ($pad=='normal'?$v:$uid);
00879 }
00880 } else {
00881 if ((string)$table==(string)$matchTable) {
00882 $list[$k]=$v;
00883 }
00884 }
00885 }
00886 }
00887 }
00888 return $list;
00889 }
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899 function isSelected($table,$uid) {
00900 $k=$table.'|'.$uid;
00901 return $this->clipData[$this->current]['el'][$k] ? ($this->current=='normal'?$this->currentMode():1) : '';
00902 }
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913 function getSelectedRecord($table='',$uid='') {
00914 if (!$table && !$uid) {
00915 $elArr = $this->elFromTable('');
00916 reset($elArr);
00917 list($table,$uid) = explode('|',key($elArr));
00918 }
00919 if ($this->isSelected($table,$uid)) {
00920 $selRec = t3lib_BEfunc::getRecordWSOL($table,$uid);
00921 $selRec['_RECORD_TITLE'] = t3lib_BEfunc::getRecordTitle($table,$selRec);
00922 return $selRec;
00923 }
00924 }
00925
00926
00927
00928
00929
00930
00931 function isElements() {
00932 return is_array($this->clipData[$this->current]['el']) && count($this->clipData[$this->current]['el']);
00933 }
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972 function makePasteCmdArray($ref,$CMD) {
00973 list($pTable,$pUid) = explode('|',$ref);
00974 $pUid = intval($pUid);
00975
00976 if ($pTable || $pUid>=0) {
00977 $elements = $this->elFromTable($pTable);
00978
00979 $elements = array_reverse($elements);
00980 $mode = $this->currentMode()=='copy' ? 'copy' : 'move';
00981
00982
00983 foreach ($elements as $tP => $value) {
00984 list($table,$uid) = explode('|',$tP);
00985 if (!is_array($CMD[$table])) $CMD[$table]=array();
00986 $CMD[$table][$uid][$mode]=$pUid;
00987 if ($mode=='move') $this->removeElement($tP);
00988 }
00989 $this->endClipboard();
00990 }
00991 return $CMD;
00992 }
00993
00994
00995
00996
00997
00998
00999
01000 function makeDeleteCmdArray($CMD) {
01001 $elements = $this->elFromTable('');
01002 foreach ($elements as $tP => $value) {
01003 list($table,$uid) = explode('|',$tP);
01004 if (!is_array($CMD[$table])) $CMD[$table]=array();
01005 $CMD[$table][$uid]['delete']=1;
01006 $this->removeElement($tP);
01007 }
01008 $this->endClipboard();
01009 return $CMD;
01010 }
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042 function makePasteCmdArray_file($ref,$FILE) {
01043 list($pTable,$pUid) = explode('|',$ref);
01044 $elements = $this->elFromTable('_FILE');
01045 $mode = $this->currentMode()=='copy' ? 'copy' : 'move';
01046
01047
01048 foreach ($elements as $tP => $path) {
01049 $FILE[$mode][]=array('data'=>$path,'target'=>$pUid,'altName'=>1);
01050 if ($mode=='move') $this->removeElement($tP);
01051 }
01052 $this->endClipboard();
01053
01054 return $FILE;
01055 }
01056
01057
01058
01059
01060
01061
01062
01063 function makeDeleteCmdArray_file($FILE) {
01064 $elements = $this->elFromTable('_FILE');
01065
01066 foreach ($elements as $tP => $path) {
01067 $FILE['delete'][]=array('data'=>$path);
01068 $this->removeElement($tP);
01069 }
01070 $this->endClipboard();
01071
01072 return $FILE;
01073 }
01074 }
01075
01076
01077
01078 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_clipboard.php']) {
01079 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_clipboard.php']);
01080 }
01081
01082 ?>