From: Roland Häder Date: Tue, 29 Jun 2010 02:06:15 +0000 (+0000) Subject: More rewrites to make lesser use of getMessage() X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4cd3aebe807c719e7867ef5aefe824c55033f72d;p=mailer.git More rewrites to make lesser use of getMessage() --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 9e5ceb7d0e..265e6831f8 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -42,12 +42,12 @@ ./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? diff --git a/inc/functions.php b/inc/functions.php index 6f82e17789..5f62c27341 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -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 '': diff --git a/inc/install-inc.php b/inc/install-inc.php index 2962d374a7..0b8928b27c 100644 --- a/inc/install-inc.php +++ b/inc/install-inc.php @@ -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('
' . getMessage('INSTALL_SMTP_HOSTNAME_EMPTY') . '
'); + addToInstallContent('
{--INSTALL_SMTP_HOSTNAME_EMPTY--}
'); setGetRequestParameter('page', 3); } // END - if if ((!isPostRequestParameterSet('smtp_pass1')) && (isPostRequestParameterSet('smtp_pass2'))) { // Password is empty - addToInstallContent('
' . getMessage('INSTALL_SMTP_PASS1_EMPTY') . '
'); + addToInstallContent('
{--INSTALL_SMTP_PASS1_EMPTY--}
'); setGetRequestParameter('page', 3); } // END - if if ((isPostRequestParameterSet('smtp_pass1')) && (!isPostRequestParameterSet('smtp_pass2'))) { // Password repeat is empty - addToInstallContent('
' . getMessage('INSTALL_SMTP_PASS2_EMPTY') . '
'); + addToInstallContent('
{--INSTALL_SMTP_PASS2_EMPTY--}
'); setGetRequestParameter('page', 3); } // END - if if (postRequestParameter('smtp_pass1') != postRequestParameter('smtp_pass1')) { // Passwords are not matching - addToInstallContent('
' . getMessage('INSTALL_SMTP_PASS_MISMATCH') . '
'); + addToInstallContent('
{--INSTALL_SMTP_PASS_MISMATCH--}
'); setGetRequestParameter('page', 3); } // END - if } // END - if diff --git a/inc/libs/network_functions.php b/inc/libs/network_functions.php index ad261c9aa0..da20b81374 100644 --- a/inc/libs/network_functions.php +++ b/inc/libs/network_functions.php @@ -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'] ); diff --git a/inc/libs/removeip_functions.php b/inc/libs/removeip_functions.php index ba03102acc..0ad68ef3e7 100644 --- a/inc/libs/removeip_functions.php +++ b/inc/libs/removeip_functions.php @@ -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); diff --git a/inc/libs/sponsor_functions.php b/inc/libs/sponsor_functions.php index 10393757c2..76296b04e9 100644 --- a/inc/libs/sponsor_functions.php +++ b/inc/libs/sponsor_functions.php @@ -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); } diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 3939b0e407..09e25ee441 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -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 diff --git a/inc/libs/wernis_functions.php b/inc/libs/wernis_functions.php index 05c11107ac..21c3f2f147 100644 --- a/inc/libs/wernis_functions.php +++ b/inc/libs/wernis_functions.php @@ -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--}'; } } diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index d455f6cc24..5adf74d855 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -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 diff --git a/inc/modules/admin/what-add_rallye.php b/inc/modules/admin/what-add_rallye.php index 04c3486965..9b57ec31f3 100644 --- a/inc/modules/admin/what-add_rallye.php +++ b/inc/modules/admin/what-add_rallye.php @@ -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'); diff --git a/inc/modules/admin/what-config_admins.php b/inc/modules/admin/what-config_admins.php index aee1399056..f53b8c206a 100644 --- a/inc/modules/admin/what-config_admins.php +++ b/inc/modules/admin/what-config_admins.php @@ -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--}' ) ); diff --git a/inc/modules/admin/what-config_register.php b/inc/modules/admin/what-config_register.php index 1c6792fde0..0d65e88d6f 100644 --- a/inc/modules/admin/what-config_register.php +++ b/inc/modules/admin/what-config_register.php @@ -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'] . ']'); diff --git a/inc/modules/admin/what-email_details.php b/inc/modules/admin/what-email_details.php index c761546c94..60f0462e39 100644 --- a/inc/modules/admin/what-email_details.php +++ b/inc/modules/admin/what-email_details.php @@ -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('

'); } // 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 diff --git a/inc/modules/admin/what-list_surfbar_actions.php b/inc/modules/admin/what-list_surfbar_actions.php index 3c9061ad40..afacd0579a 100644 --- a/inc/modules/admin/what-list_surfbar_actions.php +++ b/inc/modules/admin/what-list_surfbar_actions.php @@ -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'])) { diff --git a/inc/modules/admin/what-list_user.php b/inc/modules/admin/what-list_user.php index 3bd4aabdd9..30943e37a6 100644 --- a/inc/modules/admin/what-list_user.php +++ b/inc/modules/admin/what-list_user.php @@ -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 diff --git a/inc/modules/guest/what-sponsor_login.php b/inc/modules/guest/what-sponsor_login.php index 340e211f52..89b66c180c 100644 --- a/inc/modules/guest/what-sponsor_login.php +++ b/inc/modules/guest/what-sponsor_login.php @@ -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 diff --git a/inc/modules/member/what-mydata.php b/inc/modules/member/what-mydata.php index ab440d29be..db81bda1d9 100644 --- a/inc/modules/member/what-mydata.php +++ b/inc/modules/member/what-mydata.php @@ -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&what=welcome&code=' . urlencode(getMessage('PROFILE_UPDATED')); + $url = 'modules.php?module=login&what=mydata&code=' . getCode('PROFILE_UPDATED'); break; } // END - switch