Updating version number to 4.3-dev after release of 4.3.0RC1
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_clipboard.php
old mode 100755 (executable)
new mode 100644 (file)
index 1d57aa9..b82a1c0
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
  * XHTML compliant
  *
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
  *
  *
  *
- *   90: class t3lib_clipboard
- *  126:     function initializeClipboard()
- *  155:     function lockToNormal()
- *  172:     function setCmd($cmd)
- *  219:     function setCurrentPad($padIdent)
- *  234:     function endClipboard()
- *  247:     function cleanUpCBC($CBarr,$table,$removeDeselected=0)
- *  265:     function isElements()
- *  274:     function printClipboard()
- *  363:     function printContentFromTab($pad)
- *  437:     function padTitleWrap($str,$pad)
- *  454:     function linkItemText($str,$rec,$table='')
- *  479:     function isSelected($table,$uid)
- *  493:     function getSelectedRecord($table='',$uid='')
- *  516:     function selUrlDB($table,$uid,$copy=0,$deselect=0,$baseArray=array())
- *  532:     function selUrlFile($path,$copy=0,$deselect=0,$baseArray=array())
- *  549:     function pasteUrl($table,$uid,$setRedirect=1)
- *  566:     function deleteUrl($setRedirect=1,$file=0)
- *  583:     function editUrl()
- *  604:     function removeUrl($table,$uid)
- *  614:     function cleanCurrent()
- *  641:     function elFromTable($matchTable='',$pad='')
- *  673:     function confirmMsg($table,$rec,$type,$clElements)
- *  716:     function removeElement($el)
- *  728:     function saveClipboard()
- *  738:     function currentMode()
- *  749:     function clLabel($key,$Akey='labels')
+ *   97: class t3lib_clipboard
+ *
+ *              SECTION: Initialize
+ *  150:     function initializeClipboard()
+ *  179:     function lockToNormal()
+ *  196:     function setCmd($cmd)
+ *  243:     function setCurrentPad($padIdent)
+ *  258:     function endClipboard()
+ *  271:     function cleanUpCBC($CBarr,$table,$removeDeselected=0)
+ *
+ *              SECTION: Clipboard HTML renderings
+ *  306:     function printClipboard()
+ *  413:     function printContentFromTab($pad)
+ *  487:     function padTitleWrap($str,$pad)
+ *  504:     function linkItemText($str,$rec,$table='')
+ *  531:     function selUrlDB($table,$uid,$copy=0,$deselect=0,$baseArray=array())
+ *  547:     function selUrlFile($path,$copy=0,$deselect=0,$baseArray=array())
+ *  564:     function pasteUrl($table,$uid,$setRedirect=1)
+ *  581:     function deleteUrl($setRedirect=1,$file=0)
+ *  598:     function editUrl()
+ *  619:     function removeUrl($table,$uid)
+ *  632:     function confirmMsg($table,$rec,$type,$clElements)
+ *  680:     function clLabel($key,$Akey='labels')
+ *  689:     function exportClipElementParameters()
+ *
+ *              SECTION: Helper functions
+ *  739:     function removeElement($el)
+ *  751:     function saveClipboard()
+ *  761:     function currentMode()
+ *  771:     function cleanCurrent()
+ *  798:     function elFromTable($matchTable='',$pad='')
+ *  829:     function isSelected($table,$uid)
+ *  843:     function getSelectedRecord($table='',$uid='')
+ *  861:     function isElements()
  *
  *              SECTION: FOR USE IN tce_db.php:
- *  790:     function makePasteCmdArray($ref,$CMD)
- *  819:     function makeDeleteCmdArray($CMD)
+ *  902:     function makePasteCmdArray($ref,$CMD)
+ *  931:     function makeDeleteCmdArray($CMD)
  *
  *              SECTION: FOR USE IN tce_file.php:
- *  862:     function makePasteCmdArray_file($ref,$FILE)
- *  884:     function makeDeleteCmdArray_file($FILE)
+ *  974:     function makePasteCmdArray_file($ref,$FILE)
+ *  996:     function makeDeleteCmdArray_file($FILE)
  *
