function dragDataGet( $tree, $context, $selection_data, $info, $time) {
if( count( $tree->selection) < 1) { return false; }
$node = $tree->selection[0];
$file = $tree->node_get_text( $node, 2);
if( $file == '') { return false; }
$selection_data->set($selection_data->target, 8, urlencode($this->getUriFromFile($file)) . "\r\n");
}
/**
* converts a file name to a URI
* useful to convert a file to the text/uri-list compatible format
* @param string The file
* @return string The URI
*/
function getUriFromFile( $strFile) {
if (strstr($strFile, '://')) {
//real URL
$strUri = $strFile;
} else {
//normal file
if (substr($strFile, 1, 2) == ':\\') {
//windows path c:\programs\bla\blu\file.bli
$strUri = 'file://localhost/' . str_replace('\\', '/', $strFile);
} else {
//should be nice unix file
//@fixme: convert relative names to absolute ones?
$strUri = 'file://localhost' . realpath($strFile);
}
}
return $strUri;
}
|