forked from extern/egroupware
Moved contents of egw_vfs_utils to egw_vfs, added 'egwGridViewFullRow' class to the egw_grid_view.js, which is capable of inserting a data row which spans all columns, added egwGridData.clearData method to egw_grid_data.js, which delets all data stored in the data row
This commit is contained in:
parent
c0da31b5f3
commit
fa12444ae7
@ -1496,6 +1496,60 @@ class egw_vfs extends vfs_stream_wrapper
|
||||
self::$db = isset($GLOBALS['egw_setup']->db) ? $GLOBALS['egw_setup']->db : $GLOBALS['egw']->db;
|
||||
self::$lock_cache = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL to the thumbnail of the given file. The thumbnail may simply
|
||||
* be the mime-type icon, or - if activated - the preview with the given thsize.
|
||||
*
|
||||
* @param string $file name of the file
|
||||
* @param int $thsize the size of the preview - false if the default should be used.
|
||||
* @param string $mime if you already know the mime type of the file, you can supply
|
||||
* it here. Otherwise supply "false".
|
||||
*/
|
||||
public static function thumbnail_url($file, $thsize = false, $mime = false)
|
||||
{
|
||||
// Retrive the mime-type of the file
|
||||
if (!$mime)
|
||||
{
|
||||
$mime = egw_vfs::mime_content_type($file);
|
||||
}
|
||||
|
||||
$image = "";
|
||||
|
||||
// Seperate the mime type into the primary and the secondary part
|
||||
list($mime_main, $mime_sub) = explode('/', $mime);
|
||||
|
||||
if ($mime_main == 'egw')
|
||||
{
|
||||
$image = $GLOBALS['egw']->common->image($mime_sub, 'navbar');
|
||||
}
|
||||
else if ($file && $mime_main == 'image' && in_array($mime_sub, array('png','jpeg','jpg','gif','bmp')) &&
|
||||
(string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] != '0' &&
|
||||
(string)$GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] != '0' &&
|
||||
(!is_array($value) && ($stat = egw_vfs::stat($file)) ? $stat['size'] : $value['size']) < 1500000)
|
||||
{
|
||||
if (substr($file, 0, 6) == '/apps/')
|
||||
{
|
||||
$file = parse_url(egw_vfs::resolve_url_symlinks($path), PHP_URL_PATH);
|
||||
}
|
||||
|
||||
//Assemble the thumbnail parameters
|
||||
$thparams = array();
|
||||
$thparams['path'] = $file;
|
||||
if ($thsize)
|
||||
{
|
||||
$thparams['thsize'] = $thsize;
|
||||
}
|
||||
$image = $GLOBALS['egw']->link('/etemplate/thumbnail.php', $thparams);
|
||||
}
|
||||
else
|
||||
{
|
||||
list($app, $name) = explode("/", egw_vfs::mime_icon($mime), 2);
|
||||
$image = $GLOBALS['egw']->common->image($app, $name);
|
||||
}
|
||||
|
||||
return $image;
|
||||
}
|
||||
}
|
||||
|
||||
egw_vfs::init_static();
|
||||
|
@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* eGroupWare API: VFS - static methods to use the new eGW virtual file system
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package api
|
||||
* @subpackage vfs
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @author Andreas Stöckel <as@stylite.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
class egw_vfs_utils
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the URL to the thumbnail of the given file. The thumbnail may simply
|
||||
* be the mime-type icon, or - if activated - the preview with the given thsize.
|
||||
*
|
||||
* @param string $file name of the file
|
||||
* @param int $thsize the size of the preview - false if the default should be used.
|
||||
* @param string $mime if you already know the mime type of the file, you can supply
|
||||
* it here. Otherwise supply "false".
|
||||
*/
|
||||
public static function thumbnail_url($file, $thsize = false, $mime = false)
|
||||
{
|
||||
// Retrive the mime-type of the file
|
||||
if (!$mime)
|
||||
{
|
||||
$mime = egw_vfs::mime_content_type($file);
|
||||
}
|
||||
|
||||
$image = "";
|
||||
|
||||
// Seperate the mime type into the primary and the secondary part
|
||||
list($mime_main, $mime_sub) = explode('/', $mime);
|
||||
|
||||
if ($mime_main == 'egw')
|
||||
{
|
||||
$image = $GLOBALS['egw']->common->image($mime_sub, 'navbar');
|
||||
}
|
||||
else if ($file && $mime_main == 'image' && in_array($mime_sub, array('png','jpeg','jpg','gif','bmp')) &&
|
||||
(string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] != '0' &&
|
||||
(string)$GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] != '0' &&
|
||||
(!is_array($value) && ($stat = egw_vfs::stat($file)) ? $stat['size'] : $value['size']) < 1500000)
|
||||
{
|
||||
if (substr($file, 0, 6) == '/apps/')
|
||||
{
|
||||
$file = parse_url(egw_vfs::resolve_url_symlinks($path), PHP_URL_PATH);
|
||||
}
|
||||
|
||||
//Assemble the thumbnail parameters
|
||||
$thparams = array();
|
||||
$thparams['path'] = $file;
|
||||
if ($thsize)
|
||||
{
|
||||
$thparams['thsize'] = $thsize;
|
||||
}
|
||||
$image = $GLOBALS['egw']->link('/etemplate/thumbnail.php', $thparams);
|
||||
}
|
||||
else
|
||||
{
|
||||
list($app, $name) = explode("/", egw_vfs::mime_icon($mime), 2);
|
||||
$image = $GLOBALS['egw']->common->image($app, $name);
|
||||
}
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -277,6 +277,20 @@ egwGridDataElement.prototype.loadData = function(_data, _doCallUpdate)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all relevant data (the column data, icon and icon size) of the element
|
||||
* and triggers a gridViewObj update.
|
||||
*/
|
||||
egwGridDataElement.prototype.clearData = function()
|
||||
{
|
||||
this.data = {};
|
||||
this.caption = false;
|
||||
this.iconUrl = false;
|
||||
this.iconSize = false;
|
||||
|
||||
this.callGridViewObjectUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a new element as child at the given position
|
||||
*
|
||||
|
@ -1225,9 +1225,9 @@ function egwGridViewRow_doUpdateData(_immediate)
|
||||
{
|
||||
var td = this.tdObjects[i].td;
|
||||
var col = this.tdObjects[i].col;
|
||||
td.empty();
|
||||
if (typeof data[col.id] != "undefined")
|
||||
{
|
||||
td.empty();
|
||||
if (col.type == EGW_COL_TYPE_NAME_ICON_FIXED)
|
||||
{
|
||||
// Insert the indentation spacer
|
||||
@ -1265,6 +1265,7 @@ function egwGridViewRow_doUpdateData(_immediate)
|
||||
|
||||
return false; // Don't bubble this event
|
||||
});
|
||||
arrow.dblclick(function() {return false;});
|
||||
}
|
||||
td.append(arrow);
|
||||
|
||||
@ -1499,3 +1500,112 @@ function egwGridViewSpacer_doSetViewArea()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** -- egwGridViewFullRow Class -- **/
|
||||
|
||||
/**
|
||||
* The egwGridViewFullRow Class has only one td which contains a single caption
|
||||
*/
|
||||
|
||||
function egwGridViewFullRow(_grid, _heightChangeProc, _item)
|
||||
{
|
||||
var container = new egwGridViewContainer(_grid, _heightChangeProc);
|
||||
|
||||
// Copy the item parameter, which is used when fetching data from the data
|
||||
// source
|
||||
container.item = _item;
|
||||
|
||||
// Set a few new functions/properties - use the row aoi functions
|
||||
container.aoiSetup = egwGridViewRow_aoiSetup;
|
||||
container.getAOI = egwGridViewRow_getAOI;
|
||||
container.containerClass = "row";
|
||||
container._columnClick = egwGridViewRow__columnClick;
|
||||
container.td = null;
|
||||
|
||||
// Overwrite the inherited abstract functions
|
||||
container.doInsertIntoDOM = egwGridViewFullRow_doInsertIntoDOM;
|
||||
container.doSetViewArea = egwGridViewFullRow_doSetViewArea;
|
||||
container.doUpdateData = egwGridViewFullRow_doUpdateData;
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
function egwGridViewFullRow_doInsertIntoDOM()
|
||||
{
|
||||
this.parentNode.empty();
|
||||
this.parentNode.addClass("row");
|
||||
this.parentNode.addClass("fullRow");
|
||||
|
||||
// Setup the aoi and inform the item about it
|
||||
if (!this.aoi)
|
||||
{
|
||||
this.aoiSetup();
|
||||
this.item.setGridViewObj(this);
|
||||
}
|
||||
|
||||
var td = this.td = $(document.createElement("td"));
|
||||
td.attr("colspan", this.columns.length);
|
||||
td.addClass("first");
|
||||
td.addClass("last");
|
||||
|
||||
this.parentNode.append(td);
|
||||
|
||||
// Set the column width
|
||||
if (EGW_GRID_VIEW_ROW_BORDER === false)
|
||||
{
|
||||
EGW_GRID_VIEW_ROW_BORDER = td.outerWidth() - td.width();
|
||||
}
|
||||
|
||||
var width = 0;
|
||||
for (var i = 0; i < this.columns.length; i++)
|
||||
{
|
||||
width += this.columns[i].drawnWidth;// - EGW_GRID_VIEW_ROW_BORDER;
|
||||
}
|
||||
|
||||
td.css("width", width - EGW_GRID_VIEW_ROW_BORDER);
|
||||
|
||||
this.doUpdateData(true);
|
||||
|
||||
this.checkViewArea();
|
||||
}
|
||||
|
||||
function egwGridViewFullRow_doUpdateData(_immediate)
|
||||
{
|
||||
this.td.empty();
|
||||
|
||||
if (this.item.caption)
|
||||
{
|
||||
// Insert the indentation spacer
|
||||
var depth = this.item.getDepth();
|
||||
if (depth > 0)
|
||||
{
|
||||
// Build the indentation object
|
||||
var indentation = $(document.createElement("span"));
|
||||
indentation.addClass("indentation");
|
||||
indentation.css("width", (depth * 12) + "px");
|
||||
this.td.append(indentation);
|
||||
}
|
||||
|
||||
// Insert the caption
|
||||
var caption = $(document.createElement("span"));
|
||||
caption.addClass("caption");
|
||||
caption.html(this.item.caption);
|
||||
this.td.append(caption);
|
||||
}
|
||||
|
||||
// If the call is not from inside the doInsertIntoDOM function, we have to
|
||||
// inform the parent about a possible height change
|
||||
if (!_immediate && (this.height || this.assumedHeight))
|
||||
{
|
||||
this.callHeightChangeProc();
|
||||
}
|
||||
}
|
||||
|
||||
function egwGridViewFullRow_doSetViewArea()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -68,6 +68,10 @@ body, td, th {
|
||||
border-right-width: 0;
|
||||
}
|
||||
|
||||
.egwGridView_grid tr.fullRow {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.egwGridView_grid tr.row:hover {
|
||||
background-color: #f0f0ff;
|
||||
}
|
||||
@ -176,6 +180,7 @@ body, td, th {
|
||||
.frame {
|
||||
padding: 0 !important;
|
||||
border-right: 0 none silver !important;
|
||||
border-bottom: 0 none silver !important;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user