]> git.mxchange.org Git - mailer.git/blobdiff - inc/language-functions.php
Code in 'init' phase of ext-order swapped out to daily_order.php, added filters for...
[mailer.git] / inc / language-functions.php
index 6d5735476904f0c8aaf10e7145e3d8e542958f75..3d716d966fad60481d27654dbcf188a3c7f5eda8 100644 (file)
@@ -16,8 +16,8 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
@@ -96,7 +96,7 @@ function addMessages ($messages) {
        }
 }
 
-// Checks wether given message id is valid
+// Checks whether given message id is valid
 function isMessageIdValid ($messageId) {
        return (isset($GLOBALS['messages'][getCurrentLanguage()][$messageId]));
 }
@@ -111,10 +111,15 @@ function setCurrentLanguage ($language) {
        $GLOBALS['language'] = (string) $language;
 }
 
+// Checks whether current language is set
+function isCurrentLanguageSet () {
+       return (isset($GLOBALS['language']));
+}
+
 // "Getter" for language
 function getLanguage () {
        // Do we have cache?
-       if (!isset($GLOBALS['language'])) {
+       if (!isCurrentLanguageSet()) {
                // Default is 'de'. DO NOT CHANGE THIS!!!
                $ret = 'de';
 
@@ -124,17 +129,17 @@ function getLanguage () {
                } // END - if
 
                // Is the variable set
-               if (isGetRequestParameterSet('mx_lang')) {
+               if (isGetRequestElementSet('mailer_lang')) {
                        // Accept only first 2 chars
-                       $ret = substr(getRequestParameter('mx_lang'), 0, 2);
-               } elseif (isset($GLOBALS['language'])) {
+                       $ret = substr(getRequestElement('mailer_lang'), 0, 2);
+               } elseif (isCurrentLanguageSet()) {
                        // Use cached
                        $ret = getCurrentLanguage();
-               } elseif (isSessionVariableSet('mx_lang')) {
+               } elseif (isSessionVariableSet('mailer_lang')) {
                        // Return stored value from cookie
-                       $ret = getSession('mx_lang');
+                       $ret = getSession('mailer_lang');
 
-                       // Fixes a warning before the session has the mx_lang constant
+                       // Fixes a warning before the session has the mailer_lang constant
                        if (empty($ret)) {
                                $ret = getDefaultLanguage();
                        } // END - if
@@ -154,10 +159,10 @@ function setLanguage ($lang) {
        $lang = substr(secureString($lang), 0, 2);
 
        // Set cookie
-       setSession('mx_lang', $lang);
+       setSession('mailer_lang', $lang);
 }
 
-// Checks wether a language file is there for optional extension
+// Checks whether a language file is there for optional extension
 function isLanguageIncludeReadable ($ext_name = 'none') {
        // Do we have array element?
        if (!isset($GLOBALS['lang_inc'][$ext_name])) {
@@ -265,7 +270,9 @@ function ifLanguageFilesCompares ($source, $target, $targetLanguage) {
        // Init differences
        $GLOBALS['lang_diff'][$target] = array();
        $GLOBALS['lang_diff_count'][$target] = 0;
-       if (!isset($GLOBALS['lang_diff_count']['total'])) $GLOBALS['lang_diff_count']['total'] = 0;
+       if (!isset($GLOBALS['lang_diff_count']['total'])) {
+               $GLOBALS['lang_diff_count']['total'] = 0;
+       } // END - if
 
        // *Does* match by default
        $matches = true;
@@ -273,13 +280,13 @@ function ifLanguageFilesCompares ($source, $target, $targetLanguage) {
        // Is one not readable?
        if (!isIncludeReadable($source)) {
                // Please report this bug!
-               debug_report_bug(__FUNCTION__, __LINE__, 'Source file ' . $source . ' is not readable.');
+               reportBug(__FUNCTION__, __LINE__, 'Source file ' . $source . ' is not readable.');
        } elseif (!isIncludeReadable($target)) {
                // Please report this bug!
-               debug_report_bug(__FUNCTION__, __LINE__, 'Target file ' . $target . ' is not readable.');
+               reportBug(__FUNCTION__, __LINE__, 'Target file ' . $target . ' is not readable.');
        } elseif ($targetLanguage == getCurrentLanguage()) {
                // Must be different
-               debug_report_bug(__FUNCTION__, __LINE__, 'Target language ' . $targetLanguage . ' is same as current.');
+               reportBug(__FUNCTION__, __LINE__, 'Target language ' . $targetLanguage . ' is same as current.');
        }
 
        // Backup current messages/language
@@ -340,16 +347,16 @@ function getLanguageComparisonDifference ($target) {
        return $GLOBALS['lang_diff_count'][$target];
 }
 
-// Checks wether the given message is masked
-function isMessageMasked ($messageId) {
+// Checks whether the given message is masked
+function isMessageMasked ($messageId, $strict = true) {
        // Is the message id valid?
-       if (!isMessageIdValid($messageId)) {
+       if (($strict === true) && (!isMessageIdValid($messageId))) {
                // No, then abort here
-               debug_report_bug(__FUNCTION__, __LINE__, 'Invalid message id ' . $messageId . ' detected.');
+               reportBug(__FUNCTION__, __LINE__, 'Invalid message id ' . $messageId . ' detected.');
        } // END - if
 
        // Now simply check it
-       $masked = (strpos($GLOBALS['messages'][getCurrentLanguage()][$messageId], '%') !== false);
+       $masked = isInString('%', getMessage($messageId));
 
        // Return result
        return $masked;