* New feature: cross-application document merge in filemanager GUI

This commit is contained in:
Christian Binder 2012-10-27 11:38:47 +00:00
parent f7cc51ad18
commit 3e72371fd7
2 changed files with 94 additions and 5 deletions

View File

@ -35,6 +35,12 @@ class filemanager_ui
); );
public static $views_init = false; public static $views_init = false;
/**
* vfs namespace for document merge properties
*
*/
public static $merge_prop_namespace = '';
/** /**
* Constructor * Constructor
* *
@ -53,6 +59,7 @@ class filemanager_ui
} }
self::init_views(); self::init_views();
self::$merge_prop_namespace = egw_vfs::DEFAULT_PROP_NAMESPACE.$GLOBALS['egw_info']['flags']['currentapp'];
} }
/** /**
@ -170,6 +177,44 @@ class filemanager_ui
return $actions; return $actions;
} }
/**
* Get mergeapp property for given path
*
* @param string $path
* @param string $scope='self' (default) or 'parents'
* $scope == 'self' query only the given path
* $scope == 'parents' query only path parents for property (first parent in hierarchy upwards wins)
*
* @return string merge application or NULL if no property found
*/
private static function get_mergeapp($path, $scope='self')
{
$app = null;
switch($scope)
{
case 'self':
$props = egw_vfs::propfind($path, self::$merge_prop_namespace);
$app = empty($props) ? null : $props[0]['val'];
break;
case 'parents':
// search for props in parent directories
$currentpath = $path;
while($dir = egw_vfs::dirname($currentpath))
{
$props = egw_vfs::propfind($dir, self::$merge_prop_namespace);
if(!empty($props))
{
// found prop in parent directory
return $app = $props[0]['val'];
}
$currentpath = $dir;
}
break;
}
return $app;
}
/** /**
* Main filemanager page * Main filemanager page
* *
@ -1060,6 +1105,25 @@ function force_download(_action, _senders)
{ {
$props[] = array('name' => $name, 'val' => $content[$name] ? $content[$name] : null); $props[] = array('name' => $name, 'val' => $content[$name] ? $content[$name] : null);
} }
elseif ($name == 'mergeapp')
{
$mergeprop = array(
array(
'ns' => self::$merge_prop_namespace,
'name' => 'mergeapp',
'val' => (!empty($content[$name]) ? $content[$name] : null),
),
);
if (egw_vfs::proppatch($path,$mergeprop))
{
$content['old'][$name] = $content[$name];
$msg .= lang('Setting for document merge saved.');
}
else
{
$msg .= lang('Saving setting for document merge failed!');
}
}
else else
{ {
static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod'); static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod');
@ -1223,7 +1287,31 @@ function force_download(_action, _senders)
0 => lang('No access'), 0 => lang('No access'),
); );
} }
$sel_options['mergeapp']= egw_link::app_list('merge');
// mergeapp
$content['mergeapp'] = self::get_mergeapp($path, 'self');
$content['mergeapp_parent'] = self::get_mergeapp($path, 'parents');
if(!empty($content['mergeapp']))
{
$content['mergeapp_effective'] = $content['mergeapp'];
}
elseif(!empty($content['mergeapp_parent']))
{
$content['mergeapp_effective'] = $content['mergeapp_parent'];
}
else
{
$content['mergeapp_effective'] = null;
}
// mergeapp select options
$mergeapp_list = egw_link::app_list('merge');
$mergeapp_empty = !empty($content['mergeapp_parent'])
? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : '';
$sel_options['mergeapp'] = array('' => $mergeapp_empty);
$sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list;
// mergeapp other gui options
$content['mergeapp_itempicker_disabled'] = $content['is_dir'] || empty($content['mergeapp_effective']);
$preserve = $content; $preserve = $content;
if (!isset($preserve['old'])) if (!isset($preserve['old']))
{ {
@ -1233,6 +1321,7 @@ function force_download(_action, _senders)
'uid' => $content['uid'], 'uid' => $content['uid'],
'gid' => $content['gid'], 'gid' => $content['gid'],
'comment' => (string)$content['comment'], 'comment' => (string)$content['comment'],
'mergeapp' => $content['mergeapp']
); );
if ($cfs) foreach($cfs as $name => $data) if ($cfs) foreach($cfs as $name => $data)
{ {

View File

@ -209,9 +209,9 @@
<column/> <column/>
</columns> </columns>
<rows> <rows>
<row> <row disabled="@mergeapp_itempicker_disabled">
<hbox> <hbox>
<itempicker id="itempicker_merge" application="calendar,infolog,projectmanager" action="itempickerDocumentAction" action_label="Merge"/> <itempicker id="itempicker_merge" application="@mergeapp_effective" action="itempickerDocumentAction" action_label="Merge"/>
</hbox> </hbox>
</row> </row>
<row> <row>
@ -226,13 +226,13 @@
<row disabled="@is_dir"> <row disabled="@is_dir">
<description value="Items of the selected application can be inserted into this document"/> <description value="Items of the selected application can be inserted into this document"/>
<menulist> <menulist>
<menupopup id="merge[mergeapp]"/> <menupopup id="mergeapp"/>
</menulist> </menulist>
</row> </row>
<row disabled="!@is_dir"> <row disabled="!@is_dir">
<description value="Items of the selected application can be inserted into files of this directory"/> <description value="Items of the selected application can be inserted into files of this directory"/>
<menulist> <menulist>
<menupopup id="merge[mergeapp]"/> <menupopup id="mergeapp"/>
</menulist> </menulist>
</row> </row>
</rows> </rows>