Modified: trunk/lib/cc.class.php (94 => 95)
--- trunk/lib/cc.class.php 2007-01-05 16:37:05 UTC (rev 94)
+++ trunk/lib/cc.class.php 2007-01-05 17:35:57 UTC (rev 95)
@@ -103,7 +103,7 @@
throw new CC_Exception('You must use php 5.1.0 or higher');
}
$have = get_loaded_extensions();
- $needed = array('standard', 'pcre', 'date', 'PDO', 'pdo_sqlite', 'php-gtk');
+ $needed = array('standard', 'pcre', 'date', 'reflection', 'tokenizer', 'spl', 'php-gtk');
if (stristr(PHP_OS, 'win32'))
{
$needed[] = 'com';
@@ -111,7 +111,7 @@
$diff = array_diff($needed, $have);
if (!empty($diff))
{
- throw new CC_Exception('%s : %s', 'The following extensions must be loaded in your php.ini for Callicore to function', implode(', ', $diff));
+ throw new CC_Exception('%s : %s', 'The following extensions must be present - either built into to php or loaded via your php.ini - for Callicore to function', implode(', ', $diff));
}
self::$LARGE = Gtk::icon_size_register('gtk-large',64, 64);
@@ -126,6 +126,42 @@
return;
}
+ /**
+ * static public function ext
+ *
+ * checks for and attempts to load a php extension
+ * if require is true die with an error message
+ *
+ * @param string $ext extension to load
+ * @return void
+ */
+ static public function ext($ext)
+ {
+ // is the extension loaded?
+ if(extension_loaded($ext))
+ {
+ return;
+ }
+ // let's try to dl it
+ if((bool)ini_get('enable_dl') && !(bool)ini_get('safe_mode'))
+ {
+ // get absolute path to dl
+ $path = realpath(ini_get('extension_dir'));
+ // we can't rely on PHP_SHLIB_SUFFIX because it screws up on MAC
+ if(stristr(PHP_OS, 'win') && file_exists($path . DS . 'php_' . $ext . '.dll')
+ && dl($path . DS . 'php_' . $ext . '.dll'))
+ {
+ return;
+ }
+ elseif(file_exists($path . DS . $ext . '.so') && dl($path . DS . $ext . '.so'))
+ {
+ return;
+ }
+ }
+ // loading did not work - throw a fit
+ throw new CC_Exception('The %s extension must be present - either built into to php or loaded via your php.ini - for Callicore to function', $ext);
+ }
+
//----------------------------------------------------------------
// static helper functions
//----------------------------------------------------------------