move category images to api, fixes PHP Fatal in admin_categories, if phpgwapi is not installed

This commit is contained in:
Ralf Becker 2016-05-09 10:05:57 +00:00
parent be0d2ca297
commit 251de1dc54
34 changed files with 35 additions and 19 deletions

View File

@ -34,7 +34,7 @@ class admin_categories
/** /**
* Path where the icons are stored (relative to webserver_url) * Path where the icons are stored (relative to webserver_url)
*/ */
const ICON_PATH = '/phpgwapi/images'; const ICON_PATH = '/api/images';
protected $appname = 'admin'; protected $appname = 'admin';
protected $get_rows = 'admin.admin_categories.get_rows'; protected $get_rows = 'admin.admin_categories.get_rows';
@ -332,25 +332,26 @@ class admin_categories
} }
/** /**
* Return icons from /phpgwapi/images * Return icons from /api/images
* *
* @return array filename => label * @return array filename => label
*/ */
static function get_icons() static function get_icons()
{ {
$dir = dir(EGW_SERVER_ROOT.self::ICON_PATH);
$icons = array(); $icons = array();
$matches = null; if (file_exists($image_dir=EGW_SERVER_ROOT.self::ICON_PATH) && ($dir = dir($image_dir)))
while(($file = $dir->read()))
{ {
if (preg_match('/^(.*)\\.(png|gif|jpe?g)$/i',$file,$matches)) $matches = null;
while(($file = $dir->read()))
{ {
$icons[$file] = ucfirst($matches[1]); if (preg_match('/^(.*)\\.(png|gif|jpe?g)$/i',$file,$matches))
{
$icons[$file] = ucfirst($matches[1]);
}
} }
$dir->close();
asort($icons);
} }
$dir->close();
asort($icons);
return $icons; return $icons;
} }

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 325 B

After

Width:  |  Height:  |  Size: 325 B

View File

Before

Width:  |  Height:  |  Size: 952 B

After

Width:  |  Height:  |  Size: 952 B

View File

Before

Width:  |  Height:  |  Size: 844 B

After

Width:  |  Height:  |  Size: 844 B

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -85,6 +85,11 @@ use EGroupware\Api;
*/ */
class Nextmatch extends Etemplate\Widget class Nextmatch extends Etemplate\Widget
{ {
/**
* Path where the icons are stored (relative to webserver_url)
*/
const ICON_PATH = '/api/images';
public function __construct($xml='') public function __construct($xml='')
{ {
if($xml) { if($xml) {
@ -935,9 +940,9 @@ class Nextmatch extends Etemplate\Widget
'no_lang' => true, 'no_lang' => true,
); );
// add category icon // add category icon
if ($cat['data']['icon'] && file_exists(EGW_SERVER_ROOT.'/phpgwapi/images/'.basename($cat['data']['icon']))) if ($cat['data']['icon'] && file_exists(EGW_SERVER_ROOT.self::ICON_PATH.'/'.basename($cat['data']['icon'])))
{ {
$cat_actions[$cat['id']]['iconUrl'] = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/images/'.$cat['data']['icon']; $cat_actions[$cat['id']]['iconUrl'] = $GLOBALS['egw_info']['server']['webserver_url'].self::ICON_PATH.'/'.$cat['data']['icon'];
} }
} }
} }
@ -974,9 +979,9 @@ class Nextmatch extends Etemplate\Widget
'prefix' => $prefix, 'prefix' => $prefix,
); );
// add category icon // add category icon
if ($cat['data']['icon'] && file_exists(EGW_SERVER_ROOT.'/phpgwapi/images/'.basename($cat['data']['icon']))) if ($cat['data']['icon'] && file_exists(EGW_SERVER_ROOT.self::ICON_PATH.'/'.basename($cat['data']['icon'])))
{ {
$cat_actions[$cat['id']]['iconUrl'] = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/images/'.$cat['data']['icon']; $cat_actions[$cat['id']]['iconUrl'] = $GLOBALS['egw_info']['server']['webserver_url'].self::ICON_PATH.'/'.$cat['data']['icon'];
} }
unset($cats[$key]); unset($cats[$key]);
} }

View File

@ -77,6 +77,11 @@
*/ */
class nextmatch_widget class nextmatch_widget
{ {
/**
* Path where the icons are stored (relative to webserver_url)
*/
const ICON_PATH = '/api/images';
/** /**
* Prefix for custom field names * Prefix for custom field names
* *
@ -810,9 +815,9 @@ class nextmatch_widget
'no_lang' => true, 'no_lang' => true,
); );
// add category icon // add category icon
if ($cat['data']['icon'] && file_exists(EGW_SERVER_ROOT.'/phpgwapi/images/'.basename($cat['data']['icon']))) if ($cat['data']['icon'] && file_exists(EGW_SERVER_ROOT.self::ICON_PATH.'/'.basename($cat['data']['icon'])))
{ {
$cat_actions[$cat['id']]['iconUrl'] = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/images/'.$cat['data']['icon']; $cat_actions[$cat['id']]['iconUrl'] = $GLOBALS['egw_info']['server']['webserver_url'].self::ICON_PATH.'/'.$cat['data']['icon'];
} }
} }
} }
@ -849,9 +854,9 @@ class nextmatch_widget
'prefix' => $prefix, 'prefix' => $prefix,
); );
// add category icon // add category icon
if ($cat['data']['icon'] && file_exists(EGW_SERVER_ROOT.'/phpgwapi/images/'.basename($cat['data']['icon']))) if ($cat['data']['icon'] && file_exists(EGW_SERVER_ROOT.self::ICON_PATH.'/'.basename($cat['data']['icon'])))
{ {
$cat_actions[$cat['id']]['iconUrl'] = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/images/'.$cat['data']['icon']; $cat_actions[$cat['id']]['iconUrl'] = $GLOBALS['egw_info']['server']['webserver_url'].self::ICON_PATH.'/'.$cat['data']['icon'];
} }
unset($cats[$key]); unset($cats[$key]);
} }

View File

@ -23,6 +23,11 @@ use EGroupware\Api\Vfs;
*/ */
class resources_bo class resources_bo
{ {
/**
* Path where the icons are stored (relative to webserver_url)
*/
const ICON_PATH = '/api/images';
const DELETED = 'deleted'; const DELETED = 'deleted';
const PICTURE_NAME = '.picture.jpg'; const PICTURE_NAME = '.picture.jpg';
var $resource_icons = '/resources/templates/default/images/resource_icons/'; var $resource_icons = '/resources/templates/default/images/resource_icons/';
@ -833,7 +838,7 @@ class resources_bo
$picture = Api\Categories::id2name($resource['cat_id'], 'data'); $picture = Api\Categories::id2name($resource['cat_id'], 'data');
if($picture['icon']) if($picture['icon'])
{ {
$picture = !$fullsize?$GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/images/'.$picture['icon']:'/phpgwapi/images/'.$picture['icon']; $picture = !$fullsize?$GLOBALS['egw_info']['server']['webserver_url'].self::ICON_PATH.'/'.$picture['icon']:self::ICON_PATH.'/'.$picture['icon'];
break; break;
} }
// fall through // fall through