Function loadLanguageFile() does now support extensions
[mailer.git] / inc / extensions.php
index 22f218150d7cfc16d48aa0c5c416eb67d3827d7a..1b17f1101fac4658a573bf05fec6feb3d70bbd4d 100644 (file)
@@ -79,21 +79,8 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = '', $EXT_VER = '', $dry_run
                return false;
        } // END - if
 
-       // Construct FQFN for language file
-       $langInclude = sprintf("inc/language/%s_%s.php", $ext_name, getLanguage());
-
-       // Is this include there?
-       if ((isFileReadable($langInclude)) && (!isset($GLOBALS['ext_loaded']['lang'][$ext_name]))) {
-               // Then load it
-               //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Language loaded.");
-               $GLOBALS['ext_loaded']['lang'][$ext_name] = true;
-               loadIncludeOnce($langInclude);
-       } elseif ((isDebugModeEnabled()) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) {
-               // No language file is not so good...
-               DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no language file or we cannot read from it. lang=%s",
-                       $ext_name, getLanguage()
-               ));
-       }
+       // Load extension's own language file
+       loadLanguageFile($ext_name);
 
        // Construct FQFN for functions file
        $funcsInclude = sprintf("inc/libs/%s_functions.php", $ext_name);
@@ -148,7 +135,7 @@ function REGISTER_EXTENSION ($ext_name, $task_id, $dry_run = false, $logout = tr
        // Set current extension name
        EXT_SET_CURR_NAME($ext_name);
 
-       //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()." - ENTERED!<br />\n";
+       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()." - ENTERED!<br />");
        // This shall never do a non-admin user or if the extension is active (already installed)
        if ((!IS_ADMIN()) || (EXT_IS_ACTIVE($ext_name))) {
                return false;
@@ -157,7 +144,7 @@ function REGISTER_EXTENSION ($ext_name, $task_id, $dry_run = false, $logout = tr
        // When this extension is already in install/update phase, all is fine
        if (EXT_IS_REGISTER_RUNNING($ext_name)) {
                // Then abort here which is fine
-               //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()." - ALREADY!<br />\n";
+               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()." - ALREADY!<br />");
                return true;
        } // END - if
 
@@ -236,12 +223,12 @@ function REGISTER_EXTENSION ($ext_name, $task_id, $dry_run = false, $logout = tr
                                        // Entry found?
                                        if ($task > 0) {
                                                // Try to register the extension
-                                               //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().":ext_update=".$ext_update.",taskId=".$task."<br />\n";
+                                               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().":ext_update=".$ext_update.",taskId=".$task."<br />");
                                                $test = REGISTER_EXTENSION($ext_update, $task, $dry_run, false);
 
                                                // Reset extension name
                                                EXT_SET_CURR_NAME($ext_name);
-                                               //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().':'; var_dump($test);
+                                               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().':'); var_dump($test);
                                        } // END - if
                                } elseif ($ext_ver != EXT_GET_VERSION()) {
                                        // Ok, update this extension now
@@ -273,9 +260,9 @@ function REGISTER_EXTENSION ($ext_name, $task_id, $dry_run = false, $logout = tr
                $EXT_LOAD_MODE = 'register';
 
                // Remains true if extension registration reports no failures
-               //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().':'; var_dump($test);
+               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().':'); var_dump($test);
                $test = (($test === true) && (EXT_GET_REPORTS_FAILURE() === false));
-               //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().':'; var_dump($test);
+               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().':'); var_dump($test);
 
                // Does everthing before wents ok?
                if ($test === true) {
@@ -290,7 +277,7 @@ function REGISTER_EXTENSION ($ext_name, $task_id, $dry_run = false, $logout = tr
                                runFilterChain('pre_extension_installed', array('dry_run' => $dry_run));
 
                                // Register extension
-                               //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:insert=".EXT_GET_CURR_NAME().'/'.EXT_GET_VERSION()." - INSERT!<br />\n";
+                               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."[".__LINE__."]:insert=".EXT_GET_CURR_NAME().'/'.EXT_GET_VERSION()." - INSERT!<br />");
                                SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_extensions` (ext_name, ext_active, ext_version) VALUES ('%s','%s','%s')",
                                        array(EXT_GET_CURR_NAME(), EXT_GET_ALWAYS_ACTIVE(), EXT_GET_VERSION()), __FUNCTION__, __LINE__);
 
@@ -328,7 +315,7 @@ function REGISTER_EXTENSION ($ext_name, $task_id, $dry_run = false, $logout = tr
                        $ret = false;
                }
        } elseif (($task_id > 0) && (EXT_GET_CURR_NAME() != '')) {
-               //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()."<br />\n";
+               //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()."<br />");
                // Remove task from system when id and extension's name is valid
                SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_task_system` WHERE `id`=%s AND `status`='NEW' LIMIT 1",
                        array(bigintval($task_id)), __FUNCTION__, __LINE__);
@@ -349,7 +336,7 @@ function REGISTER_EXTENSION ($ext_name, $task_id, $dry_run = false, $logout = tr
        } // END - if
 
        // Return status code
-       //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()." - LEFT!<br />\n";
+       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME()." - LEFT!<br />");
        //* DEBUG: */ var_dump($ret);
        return $ret;
 }
@@ -549,7 +536,7 @@ function EXTENSION_UPDATE ($ext_name, $ext_ver, $dry_run = false) {
                // And load SQL queries in order of version history
                for ($idx = ($start + 1); $idx < count($history); $idx++) {
                        // Set current extension name
-                       //* DEBUG: */ print __FUNCTION__.'['.__LINE__.':] ext_name='.$ext_name."<br />\n";
+                       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__.'['.__LINE__.':] ext_name='.$ext_name."<br />");
                        EXT_SET_CURR_NAME($ext_name);
 
                        // Set extension version
@@ -875,7 +862,7 @@ function MODULE_HAS_MENU ($mod, $forceDb = false) {
        }
 
        // Return status
-       //* DEBUG: */ print __FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().':'; var_dump($ret);
+       //* DEBUG: */ OUTPUT_HTML(__FUNCTION__."[".__LINE__."]:currName=".EXT_GET_CURR_NAME().':'; var_dump($ret));
        return $ret;
 }