diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-07-25 13:25:48 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-07-25 13:27:49 +0200 |
commit | 75aef80104351d276dda5dd3e6cf0b0dfa40d02d (patch) | |
tree | 56402f44e4c0d2f894f891be7c97f83400d13422 | |
parent | 9e1802396f7fdc3a9908d7c2c4d3bfb8f6156e75 (diff) | |
download | forums-75aef80104351d276dda5dd3e6cf0b0dfa40d02d.tar forums-75aef80104351d276dda5dd3e6cf0b0dfa40d02d.tar.gz forums-75aef80104351d276dda5dd3e6cf0b0dfa40d02d.tar.bz2 forums-75aef80104351d276dda5dd3e6cf0b0dfa40d02d.tar.xz forums-75aef80104351d276dda5dd3e6cf0b0dfa40d02d.zip |
[ticket/12891] Replace template loops with 1 loop to reduce generation time
PHPBB3-12891
-rw-r--r-- | phpBB/adm/style/acp_ban.html | 35 | ||||
-rw-r--r-- | phpBB/includes/acp/acp_ban.php | 55 | ||||
-rw-r--r-- | phpBB/styles/prosilver/template/mcp_ban.html | 33 | ||||
-rw-r--r-- | phpBB/styles/subsilver2/template/mcp_ban.html | 33 |
4 files changed, 73 insertions, 83 deletions
diff --git a/phpBB/adm/style/acp_ban.html b/phpBB/adm/style/acp_ban.html index 71c737de70..9e9f05120a 100644 --- a/phpBB/adm/style/acp_ban.html +++ b/phpBB/adm/style/acp_ban.html @@ -13,27 +13,34 @@ var ban_length = new Array(); ban_length[-1] = ''; - <!-- BEGIN ban_length --> - ban_length['{ban_length.BAN_ID}'] = '{ban_length.A_LENGTH}'; - <!-- END ban_length --> - var ban_reason = new Array(); ban_reason[-1] = ''; - <!-- BEGIN ban_reason --> - ban_reason['{ban_reason.BAN_ID}'] = '{ban_reason.A_REASON}'; - <!-- END ban_reason --> - var ban_give_reason = new Array(); ban_give_reason[-1] = ''; - <!-- BEGIN ban_give_reason --> - ban_give_reason['{ban_give_reason.BAN_ID}'] = '{ban_give_reason.A_REASON}'; - <!-- END ban_give_reason --> + + <!-- BEGIN bans --> + ban_length['{bans.BAN_ID}'] = '{bans.A_LENGTH}'; + <!-- IF bans.A_REASON --> + ban_reason['{bans.BAN_ID}'] = '{bans.A_REASON}'; + <!-- ENDIF --> + <!-- IF bans.A_GIVE_REASON --> + ban_give_reason['{bans.BAN_ID}'] = '{bans.A_GIVE_REASON}'; + <!-- ENDIF --> + <!-- END bans --> function display_details(option) { - document.getElementById('acp_unban').unbangivereason.innerHTML = ban_give_reason[option]; - document.getElementById('acp_unban').unbanreason.innerHTML = ban_reason[option]; - document.getElementById('acp_unban').unbanlength.value = ban_length[option]; + document.getElementById('unbanlength').value = ban_length[option]; + if (option in ban_reason) { + document.getElementById('unbanreason').innerHTML = ban_reason[option]; + } else { + document.getElementById('unbanreason').innerHTML = ''; + } + if (option in ban_give_reason) { + document.getElementById('unbangivereason').innerHTML = ban_give_reason[option]; + } else { + document.getElementById('unbangivereason').innerHTML = ''; + } } // ]]> diff --git a/phpBB/includes/acp/acp_ban.php b/phpBB/includes/acp/acp_ban.php index 7cc6741e23..361ef2666c 100644 --- a/phpBB/includes/acp/acp_ban.php +++ b/phpBB/includes/acp/acp_ban.php @@ -176,8 +176,6 @@ class acp_ban $result = $db->sql_query($sql); $banned_options = $excluded_options = array(); - $ban_length = $ban_reasons = $ban_give_reasons = array(); - while ($row = $db->sql_fetchrow($result)) { $option = '<option value="' . $row['ban_id'] . '">' . $row[$field] . '</option>'; @@ -196,60 +194,31 @@ class acp_ban if ($time_length == 0) { // Banned permanently - $ban_length[$row['ban_id']] = $user->lang['PERMANENT']; + $ban_length = $user->lang['PERMANENT']; } else if (isset($ban_end_text[$time_length])) { // Banned for a given duration - $ban_length[$row['ban_id']] = sprintf($user->lang['BANNED_UNTIL_DURATION'], $ban_end_text[$time_length], $user->format_date($row['ban_end'], false, true)); + $ban_length = $user->lang('BANNED_UNTIL_DURATION', $ban_end_text[$time_length], $user->format_date($row['ban_end'], false, true)); } else { // Banned until given date - $ban_length[$row['ban_id']] = sprintf($user->lang['BANNED_UNTIL_DATE'], $user->format_date($row['ban_end'], false, true)); + $ban_length = $user->lang('BANNED_UNTIL_DATE', $user->format_date($row['ban_end'], false, true)); } - $ban_reasons[$row['ban_id']] = $row['ban_reason']; - $ban_give_reasons[$row['ban_id']] = $row['ban_give_reason']; + $template->assign_block_vars('bans', array( + 'BAN_ID' => (int) $row['ban_id'], + 'LENGTH' => $ban_length, + 'A_LENGTH' => addslashes($ban_length), + 'REASON' => $row['ban_reason'], + 'A_REASON' => addslashes($row['ban_reason']), + 'GIVE_REASON' => $row['ban_give_reason'], + 'A_GIVE_REASON' => addslashes($row['ban_give_reason']), + )); } $db->sql_freeresult($result); - if (sizeof($ban_length)) - { - foreach ($ban_length as $ban_id => $length) - { - $template->assign_block_vars('ban_length', array( - 'BAN_ID' => (int) $ban_id, - 'LENGTH' => $length, - 'A_LENGTH' => addslashes($length), - )); - } - } - - if (sizeof($ban_reasons)) - { - foreach ($ban_reasons as $ban_id => $reason) - { - $template->assign_block_vars('ban_reason', array( - 'BAN_ID' => $ban_id, - 'REASON' => $reason, - 'A_REASON' => addslashes($reason), - )); - } - } - - if (sizeof($ban_give_reasons)) - { - foreach ($ban_give_reasons as $ban_id => $reason) - { - $template->assign_block_vars('ban_give_reason', array( - 'BAN_ID' => $ban_id, - 'REASON' => $reason, - 'A_REASON' => addslashes($reason), - )); - } - } - $options = ''; if ($excluded_options) { diff --git a/phpBB/styles/prosilver/template/mcp_ban.html b/phpBB/styles/prosilver/template/mcp_ban.html index 9504d16284..5a7eaa7840 100644 --- a/phpBB/styles/prosilver/template/mcp_ban.html +++ b/phpBB/styles/prosilver/template/mcp_ban.html @@ -5,27 +5,34 @@ var ban_length = new Array(); ban_length[-1] = ''; - <!-- BEGIN ban_length --> - ban_length['{ban_length.BAN_ID}'] = '{ban_length.A_LENGTH}'; - <!-- END ban_length --> - var ban_reason = new Array(); ban_reason[-1] = ''; - <!-- BEGIN ban_reason --> - ban_reason['{ban_reason.BAN_ID}'] = '{ban_reason.A_REASON}'; - <!-- END ban_reason --> - var ban_give_reason = new Array(); ban_give_reason[-1] = ''; - <!-- BEGIN ban_give_reason --> - ban_give_reason['{ban_give_reason.BAN_ID}'] = '{ban_give_reason.A_REASON}'; - <!-- END ban_give_reason --> + + <!-- BEGIN bans --> + ban_length['{bans.BAN_ID}'] = '{bans.A_LENGTH}'; + <!-- IF bans.A_REASON --> + ban_reason['{bans.BAN_ID}'] = '{bans.A_REASON}'; + <!-- ENDIF --> + <!-- IF bans.A_GIVE_REASON --> + ban_give_reason['{bans.BAN_ID}'] = '{bans.A_GIVE_REASON}'; + <!-- ENDIF --> + <!-- END bans --> function display_details(option) { - document.getElementById('unbangivereason').innerHTML = ban_give_reason[option]; - document.getElementById('unbanreason').innerHTML = ban_reason[option]; document.getElementById('unbanlength').innerHTML = ban_length[option]; + if (option in ban_reason) { + document.getElementById('unbanreason').innerHTML = ban_reason[option]; + } else { + document.getElementById('unbanreason').innerHTML = ''; + } + if (option in ban_give_reason) { + document.getElementById('unbangivereason').innerHTML = ban_give_reason[option]; + } else { + document.getElementById('unbangivereason').innerHTML = ''; + } } // ]]> diff --git a/phpBB/styles/subsilver2/template/mcp_ban.html b/phpBB/styles/subsilver2/template/mcp_ban.html index b6d77c5709..cc24d21d73 100644 --- a/phpBB/styles/subsilver2/template/mcp_ban.html +++ b/phpBB/styles/subsilver2/template/mcp_ban.html @@ -5,27 +5,34 @@ var ban_length = new Array(); ban_length[-1] = ''; - <!-- BEGIN ban_length --> - ban_length['{ban_length.BAN_ID}'] = '{ban_length.A_LENGTH}'; - <!-- END ban_length --> - var ban_reason = new Array(); ban_reason[-1] = ''; - <!-- BEGIN ban_reason --> - ban_reason['{ban_reason.BAN_ID}'] = '{ban_reason.A_REASON}'; - <!-- END ban_reason --> - var ban_give_reason = new Array(); ban_give_reason[-1] = ''; - <!-- BEGIN ban_give_reason --> - ban_give_reason['{ban_give_reason.BAN_ID}'] = '{ban_give_reason.A_REASON}'; - <!-- END ban_give_reason --> + + <!-- BEGIN bans --> + ban_length['{bans.BAN_ID}'] = '{bans.A_LENGTH}'; + <!-- IF bans.A_REASON --> + ban_reason['{bans.BAN_ID}'] = '{bans.A_REASON}'; + <!-- ENDIF --> + <!-- IF bans.A_GIVE_REASON --> + ban_give_reason['{bans.BAN_ID}'] = '{bans.A_GIVE_REASON}'; + <!-- ENDIF --> + <!-- END bans --> function display_details(option) { - document.getElementById('mcp_ban').unbangivereason.value = ban_give_reason[option]; - document.getElementById('mcp_ban').unbanreason.value = ban_reason[option]; document.getElementById('mcp_ban').unbanlength.value = ban_length[option]; + if (option in ban_reason) { + document.getElementById('mcp_ban').unbanreason.value = ban_reason[option]; + } else { + document.getElementById('mcp_ban').unbanreason.value = ''; + } + if (option in ban_give_reason) { + document.getElementById('mcp_ban').unbangivereason.value = ban_give_reason[option]; + } else { + document.getElementById('mcp_ban').unbangivereason.value = ''; + } } // ]]> |