mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:07 +01:00
fixed not found images in admin tree, by using static method knowing templated image path and calculating a relative path for images returned by common::image
This commit is contained in:
parent
34827545cc
commit
3a3227bc27
@ -10,8 +10,6 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
require_once EGW_INCLUDE_ROOT.'/etemplate/inc/class.etemplate.inc.php';
|
||||
|
||||
/**
|
||||
* UI for admin
|
||||
*/
|
||||
@ -36,9 +34,8 @@ class admin_ui
|
||||
* New index page
|
||||
*
|
||||
* @param array $content
|
||||
* @param string $msg
|
||||
*/
|
||||
public function index(array $content=null, $msg='')
|
||||
public function index(array $content=null)
|
||||
{
|
||||
admin_statistics::check();
|
||||
|
||||
@ -66,7 +63,7 @@ class admin_ui
|
||||
'start' => false,
|
||||
'order' => 'account_lid',
|
||||
'sort' => 'ASC',
|
||||
)) as $account_id => $data)
|
||||
)) as $data)
|
||||
{
|
||||
$sel_options['filter'][$data['account_id']] = empty($data['account_description']) ? $data['account_lid'] : array(
|
||||
'label' => $data['account_lid'],
|
||||
@ -165,7 +162,7 @@ class admin_ui
|
||||
++$group;
|
||||
// supporting both old way using $GLOBALS['menuData'] and new just returning data in hook
|
||||
$apps = array_unique(array_merge(array('admin'), $GLOBALS['egw']->hooks->hook_implemented('edit_user')));
|
||||
foreach($apps as $n => $app)
|
||||
foreach($apps as $app)
|
||||
{
|
||||
if ($app == 'felamimail') continue; // disabled fmail for now, as it break whole admin, dono why
|
||||
$GLOBALS['menuData'] = $data = array();
|
||||
@ -177,13 +174,14 @@ if ($app == 'felamimail') continue; // disabled fmail for now, as it break whole
|
||||
if (empty($item['caption']))
|
||||
{
|
||||
$item['caption'] = $item['description'];
|
||||
unset($item[$description]);
|
||||
unset($item['description']);
|
||||
}
|
||||
if (isset($item['url']) && isset($item['extradata']))
|
||||
{
|
||||
$item['url'] = $item['extradata'].'&account_id=$id';
|
||||
$item['id'] = substr($item['extradata'], 11);
|
||||
unset($item['extradata']);
|
||||
$matches = null;
|
||||
if ($item['options'] && preg_match('/(egw_openWindowCentered2?|window.open)\([^)]+,(\d+),(\d+).*(title="([^"]+)")?/', $item['options'], $matches))
|
||||
{
|
||||
$item['popup'] = $matches[2].'x'.$matches[3];
|
||||
@ -303,6 +301,7 @@ if ($app == 'felamimail') continue; // disabled fmail for now, as it break whole
|
||||
if (empty($data['id']))
|
||||
{
|
||||
$data['id'] = $root.($app == 'admin' ? 'admin' : 'apps/'.$app).'/';
|
||||
$matches = null;
|
||||
if (preg_match_all('/(menuaction|load)=([^&]+)/', $data['link'], $matches))
|
||||
{
|
||||
$data['id'] .= $matches[2][(int)array_search('load', $matches[1])];
|
||||
@ -314,9 +313,7 @@ if ($app == 'felamimail') continue; // disabled fmail for now, as it break whole
|
||||
}
|
||||
if (!empty($data['icon']))
|
||||
{
|
||||
$icon = $data['icon'];
|
||||
list(,$icon) = explode($GLOBALS['egw_info']['server']['webserver_url'], $icon);
|
||||
$icon = '../../../../..'.$icon;
|
||||
$icon = etemplate_widget_tree::imagePath($data['icon']);
|
||||
if ($data['child'] || $data['item'])
|
||||
{
|
||||
$data['im1'] = $data['im2'] = $icon;
|
||||
@ -330,16 +327,14 @@ if ($app == 'felamimail') continue; // disabled fmail for now, as it break whole
|
||||
$parent =& $tree['item'];
|
||||
$parts = explode('/', $data['id']);
|
||||
if ($data['id'][0] == '/') array_shift($parts); // remove root
|
||||
$last_part = array_pop($parts);
|
||||
array_pop($parts);
|
||||
$path = '';
|
||||
foreach($parts as $part)
|
||||
{
|
||||
$path .= ($path == '/' ? '' : '/').$part;
|
||||
if (!isset($parent[$path]))
|
||||
{
|
||||
$icon = $part == 'apps' ? common::image('phpgwapi', 'home') : common::image($part, 'navbar');
|
||||
list(,$icon) = explode($GLOBALS['egw_info']['server']['webserver_url'], $icon);
|
||||
$icon = '../../../../..'.$icon;
|
||||
$icon = etemplate_widget_tree::imagePath($part == 'apps' ? common::image('phpgwapi', 'home') : common::image($part, 'navbar'));
|
||||
$parent[$path] = array(
|
||||
'id' => $path,
|
||||
'text' => $part == 'apps' ? lang('Applications') : lang($part),
|
||||
|
@ -110,25 +110,9 @@ class etemplate_widget_tree extends etemplate_widget
|
||||
{
|
||||
$form_name = self::form_name($cname, $this->id);
|
||||
|
||||
$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
|
||||
if (empty($this->attrs['image_path']))
|
||||
if (($templated_path = self::templateImagePath($this->attrs['image_path'])) != $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']);
|
||||
self::setElementAttribute($form_name, 'image_path', $this->attrs['image_path'] = $templated_path);
|
||||
//error_log(__METHOD__."() setting templated image-path for $form_name: $templated_path");
|
||||
}
|
||||
|
||||
@ -137,7 +121,7 @@ class etemplate_widget_tree extends etemplate_widget
|
||||
{
|
||||
// += to keep further options set by app code
|
||||
self::$request->sel_options[$form_name] += self::typeOptions($this->attrs['type'], $this->attrs['options'],
|
||||
$no_lang, $this->attrs['readonly'], self::get_array(self::$request->content, $form_name));
|
||||
$no_lang=null, $this->attrs['readonly'], self::get_array(self::$request->content, $form_name));
|
||||
|
||||
// if no_lang was modified, forward modification to the client
|
||||
if ($no_lang != $this->attr['no_lang'])
|
||||
@ -161,6 +145,63 @@ class etemplate_widget_tree extends etemplate_widget
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get template specific image path
|
||||
*
|
||||
* @param string $image_path=null default path to use, or empty to use default of /phpgwapi/templates/default/images/dhtmlxtree
|
||||
* @return string templated url if available, otherwise default path
|
||||
*/
|
||||
public static function templateImagePath($image_path=null)
|
||||
{
|
||||
$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
|
||||
if (empty($image_path))
|
||||
{
|
||||
$image_path = $webserver_url.'/phpgwapi/templates/default/images/dhtmlxtree/';
|
||||
}
|
||||
// check if we have template-set specific 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))
|
||||
{
|
||||
return ($webserver_url != '/' ? $webserver_url : '').$templated_path;
|
||||
//error_log(__METHOD__."() setting templated image-path for $form_name: $templated_path");
|
||||
}
|
||||
return ($webserver_url != '/' ? $webserver_url : '').$image_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return image relative to trees image-path
|
||||
*
|
||||
* @param string $image url of image, eg. from common::image($image, $app)
|
||||
* @return string path relative to image-path, to use when returning tree data eg. via json
|
||||
*/
|
||||
public static function imagePath($image)
|
||||
{
|
||||
static $image_path=null;
|
||||
if (!isset($image_path)) $image_path = self::templateImagePath ();
|
||||
|
||||
$parts = explode('/', $image_path);
|
||||
$image_parts = explode('/', $image);
|
||||
|
||||
// remove common parts
|
||||
while(isset($parts[0]) && $parts[0] === $image_parts[0])
|
||||
{
|
||||
array_shift($parts);
|
||||
array_shift($image_parts);
|
||||
}
|
||||
// add .. for different parts, except last image part
|
||||
$url = implode('/', array_merge(array_fill(0, count($parts)-1, '..'), $image_parts));
|
||||
|
||||
//error_log(__METHOD__."('$image') image_path=$image_path returning $url");
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get options from $sel_options array for a given selectbox name
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user