From e788257512a424ca42a1ca55959ec2617bb9cf71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 5 May 2010 11:35:14 +0200 Subject: [PATCH] Generic function to warn about missing extension. --- libraries/core.lib.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libraries/core.lib.php b/libraries/core.lib.php index b56512192..70740b6ad 100644 --- a/libraries/core.lib.php +++ b/libraries/core.lib.php @@ -274,6 +274,26 @@ function PMA_fatalError($error_message, $message_args = null) exit; } +/** + * Warn or fail on missing extension. + * + * @param string $extension Extension name + * @param bool $fatal Whether the error is fatal. + / @param string $extra Extra string to append to messsage. + */ +function PMA_warnMissingExtension($extension, $fatal = false, $extra = '') +{ + $message = sprintf(__('Cannot load [a@http://php.net/%1$s@Documentation][em]%1$s[/em][/a] extension. Please check your PHP configuration.'), $extension); + if ($extra != '') { + $message .= ' ' . $extra; + } + if ($fatal) { + PMA_fatalError($message); + } else { + trigger_error($message, E_USER_WARNING); + } +} + /** * returns count of tables in given db *