mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 20:49:08 +01:00
modifications for the links via the new vfs/links stream wrapper
This commit is contained in:
parent
da4a19b7dc
commit
ea7ea8deb6
@ -1,15 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
/**
|
||||
* eGroupWare eTemplate Extension - Link Widgets / UI for the link class
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage extensions
|
||||
* @link http://www.egroupware.org
|
||||
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
/**
|
||||
* eTemplate Extension: several widgets as user-interface for the link-class
|
||||
*
|
||||
* All widgets use the link-registry, to "know" which apps use popups (and what size).
|
||||
@ -48,14 +49,9 @@
|
||||
*</code>
|
||||
*
|
||||
* This widget is independent of the UI as it only uses etemplate-widgets and has therefore no render-function.
|
||||
*
|
||||
* @package etemplate
|
||||
* @subpackage extensions
|
||||
* @author Ralf Becker <RalfBecker@outdoor-training.de>
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
*/
|
||||
class link_widget
|
||||
{
|
||||
class link_widget
|
||||
{
|
||||
/**
|
||||
* @var array exported methods of this class
|
||||
*/
|
||||
@ -204,18 +200,20 @@
|
||||
{
|
||||
$options .= " onMouseOver=\"self.status='".addslashes(html::htmlspecialchars($help))."'; return true;\"";
|
||||
$options .= " onMouseOut=\"self.status=''; return true;\"";
|
||||
|
||||
if (($popup = egw_link::is_popup($link['app'],'view')))
|
||||
{
|
||||
list($w,$h) = explode('x',$popup);
|
||||
$options = ' onclick="window.open(this,this.target,\'width='.(int)$w.',height='.(int)$h.',location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes\'); return false;"';
|
||||
}
|
||||
elseif ($GLOBALS['egw_info']['etemplate']['output_mode'] == 2) // we are in a popup
|
||||
elseif ($GLOBALS['egw_info']['etemplate']['output_mode'] == 2 || // we are in a popup
|
||||
$link['app'] == egw_link::VFS_APPNAME) // or it's a link to an attachment
|
||||
{
|
||||
$options = ' target="_blank"';
|
||||
}
|
||||
$str .= ($str !== '' ? ', ' : '') . html::a_href(
|
||||
html::htmlspecialchars(egw_link::title($link['app'],$link['id'])),
|
||||
'/index.php',egw_link::view($link['app'],$link['id'],$link),$options);
|
||||
egw_link::view($link['app'],$link['id'],$link),'',$options);
|
||||
}
|
||||
}
|
||||
$cell['type'] = 'html';
|
||||
@ -256,46 +254,9 @@
|
||||
$GLOBALS['egw_info']['flags']['include_xajax'] = true;
|
||||
if ($value['search_label'] && $extension_data['search_label'] != $value['search_label']) $value['search_label'] = lang($value['search_label']);
|
||||
$extension_data = $value;
|
||||
$tpl =& new etemplate('etemplate.link_widget.to');
|
||||
$tpl = new etemplate('etemplate.link_widget.to');
|
||||
if ($value['link_label']) $tpl->set_cell_attribute('create','label',$value['link_label']);
|
||||
if ($value['search_label']) $tpl->set_cell_attribute('search','label',$value['search_label']);
|
||||
/* old request code
|
||||
$value['msg'] = '';
|
||||
if ($value['button'] == 'search' && count($ids = egw_link::query($value['app'],$value['query'])))
|
||||
{
|
||||
$extension_data['app'] = $value['app'];
|
||||
|
||||
$value = $extension_data;
|
||||
$value['options-id'] = $ids;
|
||||
$value['remark'] = '';
|
||||
|
||||
$tpl =& new etemplate('etemplate.link_widget.create');
|
||||
if ($value['link_label'])
|
||||
{
|
||||
$tpl->set_cell_attribute('create','label',$value['link_label']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// error from search or upload
|
||||
$value['msg'] = $value['button'] == 'search' ? lang('Nothing found - try again !!!') : $extension_data['msg'];
|
||||
|
||||
if (!$value['button'])
|
||||
{
|
||||
$extension_data = $value;
|
||||
}
|
||||
$value = array_merge($extension_data,$value);
|
||||
$value['options-app'] = egw_link::app_list('query');
|
||||
asort($value['options-app']); // sort them alphabetic
|
||||
|
||||
$tpl =& new etemplate('etemplate.link_widget.search');
|
||||
if ($value['search_label'])
|
||||
{
|
||||
$tpl->set_cell_attribute('app','label',$value['search_label']);
|
||||
}
|
||||
$tpl->set_cell_attribute('comment','onchange',"set_style_by_class('*','hide_comment','display',this.checked ? 'block' : 'none');");
|
||||
unset($value['comment']);
|
||||
}*/
|
||||
break;
|
||||
|
||||
case 'link-list':
|
||||
@ -337,36 +298,43 @@
|
||||
}
|
||||
if ($link['app'] == egw_link::VFS_APPNAME)
|
||||
{
|
||||
$value[$row]['target'] = '_blank';
|
||||
$value[$row]['label'] = 'Delete';
|
||||
$value[$row]['help'] = lang('Delete this file');
|
||||
|
||||
// Get mimetype and thumbnail
|
||||
if(in_array($GLOBALS['egw_info']['user']['preferences']['common']['link_list_format'], array('icons', 'icons_and_text') )) {
|
||||
$value[$row]['mime_icon'] = ExecMethod2('filemanager.uifilemanager.mime_icon', $value[$row]['type']);
|
||||
if(in_array($GLOBALS['egw_info']['user']['preferences']['common']['link_list_format'], array('icons', 'icons_and_text') ))
|
||||
{
|
||||
list(,$icon) = explode('/',filemanager_ui::mime_icon($value[$row]['type']));
|
||||
$value[$row]['mime_icon'] = html::image('filemanager',$icon,lang('File').': '.$value[$row]['type']);
|
||||
}
|
||||
if($GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] && $GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) {
|
||||
if($GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] && $GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0)
|
||||
{
|
||||
list($image) = explode('/', $value[$row]['type']);
|
||||
if($image == 'image') {
|
||||
if($image == 'image')
|
||||
{
|
||||
$value[$row]['thumbnail'] = '<img src="' .
|
||||
$GLOBALS['egw_info']['server']['webserver_url'].
|
||||
'/etemplate/inc/thumbnail.inc.php?image=' .
|
||||
egw_link::vfs_path(
|
||||
$value[$row]['view']['app'], $value[$row]['view']['id'], $value[$row]['view']['filename']
|
||||
) . '" />';
|
||||
$GLOBALS['egw']->link('/etemplate/inc/thumbnail.inc.php',array(
|
||||
'app' => $link['app2'],
|
||||
'id' => $link['id2'],
|
||||
'file' => $link['id'],
|
||||
)) . '" />';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(in_array($GLOBALS['egw_info']['user']['preferences']['common']['link_list_format'], array('icons', 'icons_and_text') )) {
|
||||
if(in_array($GLOBALS['egw_info']['user']['preferences']['common']['link_list_format'], array('icons', 'icons_and_text') ))
|
||||
{
|
||||
// Hardcoded sizes to match the mimetype icons. Uses the navbar image and CSS to resize.
|
||||
$value[$row]['mime_icon'] = html::image($value[$row]['app'], 'navbar', $value[$row]['app'], 'style="width: 16px; height: 16px;"');
|
||||
$value[$row]['mime_icon'] = html::image($value[$row]['app'], 'navbar', lang($value[$row]['app']), 'style="width: 16px; height: 16px;"');
|
||||
}
|
||||
$value[$row]['label'] = 'Unlink';
|
||||
$value[$row]['help'] = lang('Remove this link (not the entry itself)');
|
||||
}
|
||||
// Remove appname if they only want icons
|
||||
if($value[$row]['mime_icon'] && $GLOBALS['egw_info']['user']['preferences']['common']['link_list_format'] == 'icons') {
|
||||
if($value[$row]['mime_icon'] && $GLOBALS['egw_info']['user']['preferences']['common']['link_list_format'] == 'icons')
|
||||
{
|
||||
$value[$row]['app'] = '';
|
||||
}
|
||||
}
|
||||
@ -648,4 +616,4 @@
|
||||
}
|
||||
return $response->getXML();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,19 +8,22 @@
|
||||
* @package etemplate
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
if (!preg_match('/^[a-z0-9_-]+$/i',$_GET['app'])) die('Stop'); // just to prevent someone doing nasty things
|
||||
|
||||
$GLOBALS['egw_info']['flags'] = array(
|
||||
'currentapp' => 'infolog',
|
||||
'currentapp' => $_GET['app'],
|
||||
'noheader' => true,
|
||||
'nonavbar' => true
|
||||
);
|
||||
include ('../../header.inc.php');
|
||||
|
||||
$file = $_GET['image'];
|
||||
$g_srcfile = $GLOBALS['egw_info']['server']['files_dir'] . $file;
|
||||
$g_dstfile = $GLOBALS['egw_info']['server']['temp_dir'] . $file;
|
||||
$g_srcfile = egw_link::vfs_path($_GET['app'],$_GET['id'],$_GET['file']);
|
||||
$g_dstfile = $GLOBALS['egw_info']['server']['temp_dir'] . '/egw-thumbs/'.$_GET['app'].'/'.$_GET['id'].'/'.$_GET['file'];
|
||||
|
||||
// Check for existing thumbnail
|
||||
if(file_exists($g_dstfile) && filemtime($g_dstfile) >= filemtime($g_srcfile)) {
|
||||
header('Content-Type: image/png');
|
||||
readfile($g_dstfile);
|
||||
return;
|
||||
}
|
||||
@ -46,8 +49,12 @@
|
||||
*
|
||||
* @author Nathan Gray
|
||||
*/
|
||||
function get_thumbnail($file, $return_data = true) {
|
||||
function get_thumbnail($file, $return_data = true)
|
||||
{
|
||||
global $g_srcfile,$g_dstfile;
|
||||
|
||||
$max_width = $max_height = $GLOBALS['egw_info']['server']['link_list_thumbnail'];
|
||||
|
||||
if($max_width == 0) {
|
||||
// thumbnailing disabled
|
||||
return false;
|
||||
@ -59,28 +66,9 @@
|
||||
// Quality
|
||||
$g_imgcomp=55;
|
||||
|
||||
$g_srcfile = $GLOBALS['egw_info']['server']['files_dir'] . $file;
|
||||
$g_dstfile = $GLOBALS['egw_info']['server']['temp_dir'] . $file;
|
||||
|
||||
$dir_array = explode(DIRECTORY_SEPARATOR, $g_dstfile);
|
||||
array_pop($dir_array);
|
||||
$dest_dir = implode(DIRECTORY_SEPARATOR, $dir_array);
|
||||
@mkdir($dest_dir, 0700, true);
|
||||
|
||||
if(file_exists($g_srcfile)) {
|
||||
$bolink = CreateObject('phpgwapi.bolink');
|
||||
$read = $bolink->vfs->acl_check(array(
|
||||
'string' => $file,
|
||||
'relatives' => array (),
|
||||
'operation' => EGW_ACL_READ
|
||||
));
|
||||
if(!$read) {
|
||||
$im = @imagecreatetruecolor(strlen(lang('access not permitted')) * 7, 20);
|
||||
$text_color = imagecolorallocate($im, 233, 14, 91);
|
||||
imagestring($im, 2,5,3, lang('access not permitted'), $text_color);
|
||||
return $return_data ? $im : false;
|
||||
}
|
||||
|
||||
$dst_dir = dirname($g_dstfile);
|
||||
// files dont exist, if you have no access permission
|
||||
if((file_exists($dst_dir) || mkdir($dst_dir, 0700, true)) && file_exists($g_srcfile)) {
|
||||
$g_is=getimagesize($g_srcfile);
|
||||
if($g_is[0] < $max_width && $g_is[1] < $max_height) {
|
||||
$g_iw = $g_is[0];
|
||||
@ -94,10 +82,7 @@
|
||||
}
|
||||
|
||||
// Get mime type
|
||||
$info = $bolink->vfs->ls(array(
|
||||
'string' => $file
|
||||
));
|
||||
list($type, $image_type) = explode('/', $info[0]['mime_type']);
|
||||
list($type, $image_type) = explode('/',egw_vfs::mime_content_type($g_srcfile));
|
||||
if($type != 'image') {
|
||||
return false;
|
||||
}
|
||||
@ -134,9 +119,6 @@
|
||||
imagepng($img_dst, $g_dstfile);
|
||||
return $return_data ? $img_dst : $g_dstfile;
|
||||
} else {
|
||||
if(file_exists($g_dstfile)) {
|
||||
unlink($g_dstfile);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,7 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- $Id$ -->
|
||||
<overlay>
|
||||
<grid id="etemplate.link_widget.list" template="" lang="" group="" version="0.9.15.003" class="whiteback">
|
||||
<template id="etemplate.link_widget.list" template="" lang="" group="0" version="1.5.001">
|
||||
<grid class="whiteback">
|
||||
<columns>
|
||||
<column/>
|
||||
<column/>
|
||||
@ -10,18 +11,25 @@
|
||||
</columns>
|
||||
<rows>
|
||||
<row class="nmr">
|
||||
<vbox>
|
||||
<html id="${row}[mime_icon]"/>
|
||||
<description id="${row}[app]"/>
|
||||
</vbox>
|
||||
<hbox options="0,0">
|
||||
<description options=",@${row}[view]" no_lang="1" id="${row}[title]" statustext="view this linked entry in its application"/>
|
||||
<description class="note_following" no_lang="1" id="${row}[remark]"/>
|
||||
<box no_lang="1">
|
||||
<html id="${row}[thumbnail]"/>
|
||||
<description no_lang="1" id="${row}[title]" options=",@${row}[view],,,$row_cont[target]" statustext="view this linked entry in its application"/>
|
||||
</box>
|
||||
<description no_lang="1" id="${row}[remark]" class="note_following"/>
|
||||
</hbox>
|
||||
<button image="delete.png" label="Unlink" id="unlink[$row_cont[link_id]]" statustext="Remove this link (not the entry itself)"/>
|
||||
<radio options="$row_cont[link_id]" id="primary" statustext="Select a primary contact, to show in the list"/>
|
||||
<button label="Unlink" id="unlink[$row_cont[link_id]]" image="delete.png" statustext="Remove this link (not the entry itself)"/>
|
||||
<radio id="primary" options="$row_cont[link_id]" statustext="Select a primary contact, to show in the list"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<styles>
|
||||
.whiteback { background: white; }
|
||||
.note_following { font-style: italic; padding-left: 5px; }
|
||||
</styles>
|
||||
</grid>
|
||||
</template>
|
||||
</overlay>
|
Loading…
Reference in New Issue
Block a user