Feature #15440 » typo3-dragdrop.patch
alt_clickmenu.php 18 Jan 2006 00:35:06 -0000 | ||
---|---|---|
ini_set('display_errors',0); // XML has to be parsed, no parse errors allowed
|
||
}
|
||
// Deal with Drag&Drop context menus
|
||
if (strcmp(t3lib_div::_GP('dragDrop'),'')) {
|
||
$this->iParts[0] = t3lib_div::_GP('dragDrop');
|
||
$this->iParts[1] = t3lib_div::_GP('srcId');
|
||
$this->iParts[2] = t3lib_div::_GP('dstId');
|
||
$CMcontent = $this->printDragDropClickMenu($this->iParts[0],$this->iParts[1],$this->iParts[2]);
|
||
return $CMcontent;
|
||
}
|
||
|
||
// can be set differently as well
|
||
$this->iParts[0] = t3lib_div::_GP('table');
|
||
$this->iParts[1] = t3lib_div::_GP('uid');
|
||
... | ... | |
/***************************************
|
||
*
|
||
* DRAG'N DROP
|
||
*
|
||
***************************************/
|
||
/**
|
||
* Make 1st level clickmenu:
|
||
*
|
||
* @param string The absolute path
|
||
* @param integer UID for the current record.
|
||
* @return string HTML content
|
||
*/
|
||
function printDragDropClickMenu($table,$srcId,$dstId) {
|
||
$menuItems=array();
|
||
// If the drag and drop menu should apply to PAGES use this set of menu items
|
||
if ($table == 'pages') {
|
||
// Move Into:
|
||
$menuItems['movePage_into']=$this->DRAGDROP_copymovepage($srcId,$dstId,'move','into');
|
||
// Move After:
|
||
$menuItems['movePage_after']=$this->DRAGDROP_copymovepage($srcId,$dstId,'move','after');
|
||
// Copy Into:
|
||
$menuItems['copyPage_into']=$this->DRAGDROP_copymovepage($srcId,$dstId,'copy','into');
|
||
// Copy After:
|
||
$menuItems['copyPage_after']=$this->DRAGDROP_copymovepage($srcId,$dstId,'copy','after');
|
||
}
|
||
|
||
// If the drag and drop menu should apply to FOLDERS use this set of menu items
|
||
if ($table == 'folders') {
|
||
// Move Into:
|
||
$menuItems['moveFolder_into']=$this->DRAGDROP_copymovefolder($srcId,$dstId,'move');
|
||
// Copy Into:
|
||
$menuItems['copyFolder_into']=$this->DRAGDROP_copymovefolder($srcId,$dstId,'copy');
|
||
}
|
||
// Adding external elements to the menuItems array
|
||
$menuItems = $this->processingByExtClassArray($menuItems,"dragDrop_".$table,$uid); // to extend this, you need to apply a Context Menu to a "virtual" table called "dragDrop_pages" or similar
|
||
// Processing by external functions?
|
||
$menuItems = $this->externalProcessingOfDBMenuItems($menuItems);
|
||
// Return the printed elements:
|
||
return $this->printItems($menuItems,
|
||
$root?
|
||
'<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' class="absmiddle" alt="" />'.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']):
|
||
t3lib_iconWorks::getIconImage($table,$this->rec,$this->PH_backPath,' class="absmiddle" title="'.htmlspecialchars(t3lib_BEfunc::getRecordIconAltText($this->rec,$table)).'"').t3lib_BEfunc::getRecordTitle($table,$this->rec,1)
|
||
);
|
||
}
|
||
/**
|
||
* Processing the $menuItems array (for extension classes) (DRAG'N DROP)
|
||
*
|
||
* @param array $menuItems array for manipulation.
|
||
* @return array Processed $menuItems array
|
||
*/
|
||
function externalProcessingOfDragDropMenuItems($menuItems) {
|
||
return $menuItems;
|
||
}
|
||
/**
|
||
* Adding CM element for Copying/Moving a Page Into/After from a drag & drop action
|
||
*
|
||
* @param integer source UID code for the record to modify
|
||
* @param integer destination UID code for the record to modify
|
||
* @param string Action code: either "move" or "copy"
|
||
* @param string Parameter code: either "into" or "after"
|
||
* @return array Item array, element in $menuItems
|
||
* @internal
|
||
*/
|
||
function DRAGDROP_copymovepage($srcUid,$dstUid,$action,$into) {
|
||
$negativeSign = ($into == 'into') ? '' : '-';
|
||
$editOnClick='';
|
||
$loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
|
||
$editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_db.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
|
||
'&cmd[pages]['.$srcUid.']['.$action.']='.$negativeSign.$dstUid.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
|
||
return $this->linkItem(
|
||
$this->label($action.'Page_'.$into),
|
||
$this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$action.'_page_'.$into.'.gif','width="11" height="12"').' alt="" />'),
|
||
$editOnClick.'return false;',
|
||
0
|
||
);
|
||
}
|
||
/**
|
||
* Adding CM element for Copying/Moving a Folder Into from a drag & drop action
|
||
*
|
||
* @param string source path for the record to modify
|
||
* @param string destination path for the records to modify
|
||
* @param string Action code: either "move" or "copy"
|
||
* @return array Item array, element in $menuItems
|
||
* @internal
|
||
*/
|
||
function DRAGDROP_copymovefolder($srcPath,$dstPath,$action) {
|
||
$editOnClick='';
|
||
$loc='top.content'.($this->listFrame && !$this->alwaysContentFrame ?'.list_frame':'');
|
||
$editOnClick='if('.$loc.'){'.$loc.'.document.location=top.TS.PATH_typo3+"tce_file.php?redirect="+top.rawurlencode('.$this->frameLocation($loc.'.document').')+"'.
|
||
'&file['.$action.'][0][data]='.$srcPath.'&file['.$action.'][0][target]='.$dstPath.'&prErr=1&vC='.$GLOBALS['BE_USER']->veriCode().'";hideCM();}';
|
||
return $this->linkItem(
|
||
$this->label($action.'Folder_into'),
|
||
$this->excludeIcon('<img'.t3lib_iconWorks::skinImg($this->PH_backPath,'gfx/'.$action.'_folder_into.gif','width="11" height="12"').' alt="" />'),
|
||
$editOnClick.'return false;',
|
||
0
|
||
);
|
||
}
|
||
alt_db_navframe.php 18 Jan 2006 00:35:06 -0000 | ||
---|---|---|
$thePageIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$thePageIcon.'</a>';
|
||
}
|
||
// Wrap icon in a drag/drop span.
|
||
$spanOnDrag = htmlspecialchars('return dragElement("'.$row['uid'].'")');
|
||
$spanOnDrop = htmlspecialchars('return dropElement("'.$row['uid'].'")');
|
||
$dragDropIcon = '<span id="dragIconID_'.$row['uid'].'" ondragstart="'.$spanOnDrag.'" onmousedown="'.$spanOnDrag.'" onmouseup="'.$spanOnDrop.'">'.$thePageIcon.'</span>';
|
||
// Add Page ID:
|
||
if ($this->ext_showPageId) {
|
||
$pageIdStr = '['.$row['uid'].'] ';
|
||
... | ... | |
$pageIdStr = '';
|
||
}
|
||
return $thePageIcon.$lockIcon.$pageIdStr;
|
||
return $dragDropIcon.$lockIcon.$pageIdStr;
|
||
}
|
||
/**
|
||
... | ... | |
if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler']) {
|
||
$CSM = ' oncontextmenu="'.htmlspecialchars($GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon('','pages',$row['uid'],0,'&bank='.$this->bank,'',TRUE)).'"';
|
||
}
|
||
return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'"'.$CSM.'>'.$title.'</a>';
|
||
$thePageTitle='<a href="#" onclick="'.htmlspecialchars($aOnClick).'"'.$CSM.'>'.$title.'</a>';
|
||
// Wrap title in a drag/drop span.
|
||
$spanOnDrag = htmlspecialchars('return dragElement("'.$row['uid'].'")');
|
||
$spanOnDrop = htmlspecialchars('return dropElement("'.$row['uid'].'")');
|
||
$dragDropTitle = '<span id="dragTitleID_'.$row['uid'].'" ondragstart="'.$spanOnDrag.'" onmousedown="'.$spanOnDrag.'" onmouseup="'.$spanOnDrop.'">'.$thePageTitle.'</span>';
|
||
return $dragDropTitle;
|
||
}
|
||
}
|
||
... | ... | |
$this->doc->bodyTagAdditions = $CMparts[1];
|
||
$this->doc->JScode.= $CMparts[0];
|
||
$this->doc->postCode.= $CMparts[2];
|
||
// Drag and Drop code is added:
|
||
$DDparts=$this->doc->getDragDropCode('pages');
|
||
// ignore the $DDparts[1] for now
|
||
$this->doc->JScode.= $DDparts[0];
|
||
$this->doc->postCode.= $DDparts[2];
|
||
}
|
||
/**
|
alt_file_navframe.php 18 Jan 2006 00:35:06 -0000 | ||
---|---|---|
$this->doc->bodyTagAdditions = $CMparts[1];
|
||
$this->doc->JScode.=$CMparts[0];
|
||
$this->doc->postCode.= $CMparts[2];
|
||
// Drag and Drop code is added:
|
||
$DDparts=$this->doc->getDragDropCode('folders');
|
||
// ignore the $DDparts[1] for now
|
||
$this->doc->JScode.= $DDparts[0];
|
||
$this->doc->postCode.= $DDparts[2];
|
||
}
|
||
/**
|
template.php 18 Jan 2006 00:35:07 -0000 | ||
---|---|---|
}
|
||
/**
|
||
* Returns an array with parts (JavaScript, init-functions, <div>-layers) for use on pages which have the drag and drop functionality (usually pages and folder display trees)
|
||
*
|
||
* @param string indicator of which table the drag and drop function should work on (pages or folders)
|
||
* @return array If values are present: [0] = A <script> section for the HTML page header, [1] = onmousemove/onload handler for HTML tag or alike, [2] = One empty <div> layer for the follow-mouse drag element
|
||
*/
|
||
function getDragDropCode($table) {
|
||
$content = '
|
||
<script type="text/javascript">
|
||
/*<![CDATA[*/
|
||
';
|
||
if ($this->isCMlayers()) {
|
||
$content.= '
|
||
var dragID = null;
|
||
var dragIconCSS = null;
|
||
function cancelDragEvent(event) {
|
||
dragID = null;
|
||
dragIconCSS.visibility = "hidden";
|
||
document.onmouseup = null;
|
||
document.onmousemove = null;
|
||
}
|
||
function mouseMoveEvent (event) {
|
||
dragIconCSS.left = GLV_x+5+"px";
|
||
dragIconCSS.top = GLV_y-5+"px";
|
||
dragIconCSS.visibility = "visible";
|
||
return false;
|
||
}
|
||
function dragElement(id) {
|
||
dragID = id;
|
||
document.getElementById("dragIcon").innerHTML=document.getElementById("dragIconID_"+dragID).innerHTML + document.getElementById("dragTitleID_"+dragID).getElementsByTagName("a")[0].innerHTML;
|
||
dragIconCSS = new GL_getObjCss("dragIcon");
|
||
dragIconCSS.whiteSpace = "nowrap";
|
||
document.onmouseup = cancelDragEvent;
|
||
document.onmousemove = mouseMoveEvent;
|
||
return false;
|
||
}
|
||
function dropElement(id) {
|
||
if ((dragID != null) && (dragID != id)) {
|
||
var url = "'.$this->backPath.'alt_clickmenu.php?dragDrop='.$table.'"
|
||
+ "&srcId=" + dragID
|
||
+ "&dstId=" + id
|
||
+ "&backPath='.t3lib_div::shortMD5(''.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']).'";
|
||
showClickmenu_raw(url);
|
||
}
|
||
cancelDragEvent();
|
||
return false;
|
||
}
|
||
';
|
||
}
|
||
else {
|
||
$content.= '
|
||
function dragElement(id) { return false; }
|
||
function dropElement(id) { return false; }
|
||
';
|
||
}
|
||
$content.='
|
||
/*]]>*/
|
||
</script>';
|
||
|
||
if ($this->isCMlayers()) {
|
||
return array(
|
||
$content,
|
||
'',
|
||
'<div id="dragIcon" style="z-index:1;position:absolute;visibility:hidden;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;"><img src="" width="18" height="16"></div>'
|
||
);
|
||
} else {
|
||
return array($content,'','');
|
||
}
|
||
}
|
||
/**
|
||
* Creates a tab menu from an array definition
|
||
*
|
||
* Returns a tab menu for a module
|
sysext/lang/locallang_core.xml 18 Jan 2006 00:35:08 -0000 | ||
---|---|---|
<label index="cm.info">Info</label>
|
||
<label index="cm.createnew">Create new</label>
|
||
<label index="cm.tempMountPoint">Mount as treeroot</label>
|
||
<label index="cm.copyPage_into">Copy page into</label>
|
||
<label index="cm.copyPage_after">Copy page after</label>
|
||
<label index="cm.movePage_into">Move page into</label>
|
||
<label index="cm.movePage_after">Move page after</label>
|
||
<label index="cm.copyFolder_into">Copy folder into</label>
|
||
<label index="cm.moveFolder_into">Move folder into</label>
|
||
</languageKey>
|
||
<languageKey index="dk">EXT:csh_dk/lang/dk.locallang_core.xml</languageKey>
|
||
<languageKey index="de">EXT:csh_de/lang/de.locallang_core.xml</languageKey>
|