More rewrites to make lesser use of getMessage()
authorRoland Häder <roland@mxchange.org>
Tue, 29 Jun 2010 02:06:15 +0000 (02:06 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 29 Jun 2010 02:06:15 +0000 (02:06 +0000)
17 files changed:
DOCS/TODOs.txt
inc/functions.php
inc/install-inc.php
inc/libs/network_functions.php
inc/libs/removeip_functions.php
inc/libs/sponsor_functions.php
inc/libs/surfbar_functions.php
inc/libs/wernis_functions.php
inc/modules/admin/admin-inc.php
inc/modules/admin/what-add_rallye.php
inc/modules/admin/what-config_admins.php
inc/modules/admin/what-config_register.php
inc/modules/admin/what-email_details.php
inc/modules/admin/what-list_surfbar_actions.php
inc/modules/admin/what-list_user.php
inc/modules/guest/what-sponsor_login.php
inc/modules/member/what-mydata.php

index 9e5ceb7d0e7757cebc7987358dfae700d2a66ba2..265e6831f8a9db468a9165609f6e34e4c5adc44f 100644 (file)
 ./inc/extensions-functions.php:428:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) )
 ./inc/extensions-functions.php:544:            // @TODO Extension is loaded, what next?
 ./inc/functions.php:115:               // @TODO Extension 'msg' does not exist
-./inc/functions.php:1472:                      // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ?
-./inc/functions.php:1495:                      // @TODO Rewrite this old lost code to a template
-./inc/functions.php:1563:                      // @TODO Are these convertions still required?
-./inc/functions.php:1581:// @TODO Rewrite this function to use readFromFile() and writeToFile()
+./inc/functions.php:1460:                      // @TODO Move this SQL code into a function, let's say 'getTimestampFromPoolId($id) ?
+./inc/functions.php:1483:                      // @TODO Rewrite this old lost code to a template
+./inc/functions.php:1551:                      // @TODO Are these convertions still required?
+./inc/functions.php:1569:// @TODO Rewrite this function to use readFromFile() and writeToFile()
 ./inc/functions.php:178:// @TODO Rewrite this to an extension 'smtp'
-./inc/functions.php:2234:      // @TODO This is still very static, rewrite it somehow
+./inc/functions.php:2222:      // @TODO This is still very static, rewrite it somehow
 ./inc/install-functions.php:63:        // @TODO DEACTIVATED: changeDataInFile(getConfig('CACHE_PATH') . 'config-local.php', 'OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0);
 ./inc/language/de.php:1141:// @TODO Rewrite these two constants
 ./inc/language/de.php:1156:// @TODO Rewrite these three constants
@@ -74,9 +74,9 @@
 ./inc/libs/register_functions.php:372: // @TODO Rewrite this to a filter
 ./inc/libs/register_functions.php:379: // @TODO Rewrite this whole if() block to addPointsThroughReferalSystem(). This will also make following if() block obsolete
 ./inc/libs/register_functions.php:380: // @TODO Wether the registration bonus should only be added to user directly or through referal system should be configurable
-./inc/libs/surfbar_functions.php:1541:         // @TODO This can be somehow rewritten
+./inc/libs/surfbar_functions.php:1535:         // @TODO This can be somehow rewritten
 ./inc/libs/surfbar_functions.php:713:// @TODO Can't we use our new expression language instead of this ugly code?
-./inc/libs/surfbar_functions.php:957:  // @TODO Invalid salt should be refused
+./inc/libs/surfbar_functions.php:951:  // @TODO Invalid salt should be refused
 ./inc/libs/task_functions.php:241:             // @TODO These can be rewritten to filter
 ./inc/libs/task_functions.php:53:// @TODO Move all extension-dependent queries into filters
 ./inc/libs/theme_functions.php:95:     // @TODO Can't this be rewritten to an API function?
