* Add filemanager actions to convert editable files to PDF or PNG

This commit is contained in:
nathan 2021-09-28 14:48:25 -06:00
parent f6828a8205
commit 2a4faf0137
2 changed files with 24 additions and 11 deletions

View File

@ -2440,17 +2440,9 @@ abstract class Merge
$target = $_target = (Vfs::is_writable(Vfs::get_home_dir()) ?
Vfs::get_home_dir() :
"/home/{$GLOBALS['egw_info']['user']['account_lid']}"
)."/$filename";
$dupe_count = 0;
while(is_file(Vfs::PREFIX.$target))
{
$dupe_count++;
$target = Vfs::dirname($_target) . '/' .
pathinfo($filename, PATHINFO_FILENAME) .
' ('.($dupe_count + 1).')' . '.' .
pathinfo($filename, PATHINFO_EXTENSION);
}
copy($result, Vfs::PREFIX.$target);
) . "/$filename";
$target = Vfs::make_unique($target);
copy($result, Vfs::PREFIX . $target);
unlink($result);
// Find out what to do with it

View File

@ -2386,6 +2386,27 @@ class Vfs extends Vfs\Base
}
return self::_call_on_backend('get_minimum_file_id', array($path));
}
/**
* Make sure the path is unique, by appending (#) to the filename if it already exists
*
* @param string $path
*
* @return string The same path, but modified if it exists
*/
static function make_unique($path)
{
$dupe_count = 0;
while(is_file(Vfs::PREFIX . $path))
{
$dupe_count++;
$path = Vfs::dirname($path) . '/' .
pathinfo($path, PATHINFO_FILENAME) .
' (' . ($dupe_count + 1) . ')' . '.' .
pathinfo($path, PATHINFO_EXTENSION);
}
return $path;
}
}
Vfs::init_static();