Rev 699 | Rev 704 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 699 | Rev 702 | ||
---|---|---|---|
Line 25... | Line 25... | ||
25 | private static /*OIDplusLoggerPlugin[]*/ $loggerPlugins = array(); |
25 | private static /*OIDplusLoggerPlugin[]*/ $loggerPlugins = array(); |
26 | private static /*OIDplusObjectTypePlugin[]*/ $objectTypePlugins = array(); |
26 | private static /*OIDplusObjectTypePlugin[]*/ $objectTypePlugins = array(); |
27 | private static /*string[]*/ $enabledObjectTypes = array(); |
27 | private static /*string[]*/ $enabledObjectTypes = array(); |
28 | private static /*string[]*/ $disabledObjectTypes = array(); |
28 | private static /*string[]*/ $disabledObjectTypes = array(); |
29 | private static /*OIDplusDatabasePlugin[]*/ $dbPlugins = array(); |
29 | private static /*OIDplusDatabasePlugin[]*/ $dbPlugins = array(); |
- | 30 | private static /*OIDplusCaptchaPlugin[]*/ $captchaPlugins = array(); |
|
30 | private static /*OIDplusSqlSlangPlugin[]*/ $sqlSlangPlugins = array(); |
31 | private static /*OIDplusSqlSlangPlugin[]*/ $sqlSlangPlugins = array(); |
31 | private static /*OIDplusLanguagePlugin[]*/ $languagePlugins = array(); |
32 | private static /*OIDplusLanguagePlugin[]*/ $languagePlugins = array(); |
32 | private static /*OIDplusDesignPlugin[]*/ $designPlugins = array(); |
33 | private static /*OIDplusDesignPlugin[]*/ $designPlugins = array(); |
33 | 34 | ||
34 | protected static $html = true; |
35 | protected static $html = true; |
Line 308... | Line 309... | ||
308 | public static function getDatabasePlugins() { |
309 | public static function getDatabasePlugins() { |
309 | return self::$dbPlugins; |
310 | return self::$dbPlugins; |
310 | } |
311 | } |
311 | 312 | ||
312 | public static function getActiveDatabasePlugin() { |
313 | public static function getActiveDatabasePlugin() { |
313 | if (OIDplus::baseConfig()->getValue('DATABASE_PLUGIN', '') === '') { |
314 | $db_plugin_name = OIDplus::baseConfig()->getValue('DATABASE_PLUGIN',''); |
- | 315 | if ($db_plugin_name === '') { |
|
314 | throw new OIDplusConfigInitializationException(_L('No database plugin selected in config file')); |
316 | throw new OIDplusConfigInitializationException(_L('No database plugin selected in config file')); |
315 | } |
317 | } |
316 | if (!isset(self::$dbPlugins[OIDplus::baseConfig()->getValue('DATABASE_PLUGIN')])) { |
318 | if (!isset(self::$dbPlugins[$db_plugin_name])) { |
317 | $db_plugin_name = OIDplus::baseConfig()->getValue('DATABASE_PLUGIN'); |
- | |
318 | throw new OIDplusConfigInitializationException(_L('Database plugin "%1" not found',$db_plugin_name)); |
319 | throw new OIDplusConfigInitializationException(_L('Database plugin "%1" not found',$db_plugin_name)); |
319 | } |
320 | } |
320 | return self::$dbPlugins[OIDplus::baseConfig()->getValue('DATABASE_PLUGIN')]; |
321 | return self::$dbPlugins[$db_plugin_name]; |
321 | } |
322 | } |
322 | 323 | ||
323 | private static $dbMainSession = null; |
324 | private static $dbMainSession = null; |
324 | public static function db() { |
325 | public static function db() { |
325 | if (is_null(self::$dbMainSession)) { |
326 | if (is_null(self::$dbMainSession)) { |
Line 336... | Line 337... | ||
336 | } |
337 | } |
337 | if (!self::$dbIsolatedSession->isConnected()) self::$dbIsolatedSession->connect(); |
338 | if (!self::$dbIsolatedSession->isConnected()) self::$dbIsolatedSession->connect(); |
338 | return self::$dbIsolatedSession; |
339 | return self::$dbIsolatedSession; |
339 | } |
340 | } |
340 | 341 | ||
- | 342 | # --- CAPTCHA plugin |
|
- | 343 | ||
- | 344 | private static function registerCaptchaPlugin(OIDplusCaptchaPlugin $plugin) { |
|
- | 345 | $name = $plugin::id(); |
|
- | 346 | if ($name === '') return false; |
|
- | 347 | ||
- | 348 | if (isset(self::$captchaPlugins[$name])) { |
|
- | 349 | $plugintype_hf = _L('CAPTCHA'); |
|
- | 350 | throw new OIDplusException(_L('Multiple %1 plugins use the ID %2', $plugintype_hf, $name)); |
|
- | 351 | } |
|
- | 352 | ||
- | 353 | self::$captchaPlugins[$name] = $plugin; |
|
- | 354 | ||
- | 355 | return true; |
|
- | 356 | } |
|
- | 357 | ||
- | 358 | public static function getCaptchaPlugins() { |
|
- | 359 | return self::$captchaPlugins; |
|
- | 360 | } |
|
- | 361 | ||
- | 362 | public static function getActiveCaptchaPlugin() { |
|
- | 363 | ||
- | 364 | $captcha_plugin_name = OIDplus::baseConfig()->getValue('CAPTCHA_PLUGIN', ''); |
|
- | 365 | ||
- | 366 | if (OIDplus::baseConfig()->getValue('RECAPTCHA_ENABLED', false) && ($captcha_plugin_name === '')) { |
|
- | 367 | // Legacy config file support! |
|
- | 368 | $captcha_plugin_name = 'ReCAPTCHA'; |
|
- | 369 | } |
|
- | 370 | ||
- | 371 | if ($captcha_plugin_name === '') $captcha_plugin_name = 'None'; |
|
- | 372 | ||
- | 373 | if (!isset(self::$captchaPlugins[$captcha_plugin_name])) { |
|
- | 374 | throw new OIDplusConfigInitializationException(_L('CAPTCHA plugin "%1" not found',$captcha_plugin_name)); |
|
- | 375 | } |
|
- | 376 | return self::$captchaPlugins[$captcha_plugin_name]; |
|
- | 377 | } |
|
- | 378 | ||
341 | # --- Page plugin |
379 | # --- Page plugin |
342 | 380 | ||
343 | private static function registerPagePlugin(OIDplusPagePlugin $plugin) { |
381 | private static function registerPagePlugin(OIDplusPagePlugin $plugin) { |
344 | self::$pagePlugins[] = $plugin; |
382 | self::$pagePlugins[] = $plugin; |
345 | 383 | ||
Line 540... | Line 578... | ||
540 | $res = array_merge($res, self::$pagePlugins); |
578 | $res = array_merge($res, self::$pagePlugins); |
541 | $res = array_merge($res, self::$authPlugins); |
579 | $res = array_merge($res, self::$authPlugins); |
542 | $res = array_merge($res, self::$loggerPlugins); |
580 | $res = array_merge($res, self::$loggerPlugins); |
543 | $res = array_merge($res, self::$objectTypePlugins); |
581 | $res = array_merge($res, self::$objectTypePlugins); |
544 | $res = array_merge($res, self::$dbPlugins); |
582 | $res = array_merge($res, self::$dbPlugins); |
- | 583 | $res = array_merge($res, self::$captchaPlugins); |
|
545 | $res = array_merge($res, self::$sqlSlangPlugins); |
584 | $res = array_merge($res, self::$sqlSlangPlugins); |
546 | $res = array_merge($res, self::$languagePlugins); |
585 | $res = array_merge($res, self::$languagePlugins); |
547 | $res = array_merge($res, self::$designPlugins); |
586 | $res = array_merge($res, self::$designPlugins); |
548 | return $res; |
587 | return $res; |
549 | } |
588 | } |
Line 762... | Line 801... | ||
762 | self::$loggerPlugins = array(); |
801 | self::$loggerPlugins = array(); |
763 | self::$objectTypePlugins = array(); |
802 | self::$objectTypePlugins = array(); |
764 | self::$enabledObjectTypes = array(); |
803 | self::$enabledObjectTypes = array(); |
765 | self::$disabledObjectTypes = array(); |
804 | self::$disabledObjectTypes = array(); |
766 | self::$dbPlugins = array(); |
805 | self::$dbPlugins = array(); |
- | 806 | self::$captchaPlugins = array(); |
|
767 | self::$sqlSlangPlugins = array(); |
807 | self::$sqlSlangPlugins = array(); |
768 | self::$languagePlugins = array(); |
808 | self::$languagePlugins = array(); |
769 | self::$designPlugins = array(); |
809 | self::$designPlugins = array(); |
770 | self::$system_id_cache = null; |
810 | self::$system_id_cache = null; |
771 | self::$sslAvailableCache = null; |
811 | self::$sslAvailableCache = null; |
Line 790... | Line 830... | ||
790 | self::registerAllPlugins('database', 'OIDplusDatabasePlugin', array('OIDplus','registerDatabasePlugin')); |
830 | self::registerAllPlugins('database', 'OIDplusDatabasePlugin', array('OIDplus','registerDatabasePlugin')); |
791 | foreach (OIDplus::getDatabasePlugins() as $plugin) { |
831 | foreach (OIDplus::getDatabasePlugins() as $plugin) { |
792 | $plugin->init($html); |
832 | $plugin->init($html); |
793 | } |
833 | } |
794 | 834 | ||
- | 835 | // CAPTCHA plugins |
|
- | 836 | ||
- | 837 | self::registerAllPlugins('captcha', 'OIDplusCaptchaPlugin', array('OIDplus','registerCaptchaPlugin')); |
|
- | 838 | foreach (OIDplus::getCaptchaPlugins() as $plugin) { |
|
- | 839 | $plugin->init($html); |
|
- | 840 | } |
|
- | 841 | ||
795 | // Do redirect stuff etc. |
842 | // Do redirect stuff etc. |
796 | 843 | ||
797 | self::isSslAvailable(); // This function does automatic redirects |
844 | self::isSslAvailable(); // This function does automatic redirects |
798 | 845 | ||
799 | // Construct the configuration manager |
846 | // Construct the configuration manager |