mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 04:29:28 +01:00
Add placeholder list for calendar & filemanager
This commit is contained in:
parent
417bbccbe3
commit
c73a7beac8
@ -227,8 +227,9 @@ export class et2_placeholder_select extends et2_inputWidget
|
|||||||
app.onchange = (node, widget) =>
|
app.onchange = (node, widget) =>
|
||||||
{
|
{
|
||||||
preview.set_value("");
|
preview.set_value("");
|
||||||
if(['user'].indexOf(widget.get_value()) >= 0)
|
if(['user', 'filemanager'].indexOf(widget.get_value()) >= 0)
|
||||||
{
|
{
|
||||||
|
// These ones don't let you select an entry for preview (they don't work)
|
||||||
entry.set_disabled(true);
|
entry.set_disabled(true);
|
||||||
entry.app_select.val('user');
|
entry.app_select.val('user');
|
||||||
entry.set_value({app: 'user', id: '', query: ''});
|
entry.set_value({app: 'user', id: '', query: ''});
|
||||||
|
@ -64,9 +64,13 @@ class Placeholder extends Etemplate\Widget
|
|||||||
|
|
||||||
if(is_null($apps))
|
if(is_null($apps))
|
||||||
{
|
{
|
||||||
$apps = ['addressbook', 'user', 'general'] +
|
$apps = array_merge(
|
||||||
|
['addressbook', 'user', 'general'],
|
||||||
// We use linking for preview, so limit to apps that support links
|
// We use linking for preview, so limit to apps that support links
|
||||||
array_keys(Api\Link::app_list('query'));
|
array_keys(Api\Link::app_list('query')),
|
||||||
|
// Filemanager doesn't support links, but add it anyway
|
||||||
|
['filemanager']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($apps as $appname)
|
foreach($apps as $appname)
|
||||||
@ -86,6 +90,8 @@ class Placeholder extends Etemplate\Widget
|
|||||||
// Looks like app doesn't support merging
|
// Looks like app doesn't support merging
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Api\Translation::load_app($appname, $GLOBALS['egw_info']['user']['preferences']['common']['lang']);
|
||||||
$list = method_exists($merge, 'get_placeholder_list') ? $merge->get_placeholder_list() : [];
|
$list = method_exists($merge, 'get_placeholder_list') ? $merge->get_placeholder_list() : [];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -26,15 +26,14 @@ class filemanager_merge extends Api\Storage\Merge
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $public_functions = array(
|
var $public_functions = array(
|
||||||
'show_replacements' => true,
|
'show_replacements' => true,
|
||||||
'merge_entries' => true
|
'merge_entries' => true
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fields that are numeric, for special numeric handling
|
* Fields that are numeric, for special numeric handling
|
||||||
*/
|
*/
|
||||||
protected $numeric_fields = array(
|
protected $numeric_fields = array();
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fields that are dates or timestamps
|
* Fields that are dates or timestamps
|
||||||
@ -74,12 +73,12 @@ class filemanager_merge extends Api\Storage\Merge
|
|||||||
* Get replacements
|
* Get replacements
|
||||||
*
|
*
|
||||||
* @param int $id id of entry
|
* @param int $id id of entry
|
||||||
* @param string &$content=null content to create some replacements only if they are use
|
* @param string &$content =null content to create some replacements only if they are use
|
||||||
* @return array|boolean
|
* @return array|boolean
|
||||||
*/
|
*/
|
||||||
protected function get_replacements($id,&$content=null)
|
protected function get_replacements($id, &$content = null)
|
||||||
{
|
{
|
||||||
if (!($replacements = $this->filemanager_replacements($id, '', $content)))
|
if(!($replacements = $this->filemanager_replacements($id, '', $content)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -90,58 +89,58 @@ class filemanager_merge extends Api\Storage\Merge
|
|||||||
* Get filemanager replacements
|
* Get filemanager replacements
|
||||||
*
|
*
|
||||||
* @param int $id id (vfs path) of entry
|
* @param int $id id (vfs path) of entry
|
||||||
* @param string $prefix='' prefix like eg. 'erole'
|
* @param string $prefix ='' prefix like eg. 'erole'
|
||||||
* @return array|boolean
|
* @return array|boolean
|
||||||
*/
|
*/
|
||||||
public function filemanager_replacements($id,$prefix='', &$content = null)
|
public function filemanager_replacements($id, $prefix = '', &$content = null)
|
||||||
{
|
{
|
||||||
$info = array();
|
$info = array();
|
||||||
$file = Vfs::lstat($id,true);
|
$file = Vfs::lstat($id, true);
|
||||||
|
|
||||||
$file['mtime'] = Api\DateTime::to($file['mtime']);
|
$file['mtime'] = Api\DateTime::to($file['mtime']);
|
||||||
$file['ctime'] = Api\DateTime::to($file['ctime']);
|
$file['ctime'] = Api\DateTime::to($file['ctime']);
|
||||||
|
|
||||||
$file['name'] = Vfs::basename($id);
|
$file['name'] = Vfs::basename($id);
|
||||||
$file['dir'] = ($dir = Vfs::dirname($id)) ? Vfs::decodePath($dir) : '';
|
$file['dir'] = ($dir = Vfs::dirname($id)) ? Vfs::decodePath($dir) : '';
|
||||||
$dirlist = explode('/',$file['dir']);
|
$dirlist = explode('/', $file['dir']);
|
||||||
$file['folder'] = array_pop($dirlist);
|
$file['folder'] = array_pop($dirlist);
|
||||||
$file['folder_file'] = $file['folder'] . '/'.$file['name'];
|
$file['folder_file'] = $file['folder'] . '/' . $file['name'];
|
||||||
$file['path'] = $id;
|
$file['path'] = $id;
|
||||||
$file['rel_path'] = str_replace($this->dir.'/', '', $id);
|
$file['rel_path'] = str_replace($this->dir . '/', '', $id);
|
||||||
$file['hsize'] = Vfs::hsize($file['size']);
|
$file['hsize'] = Vfs::hsize($file['size']);
|
||||||
$file['mime'] = Vfs::mime_content_type($id);
|
$file['mime'] = Vfs::mime_content_type($id);
|
||||||
$file['gid'] *= -1; // our widgets use negative gid's
|
$file['gid'] *= -1; // our widgets use negative gid's
|
||||||
if (($props = Vfs::propfind($id)))
|
if(($props = Vfs::propfind($id)))
|
||||||
{
|
{
|
||||||
foreach($props as $prop)
|
foreach($props as $prop)
|
||||||
{
|
{
|
||||||
$file[$prop['name']] = $prop['val'];
|
$file[$prop['name']] = $prop['val'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (($file['is_link'] = Vfs::is_link($id)))
|
if(($file['is_link'] = Vfs::is_link($id)))
|
||||||
{
|
{
|
||||||
$file['symlink'] = Vfs::readlink($id);
|
$file['symlink'] = Vfs::readlink($id);
|
||||||
}
|
}
|
||||||
// Custom fields
|
// Custom fields
|
||||||
if($content && strpos($content, '#') !== 0)
|
if($content && strpos($content, '#') !== 0)
|
||||||
{
|
{
|
||||||
// Expand link-to custom fields
|
// Expand link-to custom fields
|
||||||
$this->cf_link_to_expand($file, $content, $info);
|
$this->cf_link_to_expand($file, $content, $info);
|
||||||
|
|
||||||
foreach(Api\Storage\Customfields::get('filemanager') as $name => $field)
|
foreach(Api\Storage\Customfields::get('filemanager') as $name => $field)
|
||||||
{
|
{
|
||||||
// Set any missing custom fields, or the marker will stay
|
// Set any missing custom fields, or the marker will stay
|
||||||
if(!$file['#'.$name])
|
if(!$file['#' . $name])
|
||||||
{
|
{
|
||||||
$file['#'.$name] = '';
|
$file['#' . $name] = '';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format date cfs per user Api\Preferences
|
// Format date cfs per user Api\Preferences
|
||||||
if($field['type'] == 'date' || $field['type'] == 'date-time')
|
if($field['type'] == 'date' || $field['type'] == 'date-time')
|
||||||
{
|
{
|
||||||
$this->date_fields[] = '#'.$name;
|
$this->date_fields[] = '#' . $name;
|
||||||
$file['#'.$name] = Api\DateTime::to($file['#'.$name], $field['type'] == 'date' ? true : '');
|
$file['#' . $name] = Api\DateTime::to($file['#' . $name], $field['type'] == 'date' ? true : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,17 +149,19 @@ class filemanager_merge extends Api\Storage\Merge
|
|||||||
if($dirlist[1] == 'apps' && count($dirlist) > 1)
|
if($dirlist[1] == 'apps' && count($dirlist) > 1)
|
||||||
{
|
{
|
||||||
// Try this first - a normal path /apps/appname/id/file
|
// Try this first - a normal path /apps/appname/id/file
|
||||||
list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/')+5));
|
list($app, $app_id) = explode('/', substr($file['path'], strpos($file['path'], 'apps/') + 5));
|
||||||
// Symlink?
|
// Symlink?
|
||||||
if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) {
|
if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps']))
|
||||||
|
{
|
||||||
// Try resolving just app + ID - /apps/App Name/Record Title/file
|
// Try resolving just app + ID - /apps/App Name/Record Title/file
|
||||||
$resolved = Vfs::resolve_url_symlinks(implode('/',array_slice(explode('/',$file['dir']),0,4)));
|
$resolved = Vfs::resolve_url_symlinks(implode('/', array_slice(explode('/', $file['dir']), 0, 4)));
|
||||||
list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5));
|
list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/') + 5));
|
||||||
|
|
||||||
if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps'])) {
|
if(!$app || !(int)$app_id || !array_key_exists($app, $GLOBALS['egw_info']['user']['apps']))
|
||||||
|
{
|
||||||
// Get rid of any virtual folders (eg: All$) and symlinks
|
// Get rid of any virtual folders (eg: All$) and symlinks
|
||||||
$resolved = Vfs::resolve_url_symlinks($file['path']);
|
$resolved = Vfs::resolve_url_symlinks($file['path']);
|
||||||
list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/')+5));
|
list($app, $app_id) = explode('/', substr($resolved, strpos($resolved, 'apps/') + 5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($app && $app_id)
|
if($app && $app_id)
|
||||||
@ -170,7 +171,7 @@ class filemanager_merge extends Api\Storage\Merge
|
|||||||
$app_merge = null;
|
$app_merge = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$classname = $app .'_merge';
|
$classname = $app . '_merge';
|
||||||
if(class_exists($classname))
|
if(class_exists($classname))
|
||||||
{
|
{
|
||||||
$app_merge = new $classname();
|
$app_merge = new $classname();
|
||||||
@ -180,9 +181,10 @@ class filemanager_merge extends Api\Storage\Merge
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Silently discard & continue
|
// Silently discard & continue
|
||||||
catch(Exception $e) {
|
catch (Exception $e)
|
||||||
unset($e); // not used
|
{
|
||||||
|
unset($e); // not used
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,7 +213,7 @@ class filemanager_merge extends Api\Storage\Merge
|
|||||||
foreach($file as $key => &$value)
|
foreach($file as $key => &$value)
|
||||||
{
|
{
|
||||||
if(!$value) $value = '';
|
if(!$value) $value = '';
|
||||||
$info['$$'.($prefix ? $prefix.'/':'').$key.'$$'] = $value;
|
$info['$$' . ($prefix ? $prefix . '/' : '') . $key . '$$'] = $value;
|
||||||
}
|
}
|
||||||
if($app_placeholders)
|
if($app_placeholders)
|
||||||
{
|
{
|
||||||
@ -239,14 +241,18 @@ class filemanager_merge extends Api\Storage\Merge
|
|||||||
{
|
{
|
||||||
return $session;
|
return $session;
|
||||||
}
|
}
|
||||||
else if (($session = \EGroupware\Api\Cache::getSession(Api\Sharing::class, "$app::$id")) &&
|
else
|
||||||
substr($session['share_path'], -strlen($path)) === $path)
|
|
||||||
{
|
{
|
||||||
return $session;
|
if(($session = \EGroupware\Api\Cache::getSession(Api\Sharing::class, "$app::$id")) &&
|
||||||
|
substr($session['share_path'], -strlen($path)) === $path)
|
||||||
|
{
|
||||||
|
return $session;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Need to create the share here.
|
// Need to create the share here.
|
||||||
// No way to know here if it should be writable, or who it's going to
|
// No way to know here if it should be writable, or who it's going to
|
||||||
$mode = /* ? ? Sharing::WRITABLE :*/ Api\Sharing::READONLY;
|
$mode = /* ? ? Sharing::WRITABLE :*/
|
||||||
|
Api\Sharing::READONLY;
|
||||||
$recipients = array();
|
$recipients = array();
|
||||||
$extra = array();
|
$extra = array();
|
||||||
|
|
||||||
@ -302,24 +308,68 @@ class filemanager_merge extends Api\Storage\Merge
|
|||||||
|
|
||||||
echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>";
|
echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>";
|
||||||
foreach(array(
|
foreach(array(
|
||||||
'date' => lang('Date'),
|
'date' => lang('Date'),
|
||||||
'user/n_fn' => lang('Name of current user, all other contact fields are valid too'),
|
'user/n_fn' => lang('Name of current user, all other contact fields are valid too'),
|
||||||
'user/account_lid' => lang('Username'),
|
'user/account_lid' => lang('Username'),
|
||||||
'pagerepeat' => lang('For serial letter use this tag. Put the content, you want to repeat between two Tags.'),
|
'pagerepeat' => lang('For serial letter use this tag. Put the content, you want to repeat between two Tags.'),
|
||||||
'label' => lang('Use this tag for addresslabels. Put the content, you want to repeat, between two tags.'),
|
'label' => lang('Use this tag for addresslabels. Put the content, you want to repeat, between two tags.'),
|
||||||
'labelplacement' => lang('Tag to mark positions for address labels'),
|
'labelplacement' => lang('Tag to mark positions for address labels'),
|
||||||
'IF fieldname' => lang('Example {{IF n_prefix~Mr~Hello Mr.~Hello Ms.}} - search the field "n_prefix", for "Mr", if found, write Hello Mr., else write Hello Ms.'),
|
'IF fieldname' => lang('Example {{IF n_prefix~Mr~Hello Mr.~Hello Ms.}} - search the field "n_prefix", for "Mr", if found, write Hello Mr., else write Hello Ms.'),
|
||||||
'NELF' => lang('Example {{NELF role}} - if field role is not empty, you will get a new line with the value of field role'),
|
'NELF' => lang('Example {{NELF role}} - if field role is not empty, you will get a new line with the value of field role'),
|
||||||
'NENVLF' => lang('Example {{NENVLF role}} - if field role is not empty, set a LF without any value of the field'),
|
'NENVLF' => lang('Example {{NENVLF role}} - if field role is not empty, set a LF without any value of the field'),
|
||||||
'LETTERPREFIX' => lang('Example {{LETTERPREFIX}} - Gives a letter prefix without double spaces, if the title is empty for example'),
|
'LETTERPREFIX' => lang('Example {{LETTERPREFIX}} - Gives a letter prefix without double spaces, if the title is empty for example'),
|
||||||
'LETTERPREFIXCUSTOM' => lang('Example {{LETTERPREFIXCUSTOM n_prefix title n_family}} - Example: Mr Dr. James Miller'),
|
'LETTERPREFIXCUSTOM' => lang('Example {{LETTERPREFIXCUSTOM n_prefix title n_family}} - Example: Mr Dr. James Miller'),
|
||||||
) as $name => $label)
|
) as $name => $label)
|
||||||
{
|
{
|
||||||
echo '<tr><td>{{'.$name.'}}</td><td colspan="3">'.$label."</td></tr>\n";
|
echo '<tr><td>{{' . $name . '}}</td><td colspan="3">' . $label . "</td></tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
|
|
||||||
echo $GLOBALS['egw']->framework->footer();
|
echo $GLOBALS['egw']->framework->footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of placeholders provided.
|
||||||
|
*
|
||||||
|
* Placeholders are grouped logically. Group key should have a user-friendly translation.
|
||||||
|
*/
|
||||||
|
public function get_placeholder_list($prefix = '')
|
||||||
|
{
|
||||||
|
$placeholders = parent::get_placeholder_list($prefix);
|
||||||
|
|
||||||
|
$fields = array(
|
||||||
|
'name' => 'name',
|
||||||
|
'path' => 'Absolute path',
|
||||||
|
'rel_path' => 'Path relative to current directory',
|
||||||
|
'folder' => 'Containing folder',
|
||||||
|
'folder_file' => 'Containing folder and file name',
|
||||||
|
'url' => 'url',
|
||||||
|
'webdav_url' => 'External path using webdav',
|
||||||
|
'link' => 'Clickable link to file',
|
||||||
|
'comment' => 'comment',
|
||||||
|
'mtime' => 'modified',
|
||||||
|
'ctime' => 'created',
|
||||||
|
'mime' => 'Type',
|
||||||
|
'hsize' => 'Size',
|
||||||
|
'size' => 'Size (in bytes)',
|
||||||
|
);
|
||||||
|
$group = 'placeholders';
|
||||||
|
foreach($fields as $name => $label)
|
||||||
|
{
|
||||||
|
$marker = $this->prefix($prefix, $name, '{');
|
||||||
|
if(!array_filter($placeholders, function ($a) use ($marker)
|
||||||
|
{
|
||||||
|
return array_key_exists($marker, $a);
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
$placeholders[$group][] = [
|
||||||
|
'value' => $marker,
|
||||||
|
'label' => $label
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $placeholders;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user