forked from extern/egroupware
Changes to file merge
- Remove accidentally committed debug - Make URL into web-accessable URL - Add clickable link placeholder - Format custom field date/times according to user preference - Add rel_path placeholder, includes path+name relative to current directory
This commit is contained in:
parent
92e3a83be1
commit
019bfb1c93
@ -36,13 +36,22 @@ class filemanager_merge extends bo_merge
|
||||
*/
|
||||
protected $bo = null;
|
||||
|
||||
/**
|
||||
* Current directory - affects how files are named
|
||||
*/
|
||||
protected $dir = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*/
|
||||
function __construct()
|
||||
function __construct($_dir = '')
|
||||
{
|
||||
parent::__construct();
|
||||
if($_dir)
|
||||
{
|
||||
$this->dir = $_dir;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,6 +88,7 @@ class filemanager_merge extends bo_merge
|
||||
$file['name'] = egw_vfs::basename($id);
|
||||
$file['dir'] = egw_vfs::decodePath(egw_vfs::dirname($id));
|
||||
$file['path'] = $id;
|
||||
$file['rel_path'] = str_replace($this->dir.'/', '', $id);
|
||||
$file['hsize'] = egw_vfs::hsize($file['size']);
|
||||
$file['mime'] = egw_vfs::mime_content_type($id);
|
||||
$file['gid'] *= -1; // our widgets use negative gid's
|
||||
@ -92,17 +102,28 @@ class filemanager_merge extends bo_merge
|
||||
}
|
||||
$extra = egw_vfs::getExtraInfo($id);
|
||||
|
||||
// Convert to human friendly values
|
||||
// Custom fields
|
||||
if($content && strpos($content, '#') !== 0)
|
||||
{
|
||||
// Expand link-to custom fields
|
||||
$this->cf_link_to_expand($file, $content, $info);
|
||||
}
|
||||
|
||||
foreach(config::get_customfields('filemanager') as $name => $field)
|
||||
{
|
||||
// Set any missing custom fields, or the marker will stay
|
||||
if(!$file['#'.$name])
|
||||
{
|
||||
$file['#'.$name] = '';
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set any missing custom fields, or the marker will stay
|
||||
foreach(config::get_customfields('filemanager') as $name => $field)
|
||||
{
|
||||
if(!$file['#'.$name]) $file['#'.$name] = '';
|
||||
}
|
||||
// Format date cfs per user preferences
|
||||
if($field['type'] == 'date' || $field['type'] == 'date-time')
|
||||
{
|
||||
$file['#'.$name] = egw_time::to($file['#'.$name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Links
|
||||
/* Not applicable to filemanager
|
||||
@ -114,6 +135,15 @@ class filemanager_merge extends bo_merge
|
||||
$file["links/{$app}"] = $this->get_links('filemanager',$id, $app);
|
||||
}
|
||||
*/
|
||||
$link = egw_link::mime_open($file['url'], $file['mime']);
|
||||
// Prepend site
|
||||
if ($link{0} == '/')
|
||||
{
|
||||
$link = ($_SERVER['HTTPS'] || $GLOBALS['egw_info']['server']['enforce_ssl'] ? 'https://' : 'http://').
|
||||
($GLOBALS['egw_info']['server']['hostname'] ? $GLOBALS['egw_info']['server']['hostname'] : $_SERVER['HTTP_HOST']).$link;
|
||||
}
|
||||
$file['link'] = html::a_href(html::htmlspecialchars($file['name']), $link);
|
||||
$file['url'] = $link;
|
||||
|
||||
// Add markers
|
||||
foreach($file as $key => &$value)
|
||||
@ -140,8 +170,10 @@ class filemanager_merge extends bo_merge
|
||||
$n = 0;
|
||||
$fields = array(
|
||||
'name' => 'name',
|
||||
'path' => 'path',
|
||||
'path' => 'Absolute path',
|
||||
'rel_path' => 'Path relative to current directory',
|
||||
'url' => 'url',
|
||||
'link' => 'Clickable link to file',
|
||||
'comment' => 'comment',
|
||||
'mtime' => 'modified',
|
||||
'ctime' => 'created',
|
||||
|
@ -737,7 +737,7 @@ function force_download(_action, _senders)
|
||||
return $ret." egw_vfs::symlink('$to','$path')";
|
||||
case 'document':
|
||||
if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
|
||||
$document_merge = new filemanager_merge();
|
||||
$document_merge = new filemanager_merge(egw_vfs::decodePath($dir));
|
||||
$msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']);
|
||||
$failed = count($selected);
|
||||
return false;
|
||||
@ -1244,12 +1244,8 @@ function force_download(_action, _senders)
|
||||
'align' => 'right',
|
||||
));
|
||||
}
|
||||
echo 'HERE';
|
||||
_debug_array($path);
|
||||
_debug_array($content);
|
||||
if (($extra_tabs = egw_vfs::getExtraInfo($path,$content)))
|
||||
{
|
||||
_debug_array($extra_tabs);
|
||||
$tabs =& $tpl->get_widget_by_name('tabs=general|perms|eacl|preview|custom');
|
||||
foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user