From 251de1dc54d7e13713b51530e74903d12c608f2e Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 9 May 2016 10:05:57 +0000 Subject: [PATCH] move category images to api, fixes PHP Fatal in admin_categories, if phpgwapi is not installed --- admin/inc/class.admin_categories.inc.php | 21 ++++++++++--------- {phpgwapi => api}/images/README | 0 {phpgwapi => api}/images/blocks.png | Bin {phpgwapi => api}/images/books.png | Bin {phpgwapi => api}/images/charts.png | Bin {phpgwapi => api}/images/clipboard.png | Bin {phpgwapi => api}/images/communications.png | Bin {phpgwapi => api}/images/configure.png | Bin {phpgwapi => api}/images/connect.png | Bin {phpgwapi => api}/images/finance.png | Bin {phpgwapi => api}/images/gear.png | Bin {phpgwapi => api}/images/hardware.png | Bin {phpgwapi => api}/images/help.png | Bin {phpgwapi => api}/images/idea.png | Bin {phpgwapi => api}/images/important.png | Bin {phpgwapi => api}/images/index.php | 0 {phpgwapi => api}/images/info.png | Bin {phpgwapi => api}/images/linux.png | Bin {phpgwapi => api}/images/mac.png | Bin {phpgwapi => api}/images/open_book.png | Bin {phpgwapi => api}/images/open_folder.png | Bin {phpgwapi => api}/images/people.png | Bin {phpgwapi => api}/images/person.png | Bin {phpgwapi => api}/images/screen.png | Bin {phpgwapi => api}/images/security.png | Bin {phpgwapi => api}/images/star.png | Bin {phpgwapi => api}/images/stats.png | Bin {phpgwapi => api}/images/table.png | Bin {phpgwapi => api}/images/winclose.gif | Bin {phpgwapi => api}/images/windows.png | Bin {phpgwapi => api}/images/world.png | Bin api/src/Etemplate/Widget/Nextmatch.php | 13 ++++++++---- etemplate/inc/class.nextmatch_widget.inc.php | 13 ++++++++---- resources/inc/class.resources_bo.inc.php | 7 ++++++- 34 files changed, 35 insertions(+), 19 deletions(-) rename {phpgwapi => api}/images/README (100%) rename {phpgwapi => api}/images/blocks.png (100%) rename {phpgwapi => api}/images/books.png (100%) rename {phpgwapi => api}/images/charts.png (100%) rename {phpgwapi => api}/images/clipboard.png (100%) rename {phpgwapi => api}/images/communications.png (100%) rename {phpgwapi => api}/images/configure.png (100%) rename {phpgwapi => api}/images/connect.png (100%) rename {phpgwapi => api}/images/finance.png (100%) rename {phpgwapi => api}/images/gear.png (100%) rename {phpgwapi => api}/images/hardware.png (100%) rename {phpgwapi => api}/images/help.png (100%) rename {phpgwapi => api}/images/idea.png (100%) rename {phpgwapi => api}/images/important.png (100%) rename {phpgwapi => api}/images/index.php (100%) rename {phpgwapi => api}/images/info.png (100%) rename {phpgwapi => api}/images/linux.png (100%) rename {phpgwapi => api}/images/mac.png (100%) rename {phpgwapi => api}/images/open_book.png (100%) rename {phpgwapi => api}/images/open_folder.png (100%) rename {phpgwapi => api}/images/people.png (100%) rename {phpgwapi => api}/images/person.png (100%) rename {phpgwapi => api}/images/screen.png (100%) rename {phpgwapi => api}/images/security.png (100%) rename {phpgwapi => api}/images/star.png (100%) rename {phpgwapi => api}/images/stats.png (100%) rename {phpgwapi => api}/images/table.png (100%) rename {phpgwapi => api}/images/winclose.gif (100%) rename {phpgwapi => api}/images/windows.png (100%) rename {phpgwapi => api}/images/world.png (100%) diff --git a/admin/inc/class.admin_categories.inc.php b/admin/inc/class.admin_categories.inc.php index 0bedffb7e8..34bab5ff65 100644 --- a/admin/inc/class.admin_categories.inc.php +++ b/admin/inc/class.admin_categories.inc.php @@ -34,7 +34,7 @@ class admin_categories /** * Path where the icons are stored (relative to webserver_url) */ - const ICON_PATH = '/phpgwapi/images'; + const ICON_PATH = '/api/images'; protected $appname = 'admin'; 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 */ static function get_icons() { - $dir = dir(EGW_SERVER_ROOT.self::ICON_PATH); $icons = array(); - $matches = null; - while(($file = $dir->read())) + if (file_exists($image_dir=EGW_SERVER_ROOT.self::ICON_PATH) && ($dir = dir($image_dir))) { - 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; } diff --git a/phpgwapi/images/README b/api/images/README similarity index 100% rename from phpgwapi/images/README rename to api/images/README diff --git a/phpgwapi/images/blocks.png b/api/images/blocks.png similarity index 100% rename from phpgwapi/images/blocks.png rename to api/images/blocks.png diff --git a/phpgwapi/images/books.png b/api/images/books.png similarity index 100% rename from phpgwapi/images/books.png rename to api/images/books.png diff --git a/phpgwapi/images/charts.png b/api/images/charts.png similarity index 100% rename from phpgwapi/images/charts.png rename to api/images/charts.png diff --git a/phpgwapi/images/clipboard.png b/api/images/clipboard.png similarity index 100% rename from phpgwapi/images/clipboard.png rename to api/images/clipboard.png diff --git a/phpgwapi/images/communications.png b/api/images/communications.png similarity index 100% rename from phpgwapi/images/communications.png rename to api/images/communications.png diff --git a/phpgwapi/images/configure.png b/api/images/configure.png similarity index 100% rename from phpgwapi/images/configure.png rename to api/images/configure.png diff --git a/phpgwapi/images/connect.png b/api/images/connect.png similarity index 100% rename from phpgwapi/images/connect.png rename to api/images/connect.png diff --git a/phpgwapi/images/finance.png b/api/images/finance.png similarity index 100% rename from phpgwapi/images/finance.png rename to api/images/finance.png diff --git a/phpgwapi/images/gear.png b/api/images/gear.png similarity index 100% rename from phpgwapi/images/gear.png rename to api/images/gear.png diff --git a/phpgwapi/images/hardware.png b/api/images/hardware.png similarity index 100% rename from phpgwapi/images/hardware.png rename to api/images/hardware.png diff --git a/phpgwapi/images/help.png b/api/images/help.png similarity index 100% rename from phpgwapi/images/help.png rename to api/images/help.png diff --git a/phpgwapi/images/idea.png b/api/images/idea.png similarity index 100% rename from phpgwapi/images/idea.png rename to api/images/idea.png diff --git a/phpgwapi/images/important.png b/api/images/important.png similarity index 100% rename from phpgwapi/images/important.png rename to api/images/important.png diff --git a/phpgwapi/images/index.php b/api/images/index.php similarity index 100% rename from phpgwapi/images/index.php rename to api/images/index.php diff --git a/phpgwapi/images/info.png b/api/images/info.png similarity index 100% rename from phpgwapi/images/info.png rename to api/images/info.png diff --git a/phpgwapi/images/linux.png b/api/images/linux.png similarity index 100% rename from phpgwapi/images/linux.png rename to api/images/linux.png diff --git a/phpgwapi/images/mac.png b/api/images/mac.png similarity index 100% rename from phpgwapi/images/mac.png rename to api/images/mac.png diff --git a/phpgwapi/images/open_book.png b/api/images/open_book.png similarity index 100% rename from phpgwapi/images/open_book.png rename to api/images/open_book.png diff --git a/phpgwapi/images/open_folder.png b/api/images/open_folder.png similarity index 100% rename from phpgwapi/images/open_folder.png rename to api/images/open_folder.png diff --git a/phpgwapi/images/people.png b/api/images/people.png similarity index 100% rename from phpgwapi/images/people.png rename to api/images/people.png diff --git a/phpgwapi/images/person.png b/api/images/person.png similarity index 100% rename from phpgwapi/images/person.png rename to api/images/person.png diff --git a/phpgwapi/images/screen.png b/api/images/screen.png similarity index 100% rename from phpgwapi/images/screen.png rename to api/images/screen.png diff --git a/phpgwapi/images/security.png b/api/images/security.png similarity index 100% rename from phpgwapi/images/security.png rename to api/images/security.png diff --git a/phpgwapi/images/star.png b/api/images/star.png similarity index 100% rename from phpgwapi/images/star.png rename to api/images/star.png diff --git a/phpgwapi/images/stats.png b/api/images/stats.png similarity index 100% rename from phpgwapi/images/stats.png rename to api/images/stats.png diff --git a/phpgwapi/images/table.png b/api/images/table.png similarity index 100% rename from phpgwapi/images/table.png rename to api/images/table.png diff --git a/phpgwapi/images/winclose.gif b/api/images/winclose.gif similarity index 100% rename from phpgwapi/images/winclose.gif rename to api/images/winclose.gif diff --git a/phpgwapi/images/windows.png b/api/images/windows.png similarity index 100% rename from phpgwapi/images/windows.png rename to api/images/windows.png diff --git a/phpgwapi/images/world.png b/api/images/world.png similarity index 100% rename from phpgwapi/images/world.png rename to api/images/world.png diff --git a/api/src/Etemplate/Widget/Nextmatch.php b/api/src/Etemplate/Widget/Nextmatch.php index 5eef7eedaf..3b3a6cc1dc 100644 --- a/api/src/Etemplate/Widget/Nextmatch.php +++ b/api/src/Etemplate/Widget/Nextmatch.php @@ -85,6 +85,11 @@ use EGroupware\Api; */ class Nextmatch extends Etemplate\Widget { + /** + * Path where the icons are stored (relative to webserver_url) + */ + const ICON_PATH = '/api/images'; + public function __construct($xml='') { if($xml) { @@ -935,9 +940,9 @@ class Nextmatch extends Etemplate\Widget 'no_lang' => true, ); // 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, ); // 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]); } diff --git a/etemplate/inc/class.nextmatch_widget.inc.php b/etemplate/inc/class.nextmatch_widget.inc.php index a805e885be..40a7b36e5b 100644 --- a/etemplate/inc/class.nextmatch_widget.inc.php +++ b/etemplate/inc/class.nextmatch_widget.inc.php @@ -77,6 +77,11 @@ */ class nextmatch_widget { + /** + * Path where the icons are stored (relative to webserver_url) + */ + const ICON_PATH = '/api/images'; + /** * Prefix for custom field names * @@ -810,9 +815,9 @@ class nextmatch_widget 'no_lang' => true, ); // 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, ); // 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]); } diff --git a/resources/inc/class.resources_bo.inc.php b/resources/inc/class.resources_bo.inc.php index 6ca0b6c2f2..48f882b455 100755 --- a/resources/inc/class.resources_bo.inc.php +++ b/resources/inc/class.resources_bo.inc.php @@ -23,6 +23,11 @@ use EGroupware\Api\Vfs; */ class resources_bo { + /** + * Path where the icons are stored (relative to webserver_url) + */ + const ICON_PATH = '/api/images'; + const DELETED = 'deleted'; const PICTURE_NAME = '.picture.jpg'; var $resource_icons = '/resources/templates/default/images/resource_icons/'; @@ -833,7 +838,7 @@ class resources_bo $picture = Api\Categories::id2name($resource['cat_id'], 'data'); 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; } // fall through