]> git.mxchange.org Git - mailer.git/blobdiff - inc/load_extensions.php
rewritten to new functions, some parts rewritten to filters
[mailer.git] / inc / load_extensions.php
index c3d2574d795659a6f0b006496f694a9f6f27fce5..e06f522cbdc20053d0788b2c0a2163eeb789411f 100644 (file)
@@ -38,8 +38,7 @@ if (!defined('__SECURITY')) {
 }
 
 // Init variables
-global $EXT_CSS_FILES;
-$EXT_CSS_FILES = array();
+EXT_INIT_CSS_FILES();
 $ADD = "";
 
 // Init cache instance and array
@@ -47,7 +46,13 @@ $GLOBALS['cache_instance'] = null;
 $GLOBALS['cache_array'] = array();
 
 // Skip loading extensions
-if ((!isBooleanConstantAndTrue('mxchange_installed')) || (isBooleanConstantAndTrue('mxchange_installing'))) return;
+if ((!isInstalled()) || (isInstalling())) {
+       // Init filter system here
+       INIT_FILTER_SYSTEM();
+
+       // Skip loading
+       return;
+} // END - if
 
 // Initialize array for "always keep active extensions"
 $GLOBALS['cache_array']['active_extensions'] = array();
@@ -56,14 +61,23 @@ $GLOBALS['cache_array']['active_extensions'] = array();
 $GLOBALS['cacheMode'] = "no";
 
 // Load sql_patchrs extension alone
-LOAD_EXTENSION("sql_patches");
+if (!LOAD_EXTENSION("sql_patches")) {
+       // Could not load sql_patches! ARGH!!!
+       trigger_error("Cannot load extension sql_patches.");
+} // END - if
+
+// Init inc pool array
+$INC_POOL = array();
 
 //
 // Load extensions
 //
 if (EXT_IS_ACTIVE("cache")) {
        // Load cache extension alone
-       LOAD_EXTENSION("cache");
+       if (!LOAD_EXTENSION("cache")) {
+               // Extension 'cache' was not loaded
+               trigger_error("Cannot load extension cache.");
+       } // END - if
 
        // Check extension cache
        switch (($GLOBALS['cache_instance']->loadCacheFile("extensions", true)) && ($GLOBALS['cache_instance']->extensionVersionMatches("sql_patches"))) {
@@ -107,7 +121,7 @@ if ($GLOBALS['cacheMode'] == "load") {
        $EXT_NAMES = array();
        foreach ($EXT_DUMMY['ext_name'] as $k => $name) {
                // Load CSS file
-               if ($EXT_DUMMY['ext_css'][$k] == "Y") $EXT_CSS_FILES[] = "".$name.".css";
+               if ($EXT_DUMMY['ext_css'][$k] == "Y") EXT_ADD_CSS_FILE("".$name.".css");
 
                // Load extension file itself
                if ((($EXT_DUMMY['ext_active'][$k] == "Y") || ($EXT_DUMMY['ext_keep'][$k] == "Y") || (IS_ADMIN())) && (!in_array($name, array("sql_patches", "cache")))) {
@@ -195,9 +209,6 @@ $DEL = array();
 
 // At least one found?
 if ((SQL_NUMROWS($res_ext_crt) > 0) && ((($GLOBALS['cacheMode'] == "init") && ($GLOBALS['output_mode'] != "1") && ($GLOBALS['output_mode'] != "-1")) || ($GLOBALS['cacheMode'] == "no"))) {
-       // Load session management
-       LOAD_INC_ONCE("inc/session.php");
-
        // Extensions are registered so we load them
        while ($content = SQL_FETCHARRAY($res_ext_crt)) {
                // Get menu entry
@@ -212,7 +223,7 @@ if ((SQL_NUMROWS($res_ext_crt) > 0) && ((($GLOBALS['cacheMode'] == "init") && ($
                // Does the extension file exists?
                if (FILE_READABLE($FQFN)) {
                        // By default no extension is always active, except sql_patches
-                       $EXT_ALWAYS_ACTIVE = "N";
+                       EXT_SET_ALWAYS_ACTIVE("N");
 
                        // Load extension
                        if (($content['ext_name'] != "sql_patches") && (($content['ext_name'] != "cache") || (!EXT_IS_ACTIVE("cache")))) {
@@ -220,21 +231,21 @@ if ((SQL_NUMROWS($res_ext_crt) > 0) && ((($GLOBALS['cacheMode'] == "init") && ($
                                LOAD_EXTENSION($content['ext_name']);
                        } else {
                                // Keep sql_patches always active
-                               $EXT_ALWAYS_ACTIVE = "Y";
+                               EXT_SET_ALWAYS_ACTIVE("Y");
                        }
 
                        // Transfer EXT_ALWAYS_ACTIVE flag
-                       $content['ext_keep'] = $EXT_ALWAYS_ACTIVE;
+                       $content['ext_keep'] = EXT_GET_ALWAYS_ACTIVE();
 
                        // CSS file handling:
                        if ((!isset($content['ext_css'])) || ($content['ext_css'] == "Y")) {
                                // Create FQFN for the CSS file
-                               $GLOBALS['output_mode']_FILE = sprintf("%stheme/%s/css/%s.css", constant('PATH'), GET_CURR_THEME(), $content['ext_name']);
+                               $FQFN = sprintf("%stheme/%s/css/%s.css", constant('PATH'), GET_CURR_THEME(), $content['ext_name']);
 
                                // Is the file there?
-                               if (FILE_READABLE($GLOBALS['output_mode']_FILE)) {
+                               if (FILE_READABLE($FQFN)) {
                                        // CSS file for extension was found (use only relative path for now!)
-                                       $EXT_CSS_FILES[] = $content['ext_name'].".css";
+                                       EXT_ADD_CSS_FILE($content['ext_name'].".css");
                                        $content['ext_css'] = "Y";
                                } else {
                                        // Don't load CSS file
@@ -248,7 +259,7 @@ if ((SQL_NUMROWS($res_ext_crt) > 0) && ((($GLOBALS['cacheMode'] == "init") && ($
                                $GLOBALS['cache_instance']->addRow($content);
                        } elseif ($GLOBALS['cacheMode'] == "no") {
                                // Remember this value for later usage
-                               $GLOBALS['cache_array']['active_extensions'][$content['ext_name']] = $EXT_ALWAYS_ACTIVE;
+                               $GLOBALS['cache_array']['active_extensions'][$content['ext_name']] = EXT_GET_ALWAYS_ACTIVE();
                        }
                } elseif (!FILE_READABLE($FQFN)) {
                        // Deleted extension file so we mark it for removal from DB