use template specific images for foldertree, use "template" handler for all calls to template/framework object, NOT instanciating a new one using eg. a parent class

This commit is contained in:
Ralf Becker 2013-11-15 16:28:24 +00:00
parent 3c38cd10c4
commit 8e69433829
4 changed files with 59 additions and 23 deletions

View File

@ -109,6 +109,29 @@ class etemplate_widget_tree extends etemplate_widget
public function beforeSendToClient($cname)
{
$form_name = self::form_name($cname, $this->id);
$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
if (empty($this->attrs['image_path']))
{
$this->attrs['image_path'] = $webserver_url.'/phpgwapi/templates/default/images/dhtmlxtree/';
}
// check if we have template-set specific image path
$image_path = $this->attrs['image_path'];
if ($webserver_url && $webserver_url != '/')
{
list(,$image_path) = explode($webserver_url, $image_path, 2);
}
$templated_path = strtr($image_path, array(
'/phpgwapi/templates/default' => $GLOBALS['egw']->framework->template_dir,
'/default/' => '/'.$GLOBALS['egw']->framework->template.'/',
));
if (file_exists(EGW_SERVER_ROOT.$templated_path))
{
$this->attrs['image_path'] = ($webserver_url != '/' ? $webserver_url : '').$templated_path;
self::setElementAttribute($form_name, 'image_path', $this->attrs['image_path']);
//error_log(__METHOD__."() setting templated image-path for $form_name: $templated_path");
}
if (!is_array(self::$request->sel_options[$form_name])) self::$request->sel_options[$form_name] = array();
if ($this->attrs['type'])
{

View File

@ -106,16 +106,10 @@ class egw_json_request
case 'etemplate': // eg. ajax code in an eTemplate widget
$menuaction = ($appName = 'etemplate').'.'.$className.'.'.$functionName;
break;
case 'template':
case 'template': // calling current template / framework object
$menuaction = $appName.'.'.$className.'.'.$functionName;
$className = get_class($GLOBALS['egw']->framework);
list($template) = explode('_', $className);
if ($className == 'egw_framework') // allow to use egw_framework to call framework / template used by user
{
$template = $GLOBALS['egw_info']['user']['preferences']['common']['template_set'];
if (empty($template)) $template = 'idots';
$className = $template.'_framework';
//error_log(__METHOD__."('$menuaction', ".array($parameters).") --> template='$template', className='$className'");
}
break;
}
@ -132,8 +126,7 @@ class egw_json_request
if (isset($template))
{
if (!class_exists($className)) require_once(EGW_SERVER_ROOT.'/phpgwapi/templates/'.$template.'/class.'.$className.'.inc.php');
$ajaxClass = new $className;
$ajaxClass = $GLOBALS['egw']->framework;
}
else
{

View File

@ -1190,9 +1190,25 @@ egw_LAB.wait(function() {
$_leafImage='',$_onCheckHandler=false,$delimiter='/',$folderImageDir=null,$autoLoading=null,$dataMode='JSON',
$dragndrop=false)
{
if(is_null($folderImageDir))
$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
if (empty($folderImageDir))
{
$folderImageDir = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/templates/default/images';
$folderImageDir = $webserver_url.'/phpgwapi/templates/default/images';
}
// check if we have template-set specific image path
$image_path = $folderImageDir;
if ($webserver_url && $webserver_url != '/')
{
list(,$image_path) = explode($webserver_url, $image_path, 2);
}
$templated_path = strtr($image_path, array(
'/phpgwapi/templates/default' => $GLOBALS['egw']->framework->template_dir,
'/default/' => '/'.$GLOBALS['egw']->framework->template.'/',
));
if (file_exists(EGW_SERVER_ROOT.$templated_path))
{
$folderImageDir = ($webserver_url != '/' ? $webserver_url : '').$templated_path;
//error_log(__METHOD__."() setting templated image-path: $folderImageDir");
}
static $tree_initialised=false;

View File

@ -20,7 +20,7 @@ egw.extend('images', egw.MODULE_GLOBAL, function() {
/**
* Map to serverside available images for users template-set
*
*
* @access: private, use egw.image(_name, _app)
*/
var images = {};
@ -28,7 +28,7 @@ egw.extend('images', egw.MODULE_GLOBAL, function() {
return {
/**
* Set imagemap, called from /phpgwapi/images.php
*
*
* @param array/object _images
*/
set_images: function (_images)
@ -38,7 +38,7 @@ egw.extend('images', egw.MODULE_GLOBAL, function() {
/**
* Get image URL for a given image-name and application
*
*
* @param string _name image-name without extension
* @param string _app application name, default current app of window
* @return string with URL of image
@ -58,11 +58,15 @@ egw.extend('images', egw.MODULE_GLOBAL, function() {
if(_name.indexOf('/') > 0)
{
var split = _name.split('/',2);
_app = split[0];
_name = split[1];
// dhtmlxtree and egw_action are subdirs in image dir, not applications
if (split[0] !== 'dhtmlxtree' && split[0] !== 'egw_action')
{
_app = split[0];
_name = split[1];
}
}
}
// own instance specific images in vfs have highest precedence
tries['vfs']=_name;
if (typeof images['vfs'] != 'undefined' && typeof images['vfs'][_name] != 'undefined')
@ -89,10 +93,10 @@ egw.extend('images', egw.MODULE_GLOBAL, function() {
console.log('egw.image("'+_name+'", "'+_app+'") image NOT found! Tried ', tries);
return null;
},
/**
* Get image url for a given mime-type and option file
*
*
* @param _mime
* @param _path vfs path to generate thumbnails for images
* @param _size defaults to 16 (only supported size currently)
@ -103,13 +107,13 @@ egw.extend('images', egw.MODULE_GLOBAL, function() {
if (typeof _size == 'undefined') _size = 16;
if (!_mime) _mime = 'unknown';
if (_mime == 'httpd/unix-directory') _mime = 'directory';
var type = _mime.toLowerCase().split('/');
var image;
if (type[0] == 'egw' && (image = this.image('navbar',type[1])))
{
}
else if (typeof _path == 'string' && type[0] == 'image' && type[1].match(/^(png|jpe?g|gif|bmp)$/))
{