Index: t3lib/class.t3lib_clipboard.php =================================================================== --- t3lib/class.t3lib_clipboard.php (revision 9131) +++ t3lib/class.t3lib_clipboard.php (revision ) @@ -1,29 +1,29 @@ =1 and denotes the pad-number + * 'tab_[x]' where x is >=1 and denotes the pad-number - * \ 'mode' : 'copy' means copy-mode, default = moving ('cut') + * \ 'mode' : 'copy' means copy-mode, default = moving ('cut') - * \ 'el' : Array of elements: + * \ 'el' : Array of elements: - * DB: keys = '[tablename]|[uid]' eg. 'tt_content:123' + * DB: keys = '[tablename]|[uid]' eg. 'tt_content:123' - * DB: values = 1 (basically insignificant) + * DB: values = 1 (basically insignificant) - * FILE: keys = '_FILE|[shortmd5 of path]' eg. '_FILE|9ebc7e5c74' + * FILE: keys = '_FILE|[shortmd5 of path]' eg. '_FILE|9ebc7e5c74' - * FILE: values = The full filepath, eg. '/www/htdocs/typo3/32/dummy/fileadmin/sem1_3_examples/alternative_index.php' or 'C:/www/htdocs/typo3/32/dummy/fileadmin/sem1_3_examples/alternative_index.php' + * FILE: values = The full filepath, eg. '/www/htdocs/typo3/32/dummy/fileadmin/sem1_3_examples/alternative_index.php' or 'C:/www/htdocs/typo3/32/dummy/fileadmin/sem1_3_examples/alternative_index.php' * - * 'current' pointer to current tab (among the above...) + * 'current' pointer to current tab (among the above...) - * '_setThumb' boolean: If set, file thumbnails are shown. + * '_setThumb' boolean: If set, file thumbnails are shown. * - * The virtual tablename '_FILE' will always indicate files/folders. When checking for elements from eg. 'all tables' (by using an empty string) '_FILE' entries are excluded (so in effect only DB elements are counted) + * The virtual tablename '_FILE' will always indicate files/folders. When checking for elements from eg. 'all tables' (by using an empty string) '_FILE' entries are excluded (so in effect only DB elements are counted) * */ - var $clipData=array(); + var $clipData = array(); - var $changed=0; + var $changed = 0; - var $current=''; + var $current = ''; - var $backPath=''; + var $backPath = ''; - var $lockToNormal=0; + var $lockToNormal = 0; - var $fileMode=0; // If set, clipboard is displaying files. + var $fileMode = 0; // If set, clipboard is displaying files. - - - - - - - - - - - /***************************************** * * Initialize @@ -147,24 +136,24 @@ * * @return void */ - function initializeClipboard() { + function initializeClipboard() { global $BE_USER; $this->backPath = $GLOBALS['BACK_PATH']; // Get data - $clipData = $BE_USER->getModuleData('clipboard',$BE_USER->getTSConfigVal('options.saveClipboard')?'':'ses'); + $clipData = $BE_USER->getModuleData('clipboard', $BE_USER->getTSConfigVal('options.saveClipboard') ? '' : 'ses'); // NumberTabs $clNP = $BE_USER->getTSConfigVal('options.clipboardNumberPads'); - if (t3lib_div::testInt($clNP) && $clNP>=0) { + if (t3lib_div::testInt($clNP) && $clNP >= 0) { - $this->numberTabs = t3lib_div::intInRange($clNP,0,20); + $this->numberTabs = t3lib_div::intInRange($clNP, 0, 20); } // Resets/reinstates the clipboard pads $this->clipData['normal'] = is_array($clipData['normal']) ? $clipData['normal'] : array(); - for ($a=1;$a<=$this->numberTabs;$a++) { + for ($a = 1; $a <= $this->numberTabs; $a++) { - $this->clipData['tab_'.$a] = is_array($clipData['tab_'.$a]) ? $clipData['tab_'.$a] : array(); + $this->clipData['tab_' . $a] = is_array($clipData['tab_' . $a]) ? $clipData['tab_' . $a] : array(); } // Setting the current pad pointer ($this->current) and _setThumb (which determines whether or not do show file thumbnails) @@ -178,7 +167,7 @@ * * @return void */ - function lockToNormal() { + function lockToNormal() { $this->lockToNormal = 1; $this->current = 'normal'; } @@ -188,50 +177,50 @@ * Normally perform only one action at a time. * In scripts like db_list.php / file_list.php the GET-var CB is used to control the clipboard. * - * Selecting / Deselecting elements + * Selecting / Deselecting elements - * Array $cmd['el'] has keys = element-ident, value = element value (see description of clipData array in header) + * Array $cmd['el'] has keys = element-ident, value = element value (see description of clipData array in header) - * Selecting elements for 'copy' should be done by simultaneously setting setCopyMode. + * Selecting elements for 'copy' should be done by simultaneously setting setCopyMode. * * @param array Array of actions, see function description * @return void */ - function setCmd($cmd) { + function setCmd($cmd) { - if (is_array($cmd['el'])) { + if (is_array($cmd['el'])) { foreach ($cmd['el'] as $k => $v) { - if ($this->current=='normal') { + if ($this->current == 'normal') { unset($this->clipData['normal']); } - if ($v) { + if ($v) { - $this->clipData[$this->current]['el'][$k]=$v; + $this->clipData[$this->current]['el'][$k] = $v; } else { $this->removeElement($k); } - $this->changed=1; + $this->changed = 1; } } // Change clipboard pad (if not locked to normal) - if ($cmd['setP']) { + if ($cmd['setP']) { $this->setCurrentPad($cmd['setP']); } // Remove element (value = item ident: DB; '[tablename]|[uid]' FILE: '_FILE|[shortmd5 hash of path]' - if ($cmd['remove']) { + if ($cmd['remove']) { $this->removeElement($cmd['remove']); - $this->changed=1; + $this->changed = 1; } // Remove all on current pad (value = pad-ident) - if ($cmd['removeAll']) { + if ($cmd['removeAll']) { - $this->clipData[$cmd['removeAll']]=array(); + $this->clipData[$cmd['removeAll']] = array(); - $this->changed=1; + $this->changed = 1; } // Set copy mode of the tab - if (isset($cmd['setCopyMode'])) { + if (isset($cmd['setCopyMode'])) { - $this->clipData[$this->current]['mode']=$this->isElements()?($cmd['setCopyMode']?'copy':''):''; + $this->clipData[$this->current]['mode'] = $this->isElements() ? ($cmd['setCopyMode'] ? 'copy' : '') : ''; - $this->changed=1; + $this->changed = 1; } // Toggle thumbnail display for files on/off - if (isset($cmd['setThumb'])) { + if (isset($cmd['setThumb'])) { - $this->clipData['_setThumb']=$cmd['setThumb']; + $this->clipData['_setThumb'] = $cmd['setThumb']; - $this->changed=1; + $this->changed = 1; } } @@ -241,12 +230,16 @@ * @param string Key in the array $this->clipData * @return void */ - function setCurrentPad($padIdent) { + function setCurrentPad($padIdent) { // Change clipboard pad (if not locked to normal) - if (!$this->lockToNormal && $this->current!=$padIdent) { + if (!$this->lockToNormal && $this->current != $padIdent) { - if (isset($this->clipData[$padIdent])) $this->clipData['current'] = $this->current = $padIdent; - 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' + if (isset($this->clipData[$padIdent])) { + $this->clipData['current'] = $this->current = $padIdent; + } + 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' - $this->changed=1; + $this->changed = 1; } } @@ -256,9 +249,11 @@ * * @return void */ - function endClipboard() { + function endClipboard() { - if ($this->changed) $this->saveClipboard(); + if ($this->changed) { + $this->saveClipboard(); + } - $this->changed=0; + $this->changed = 0; } /** @@ -269,11 +264,11 @@ * @param boolean $removeDeselected can be set in order to remove entries which are marked for deselection. * @return array Processed input $CBarr */ - function cleanUpCBC($CBarr,$table,$removeDeselected=0) { + function cleanUpCBC($CBarr, $table, $removeDeselected = 0) { - if (is_array($CBarr)) { + if (is_array($CBarr)) { foreach ($CBarr as $k => $v) { - $p=explode('|',$k); + $p = explode('|', $k); - if ((string)$p[0]!=(string)$table || ($removeDeselected && !$v)) { + if ((string) $p[0] != (string) $table || ($removeDeselected && !$v)) { unset($CBarr[$k]); } } @@ -282,16 +277,6 @@ } - - - - - - - - - - /***************************************** * * Clipboard HTML renderings @@ -303,97 +288,101 @@ * * @return string HTML output */ - function printClipboard() { + function printClipboard() { - global $TBE_TEMPLATE,$LANG; + global $TBE_TEMPLATE, $LANG; - $out=array(); + $out = array(); - $elCount = count($this->elFromTable($this->fileMode?'_FILE':'')); + $elCount = count($this->elFromTable($this->fileMode ? '_FILE' : '')); // Upper header - $out[]=' + $out[] = ' ' . t3lib_BEfunc::wrapInHelp('xMOD_csh_corebe', 'list_clipboard', $this->clLabel('clipboard', 'buttons')) . ' '; // Button/menu header: - $thumb_url = t3lib_div::linkThisScript(array('CB'=>array('setThumb'=>$this->clipData['_setThumb']?0:1))); + $thumb_url = t3lib_div::linkThisScript(array('CB' => array('setThumb' => $this->clipData['_setThumb'] ? 0 : 1))); - $rmall_url = t3lib_div::linkThisScript(array('CB'=>array('removeAll'=>$this->current))); + $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 = array(); - $opt[]=''; + $opt[] = ''; - $opt[]=''; + $opt[] = ''; - $copymode_selector = ' '; + $copymode_selector = ' '; // Selector menu + clear button - $opt=array(); + $opt = array(); - $opt[]=''; + $opt[] = ''; - // Import / Export link: + // Import / Export link: - if ($elCount && t3lib_extMgm::isLoaded('impexp')) { + if ($elCount && t3lib_extMgm::isLoaded('impexp')) { - $opt[] = ''; + $opt[] = ''; } - // Edit: + // Edit: - if (!$this->fileMode && $elCount) { + if (!$this->fileMode && $elCount) { - $opt[]=''; + $opt[] = ''; } - // Delete: + // Delete: - if ($elCount) { + if ($elCount) { - if($GLOBALS['BE_USER']->jsConfirmation(4)) { + if ($GLOBALS['BE_USER']->jsConfirmation(4)) { $js = " - if(confirm(".$GLOBALS['LANG']->JScharCode(sprintf($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.deleteClip'),$elCount)).")){ + if(confirm(" . $GLOBALS['LANG']->JScharCode(sprintf($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.deleteClip'), $elCount)) . ")){ 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); "; } - $opt[]=''; + $opt[] = ''; } - $selector_menu = ''; + $selector_menu = ''; - $out[]=' + $out[] = ' - '. + ' . - ''. + '' . - 'backPath,'gfx/thumb_'.($this->clipData['_setThumb']?'s':'n').'.gif','width="21" height="16"').' vspace="2" border="0" title="'.$this->clLabel('thumbmode_clip').'" alt="" />'. + 'backPath, 'gfx/thumb_' . ($this->clipData['_setThumb'] ? 's' : 'n') . '.gif', 'width="21" height="16"') . ' vspace="2" border="0" title="' . $this->clLabel('thumbmode_clip') . '" alt="" />' . - ''. + '' . ' - '. + ' . - $copymode_selector.' '. + $copymode_selector . ' ' . - $selector_menu. + $selector_menu . ' - '. + ' . - ''. + '' . - t3lib_iconWorks::getSpriteIcon('actions-document-close', array('title' => $LANG->sL('LLL:EXT:lang/locallang_core.php:buttons.clear', TRUE))) . + t3lib_iconWorks::getSpriteIcon('actions-document-close', array('title' => $LANG->sL('LLL:EXT:lang/locallang_core.php:buttons.clear', TRUE))) . ' '; // Print header and content for the NORMAL tab: - $out[]=' + $out[] = ' - '. + ' . - t3lib_iconWorks::getSpriteIcon('actions-view-table-' . (($this->current == 'normal') ? 'collapse' : 'expand')) . + t3lib_iconWorks::getSpriteIcon('actions-view-table-' . (($this->current == 'normal') ? 'collapse' : 'expand')) . - $this->padTitleWrap('Normal','normal'). + $this->padTitleWrap('Normal', 'normal') . - ' + ' '; - if ($this->current=='normal') $out=array_merge($out,$this->printContentFromTab('normal')); + if ($this->current == 'normal') { + $out = array_merge($out, $this->printContentFromTab('normal')); + } // Print header and content for the NUMERIC tabs: - for ($a=1;$a<=$this->numberTabs;$a++) { + for ($a = 1; $a <= $this->numberTabs; $a++) { - $out[]=' + $out[] = ' - '. + ' . - t3lib_iconWorks::getSpriteIcon('actions-view-table-' . (($this->current == 'tab_' . $a) ? 'collapse' : 'expand')) . + t3lib_iconWorks::getSpriteIcon('actions-view-table-' . (($this->current == 'tab_' . $a) ? 'collapse' : 'expand')) . - $this->padTitleWrap($this->clLabel('cliptabs').$a,'tab_'.$a). + $this->padTitleWrap($this->clLabel('cliptabs') . $a, 'tab_' . $a) . - ' + ' '; - if ($this->current=='tab_'.$a) $out=array_merge($out,$this->printContentFromTab('tab_'.$a)); + if ($this->current == 'tab_' . $a) { + $out = array_merge($out, $this->printContentFromTab('tab_' . $a)); - } + } + } // Wrap accumulated rows in a table: $output = ' @@ -402,11 +391,11 @@ TYPO3 Clipboard: --> - '.implode('',$out).' + ' . implode('', $out) . '
'; // Wrap in form tag: - $output = '
'.$output.'
'; + $output = '
' . $output . '
'; // Return the accumulated content: return $output; @@ -419,50 +408,50 @@ * @return array Array with table rows for the clipboard. * @access private */ - function printContentFromTab($pad) { + function printContentFromTab($pad) { global $TBE_TEMPLATE; - $lines=array(); + $lines = array(); - if (is_array($this->clipData[$pad]['el'])) { + if (is_array($this->clipData[$pad]['el'])) { foreach ($this->clipData[$pad]['el'] as $k => $v) { - if ($v) { + if ($v) { - list($table,$uid) = explode('|',$k); + list($table, $uid) = explode('|', $k); - $bgColClass = ($table=='_FILE'&&$this->fileMode)||($table!='_FILE'&&!$this->fileMode) ? 'bgColor4-20' : 'bgColor4'; + $bgColClass = ($table == '_FILE' && $this->fileMode) || ($table != '_FILE' && !$this->fileMode) ? 'bgColor4-20' : 'bgColor4'; - if ($table=='_FILE') { // Rendering files/directories on the clipboard: + 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)'; + $size = ' (' . t3lib_div::formatSize(filesize($v)) . 'bytes)'; $icon = t3lib_iconWorks::getSpriteIconForFile(is_dir($v) ? 'folder' : strtolower($fI['extension']), array('style' => 'margin: 0 20px;', 'title' => htmlspecialchars($fI['basename'] . $size))); - $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"') : '') :''; + $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"') : '') : ''; - $lines[]=' + $lines[] = ' - '.$icon.' + ' . $icon . ' -  '.$this->linkItemText(htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($v),$GLOBALS['BE_USER']->uc['titleLen'])),$v). +  ' . $this->linkItemText(htmlspecialchars(t3lib_div::fixed_lgd_cs(basename($v), $GLOBALS['BE_USER']->uc['titleLen'])), $v) . - ($pad=='normal'?(' ('.($this->clipData['normal']['mode']=='copy'?$this->clLabel('copy','cm'):$this->clLabel('cut','cm')).')'):'').' '.($thumb?'
'.$thumb:'').' + ($pad == 'normal' ? (' (' . ($this->clipData['normal']['mode'] == 'copy' ? $this->clLabel('copy', 'cm') : $this->clLabel('cut', 'cm')) . ')') : '') . ' ' . ($thumb ? '
' . $thumb : '') . ' - '. + ' . - '' . t3lib_iconWorks::getSpriteIcon('actions-document-info', array('title' => $this->clLabel('info', 'cm'))) . ''. + '' . t3lib_iconWorks::getSpriteIcon('actions-document-info', array('title' => $this->clLabel('info', 'cm'))) . '' . - '' . t3lib_iconWorks::getSpriteIcon('actions-selection-delete', array('title' => $this->clLabel('removeItem'))) . ''. + '' . t3lib_iconWorks::getSpriteIcon('actions-selection-delete', array('title' => $this->clLabel('removeItem'))) . '' . ' '; } else { // If the file did not exist (or is illegal) then it is removed from the clipboard immediately: unset($this->clipData[$pad]['el'][$k]); - $this->changed=1; + $this->changed = 1; } - } else { // Rendering records: + } else { // Rendering records: - $rec=t3lib_BEfunc::getRecordWSOL($table,$uid); + $rec = t3lib_BEfunc::getRecordWSOL($table, $uid); - if (is_array($rec)) { + if (is_array($rec)) { - $lines[]=' + $lines[] = ' ' . $this->linkItemText(t3lib_iconWorks::getSpriteIconForRecord($table, $rec, array('style' => 'margin: 0 20px;', 'title' => htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($rec, $table)))), $rec, $table) . ' -  '.$this->linkItemText(htmlspecialchars(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table,$rec),$GLOBALS['BE_USER']->uc['titleLen'])),$rec,$table). +  ' . $this->linkItemText(htmlspecialchars(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table, $rec), $GLOBALS['BE_USER']->uc['titleLen'])), $rec, $table) . - ($pad=='normal'?(' ('.($this->clipData['normal']['mode']=='copy'?$this->clLabel('copy','cm'):$this->clLabel('cut','cm')).')'):'').'  + ($pad == 'normal' ? (' (' . ($this->clipData['normal']['mode'] == 'copy' ? $this->clLabel('copy', 'cm') : $this->clLabel('cut', 'cm')) . ')') : '') . '  - '. + ' . - '' . t3lib_iconWorks::getSpriteIcon('actions-document-info', array('title' => $this->clLabel('info','cm'))) . ''. + '' . t3lib_iconWorks::getSpriteIcon('actions-document-info', array('title' => $this->clLabel('info', 'cm'))) . '' . - '' . t3lib_iconWorks::getSpriteIcon('actions-selection-delete', array('title' => $this->clLabel('removeItem'))) . ''. + '' . t3lib_iconWorks::getSpriteIcon('actions-selection-delete', array('title' => $this->clLabel('removeItem'))) . '' . ' '; @@ -473,17 +462,17 @@ } else { unset($this->clipData[$pad]['el'][$k]); - $this->changed=1; + $this->changed = 1; } } } } } - if (!count($lines)) { + if (!count($lines)) { - $lines[]=' + $lines[] = ' -  ('.$this->clLabel('clipNoEl').')  +  (' . $this->clLabel('clipNoEl') . ')  '; } @@ -526,23 +515,22 @@ } foreach ($rows as $rec) { - $lines[]=' + $lines[] = ' ' . t3lib_iconWorks::getSpriteIconForRecord($table, $rec, array('style' => "margin-left: 38px;")) . '  ' . htmlspecialchars( - t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table, $rec), $GLOBALS['BE_USER']->uc['titleLen'])) . - $modeData . '  + t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table, $rec), $GLOBALS['BE_USER']->uc['titleLen'])) . + $modeData . '    '; } } } - return implode('',$lines); + return implode('', $lines); } - /** * Wraps title of pad in bold-tags and maybe the number of elements if any. * @@ -550,10 +538,10 @@ * @param string Pad reference * @return string HTML output (htmlspecialchar'ed content inside of tags.) */ - function padTitleWrap($str,$pad) { + function padTitleWrap($str, $pad) { - $el = count($this->elFromTable($this->fileMode?'_FILE':'',$pad)); + $el = count($this->elFromTable($this->fileMode ? '_FILE' : '', $pad)); - if ($el) { + if ($el) { - return ''.$str.' ('.($pad=='normal'?($this->clipData['normal']['mode']=='copy'?$this->clLabel('copy','cm'):$this->clLabel('cut','cm')):htmlspecialchars($el)).')'; + return '' . $str . ' (' . ($pad == 'normal' ? ($this->clipData['normal']['mode'] == 'copy' ? $this->clLabel('copy', 'cm') : $this->clLabel('cut', 'cm')) : htmlspecialchars($el)) . ')'; } else { return $GLOBALS['TBE_TEMPLATE']->dfw($str); } @@ -567,10 +555,10 @@ * @param string Table name * @return string */ - function linkItemText($str,$rec,$table='') { + function linkItemText($str, $rec, $table = '') { - if (is_array($rec) && $table) { + if (is_array($rec) && $table) { - if ($this->fileMode) { + if ($this->fileMode) { - $str=$GLOBALS['TBE_TEMPLATE']->dfw($str); + $str = $GLOBALS['TBE_TEMPLATE']->dfw($str); } else { if (t3lib_extMgm::isLoaded('list')) { $str = '' . $str . ''; } } - } elseif (file_exists($rec)) { + } elseif (file_exists($rec)) { - if (!$this->fileMode) { + if (!$this->fileMode) { - $str=$GLOBALS['TBE_TEMPLATE']->dfw($str); + $str = $GLOBALS['TBE_TEMPLATE']->dfw($str); } else { if (t3lib_extMgm::isLoaded('filelist')) { $str = 'jsConfirmation(2)) { + if ($GLOBALS['BE_USER']->jsConfirmation(2)) { - $labelKey = 'LLL:EXT:lang/locallang_core.php:mess.'.($this->currentMode()=='copy'?'copy':'move').($this->current=='normal'?'':'cb').'_'.$type; + $labelKey = 'LLL:EXT:lang/locallang_core.php:mess.' . ($this->currentMode() == 'copy' ? 'copy' : 'move') . ($this->current == 'normal' ? '' : 'cb') . '_' . $type; - $msg = $GLOBALS['LANG']->sL($labelKey); + $msg = $GLOBALS['LANG']->sL($labelKey); - if ($table=='_FILE') { + if ($table == '_FILE') { - $thisRecTitle = basename($rec); + $thisRecTitle = basename($rec); - if ($this->current=='normal') { + if ($this->current == 'normal') { - reset($clElements); - $selItem = current($clElements); - $selRecTitle = basename($selItem); - } else { + reset($clElements); + $selItem = current($clElements); + $selRecTitle = basename($selItem); + } else { - $selRecTitle=count($clElements); + $selRecTitle = count($clElements); - } - } else { - $thisRecTitle = ( + } + } else { + $thisRecTitle = ( - $table=='pages' && !is_array($rec) ? + $table == 'pages' && !is_array($rec) ? - $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] : + $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] : - t3lib_BEfunc::getRecordTitle($table,$rec) + t3lib_BEfunc::getRecordTitle($table, $rec) - ); + ); - if ($this->current=='normal') { + if ($this->current == 'normal') { - $selItem = $this->getSelectedRecord(); + $selItem = $this->getSelectedRecord(); - $selRecTitle=$selItem['_RECORD_TITLE']; + $selRecTitle = $selItem['_RECORD_TITLE']; - } else { + } else { - $selRecTitle=count($clElements); + $selRecTitle = count($clElements); - } - } + } + } - // Message: + // Message: - $conf='confirm('.$GLOBALS['LANG']->JScharCode(sprintf( + $conf = 'confirm(' . $GLOBALS['LANG']->JScharCode(sprintf( - $msg, + $msg, - t3lib_div::fixed_lgd_cs($selRecTitle,30), + t3lib_div::fixed_lgd_cs($selRecTitle, 30), - t3lib_div::fixed_lgd_cs($thisRecTitle,30) + t3lib_div::fixed_lgd_cs($thisRecTitle, 30) - )).')'; + )) . ')'; } else { $conf = ''; } @@ -750,8 +742,8 @@ * @param string Alternative key to "labels" * @return string */ - function clLabel($key,$Akey='labels') { + function clLabel($key, $Akey = 'labels') { - return htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:'.$Akey.'.'.$key)); + return htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:' . $Akey . '.' . $key)); } /** @@ -759,7 +751,7 @@ * * @return string GET parameters for current clipboard content to be exported. */ - function exportClipElementParameters() { + function exportClipElementParameters() { // Init: $pad = $this->current; @@ -767,35 +759,29 @@ $params[] = 'tx_impexp[action]=export'; // Traverse items: - if (is_array($this->clipData[$pad]['el'])) { + if (is_array($this->clipData[$pad]['el'])) { foreach ($this->clipData[$pad]['el'] as $k => $v) { - if ($v) { + if ($v) { - list($table,$uid) = explode('|',$k); + list($table, $uid) = explode('|', $k); - if ($table=='_FILE') { // Rendering files/directories on the clipboard: + 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)) { - $params[] = 'tx_impexp['.(is_dir($v) ? 'dir' : 'file').'][]='.rawurlencode($v); + $params[] = 'tx_impexp[' . (is_dir($v) ? 'dir' : 'file') . '][]=' . rawurlencode($v); } - } else { // Rendering records: + } else { // Rendering records: - $rec = t3lib_BEfunc::getRecord($table,$uid); + $rec = t3lib_BEfunc::getRecord($table, $uid); - if (is_array($rec)) { + if (is_array($rec)) { - $params[] = 'tx_impexp[record][]='.rawurlencode($table.':'.$uid); + $params[] = 'tx_impexp[record][]=' . rawurlencode($table . ':' . $uid); } } } } } - return '?'.implode('&', $params); + return '?' . implode('&', $params); } - - - - - - /***************************************** * * Helper functions @@ -808,9 +794,9 @@ * @param string Key of element in ->clipData array * @return void */ - function removeElement($el) { + function removeElement($el) { unset($this->clipData[$this->current]['el'][$el]); - $this->changed=1; + $this->changed = 1; } /** @@ -820,9 +806,9 @@ * @return void * @access private */ - function saveClipboard() { + function saveClipboard() { global $BE_USER; - $BE_USER->pushModuleData('clipboard',$this->clipData); + $BE_USER->pushModuleData('clipboard', $this->clipData); } /** @@ -830,8 +816,8 @@ * * @return string "copy" or "cut" */ - function currentMode() { + function currentMode() { - return $this->clipData[$this->current]['mode']=='copy' ? 'copy' : 'cut'; + return $this->clipData[$this->current]['mode'] == 'copy' ? 'copy' : 'cut'; } /** @@ -840,19 +826,19 @@ * * @return void */ - function cleanCurrent() { + function cleanCurrent() { - if (is_array($this->clipData[$this->current]['el'])) { + if (is_array($this->clipData[$this->current]['el'])) { foreach ($this->clipData[$this->current]['el'] as $k => $v) { - list($table,$uid) = explode('|',$k); + list($table, $uid) = explode('|', $k); - if ($table!='_FILE') { + if ($table != '_FILE') { - if (!$v || !is_array(t3lib_BEfunc::getRecord($table,$uid,'uid'))) { + if (!$v || !is_array(t3lib_BEfunc::getRecord($table, $uid, 'uid'))) { unset($this->clipData[$this->current]['el'][$k]); - $this->changed=1; + $this->changed = 1; } } else { - if (!$v || !file_exists($v)) { + if (!$v || !file_exists($v)) { unset($this->clipData[$this->current]['el'][$k]); - $this->changed=1; + $this->changed = 1; } } } @@ -866,20 +852,20 @@ * @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='') { + function elFromTable($matchTable = '', $pad = '') { $pad = $pad ? $pad : $this->current; - $list=array(); + $list = array(); - if (is_array($this->clipData[$pad]['el'])) { + if (is_array($this->clipData[$pad]['el'])) { foreach ($this->clipData[$pad]['el'] as $k => $v) { - if ($v) { + if ($v) { - list($table,$uid) = explode('|',$k); + list($table, $uid) = explode('|', $k); - if ($table!='_FILE') { + if ($table != '_FILE') { - if ((!$matchTable || (string)$table==(string)$matchTable) && $GLOBALS['TCA'][$table]) { + if ((!$matchTable || (string) $table == (string) $matchTable) && $GLOBALS['TCA'][$table]) { - $list[$k]= ($pad=='normal'?$v:$uid); + $list[$k] = ($pad == 'normal' ? $v : $uid); } } else { - if ((string)$table==(string)$matchTable) { + if ((string) $table == (string) $matchTable) { - $list[$k]=$v; + $list[$k] = $v; } } } @@ -896,9 +882,9 @@ * @param integer Element uid (path for files) * @return string */ - function isSelected($table,$uid) { + function isSelected($table, $uid) { - $k=$table.'|'.$uid; + $k = $table . '|' . $uid; - return $this->clipData[$this->current]['el'][$k] ? ($this->current=='normal'?$this->currentMode():1) : ''; + return $this->clipData[$this->current]['el'][$k] ? ($this->current == 'normal' ? $this->currentMode() : 1) : ''; } /** @@ -910,15 +896,15 @@ * @param integer Element uid * @return array Element record with extra field _RECORD_TITLE set to the title of the record... */ - function getSelectedRecord($table='',$uid='') { + function getSelectedRecord($table = '', $uid = '') { - if (!$table && !$uid) { + if (!$table && !$uid) { $elArr = $this->elFromTable(''); reset($elArr); - list($table,$uid) = explode('|',key($elArr)); + list($table, $uid) = explode('|', key($elArr)); } - if ($this->isSelected($table,$uid)) { + if ($this->isSelected($table, $uid)) { - $selRec = t3lib_BEfunc::getRecordWSOL($table,$uid); + $selRec = t3lib_BEfunc::getRecordWSOL($table, $uid); - $selRec['_RECORD_TITLE'] = t3lib_BEfunc::getRecordTitle($table,$selRec); + $selRec['_RECORD_TITLE'] = t3lib_BEfunc::getRecordTitle($table, $selRec); return $selRec; } } @@ -928,24 +914,11 @@ * * @return boolean True if elements exist. */ - function isElements() { + function isElements() { return is_array($this->clipData[$this->current]['el']) && count($this->clipData[$this->current]['el']); } - - - - - - - - - - - - - /***************************************** * * FOR USE IN tce_db.php: @@ -957,35 +930,39 @@ * $ref is the target, see description below. * The current pad is pasted * - * $ref: [tablename]:[paste-uid]. + * $ref: [tablename]:[paste-uid]. - * tablename is the name of the table from which elements *on the current clipboard* is pasted with the 'pid' paste-uid. + * tablename is the name of the table from which elements *on the current clipboard* is pasted with the 'pid' paste-uid. - * No tablename means that all items on the clipboard (non-files) are pasted. This requires paste-uid to be positive though. + * No tablename means that all items on the clipboard (non-files) are pasted. This requires paste-uid to be positive though. - * so 'tt_content:-3' means 'paste tt_content elements on the clipboard to AFTER tt_content:3 record + * so 'tt_content:-3' means 'paste tt_content elements on the clipboard to AFTER tt_content:3 record - * 'tt_content:30' means 'paste tt_content elements on the clipboard into page with id 30 + * 'tt_content:30' means 'paste tt_content elements on the clipboard into page with id 30 - * ':30' means 'paste ALL database elements on the clipboard into page with id 30 + * ':30' means 'paste ALL database elements on the clipboard into page with id 30 - * ':-30' not valid. + * ':-30' not valid. * * @param string [tablename]:[paste-uid], see description * @param array Command-array * @return array Modified Command-array */ - function makePasteCmdArray($ref,$CMD) { + function makePasteCmdArray($ref, $CMD) { - list($pTable,$pUid) = explode('|',$ref); + list($pTable, $pUid) = explode('|', $ref); $pUid = intval($pUid); - 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) + 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) $elements = $this->elFromTable($pTable); - $elements = array_reverse($elements); // So the order is preserved. + $elements = array_reverse($elements); // So the order is preserved. - $mode = $this->currentMode()=='copy' ? 'copy' : 'move'; + $mode = $this->currentMode() == 'copy' ? 'copy' : 'move'; // Traverse elements and make CMD array foreach ($elements as $tP => $value) { - list($table,$uid) = explode('|',$tP); + list($table, $uid) = explode('|', $tP); - if (!is_array($CMD[$table])) $CMD[$table]=array(); + if (!is_array($CMD[$table])) { + $CMD[$table] = array(); + } - $CMD[$table][$uid][$mode]=$pUid; + $CMD[$table][$uid][$mode] = $pUid; - if ($mode=='move') $this->removeElement($tP); + if ($mode == 'move') { + $this->removeElement($tP); - } + } + } $this->endClipboard(); } return $CMD; @@ -997,12 +974,14 @@ * @param array Command-array * @return array Modified Command-array */ - function makeDeleteCmdArray($CMD) { + function makeDeleteCmdArray($CMD) { - $elements = $this->elFromTable(''); // all records + $elements = $this->elFromTable(''); // all records foreach ($elements as $tP => $value) { - list($table,$uid) = explode('|',$tP); + list($table, $uid) = explode('|', $tP); - if (!is_array($CMD[$table])) $CMD[$table]=array(); + if (!is_array($CMD[$table])) { + $CMD[$table] = array(); + } - $CMD[$table][$uid]['delete']=1; + $CMD[$table][$uid]['delete'] = 1; $this->removeElement($tP); } $this->endClipboard(); @@ -1010,21 +989,6 @@ } - - - - - - - - - - - - - - - /***************************************** * * FOR USE IN tce_file.php: @@ -1039,16 +1003,18 @@ * @param array Command-array * @return array Modified Command-array */ - function makePasteCmdArray_file($ref,$FILE) { + function makePasteCmdArray_file($ref, $FILE) { - list($pTable,$pUid) = explode('|',$ref); + list($pTable, $pUid) = explode('|', $ref); $elements = $this->elFromTable('_FILE'); - $mode = $this->currentMode()=='copy' ? 'copy' : 'move'; + $mode = $this->currentMode() == 'copy' ? 'copy' : 'move'; // Traverse elements and make CMD array foreach ($elements as $tP => $path) { - $FILE[$mode][]=array('data'=>$path,'target'=>$pUid,'altName'=>1); + $FILE[$mode][] = array('data' => $path, 'target' => $pUid, 'altName' => 1); - if ($mode=='move') $this->removeElement($tP); + if ($mode == 'move') { + $this->removeElement($tP); - } + } + } $this->endClipboard(); return $FILE; @@ -1060,11 +1026,11 @@ * @param array Command-array * @return array Modified Command-array */ - function makeDeleteCmdArray_file($FILE) { + function makeDeleteCmdArray_file($FILE) { $elements = $this->elFromTable('_FILE'); // Traverse elements and make CMD array foreach ($elements as $tP => $path) { - $FILE['delete'][]=array('data'=>$path); + $FILE['delete'][] = array('data' => $path); $this->removeElement($tP); } $this->endClipboard(); @@ -1074,8 +1040,7 @@ } - -if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_clipboard.php']) { +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']); }