Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00090 class t3lib_clipboard { 00091 var $numberTabs = 3; 00092 00112 var $clipData=array(); 00113 00114 var $changed=0; 00115 var $current=''; 00116 var $backPath=''; 00117 var $lockToNormal=0; 00118 var $fileMode=0; // If set, clipboard is displaying files. 00119 00120 00126 function initializeClipboard() { 00127 global $BE_USER; 00128 00129 // Get data 00130 $clipData = $BE_USER->getModuleData('clipboard',$BE_USER->getTSConfigVal('options.saveClipboard')?'':'ses'); 00131 00132 // NumberTabs 00133 $clNP = $BE_USER->getTSConfigVal('options.clipboardNumberPads'); 00134 if (t3lib_div::testInt($clNP) && $clNP>=0) { 00135 $this->numberTabs = t3lib_div::intInRange($clNP,0,20); 00136 } 00137 00138 // Resets/reinstates the clipboard pads 00139 $this->clipData['normal'] = is_array($clipData['normal']) ? $clipData['normal'] : array(); 00140 for ($a=1;$a<=$this->numberTabs;$a++) { 00141 $this->clipData['tab_'.$a] = is_array($clipData['tab_'.$a]) ? $clipData['tab_'.$a] : array(); 00142 } 00143 00144 // Setting the current pad pointer ($this->current) and _setThumb (which determines whether or not do show file thumbnails) 00145 $this->clipData['current'] = $this->current = isset($this->clipData[$clipData['current']]) ? $clipData['current'] : 'normal'; 00146 $this->clipData['_setThumb'] = $clipData['_setThumb']; 00147 } 00148 00155 function lockToNormal() { 00156 $this->lockToNormal=1; 00157 $this->current='normal'; 00158 } 00159 00172 function setCmd($cmd) { 00173 if (is_array($cmd['el'])) { 00174 reset($cmd['el']); 00175 while(list($k,$v)=each($cmd['el'])) { 00176 if ($this->current=='normal') { 00177 unset($this->clipData['normal']); 00178 } 00179 if ($v) { 00180 $this->clipData[$this->current]['el'][$k]=$v; 00181 } else { 00182 $this->removeElement($k); 00183 } 00184 $this->changed=1; 00185 } 00186 } 00187 // Change clipboard pad (if not locked to normal) 00188 if ($cmd['setP']) { 00189 $this->setCurrentPad($cmd['setP']); 00190 } 00191 // Remove element (value = item ident: DB; '[tablename]|[uid]' FILE: '_FILE|[shortmd5 hash of path]' 00192 if ($cmd['remove']) { 00193 $this->removeElement($cmd['remove']); 00194 $this->changed=1; 00195 } 00196 // Remove all on current pad (value = pad-ident) 00197 if ($cmd['removeAll']) { 00198 $this->clipData[$cmd['removeAll']]=array(); 00199 $this->changed=1; 00200 } 00201 // Set copy mode of the tab 00202 if (isset($cmd['setCopyMode'])) { 00203 $this->clipData[$this->current]['mode']=$this->isElements()?($cmd['setCopyMode']?'copy':''):''; 00204 $this->changed=1; 00205 } 00206 // Toggle thumbnail display for files on/off 00207 if (isset($cmd['setThumb'])) { 00208 $this->clipData['_setThumb']=$cmd['setThumb']; 00209 $this->changed=1; 00210 } 00211 } 00212 00219 function setCurrentPad($padIdent) { 00220 // Change clipboard pad (if not locked to normal) 00221 if (!$this->lockToNormal && $this->current!=$padIdent) { 00222 if (isset($this->clipData[$padIdent])) $this->clipData['current'] = $this->current = $padIdent; 00223 if ($this->current!='normal' || !$this->isElements()) $this->clipData[$this->current]['mode']=''; // Setting mode to default (move) if no items on it or if not 'normal' 00224 $this->changed=1; 00225 } 00226 } 00227 00234 function endClipboard() { 00235 if ($this->changed) $this->saveClipboard(); 00236 $this->changed=0; 00237 } 00238 00247 function cleanUpCBC($CBarr,$table,$removeDeselected=0) { 00248 if (is_array($CBarr)) { 00249 reset($CBarr); 00250 while(list($k,$v)=each($CBarr)) { 00251 $p=explode('|',$k); 00252 if ((string)$p[0]!=(string)$table || ($removeDeselected && !$v)) { 00253 unset($CBarr[$k]); 00254 } 00255 } 00256 } 00257 return $CBarr; 00258 } 00259 00265 function isElements() { 00266 return is_array($this->clipData[$this->current]['el']) && count($this->clipData[$this->current]['el']); 00267 } 00268 00274 function printClipboard() { 00275 global $TBE_TEMPLATE,$LANG; 00276 00277 $out=array(); 00278 $elCount = count($this->elFromTable($this->fileMode?'_FILE':'')); 00279 00280 // Upper header 00281 $out[]=' 00282 <tr class="bgColor2"> 00283 <td colspan="3" nowrap="nowrap" align="center"><span class="uppercase"><strong>'.$this->clLabel('clipboard','buttons').'</strong></span></td> 00284 </tr>'; 00285 00286 // Button/menu header: 00287 $thumb_url = t3lib_div::linkThisScript(array('CB'=>array('setThumb'=>$this->clipData['_setThumb']?0:1))); 00288 $copymode_url = t3lib_div::linkThisScript(array('CB'=>array('setCopyMode'=>($this->currentMode()=='copy'?'':'copy')))); 00289 $rmall_url = t3lib_div::linkThisScript(array('CB'=>array('removeAll'=>$this->current))); 00290 00291 // Selector menu + clear button 00292 $opt=array(); 00293 $opt[]='<option value="" selected="selected">'.$this->clLabel('menu','rm').'</option>'; 00294 if (!$this->fileMode && $elCount) $opt[]='<option value="'.htmlspecialchars("document.location='".$this->editUrl()."&returnUrl='+top.rawurlencode(document.location);").'">'.$this->clLabel('edit','rm').'</option>'; 00295 if ($elCount) $opt[]='<option value="'.htmlspecialchars(" 00296 if(confirm(".$GLOBALS['LANG']->JScharCode(sprintf($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.deleteClip'),$elCount)).")){ 00297 document.location='".$this->deleteUrl(0,$this->fileMode?1:0)."&redirect='+top.rawurlencode(document.location); 00298 } 00299 ").'">'.$this->clLabel('delete','rm').'</option>'; 00300 $selector_menu = '<select name="_clipMenu" onchange="eval(this.options[this.selectedIndex].value);this.selectedIndex=0;">'.implode('',$opt).'</select>'; 00301 00302 $out[]=' 00303 <tr class="typo3-clipboard-head"> 00304 <td>'. 00305 '<a href="'.htmlspecialchars($thumb_url).'#clip_head">'. 00306 '<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="" />'. 00307 '</a>'. 00308 '<a href="'.htmlspecialchars($copymode_url).'#clip_head">'. 00309 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/copymode_'.($this->currentMode()=='copy'?'s':'n').'.gif','width="21" height="16"').' vspace="2" border="0" title="'.$this->clLabel('copymode').'" alt="" />'. 00310 '</a>'. 00311 '</td> 00312 <td width="95%">'.$selector_menu.'</td> 00313 <td><a href="'.htmlspecialchars($rmall_url).'#clip_head">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:buttons.clear',1).'</a></td> 00314 </tr>'; 00315 00316 00317 // Print header and content for the NORMAL tab: 00318 $out[]=' 00319 <tr class="bgColor5"> 00320 <td colspan="3"><a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('CB'=>array('setP'=>'normal')))).'#clip_head">'. 00321 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($this->current=='normal'?'minus':'plus').'bullet.gif','width="18" height="16"').' border="0" align="top" alt="" />'. 00322 $this->padTitleWrap('Normal','normal'). 00323 '</a></td> 00324 </tr>'; 00325 if ($this->current=='normal') $out=array_merge($out,$this->printContentFromTab('normal')); 00326 00327 // Print header and content for the NUMERIC tabs: 00328 for ($a=1;$a<=$this->numberTabs;$a++) { 00329 $out[]=' 00330 <tr class="bgColor5"> 00331 <td colspan="3"><a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('CB'=>array('setP'=>'tab_'.$a)))).'#clip_head">'. 00332 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($this->current=='tab_'.$a?'minus':'plus').'bullet.gif','width="18" height="16"').' border="0" align="top" alt="" />'. 00333 $this->padTitleWrap($this->clLabel('cliptabs').$a,'tab_'.$a). 00334 '</a></td> 00335 </tr>'; 00336 if ($this->current=='tab_'.$a) $out=array_merge($out,$this->printContentFromTab('tab_'.$a)); 00337 } 00338 00339 // Wrap accumulated rows in a table: 00340 $output = '<a name="clip_head"></a> 00341 00342 <!-- 00343 TYPO3 Clipboard: 00344 --> 00345 <table cellpadding="0" cellspacing="1" border="0" width="290" id="typo3-clipboard"> 00346 '.implode('',$out).' 00347 </table>'; 00348 00349 // Wrap in form tag: 00350 $output = '<form action="">'.$output.'</form>'; 00351 00352 // Return the accumulated content: 00353 return $output; 00354 } 00355 00363 function printContentFromTab($pad) { 00364 global $TBE_TEMPLATE; 00365 00366 $lines=array(); 00367 if (is_array($this->clipData[$pad]['el'])) { 00368 reset($this->clipData[$pad]['el']); 00369 while(list($k,$v)=each($this->clipData[$pad]['el'])) { 00370 if ($v) { 00371 list($table,$uid) = explode('|',$k); 00372 $bgColClass = ($table=='_FILE'&&$this->fileMode)||($table!='_FILE'&&!$this->fileMode) ? 'bgColor4-20' : 'bgColor4'; 00373 00374 if ($table=='_FILE') { // Rendering files/directories on the clipboard: 00375 if (@file_exists($v) && t3lib_div::isAllowedAbsPath($v)) { 00376 $fI = pathinfo($v); 00377 $icon = is_dir($v) ? 'folder.gif' : t3lib_BEfunc::getFileIcon(strtolower($fI['extension'])); 00378 $size = ' ('.t3lib_div::formatSize(filesize($v)).'bytes)'; 00379 $icon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/fileicons/'.$icon,'width="18" height="16"').' border="0" hspace="20" class="absmiddle" title="'.htmlspecialchars($fI['basename'].$size).'" alt="" />'; 00380 $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"') : '') :''; 00381 00382 $lines[]=' 00383 <tr> 00384 <td class="'.$bgColClass.'">'.$icon.'</td> 00385 <td class="'.$bgColClass.'" nowrap="nowrap" width="95%"> '.$this->linkItemText(htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($v),$GLOBALS['BE_USER']->uc['titleLen'])),$v). 00386 ($pad=='normal'?(' <strong>('.($this->clipData['normal']['mode']=='copy'?$this->clLabel('copy','cm'):$this->clLabel('cut','cm')).')</strong>'):'').' '.($thumb?'<br />'.$thumb:'').'</td> 00387 <td class="'.$bgColClass.'" align="center">'. 00388 '<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$v.'\', \'\'); return false;').'"><img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom2.gif','width="12" height="12"').' hspace="2" border="0" title="'.$this->clLabel('info','cm').'" alt="" /></a>'. 00389 '<a href="'.htmlspecialchars($this->removeUrl('_FILE',t3lib_div::shortmd5($v))).'#clip_head"><img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/close_12h.gif','width="11" height="12"').' border="0" title="'.$this->clLabel('removeItem').'" alt="" /></a>'. 00390 '</td> 00391 </tr>'; 00392 } else { 00393 // If the file did not exist (or is illegal) then it is removed from the clipboard immediately: 00394 unset($this->clipData[$pad]['el'][$k]); 00395 $this->changed=1; 00396 } 00397 } else { // Rendering records: 00398 $rec=t3lib_BEfunc::getRecord($table,$uid); 00399 if (is_array($rec)) { 00400 $lines[]=' 00401 <tr> 00402 <td class="'.$bgColClass.'">'.$this->linkItemText(t3lib_iconWorks::getIconImage($table,$rec,$this->backPath,'hspace="20" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($rec,$table)).'"'),$rec,$table).'</td> 00403 <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). 00404 ($pad=='normal'?(' <strong>('.($this->clipData['normal']['mode']=='copy'?$this->clLabel('copy','cm'):$this->clLabel('cut','cm')).')</strong>'):'').' </td> 00405 <td class="'.$bgColClass.'" align="center">'. 00406 '<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.intval($uid).'\'); return false;').'"><img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom2.gif','width="12" height="12"').' hspace="2" border="0" title="'.$this->clLabel('info','cm').'" alt="" /></a>'. 00407 '<a href="'.htmlspecialchars($this->removeUrl($table,$uid)).'#clip_head"><img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/close_12h.gif','width="11" height="12"').' border="0" title="'.$this->clLabel('removeItem').'" alt="" /></a>'. 00408 '</td> 00409 </tr>'; 00410 } else { 00411 unset($this->clipData[$pad]['el'][$k]); 00412 $this->changed=1; 00413 } 00414 } 00415 } 00416 } 00417 } 00418 if (!count($lines)) { 00419 $lines[]=' 00420 <tr> 00421 <td class="bgColor4"><img src="clear.gif" width="56" height="1" alt="" /></td> 00422 <td colspan="2" class="bgColor4" nowrap="nowrap" width="95%"> <em>('.$this->clLabel('clipNoEl').')</em> </td> 00423 </tr>'; 00424 } 00425 00426 $this->endClipboard(); 00427 return $lines; 00428 } 00429 00437 function padTitleWrap($str,$pad) { 00438 $el = count($this->elFromTable($this->fileMode?'_FILE':'',$pad)); 00439 if ($el) { 00440 return '<strong>'.$str.'</strong> ('.($pad=='normal'?($this->clipData['normal']['mode']=='copy'?$this->clLabel('copy','cm'):$this->clLabel('cut','cm')):htmlspecialchars($el)).')'; 00441 } else { 00442 return $GLOBALS['TBE_TEMPLATE']->dfw($str); 00443 } 00444 } 00445 00454 function linkItemText($str,$rec,$table='') { 00455 if (is_array($rec) && $table) { 00456 if ($this->fileMode) { 00457 $str=$GLOBALS['TBE_TEMPLATE']->dfw($str); 00458 } else { 00459 $str='<a href="'.htmlspecialchars($this->backPath.'db_list.php?id='.$rec['pid']).'">'.$str.'</a>'; 00460 } 00461 } elseif (@file_exists($rec)) { 00462 if (!$this->fileMode) { 00463 $str=$GLOBALS['TBE_TEMPLATE']->dfw($str); 00464 } else { 00465 $str='<a href="'.htmlspecialchars($this->backPath.'file_list.php?id='.dirname($rec)).'">'.$str.'</a>'; 00466 } 00467 } 00468 return $str; 00469 } 00470 00479 function isSelected($table,$uid) { 00480 $k=$table.'|'.$uid; 00481 return $this->clipData[$this->current]['el'][$k] ? ($this->current=='normal'?$this->currentMode():1) : ''; 00482 } 00483 00493 function getSelectedRecord($table='',$uid='') { 00494 if (!$table && !$uid) { 00495 $elArr = $this->elFromTable(''); 00496 reset($elArr); 00497 list($table,$uid) = explode('|',key($elArr)); 00498 } 00499 if ($this->isSelected($table,$uid)) { 00500 $selRec = t3lib_BEfunc::getRecord($table,$uid); 00501 $selRec['_RECORD_TITLE'] = t3lib_BEfunc::getRecordTitle($table,$selRec); 00502 return $selRec; 00503 } 00504 } 00505 00516 function selUrlDB($table,$uid,$copy=0,$deselect=0,$baseArray=array()) { 00517 $CB = array('el'=>array(rawurlencode($table.'|'.$uid)=>$deselect?0:1)); 00518 if ($copy) $CB['setCopyMode'] = 1; 00519 $baseArray['CB'] = $CB; 00520 return t3lib_div::linkThisScript($baseArray); 00521 } 00522 00532 function selUrlFile($path,$copy=0,$deselect=0,$baseArray=array()) { 00533 $CB=array('el'=>array(rawurlencode('_FILE|'.t3lib_div::shortmd5($path))=>$deselect?'':$path)); 00534 if ($copy) $CB['setCopyMode']=1; 00535 $baseArray['CB']=$CB; 00536 return t3lib_div::linkThisScript($baseArray); 00537 } 00538 00549 function pasteUrl($table,$uid,$setRedirect=1) { 00550 $rU = $this->backPath.($table=='_FILE'?'tce_file.php':'tce_db.php').'?'. 00551 ($setRedirect ? 'redirect='.rawurlencode(t3lib_div::linkThisScript(array('CB'=>''))) : ''). 00552 '&vC='.$GLOBALS['BE_USER']->veriCode(). 00553 '&prErr=1&uPT=1'. 00554 '&CB[paste]='.rawurlencode($table.'|'.$uid). 00555 '&CB[pad]='.$this->current; 00556 return $rU; 00557 } 00558 00566 function deleteUrl($setRedirect=1,$file=0) { 00567 $rU = $this->backPath.($file?'tce_file.php':'tce_db.php').'?'. 00568 ($setRedirect ? 'redirect='.rawurlencode(t3lib_div::linkThisScript(array('CB'=>''))) : ''). 00569 '&vC='.$GLOBALS['BE_USER']->veriCode(). 00570 '&prErr=1&uPT=1'. 00571 '&CB[delete]=1'. 00572 '&CB[pad]='.$this->current; 00573 return $rU; 00574 } 00575 00583 function editUrl() { 00584 $elements = $this->elFromTable(''); // all records 00585 reset($elements); 00586 $editCMDArray=array(); 00587 while(list($tP)=each($elements)) { 00588 list($table,$uid) = explode('|',$tP); 00589 $editCMDArray[] = '&edit['.$table.']['.$uid.']=edit'; 00590 } 00591 00592 $rU = $this->backPath.'alt_doc.php?'.implode('',$editCMDArray); 00593 return $rU; 00594 } 00595 00604 function removeUrl($table,$uid) { 00605 return t3lib_div::linkThisScript(array('CB'=>array('remove'=>$table.'|'.$uid))); 00606 } 00607 00614 function cleanCurrent() { 00615 if (is_array($this->clipData[$this->current]['el'])) { 00616 reset($this->clipData[$this->current]['el']); 00617 while(list($k,$v)=each($this->clipData[$this->current]['el'])) { 00618 list($table,$uid) = explode('|',$k); 00619 if ($table!='_FILE') { 00620 if (!$v || !is_array(t3lib_BEfunc::getRecord($table,$uid,'uid'))) { 00621 unset($this->clipData[$this->current]['el'][$k]); 00622 $this->changed=1; 00623 } 00624 } else { 00625 if (!$v || !@file_exists($v)) { 00626 unset($this->clipData[$this->current]['el'][$k]); 00627 $this->changed=1; 00628 } 00629 } 00630 } 00631 } 00632 } 00633 00641 function elFromTable($matchTable='',$pad='') { 00642 $pad = $pad ? $pad : $this->current; 00643 $list=array(); 00644 if (is_array($this->clipData[$pad]['el'])) { 00645 reset($this->clipData[$pad]['el']); 00646 while(list($k,$v)=each($this->clipData[$pad]['el'])) { 00647 if ($v) { 00648 list($table,$uid) = explode('|',$k); 00649 if ($table!='_FILE') { 00650 if ((!$matchTable || (string)$table==(string)$matchTable) && $GLOBALS['TCA'][$table]) { 00651 $list[$k]= ($pad=='normal'?$v:$uid); 00652 } 00653 } else { 00654 if ((string)$table==(string)$matchTable) { 00655 $list[$k]=$v; 00656 } 00657 } 00658 } 00659 } 00660 } 00661 return $list; 00662 } 00663 00673 function confirmMsg($table,$rec,$type,$clElements) { 00674 $labelKey = 'LLL:EXT:lang/locallang_core.php:mess.'.($this->currentMode()=='copy'?'copy':'move').($this->current=='normal'?'':'cb').'_'.$type; 00675 $msg = $GLOBALS['LANG']->sL($labelKey); 00676 00677 if ($table=='_FILE') { 00678 $thisRecTitle = basename($rec); 00679 if ($this->current=='normal') { 00680 reset($clElements); 00681 $selItem = current($clElements); 00682 $selRecTitle = basename($selItem); 00683 } else { 00684 $selRecTitle=count($clElements); 00685 } 00686 } else { 00687 $thisRecTitle = ( 00688 $table=='pages' && !is_array($rec) ? 00689 $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] : 00690 t3lib_BEfunc::getRecordTitle($table,$rec) 00691 ); 00692 00693 if ($this->current=='normal') { 00694 $selItem = $this->getSelectedRecord(); 00695 $selRecTitle=$selItem['_RECORD_TITLE']; 00696 } else { 00697 $selRecTitle=count($clElements); 00698 } 00699 } 00700 00701 // Message: 00702 $conf='confirm('.$GLOBALS['LANG']->JScharCode(sprintf( 00703 $msg, 00704 t3lib_div::fixed_lgd_cs($selRecTitle,30), 00705 t3lib_div::fixed_lgd_cs($thisRecTitle,30) 00706 )).')'; 00707 return $conf; 00708 } 00709 00716 function removeElement($el) { 00717 unset($this->clipData[$this->current]['el'][$el]); 00718 $this->changed=1; 00719 } 00720 00728 function saveClipboard() { 00729 global $BE_USER; 00730 $BE_USER->pushModuleData('clipboard',$this->clipData); 00731 } 00732 00738 function currentMode() { 00739 return $this->clipData[$this->current]['mode']=='copy' ? 'copy' : 'cut'; 00740 } 00741 00749 function clLabel($key,$Akey='labels') { 00750 return htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:'.$Akey.'.'.$key)); 00751 } 00752 00753 00754 00755 00756 00757 00758 00759 00760 00761 00762 00763 00764 00765 00766 00767 /***************************************** 00768 * 00769 * FOR USE IN tce_db.php: 00770 * 00771 ****************************************/ 00772 00790 function makePasteCmdArray($ref,$CMD) { 00791 list($pTable,$pUid) = explode('|',$ref); 00792 $pUid = intval($pUid); 00793 00794 if ($pTable || $pUid>=0) { // pUid must be set and if pTable is not set (that means paste ALL elements) the uid MUST be positive/zero (pointing to page id) 00795 $elements = $this->elFromTable($pTable); 00796 00797 $elements = array_reverse($elements); // So the order is preserved. 00798 $mode = $this->currentMode()=='copy' ? 'copy' : 'move'; 00799 00800 // Traverse elements and make CMD array 00801 reset($elements); 00802 while(list($tP)=each($elements)) { 00803 list($table,$uid) = explode('|',$tP); 00804 if (!is_array($CMD[$table])) $CMD[$table]=array(); 00805 $CMD[$table][$uid][$mode]=$pUid; 00806 if ($mode=='move') $this->removeElement($tP); 00807 } 00808 $this->endClipboard(); 00809 } 00810 return $CMD; 00811 } 00812 00819 function makeDeleteCmdArray($CMD) { 00820 $elements = $this->elFromTable(''); // all records 00821 reset($elements); 00822 while(list($tP)=each($elements)) { 00823 list($table,$uid) = explode('|',$tP); 00824 if (!is_array($CMD[$table])) $CMD[$table]=array(); 00825 $CMD[$table][$uid]['delete']=1; 00826 $this->removeElement($tP); 00827 } 00828 $this->endClipboard(); 00829 return $CMD; 00830 } 00831 00832 00833 00834 00835 00836 00837 00838 00839 00840 00841 00842 00843 00844 00845 00846 00847 00848 /***************************************** 00849 * 00850 * FOR USE IN tce_file.php: 00851 * 00852 ****************************************/ 00853 00862 function makePasteCmdArray_file($ref,$FILE) { 00863 list($pTable,$pUid) = explode('|',$ref); 00864 $elements = $this->elFromTable('_FILE'); 00865 $mode = $this->currentMode()=='copy' ? 'copy' : 'move'; 00866 00867 // Traverse elements and make CMD array 00868 reset($elements); 00869 while(list($tP,$path)=each($elements)) { 00870 $FILE[$mode][]=array('data'=>$path,'target'=>$pUid); 00871 if ($mode=='move') $this->removeElement($tP); 00872 } 00873 $this->endClipboard(); 00874 00875 return $FILE; 00876 } 00877 00884 function makeDeleteCmdArray_file($FILE) { 00885 $elements = $this->elFromTable('_FILE'); 00886 // Traverse elements and make CMD array 00887 reset($elements); 00888 while(list($tP,$path)=each($elements)) { 00889 $FILE['delete'][]=array('data'=>$path); 00890 $this->removeElement($tP); 00891 } 00892 $this->endClipboard(); 00893 00894 return $FILE; 00895 } 00896 } 00897 00898 00899 00900 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_clipboard.php']) { 00901 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_clipboard.php']); 00902 } 00903 ?>