- * TOTAL FUNCTIONS: 30
+ * TOTAL FUNCTIONS: 31
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
@@ -83,7 +90,7 @@
 /**
  * TYPO3 clipboard for records and files
  *
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage t3lib
  */
@@ -118,6 +125,23 @@ class t3lib_clipboard {
        var $fileMode=0;                // If set, clipboard is displaying files.
 
 
+
+
+
+
+
+
+
+
+
+
+
+       /*****************************************
+        *
+        * Initialize
+        *
+        ****************************************/
+
        /**
         * Initialize the clipboard from the be_user session
         *
@@ -153,8 +177,8 @@ class t3lib_clipboard {
         * @return      void
         */
        function lockToNormal() {
-               $this->lockToNormal=1;
-               $this->current='normal';
+               $this->lockToNormal = 1;
+               $this->current = 'normal';
        }
 
        /**
@@ -257,14 +281,22 @@ class t3lib_clipboard {
                return $CBarr;
        }
 
-       /**
-        * Reports if the current pad has elements (does not check file/DB type OR if file/DBrecord exists or not. Only counting array)
+
+
+
+
+
+
+
+
+
+
+
+       /*****************************************
         *
-        * @return      boolean         True if elements exist.
-        */
-       function isElements()   {
-               return is_array($this->clipData[$this->current]['el']) && count($this->clipData[$this->current]['el']);
-       }
+        * Clipboard HTML renderings
+        *
+        ****************************************/
 
        /**
         * Prints the clipboard
@@ -285,32 +317,59 @@ class t3lib_clipboard {
 
                        // Button/menu header:
                $thumb_url = t3lib_div::linkThisScript(array('CB'=>array('setThumb'=>$this->clipData['_setThumb']?0:1)));
-               $copymode_url = t3lib_div::linkThisScript(array('CB'=>array('setCopyMode'=>($this->currentMode()=='copy'?'':'copy'))));
                $rmall_url = t3lib_div::linkThisScript(array('CB'=>array('removeAll'=>$this->current)));
 
+                       // Copymode Selector menu
+               $copymode_url = t3lib_div::linkThisScript();
+               $moveLabel = htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.php:moveElements'));
+               $copyLabel = htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.php:copyElements'));
+               $opt=array();
+               $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>';
+               $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>';
+
+               $copymode_selector = ' <select name="CB[setCopyMode]" onchange="this.form.method=\'POST\'; this.form.action=\''.$copymode_url.'&CB[setCopyMode]=\'+(this.options[this.selectedIndex].value); this.form.submit(); return true;" >'.implode('',$opt).'</select>';
+
                        // Selector menu + clear button
                $opt=array();
                $opt[]='<option value="" selected="selected">'.$this->clLabel('menu','rm').'</option>';
-               if (!$this->fileMode && $elCount)       $opt[]='<option value="'.htmlspecialchars("document.location='".$this->editUrl()."&returnUrl='+top.rawurlencode(document.location);").'">'.$this->clLabel('edit','rm').'</option>';
-               if ($elCount)   $opt[]='<option value="'.htmlspecialchars("
+                               // Import / Export link:
+               if ($elCount && t3lib_extMgm::isLoaded('impexp'))       {
+                       $opt[] = '<option value="'.htmlspecialchars("window.location.href='".$this->backPath.'mod.php?M=xMOD_tximpexp'.$this->exportClipElementParameters().'\';').'">'.$this->clLabel('export','rm').'</option>';
+               }
+                               // Edit:
+               if (!$this->fileMode && $elCount)       {
+                       $opt[]='<option value="' . htmlspecialchars("window.location.href='" . $this->editUrl() . "&returnUrl='+top.rawurlencode(window.location.href);") . '">' . $this->clLabel('edit', 'rm') . '</option>';
+               }
+                               // Delete:
+               if ($elCount)   {
+                       if($GLOBALS['BE_USER']->jsConfirmation(4))      {
+                               $js = "
                        if(confirm(".$GLOBALS['LANG']->JScharCode(sprintf($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.deleteClip'),$elCount)).")){
-                               document.location='".$this->deleteUrl(0,$this->fileMode?1:0)."&redirect='+top.rawurlencode(document.location);
+                               window.location.href='" . $this->deleteUrl(0, $this->fileMode ? 1 : 0) . "&redirect='+top.rawurlencode(window.location.href);
+                       }
+                                       ";
+                       } else {
+                               $js = " window.location.href='" . $this->deleteUrl(0, $this->fileMode ? 1 : 0) . "&redirect='+top.rawurlencode(window.location.href); ";
                        }
-                       ").'">'.$this->clLabel('delete','rm').'</option>';
+                       $opt[]='<option value="'.htmlspecialchars($js).'">'.$this->clLabel('delete','rm').'</option>';
+               }
                $selector_menu = '<select name="_clipMenu" onchange="eval(this.options[this.selectedIndex].value);this.selectedIndex=0;">'.implode('',$opt).'</select>';
 
                $out[]='
                        <tr class="typo3-clipboard-head">
-                               <td>'.
+                               <td nowrap="nowrap">'.
                                '<a href="'.htmlspecialchars($thumb_url).'#clip_head">'.
                                        '<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="" />'.
                                        '</a>'.
-                               '<a href="'.htmlspecialchars($copymode_url).'#clip_head">'.
-                                       '<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="" />'.
-                                       '</a>'.
                                '</td>
-                               <td width="95%">'.$selector_menu.'</td>
-                               <td><a href="'.htmlspecialchars($rmall_url).'#clip_head">'.$LANG->sL('LLL:EXT:lang/locallang_core.php:buttons.clear',1).'</a></td>
+                               <td width="95%" nowrap="nowrap">'.
+                                       $copymode_selector.' '.
+                                       $selector_menu.
+                               '</td>
+                               <td>'.
+                               '<a href="'.htmlspecialchars($rmall_url).'#clip_head">'.
+                                       '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/closedok_2.gif','width="21" height="16"').' vspace="2" border="0" title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:buttons.clear',1).'" alt="" />'.
+                                       '</a></td>
                        </tr>';
 
 
@@ -372,7 +431,7 @@ class t3lib_clipboard {
                                        $bgColClass = ($table=='_FILE'&&$this->fileMode)||($table!='_FILE'&&!$this->fileMode) ? 'bgColor4-20' : 'bgColor4';
 
                                        if ($table=='_FILE')    {       // Rendering files/directories on the clipboard:
-                                               if (@file_exists($v) && t3lib_div::isAllowedAbsPath($v))        {
+                                               if (file_exists($v) && t3lib_div::isAllowedAbsPath($v)) {
                                                        $fI = pathinfo($v);
                                                        $icon = is_dir($v) ? 'folder.gif' : t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
                                                        $size = ' ('.t3lib_div::formatSize(filesize($v)).'bytes)';
@@ -384,7 +443,7 @@ class t3lib_clipboard {
                                                                        <td class="'.$bgColClass.'">'.$icon.'</td>
                                                                        <td class="'.$bgColClass.'" nowrap="nowrap" width="95%">&nbsp;'.$this->linkItemText(htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($v),$GLOBALS['BE_USER']->uc['titleLen'])),$v).
                                                                                ($pad=='normal'?(' <strong>('.($this->clipData['normal']['mode']=='copy'?$this->clLabel('copy','cm'):$this->clLabel('cut','cm')).')</strong>'):'').'&nbsp;'.($thumb?'<br />'.$thumb:'').'</td>
-                                                                       <td class="'.$bgColClass.'" align="center">'.
+                                                                       <td class="'.$bgColClass.'" align="center" nowrap="nowrap">'.
                                                                        '<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>'.
                                                                        '<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>'.
                                                                        '</td>
@@ -395,18 +454,24 @@ class t3lib_clipboard {
                                                        $this->changed=1;
                                                }
                                        } else {        // Rendering records:
-                                               $rec=t3lib_BEfunc::getRecord($table,$uid);
+                                               $rec=t3lib_BEfunc::getRecordWSOL($table,$uid);
                                                if (is_array($rec))     {
                                                        $lines[]='
                                                                <tr>
                                                                        <td class="'.$bgColClass.'">'.$this->linkItemText(t3lib_iconWorks::getIconImage($table,$rec,$this->backPath,'hspace="20" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($rec,$table)).'"'),$rec,$table).'</td>
                                                                        <td class="'.$bgColClass.'" nowrap="nowrap" width="95%">&nbsp;'.$this->linkItemText(htmlspecialchars(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$rec),$GLOBALS['BE_USER']->uc['titleLen'])),$rec,$table).
                                                                                ($pad=='normal'?(' <strong>('.($this->clipData['normal']['mode']=='copy'?$this->clLabel('copy','cm'):$this->clLabel('cut','cm')).')</strong>'):'').'&nbsp;</td>
-                                                                       <td class="'.$bgColClass.'" align="center">'.
+                                                                       <td class="'.$bgColClass.'" align="center" nowrap="nowrap">'.
                                                                        '<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>'.
                                                                        '<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>'.
                                                                        '</td>
                                                                </tr>';
+
+                                                       $localizationData = $this->getLocalizations($table, $rec, $bgColClass, $pad);
+                                                       if ($localizationData) {
+                                                               $lines[] = $localizationData;
+                                                       }
+
                                                } else {
                                                        unset($this->clipData[$pad]['el'][$k]);
                                                        $this->changed=1;
@@ -427,6 +492,58 @@ class t3lib_clipboard {
                return $lines;
        }
 
+
+       /**
+        * Gets all localizations of the current record.
+        *
+        * @param       string          the table
+        * @param       array           the current record
+        * @return      string          HTML table rows
+        */
+       function getLocalizations($table, $parentRec, $bgColClass, $pad) {
+               $lines = array();
+               $tcaCtrl = $GLOBALS['TCA'][$table]['ctrl'];
+
+               if ($table != 'pages' && t3lib_BEfunc::isTableLocalizable($table) && !$tcaCtrl['transOrigPointerTable']) {
+                       $where = array();
+                       $where[] = $tcaCtrl['transOrigPointerField'] . '=' . intval($parentRec['uid']);
+                       $where[] = $tcaCtrl['languageField'] . '!=0';
+
+                       if (isset($tcaCtrl['delete']) && $tcaCtrl['delete']) {
+                               $where[] = $tcaCtrl['delete'] . '=0';
+                       }
+
+                       if (isset($tcaCtrl['versioningWS']) && $tcaCtrl['versioningWS']) {
+                               $where[] = 't3ver_wsid=' . $parentRec['t3ver_wsid'];
+                       }
+
+                       $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', $table, implode(' AND ', $where));
+
+                       if (is_array($rows)) {
+                               $modeData = '';
+                               if ($pad == 'normal') {
+                                       $mode = ($this->clipData['normal']['mode'] == 'copy' ? 'copy' : 'cut');
+                                       $modeData = ' <strong>(' . $this->clLabel($mode, 'cm') . ')</strong>';
+                               }
+
+                               foreach ($rows as $rec) {
+                                       $lines[]='
+                                       <tr>
+                                               <td class="' . $bgColClass . '">' .
+                                                       t3lib_iconWorks::getIconImage($table, $rec, $this->backPath,' style="margin-left: 38px;"') . '</td>
+                                               <td class="' . $bgColClass . '" nowrap="nowrap" width="95%">&nbsp;' . htmlspecialchars(
+                                                               t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table, $rec), $GLOBALS['BE_USER']->uc['titleLen'])) .
+                                                               $modeData . '&nbsp;</td>
+                                               <td class="' . $bgColClass . '" align="center" nowrap="nowrap">&nbsp;</td>
+                                       </tr>';
+                               }
+                       }
+               }
+               return implode('',$lines);
+       }
+
+
+
        /**
         * Wraps title of pad in bold-tags and maybe the number of elements if any.
         *
@@ -458,7 +575,7 @@ class t3lib_clipboard {
                        } else {
                                $str='<a href="'.htmlspecialchars($this->backPath.'db_list.php?id='.$rec['pid']).'">'.$str.'</a>';
                        }
-               } elseif (@file_exists($rec))   {
+               } elseif (file_exists($rec))    {
                        if (!$this->fileMode)   {
                                $str=$GLOBALS['TBE_TEMPLATE']->dfw($str);
                        } else {
@@ -469,41 +586,6 @@ class t3lib_clipboard {
        }
 
        /**
-        * Verifies if the item $table/$uid is on the current pad.
-        * If the pad is "normal", the mode value is returned if the element existed. Thus you'll know if the item was copy or cut moded...
-        *
-        * @param       string          Table name, (_FILE for files...)
-        * @param       integer         Element uid (path for files)
-        * @return      string
-        */
-       function isSelected($table,$uid)        {
-               $k=$table.'|'.$uid;
-               return $this->clipData[$this->current]['el'][$k] ? ($this->current=='normal'?$this->currentMode():1) : '';
-       }
-
-       /**
-        * Returns item record $table,$uid if selected on current clipboard
-        * If table and uid is blank, the first element is returned.
-        * Makes sense only for DB records - not files!
-        *
-        * @param       string          Table name
-        * @param       integer         Element uid
-        * @return      array           Element record with extra field _RECORD_TITLE set to the title of the record...
-        */
-       function getSelectedRecord($table='',$uid='')   {
-               if (!$table && !$uid)   {
-                       $elArr = $this->elFromTable('');
-                       reset($elArr);
-                       list($table,$uid) = explode('|',key($elArr));
-               }
-               if ($this->isSelected($table,$uid))     {
-                       $selRec = t3lib_BEfunc::getRecord($table,$uid);
-                       $selRec['_RECORD_TITLE'] = t3lib_BEfunc::getRecordTitle($table,$selRec);
-                       return $selRec;
-               }
-       }
-
-       /**
         * Returns the select-url for database elements
         *
         * @param       string          Table name
@@ -606,62 +688,6 @@ class t3lib_clipboard {
        }
 
        /**
-        * This traverses the elements on the current clipboard pane
-        * and unsets elements which does not exist anymore or are disabled.
-        *
-        * @return      void
-        */
-       function cleanCurrent() {
-               if (is_array($this->clipData[$this->current]['el']))    {
-                       reset($this->clipData[$this->current]['el']);
-                       while(list($k,$v)=each($this->clipData[$this->current]['el']))  {
-                               list($table,$uid) = explode('|',$k);
-                               if ($table!='_FILE')    {
-                                       if (!$v || !is_array(t3lib_BEfunc::getRecord($table,$uid,'uid')))       {
-                                               unset($this->clipData[$this->current]['el'][$k]);
-                                               $this->changed=1;
-                                       }
-                               } else {
-                                       if (!$v || !@file_exists($v))   {
-                                               unset($this->clipData[$this->current]['el'][$k]);
-                                               $this->changed=1;
-                                       }
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Counts the number of elements from the table $matchTable. If $matchTable is blank, all tables (except '_FILE' of course) is counted.
-        *
-        * @param       string          Table to match/count for.
-        * @param       string          $pad can optionally be used to set another pad than the current.
-        * @return      array           Array with keys from the CB.
-        */
-       function elFromTable($matchTable='',$pad='')    {
-               $pad = $pad ? $pad : $this->current;
-               $list=array();
-               if (is_array($this->clipData[$pad]['el']))      {
-                       reset($this->clipData[$pad]['el']);
-                       while(list($k,$v)=each($this->clipData[$pad]['el']))    {
-                               if ($v) {
-                                       list($table,$uid) = explode('|',$k);
-                                       if ($table!='_FILE')    {
-                                               if ((!$matchTable || (string)$table==(string)$matchTable) && $GLOBALS['TCA'][$table])   {
-                                                       $list[$k]= ($pad=='normal'?$v:$uid);
-                                               }
-                                       } else {
-                                               if ((string)$table==(string)$matchTable)        {
-                                                       $list[$k]=$v;
-                                               }
-                                       }
-                               }
-                       }
-               }
-               return $list;
-       }
-
-       /**
         * Returns confirm JavaScript message
         *
         * @param       string          Table name
@@ -671,6 +697,7 @@ class t3lib_clipboard {
         * @return      string          JavaScript "confirm" message
         */
        function confirmMsg($table,$rec,$type,$clElements)      {
+               if($GLOBALS['BE_USER']->jsConfirmation(2))      {
                $labelKey = 'LLL:EXT:lang/locallang_core.php:mess.'.($this->currentMode()=='copy'?'copy':'move').($this->current=='normal'?'':'cb').'_'.$type;
                $msg = $GLOBALS['LANG']->sL($labelKey);
 
@@ -704,10 +731,73 @@ class t3lib_clipboard {
                        t3lib_div::fixed_lgd_cs($selRecTitle,30),
                        t3lib_div::fixed_lgd_cs($thisRecTitle,30)
                        )).')';
+               } else {
+                       $conf = '';
+               }
                return $conf;
        }
 
        /**
+        * Clipboard label - getting from "EXT:lang/locallang_core.php:"
+        *
+        * @param       string          Label Key
+        * @param       string          Alternative key to "labels"
+        * @return      string
+        */
+       function clLabel($key,$Akey='labels')   {
+               return htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:'.$Akey.'.'.$key));
+       }
+
+       /**
+        * Creates GET parameters for linking to the export module.
+        *
+        * @return      string          GET parameters for current clipboard content to be exported.
+        */
+       function exportClipElementParameters()  {
+
+                       // Init:
+               $pad = $this->current;
+               $params = array();
+               $params[] = 'tx_impexp[action]=export';
+
+                       // Traverse items:
+               if (is_array($this->clipData[$pad]['el']))      {
+                       reset($this->clipData[$pad]['el']);
+                       while(list($k,$v)=each($this->clipData[$pad]['el']))    {
+                               if ($v) {
+                                       list($table,$uid) = explode('|',$k);
+
+                                       if ($table=='_FILE')    {       // Rendering files/directories on the clipboard:
+                                               if (file_exists($v) && t3lib_div::isAllowedAbsPath($v)) {
+                                                       $params[] = 'tx_impexp['.(is_dir($v) ? 'dir' : 'file').'][]='.rawurlencode($v);
+                                               }
+                                       } else {        // Rendering records:
+                                               $rec = t3lib_BEfunc::getRecord($table,$uid);
+                                               if (is_array($rec))     {
+                                                       $params[] = 'tx_impexp[record][]='.rawurlencode($table.':'.$uid);
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               return '&'.implode('&', $params);
+       }
+
+
+
+
+
+
+
+
+       /*****************************************
+        *
+        * Helper functions
+        *
+        ****************************************/
+
+       /**
         * Removes element on clipboard
         *
         * @param       string          Key of element in ->clipData array
@@ -740,14 +830,103 @@ class t3lib_clipboard {
        }
 
        /**
-        * Clipboard label - getting from "EXT:lang/locallang_core.php:"
+        * This traverses the elements on the current clipboard pane
+        * and unsets elements which does not exist anymore or are disabled.
         *
-        * @param       string          Label Key
-        * @param       string          Alternative key to "labels"
+        * @return      void
+        */
+       function cleanCurrent() {
+               if (is_array($this->clipData[$this->current]['el']))    {
+                       reset($this->clipData[$this->current]['el']);
+                       while(list($k,$v)=each($this->clipData[$this->current]['el']))  {
+                               list($table,$uid) = explode('|',$k);
+                               if ($table!='_FILE')    {
+                                       if (!$v || !is_array(t3lib_BEfunc::getRecord($table,$uid,'uid')))       {
+                                               unset($this->clipData[$this->current]['el'][$k]);
+                                               $this->changed=1;
+                                       }
+                               } else {
+                                       if (!$v || !file_exists($v))    {
+                                               unset($this->clipData[$this->current]['el'][$k]);
+                                               $this->changed=1;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Counts the number of elements from the table $matchTable. If $matchTable is blank, all tables (except '_FILE' of course) is counted.
+        *
+        * @param       string          Table to match/count for.
+        * @param       string          $pad can optionally be used to set another pad than the current.
+        * @return      array           Array with keys from the CB.
+        */
+       function elFromTable($matchTable='',$pad='')    {
+               $pad = $pad ? $pad : $this->current;
+               $list=array();
+               if (is_array($this->clipData[$pad]['el']))      {
+                       reset($this->clipData[$pad]['el']);
+                       while(list($k,$v)=each($this->clipData[$pad]['el']))    {
+                               if ($v) {
+                                       list($table,$uid) = explode('|',$k);
+                                       if ($table!='_FILE')    {
+                                               if ((!$matchTable || (string)$table==(string)$matchTable) && $GLOBALS['TCA'][$table])   {
+                                                       $list[$k]= ($pad=='normal'?$v:$uid);
+                                               }
+                                       } else {
+                                               if ((string)$table==(string)$matchTable)        {
+                                                       $list[$k]=$v;
+                                               }
+                                       }
+                               }
+                       }
+               }
+               return $list;
+       }
+
+       /**
+        * Verifies if the item $table/$uid is on the current pad.
+        * If the pad is "normal", the mode value is returned if the element existed. Thus you'll know if the item was copy or cut moded...
+        *
+        * @param       string          Table name, (_FILE for files...)
+        * @param       integer         Element uid (path for files)
         * @return      string
         */
-       function clLabel($key,$Akey='labels')   {
-               return htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:'.$Akey.'.'.$key));
+       function isSelected($table,$uid)        {
+               $k=$table.'|'.$uid;
+               return $this->clipData[$this->current]['el'][$k] ? ($this->current=='normal'?$this->currentMode():1) : '';
+       }
+
+       /**
+        * Returns item record $table,$uid if selected on current clipboard
+        * If table and uid is blank, the first element is returned.
+        * Makes sense only for DB records - not files!
+        *
+        * @param       string          Table name
+        * @param       integer         Element uid
+        * @return      array           Element record with extra field _RECORD_TITLE set to the title of the record...
+        */
+       function getSelectedRecord($table='',$uid='')   {
+               if (!$table && !$uid)   {
+                       $elArr = $this->elFromTable('');
+                       reset($elArr);
+                       list($table,$uid) = explode('|',key($elArr));
+               }
+               if ($this->isSelected($table,$uid))     {
+                       $selRec = t3lib_BEfunc::getRecordWSOL($table,$uid);
+                       $selRec['_RECORD_TITLE'] = t3lib_BEfunc::getRecordTitle($table,$selRec);
+                       return $selRec;
+               }
+       }
+
+       /**
+        * Reports if the current pad has elements (does not check file/DB type OR if file/DBrecord exists or not. Only counting array)
+        *
+        * @return      boolean         True if elements exist.
+        */
+       function isElements()   {
+               return is_array($this->clipData[$this->current]['el']) && count($this->clipData[$this->current]['el']);
        }
 
 
@@ -867,7 +1046,7 @@ class t3lib_clipboard {
                        // Traverse elements and make CMD array
                reset($elements);
                while(list($tP,$path)=each($elements))  {
-                       $FILE[$mode][]=array('data'=>$path,'target'=>$pUid);
+                       $FILE[$mode][]=array('data'=>$path,'target'=>$pUid,'altName'=>1);
                        if ($mode=='move')      $this->removeElement($tP);
                }
                $this->endClipboard();
@@ -900,4 +1079,5 @@ class t3lib_clipboard {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_clipboard.php'])        {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_clipboard.php']);
 }
+
 ?>