index 6f82e177899d66bd008f5f943499ff3ee40c48cd..5f62c273416bde14d01b56aa74fa8dd90ab813cf 100644 (file)
@@ -281,7 +281,7 @@ function generateDateTime ($time, $mode = '0') {
        // If the stamp is zero it mostly didn't "happen"
        if ($time == '0') {
                // Never happend
-               return getMessage('NEVER_HAPPENED');
+               return '{--NEVER_HAPPENED--}';
        } // END - if
 
        switch (getLanguage()) {
@@ -332,20 +332,8 @@ function translateYesNo ($yn) {
 
 // Translates the "pool type" into human-readable
 function translatePoolType ($type) {
-       // Default?type is unknown
-       $translated = getMaskedMessage('POOL_TYPE_UNKNOWN', $type);
-
-       // Generate constant
-       $constName = sprintf("POOL_TYPE_%s", $type);
-
-       // Does it exist?
-       if (isMessageIdValid($constName)) {
-               // Then use it
-               $translated = getMessage($constName);
-       } // END - if
-
        // Return "translation"
-       return $translated;
+       return sprintf("{--POOL_TYPE_%s--}", $type);
 }
 
 // Translates the american decimal dot into a german comma
@@ -417,7 +405,7 @@ function translateUserStatus ($status) {
                case 'UNCONFIRMED':
                case 'CONFIRMED':
                case 'LOCKED':
-                       $ret = getMessage(sprintf("ACCOUNT_%s", $status));
+                       $ret = sprintf("{--ACCOUNT_%s--}", $status);
                        break;
 
                case '':
index 2962d374a7c8f6b002fd92936d57c3ae50f8eb87..0b8928b27ce1bfc126c2da8a6c11284b2f161d04 100644 (file)
@@ -58,25 +58,25 @@ if ((isGetRequestParameterSet('page') && (getRequestParameter('page') == 5))) {
        // Okay, we have to check it
        if (isPostRequestParameterSet('smtp_user') && (!isPostRequestParameterSet('smtp_host'))) {
                // Hostname not set
-               addToInstallContent('<div class="para">' . getMessage('INSTALL_SMTP_HOSTNAME_EMPTY') . '</div>');
+               addToInstallContent('<div class="para">{--INSTALL_SMTP_HOSTNAME_EMPTY--}</div>');
                setGetRequestParameter('page', 3);
        } // END - if
 
        if ((!isPostRequestParameterSet('smtp_pass1')) && (isPostRequestParameterSet('smtp_pass2'))) {
                // Password is empty
-               addToInstallContent('<div class="para">' . getMessage('INSTALL_SMTP_PASS1_EMPTY') . '</div>');
+               addToInstallContent('<div class="para">{--INSTALL_SMTP_PASS1_EMPTY--}</div>');
                setGetRequestParameter('page', 3);
        } // END - if
 
        if ((isPostRequestParameterSet('smtp_pass1')) && (!isPostRequestParameterSet('smtp_pass2'))) {
                // Password repeat is empty
-               addToInstallContent('<div class="para">' . getMessage('INSTALL_SMTP_PASS2_EMPTY') . '</div>');
+               addToInstallContent('<div class="para">{--INSTALL_SMTP_PASS2_EMPTY--}</div>');
                setGetRequestParameter('page', 3);
        } // END - if
 
        if (postRequestParameter('smtp_pass1') != postRequestParameter('smtp_pass1')) {
                // Passwords are not matching
-               addToInstallContent('<div class="para">' . getMessage('INSTALL_SMTP_PASS_MISMATCH') . '</div>');
+               addToInstallContent('<div class="para">{--INSTALL_SMTP_PASS_MISMATCH--}</div>');
                setGetRequestParameter('page', 3);
        } // END - if
 } // END - if
index ad261c9aa045e27ec573a809acdd1f944d11e36b..da20b81374de623e09200c14277b09daa030a084 100644 (file)
@@ -638,8 +638,8 @@ function doAdminNetworkProcessHandlenetworkForm () {
                                                                'POST'
                                                        ),
                                                        array(
-                                                               getMessage('ADMIN_NETWORK_REQUEST_TYPE_GET'),
-                                                               getMessage('ADMIN_NETWORK_REQUEST_TYPE_POST')
+                                                               '{--ADMIN_NETWORK_REQUEST_TYPE_GET--}',
+                                                               '{--ADMIN_NETWORK_REQUEST_TYPE_POST--}'
                                                        ),
                                                        $networkData['network_request_type']
                                                );
index ba03102accb0b72477d0060ef01b6ddf16140e39..0ad68ef3e7baf317f30918f87182d6085caf284f 100644 (file)
@@ -136,17 +136,8 @@ function addAnonymityLevel () {
                        break;
        } // END - while
 
-       // Construct constant name
-       $constantName = sprintf("REMOVEIP_LEVEL_%s", strtoupper($suffix));
-
        // Default message
-       $message = getMaskedMessage('REMOVEIP_UNKNOWN_LEVEL', $suffix);
-
-       // Is that constant there?
-       if (isMessageIdValid($constantName)) {
-               // Use that string
-               $message = getMessage($constantName);
-       } // END - if
+       $message = sprintf("{--REMOVEIP_LEVEL_%s--}", strtoupper($suffix));
 
        // Output message in template
        return loadTemplate('removeip_level', true, $message);
index 10393757c299114f95007dfa1359393734c8fb60..76296b04e9743e337a4296953d98e6edf9c277d7 100644 (file)
@@ -141,8 +141,8 @@ function handlSponsorRequest (&$postData, $update=false, $messageArray=array(),
                                $DATA['values'][] = bigintval(getRequestParameter('id'));
 
                                // Generate message
-                               $message = getMessageFromIndexedArray(getMessage('ADMIN_SPONSOR_UPDATED'), 'updated', $messageArray);
-                               $ret = "updated";
+                               $message = getMessageFromIndexedArray('{--ADMIN_SPONSOR_UPDATED--}', 'updated', $messageArray);
+                               $ret = 'updated';
                        } elseif (($ALREADY === false) || (($postData['force'] == 1) && (isAdmin()))) {
                                // Add new sponsor, first add more data
                                $DATA['keys'][] = 'sponsor_created'; $DATA['values'][] = time();
@@ -162,14 +162,14 @@ function handlSponsorRequest (&$postData, $update=false, $messageArray=array(),
                                }
 
                                // Implode all data into strings
-                               $keyArray   = implode("`, `"  , $DATA['keys']);
+                               $keyArray   = implode('`, `'  , $DATA['keys']);
                                $valueArray = str_repeat("%s', '", count($DATA['values']) - 1);
 
                                // Generate string
-                               $sql = "INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_data` (`" . $keyArray . "`) VALUES ('" . $valueArray . "%s')";
+                               $sql = 'INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_data` (`' . $keyArray . "`) VALUES ('" . $valueArray . "%s')";
 
                                // Generate message
-                               $message = getMessageFromIndexedArray(getMessage('ADMIN_SPONSOR_ADDED'), 'added', $messageArray);
+                               $message = getMessageFromIndexedArray('{--ADMIN_SPONSOR_ADDED--}', 'added', $messageArray);
                                $ret = 'added';
                        } elseif (($update === true) && (isAdmin())) {
                                // Add all data as hidden data
@@ -205,7 +205,7 @@ function handlSponsorRequest (&$postData, $update=false, $messageArray=array(),
                        } // END - if
                } else {
                        // Error found!
-                       $message = getMessageFromIndexedArray(getMessage('SPONSOR_DATA_NOT_SAVED'), 'failed', $messageArray);
+                       $message = getMessageFromIndexedArray('{--SPONSOR_DATA_NOT_SAVED--}', 'failed', $messageArray);
                        loadTemplate('admin_settings_saved', false, $message);
                }
 
index 3939b0e40774716a310ddefc47c7f45934b8a9a2..09e25ee44143dac3cf22e7c87de5142b250db058 100644 (file)
@@ -661,9 +661,9 @@ function SURFBAR_NOTIFY_ADMIN ($messageType, $content) {
        $templateName = sprintf("admin_surfbar_%s", $messageType);
 
        // Prepare subject
-       $subject = getMessage(sprintf("ADMIN_SURFBAR_NOTIFY_%s_SUBJECT",
+       $subject = sprintf("{--ADMIN_SURFBAR_NOTIFY_%s_SUBJECT--}",
                strtoupper($messageType)
-       ));
+       );
 
        // Is the subject line there?
        if ((substr($subject, 0, 1) == '!') && (substr($subject, -1, 1) == '!')) {
@@ -689,9 +689,9 @@ function SURFBAR_NOTIFY_USER ($messageType, $content) {
        $templateName = sprintf("member_surfbar_%s", $messageType);
 
        // Prepare subject
-       $subject = getMessage(sprintf("MEMBER_SURFBAR_NOTIFY_%s_SUBJECT",
+       $subject = sprintf("{--MEMBER_SURFBAR_NOTIFY_%s_SUBJECT--}",
                strtoupper($messageType)
-       ));
+       );
 
        // Is the subject line there?
        if ((substr($subject, 0, 1) == '!') && (substr($subject, -1, 1) == '!')) {
@@ -737,14 +737,8 @@ function translateSurfbarLimit ($limit) {
 
 // Translate the URL status
 function translateSurfbarUrlStatus ($status) {
-       // Create constant name
-       $constantName = sprintf("SURFBAR_URL_STATUS_%s", strtoupper($status));
-
-       // Get message
-       $statusTranslated = getMessage($constantName);
-
        // Return result
-       return $statusTranslated;
+       return sprintf("{--SURFBAR_URL_STATUS_%s--}", strtoupper($status));
 }
 
 // Determine reward
index 05c11107ac9d38c407645ae391efee50d5a69431..21c3f2f1478c3e8896d0e69a60f8c690e9d05972 100644 (file)
@@ -58,7 +58,7 @@ function GET_WERNIS_ERROR_MESSAGE () {
                return getMaskedMessage('WERNIS_ERROR_STATUS', $GLOBALS['wernis_data']['status']);
        } else {
                // Something bad happend
-               return getMessage('WERNIS_UNKNOWN_ERROR');
+               return '{--WERNIS_UNKNOWN_ERROR--}';
        }
 }
 
@@ -69,7 +69,7 @@ function GET_WERNIS_ERROR_CODE () {
                return $GLOBALS['wernis_data']['status'];
        } else {
                // Something bad happend
-               return getMessage('WERNIS_UNKNOWN_ERROR');
+               return '{--WERNIS_UNKNOWN_ERROR--}';
        }
 }
 
index d455f6cc24b26c33ff02be1531959e2da40fbade..5adf74d855828a3b247f18ddd211ec1eaf9d6bbf 100644 (file)
@@ -1114,7 +1114,7 @@ function sendAdminPasswordResetLink ($email) {
        // Is there an account?
        if (SQL_HASZERONUMS($result)) {
                // No account found!
-               return getMessage('ADMIN_NO_LOGIN_WITH_EMAIL');
+               return '{--ADMIN_NO_LOGIN_WITH_EMAIL--}';
        } // END - if
 
        // Load all data
@@ -1137,7 +1137,7 @@ function sendAdminPasswordResetLink ($email) {
        sendEmail($email, '{--ADMIN_RESET_PASS_LINK_SUBJECT--}', $mailText);
 
        // Prepare output
-       return getMessage('ADMIN_RESET_LINK_SENT');
+       return '{--ADMIN_RESET_LINK_SENT--}';
 }
 
 // Validate hash and login for password reset
@@ -1181,7 +1181,7 @@ function doResetAdminPassword ($login, $password) {
        runFilterChain('post_admin_reset_pass', array('login' => $login, 'hash' => $passHash));
 
        // Return output
-       return getMessage('ADMIN_PASSWORD_RESET_DONE');
+       return '{--ADMIN_PASSWORD_RESET_DONE--}';
 }
 
 // Solves a task by given id number
index 04c34869655407cc523a4d06c4923def375d31af..9b57ec31f3e982baf3a97320f8029a0ce9138323 100644 (file)
@@ -93,9 +93,9 @@ VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s')",
 }
 
 // Prepare some constants for the template
-$content['auto_add_options'] = generateOptionList('/ARRAY/', array('Y','N'), array(getMessage('YES'), '{--NO--}' ));
-$content['active_options']   = generateOptionList('/ARRAY/', array('N','Y'), array(getMessage('NO') , '{--YES--}'));
-$content['notify_options']   = generateOptionList('/ARRAY/', array('Y','N'), array(getMessage('YES'), '{--NO--}' ));
+$content['auto_add_options'] = generateOptionList('/ARRAY/', array('Y','N'), array('{--YES--}', '{--NO--}' ));
+$content['active_options']   = generateOptionList('/ARRAY/', array('N','Y'), array('{--NO--}' , '{--YES--}'));
+$content['notify_options']   = generateOptionList('/ARRAY/', array('Y','N'), array('{--YES--}', '{--NO--}' ));
 
 // Starting day
 $content['start_sec']   = addSelectionBox('sec'  , 0              , 'start');
index aee1399056fd3727118618b897cffd2f8009a720..f53b8c206a06a4eb96d9b5808112b0a4358a0eab 100644 (file)
@@ -65,8 +65,8 @@ if ((isFormSent('edit')) && (countPostSelection() > 0)) {
                                '/ARRAY/',
                                array('allow', 'deny'),
                                array(
-                                       getMessage('ADMINS_ALLOW_MODE'),
-                                       getMessage('ADMINS_DENY_MODE')
+                                       '{--ADMINS_ALLOW_MODE--}',
+                                       '{--ADMINS_DENY_MODE--}'
                                ),
                                $mode
                        ),
@@ -219,8 +219,8 @@ VALUES ('%s','%s','%s','%s')",
                '/ARRAY/',
                array('allow', 'deny'),
                array(
-                       getMessage('ADMINS_ALLOW_MODE'),
-                       getMessage('ADMINS_DENY_MODE')
+                       'ADMINS_ALLOW_MODE--}',
+                       'ADMINS_DENY_MODE--}'
                )
        );
 
index 1c6792fde03c6b69c2818f99357c086b30fba970..0d65e88d6fb481cb28e3dfab614f1c61413a358c 100644 (file)
@@ -69,7 +69,7 @@ $result = SQL_QUERY("SELECT `id`, `field_name`, `field_required` FROM `{?_MYSQL_
 $OUT = '';
 while ($content = SQL_FETCHARRAY($result)) {
        // Get language string
-       $content['field_name'] =  getMessage(strtoupper($content['field_name']));
+       $content['field_name'] = '{--' . strtoupper($content['field_name']) . '--}';
 
        // Add more data
        $content['selection'] = addSelectionBox('yn', $content['field_required'], 'sel[' . $content['id'] . ']');
index c761546c94d512b27e7dfaad86de1d683ced90e1..60f0462e39ddc7027bbe307abd62de6c5ddb2d73 100644 (file)
@@ -65,7 +65,7 @@ WHERE
 ORDER BY
        `timestamp` DESC";
 
-$WHO = '{--_ALL--}';
+$WHO = '';
 $SQL2 = '';
 
 if (isGetRequestParameterSet(('mid'))) {
@@ -98,7 +98,7 @@ ORDER BY
 // Init result_bonus
 $result_bonus = false;
 
-if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
+if ((isExtensionActive('bonus')) && (empty($WHO))) {
        // Check for maximum pages
        $result_bonus = SQL_QUERY("SELECT
        `id`, `subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `mails_sent`, `clicks`
@@ -141,7 +141,7 @@ if (!isGetRequestParameterSet(('mid'))) {
 
 // Run SQL query for normal mails
 $result_list = SQL_QUERY($sql, __FILE__, __LINE__);
-if ((!empty($SQL2)) && ($WHO == getMessage('_ALL'))) $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
+if ((!empty($SQL2)) && (empty($WHO))) $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
 
 // Calculate pages
 $numPages = '0';
@@ -193,13 +193,13 @@ if (SQL_NUMROWS($result_list) > 0) {
        loadTemplate('admin_list_emails', false, $content);
 
        $MAIL = true;
-       if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
+       if ((isExtensionActive('bonus')) && (empty($WHO))) {
                // Only check if bonus extension is active
                if (SQL_NUMROWS($result_bonus) > 0) outputHtml('<br /><br />');
        } // END - if
 }
 
-if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
+if ((isExtensionActive('bonus')) && (empty($WHO))) {
        // Load bonus mails only when extension is active
        if (SQL_NUMROWS($result_bonus) > 0) {
                // Calculate pages
index 3c9061ad4000ab2f7ebdf60321ed3d3ff859bcff..afacd0579ab63250cddd2570712db56e80ad7233 100644 (file)
@@ -63,7 +63,7 @@ if (SQL_NUMROWS($result) > 0) {
        $OUT = '';
        while ($content = SQL_FETCHARRAY($result)) {
                // "Translate" some data
-               $content['actions_action'] = getMessage(sprintf("MEMBER_SURFBAR_ACTION_%s_SUBMIT", $content['actions_action']));
+               $content['actions_action'] = sprintf("{--MEMBER_SURFBAR_ACTION_%s_SUBMIT--}", strtoupper($content['actions_action']));
 
                // New status set?
                if (!is_null($content['actions_new_status'])) {
index 3bd4aabdd964e5e4cb0e9bb8c814c7caf1e8ff7e..30943e37a68e34bb4ee8d7ab16edc6cea0a80bd8 100644 (file)
@@ -323,10 +323,10 @@ LIMIT 1",
                $content['title'] = '{--ADMIN_ALL_ACCOUNTS--}';
                if (isGetRequestParameterSet(('status'))) {
                        // Set title according to the 'status'
-                       $content['title'] = getMessage(sprintf("ADMIN_LIST_STATUS_%s_ACCOUNTS", strtoupper(getRequestParameter(('status')))));
+                       $content['title'] = sprintf("{--ADMIN_LIST_STATUS_%s_ACCOUNTS--}", strtoupper(getRequestParameter(('status'))));
                } elseif (isGetRequestParameterSet('mode')) {
                        // Set title according to the "mode"
-                       $content['title'] = getMessage(sprintf("ADMIN_LIST_MODE_%s_ACCOUNTS", strtoupper(getRequestParameter('mode'))));
+                       $content['title'] = sprintf("{--ADMIN_LIST_MODE_%s_ACCOUNTS--}", strtoupper(getRequestParameter('mode')));
                }
 
                // Merge more data again
index 340e211f52649f91172daf7eaf1ef22700e3c33b..89b66c180ce207a31344ee83eddaa8f3e5d36ede 100644 (file)
@@ -135,7 +135,7 @@ LIMIT 1",
                }
        } else {
                // No sponsor found
-               loadTemplate('admin_settings_saved', false, sprintf(getMessage('SPONSOR_ACCOUNT_404'), getRequestParameter('hash')));
+               loadTemplate('admin_settings_saved', false, getMaskedMessage('SPONSOR_ACCOUNT_404', getRequestParameter('hash')));
        }
 
        // Free memory
index ab440d29bea8b2650edcd539e4143912132daba3..db81bda1d978499ef228e7bf6a029c82875c68cb 100644 (file)
@@ -317,7 +317,7 @@ LIMIT 1",
        case 'notify': // Switch off notfication
                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `notified`='N', `last_update`=UNIX_TIMESTAMP() WHERE `userid`=%s LIMIT 1",
                        array(getMemberId()), __FILE__, __LINE__);
-               $url = 'modules.php?module=login&amp;what=welcome&amp;code=' . urlencode(getMessage('PROFILE_UPDATED'));
+               $url = 'modules.php?module=login&amp;what=mydata&amp;code=' . getCode('PROFILE_UPDATED');
                break;
 } // END - switch