diff options
44 files changed, 180 insertions, 155 deletions
diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html index 9db0fc6521..5fb9a12cda 100644 --- a/phpBB/adm/style/acp_attachments.html +++ b/phpBB/adm/style/acp_attachments.html @@ -384,7 +384,7 @@ <!-- IF .pagination --> • <!-- INCLUDE pagination.html --> <!-- ELSE --> - • {S_ON_PAGE} + • {PAGE_NUMBER} <!-- ENDIF --> <!-- ENDIF --> </div> diff --git a/phpBB/adm/style/overall_header.html b/phpBB/adm/style/overall_header.html index 04f818f95a..1fc1261489 100644 --- a/phpBB/adm/style/overall_header.html +++ b/phpBB/adm/style/overall_header.html @@ -11,7 +11,7 @@ <script type="text/javascript"> // <![CDATA[ var jump_page = '{LA_JUMP_PAGE}{L_COLON}'; -var on_page = '{ON_PAGE}'; +var on_page = '{CURRENT_PAGE}'; var per_page = '{PER_PAGE}'; var base_url = '{BASE_URL|e('js')}'; diff --git a/phpBB/adm/style/simple_header.html b/phpBB/adm/style/simple_header.html index 9c4c8a2960..0ca751cd7e 100644 --- a/phpBB/adm/style/simple_header.html +++ b/phpBB/adm/style/simple_header.html @@ -10,7 +10,7 @@ <script type="text/javascript"> // <![CDATA[ var jump_page = '{LA_JUMP_PAGE}{L_COLON}'; -var on_page = '{ON_PAGE}'; +var on_page = '{CURRENT_PAGE}'; var per_page = '{PER_PAGE}'; var base_url = '{BASE_URL|e('js')}'; diff --git a/phpBB/assets/javascript/editor.js b/phpBB/assets/javascript/editor.js index be3d868f13..dfc7dab525 100644 --- a/phpBB/assets/javascript/editor.js +++ b/phpBB/assets/javascript/editor.js @@ -288,7 +288,7 @@ function mozWrap(txtarea, open, close) { * http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130 */ function storeCaret(textEl) { - if (textEl.createTextRange) { + if (textEl.createTextRange && document.selection) { textEl.caretPos = document.selection.createRange().duplicate(); } } diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index a90757d487..91a9806955 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -230,6 +230,9 @@ phpbb.plupload.updateHiddenData = function(row, attach, index) { phpbb.plupload.deleteFile = function(row, attachId) { // If there's no attach id, then the file hasn't been uploaded. Simply delete the row. if (typeof attachId === 'undefined') { + var file = uploader.getFile(row.attr('id')); + uploader.removeFile(file); + row.slideUp(100, function() { row.remove(); phpbb.plupload.hideEmptyList(); diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 7d507216ef..c4e7bb031e 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -279,6 +279,22 @@ posting_editor_subject_before * Since: 3.1.0-a2 * Purpose: Add field (e.g. textbox) to the posting screen before the subject +quickreply_editor_message_after +=== +* Locations: + + styles/prosilver/template/quickreply_editor.html + + styles/subsilver2/template/quickreply_editor.html +* Since: 3.1.0-a4 +* Purpose: Add content after the quick reply textbox + +quickreply_editor_message_before +=== +* Locations: + + styles/prosilver/template/quickreply_editor.html + + styles/subsilver2/template/quickreply_editor.html +* Since: 3.1.0-a4 +* Purpose: Add content before the quick reply textbox + simple_footer_after === * Locations: @@ -398,6 +414,22 @@ ucp_prefs_view_select_menu_append * Purpose: Add options to the bottom of the drop-down lists block of the Edit Display Options screen +ucp_friend_list_before +=== +* Locations: + + styles/prosilver/template/ucp_zebra_friends.html + + styles/subsilver2/template/ucp_zebra_friends.html +* Since: 3.1.0-a4 +* Purpose: Add optional elements before list of friends in UCP + +ucp_friend_list_after +=== +* Locations: + + styles/prosilver/template/ucp_zebra_friends.html + + styles/subsilver2/template/ucp_zebra_friends.html +* Since: 3.1.0-a4 +* Purpose: Add optional elements after list of friends in UCP + viewtopic_print_head_append === * Locations: diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index e710260b35..b0b9fdbd15 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -1222,7 +1222,6 @@ class acp_attachments 'TOTAL_FILES' => $num_files, 'TOTAL_SIZE' => get_formatted_filesize($total_size), - 'S_ON_PAGE' => $pagination->on_page($base_url, $num_files, $attachments_per_page, $start), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index ec78e0b32b..7ecedcf51e 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -727,7 +727,6 @@ class acp_groups 'S_GROUP_SPECIAL' => ($group_row['group_type'] == GROUP_SPECIAL) ? true : false, 'S_ACTION_OPTIONS' => $s_action_options, - 'S_ON_PAGE' => $pagination->on_page($base_url, $total_members, $config['topics_per_page'], $start), 'GROUP_NAME' => ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'], 'U_ACTION' => $this->u_action . "&g=$group_id", diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php index 305ba9ac69..140815f06a 100644 --- a/phpBB/includes/acp/acp_inactive.php +++ b/phpBB/includes/acp/acp_inactive.php @@ -295,7 +295,6 @@ class acp_inactive 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, - 'S_ON_PAGE' => $pagination->on_page($base_url, $inactive_count, $per_page, $start), 'USERS_PER_PAGE' => $per_page, 'U_ACTION' => $this->u_action . "&$u_sort_param&users_per_page=$per_page&start=$start", diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php index 0ffea2737b..10852e3a68 100644 --- a/phpBB/includes/acp/acp_logs.php +++ b/phpBB/includes/acp/acp_logs.php @@ -138,8 +138,6 @@ class acp_logs 'L_EXPLAIN' => $l_title_explain, 'U_ACTION' => $this->u_action . "&$u_sort_param$keywords_param&start=$start", - 'S_ON_PAGE' => $pagination->on_page($base_url, $log_count, $config['topics_per_page'], $start), - 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index fbff6a73da..87582dcedb 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1174,7 +1174,6 @@ class acp_users $template->assign_vars(array( 'S_FEEDBACK' => true, - 'S_ON_PAGE' => $pagination->on_page($base_url, $log_count, $config['topics_per_page'], $start), 'S_LIMIT_DAYS' => $s_limit_days, 'S_SORT_KEY' => $s_sort_key, @@ -2130,7 +2129,6 @@ class acp_users $template->assign_vars(array( 'S_ATTACHMENTS' => true, - 'S_ON_PAGE' => $pagination->on_page($base_url, $num_attachments, $config['topics_per_page'], $start), 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, )); diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index a3b2184d48..7c1c61dae7 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -135,7 +135,6 @@ function mcp_forum_view($id, $mode, $action, $forum_info) 'S_MCP_ACTION' => $url . "&i=$id&forum_action=$action&mode=$mode&start=$start" . (($merge_select) ? $selected_ids : ''), - 'PAGE_NUMBER' => $pagination->on_page($base_url, $forum_topics, $topics_per_page, $start), 'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics), )); diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index ac7896606a..7bcb0fc477 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -177,7 +177,6 @@ class mcp_logs $pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); $template->assign_vars(array( - 'PAGE_NUMBER' => $pagination->on_page($base_url, $log_count, $config['topics_per_page'], $start), 'TOTAL' => $user->lang('TOTAL_LOGS', (int) $log_count), 'L_TITLE' => $user->lang['MCP_LOGS'], diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php index 055ca0e882..28de8724be 100644 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -229,7 +229,6 @@ class mcp_notes 'L_TITLE' => $user->lang['MCP_NOTES_USER'], - 'PAGE_NUMBER' => $pagination->on_page($base_url, $log_count, $config['topics_per_page'], $start), 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $log_count), 'RANK_TITLE' => $rank_title, diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php index d0801a2b47..008984b1c3 100644 --- a/phpBB/includes/mcp/mcp_pm_reports.php +++ b/phpBB/includes/mcp/mcp_pm_reports.php @@ -309,7 +309,6 @@ class mcp_pm_reports 'S_MCP_ACTION' => $this->u_action, 'S_CLOSED' => ($mode == 'pm_reports_closed') ? true : false, - 'PAGE_NUMBER' => $pagination->on_page($base_url, $total, $config['topics_per_page'], $start), 'TOTAL' => $total, 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total), ) diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 9f9c22a5c5..a46c4bd499 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -547,7 +547,6 @@ class mcp_queue 'S_TOPICS' => $is_topics, 'S_RESTORE' => $is_restore, - 'PAGE_NUMBER' => $pagination->on_page($base_url, $total, $config['topics_per_page'], $start), 'TOPIC_ID' => $topic_id, 'TOTAL' => $user->lang(((!$is_topics) ? 'VIEW_TOPIC_POSTS' : 'VIEW_FORUM_TOPICS'), (int) $total), )); diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 954f8a8349..8026e071cd 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -423,7 +423,6 @@ class mcp_reports 'S_FORUM_OPTIONS' => $forum_options, 'S_CLOSED' => ($mode == 'reports_closed') ? true : false, - 'PAGE_NUMBER' => $pagination->on_page($base_url, $total, $config['topics_per_page'], $start), 'TOPIC_ID' => $topic_id, 'TOTAL' => $total, 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total), diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index a4c561a3bf..cdb88bf2bf 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -343,7 +343,6 @@ function mcp_topic_view($id, $mode, $action) 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_info['forum_id']}&t={$topic_info['topic_id']}&start=$start") . '">', '</a>'), 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f={$topic_info['forum_id']}&start=$start") . '">', '</a>'), - 'PAGE_NUMBER' => $pagination->on_page($base_url, $total, $posts_per_page, $start), 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total), )); } diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index e39bddec5b..d396d004dc 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -186,7 +186,6 @@ class mcp_warn 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, - 'PAGE_NUMBER' => $pagination->on_page($base_url, $user_count, $config['topics_per_page'], $start), 'TOTAL_USERS' => $user->lang('LIST_USERS', (int) $user_count), )); } diff --git a/phpBB/includes/ucp/ucp_attachments.php b/phpBB/includes/ucp/ucp_attachments.php index e687ee9cdc..6a5b48a181 100644 --- a/phpBB/includes/ucp/ucp_attachments.php +++ b/phpBB/includes/ucp/ucp_attachments.php @@ -178,7 +178,6 @@ class ucp_attachments $pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start); $template->assign_vars(array( - 'PAGE_NUMBER' => $pagination->on_page($base_url, $num_attachments, $config['topics_per_page'], $start), 'TOTAL_ATTACHMENTS' => $num_attachments, 'L_TITLE' => $user->lang['UCP_ATTACHMENTS'], diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index a17c87e5a1..373d9433b2 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -821,7 +821,6 @@ class ucp_groups $template->assign_vars(array( 'S_LIST' => true, 'S_ACTION_OPTIONS' => $s_action_options, - 'S_ON_PAGE' => $pagination->on_page($template, $user, $base_url, $total_members, $config['topics_per_page'], $start), 'U_ACTION' => $this->u_action . "&g=$group_id", 'S_UCP_ACTION' => $this->u_action . "&g=$group_id", diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index ddea336ce9..3ccf3e3545 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -671,7 +671,6 @@ class ucp_main $pagination->generate_template_pagination($this->u_action, 'pagination', 'start', $topics_count, $config['topics_per_page'], $start); $template->assign_vars(array( - 'PAGE_NUMBER' => $pagination->on_page($this->u_action, $topics_count, $config['topics_per_page'], $start), 'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $topics_count), )); } diff --git a/phpBB/includes/ucp/ucp_notifications.php b/phpBB/includes/ucp/ucp_notifications.php index c5963a1ebc..7c487b9073 100644 --- a/phpBB/includes/ucp/ucp_notifications.php +++ b/phpBB/includes/ucp/ucp_notifications.php @@ -154,7 +154,6 @@ class ucp_notifications $pagination->generate_template_pagination($base_url, 'pagination', 'start', $notifications['total_count'], $config['topics_per_page'], $start); $template->assign_vars(array( - 'PAGE_NUMBER' => $pagination->on_page($base_url, $notifications['total_count'], $config['topics_per_page'], $start), 'TOTAL_COUNT' => $notifications['total_count'], 'U_MARK_ALL' => $base_url . '&mark=all&token=' . generate_link_hash('mark_all_notifications_read'), )); diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index 0ea94835f2..a567283543 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -458,7 +458,6 @@ function get_pm_from($folder_id, $folder, $user_id) $pagination->generate_template_pagination($base_url, 'pagination', 'start', $pm_count, $config['topics_per_page'], $start); $template->assign_vars(array( - 'PAGE_NUMBER' => $pagination->on_page($base_url, $pm_count, $config['topics_per_page'], $start), 'TOTAL_MESSAGES' => $user->lang('VIEW_PM_MESSAGES', (int) $pm_count), 'POST_IMG' => (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'POST_PM_LOCKED') : $user->img('button_pm_new', 'POST_NEW_PM'), diff --git a/phpBB/language/en/plupload.php b/phpBB/language/en/plupload.php index 6039de7dbf..f174920f6b 100644 --- a/phpBB/language/en/plupload.php +++ b/phpBB/language/en/plupload.php @@ -46,9 +46,9 @@ $lang = array_merge($lang, array( 'PLUPLOAD_ERR_INPUT' => 'Failed to open input stream.', 'PLUPLOAD_ERR_MOVE_UPLOADED' => 'Failed to move uploaded file.', 'PLUPLOAD_ERR_OUTPUT' => 'Failed to open output stream.', - 'PLUPLOAD_ERR_FILE_TOO_LARGE' => 'Error: File too large:', + 'PLUPLOAD_ERR_FILE_TOO_LARGE' => 'File too large:', 'PLUPLOAD_ERR_FILE_COUNT' => 'File count error.', - 'PLUPLOAD_ERR_FILE_INVALID_EXT' => 'Error: Invalid file extension:', + 'PLUPLOAD_ERR_FILE_INVALID_EXT' => 'Invalid file extension:', 'PLUPLOAD_ERR_RUNTIME_MEMORY' => 'Runtime ran out of available memory.', 'PLUPLOAD_ERR_UPLOAD_URL' => 'Upload URL might be wrong or does not exist.', 'PLUPLOAD_EXTENSION_ERROR' => 'File extension error.', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 16e4c86a4e..e927429810 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1633,7 +1633,6 @@ switch ($mode) // Generate page $template->assign_vars(array( - 'PAGE_NUMBER' => $pagination->on_page($pagination_url, $total_users, $config['topics_per_page'], $start), 'TOTAL_USERS' => $user->lang('LIST_USERS', (int) $total_users), 'PROFILE_IMG' => $user->img('icon_user_profile', $user->lang['PROFILE']), diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php index 65098b643b..3a7207e743 100644 --- a/phpBB/phpbb/db/tools.php +++ b/phpBB/phpbb/db/tools.php @@ -492,7 +492,7 @@ class tools // here lies an array, filled with information compiled on the column's data $prepared_column = $this->sql_prepare_column_data($table_name, $column_name, $column_data); - if (isset($prepared_column['auto_increment']) && strlen($column_name) > 26) // "${column_name}_gen" + if (isset($prepared_column['auto_increment']) && $prepared_column['auto_increment'] && strlen($column_name) > 26) // "${column_name}_gen" { trigger_error("Index name '${column_name}_gen' on table '$table_name' is too long. The maximum auto increment column length is 26 characters.", E_USER_ERROR); } diff --git a/phpBB/phpbb/pagination.php b/phpBB/phpbb/pagination.php index 467dc2157f..57e7932341 100644 --- a/phpBB/phpbb/pagination.php +++ b/phpBB/phpbb/pagination.php @@ -76,107 +76,104 @@ class pagination public function generate_template_pagination($base_url, $block_var_name, $start_name, $num_items, $per_page, $start = 1, $reverse_count = false, $ignore_on_page = false) { $total_pages = ceil($num_items / $per_page); - - if ($total_pages == 1 || !$num_items) - { - return; - } - $on_page = $this->get_on_page($per_page, $start); - - if ($reverse_count) - { - $start_page = ($total_pages > 5) ? $total_pages - 4 : 1; - $end_page = $total_pages; - } - else - { - // What we're doing here is calculating what the "start" and "end" pages should be. We - // do this by assuming pagination is "centered" around the currently active page with - // the three previous and three next page links displayed. Anything more than that and - // we display the ellipsis, likewise anything less. - // - // $start_page is the page at which we start creating the list. When we have five or less - // pages we start at page 1 since there will be no ellipsis displayed. Anymore than that - // and we calculate the start based on the active page. This is the min/max calculation. - // First (max) would we end up starting on a page less than 1? Next (min) would we end - // up starting so close to the end that we'd not display our minimum number of pages. - // - // $end_page is the last page in the list to display. Like $start_page we use a min/max to - // determine this number. Again at most five pages? Then just display them all. More than - // five and we first (min) determine whether we'd end up listing more pages than exist. - // We then (max) ensure we're displaying the minimum number of pages. - $start_page = ($total_pages > 5) ? min(max(1, $on_page - 3), $total_pages - 4) : 1; - $end_page = ($total_pages > 5) ? max(min($total_pages, $on_page + 3), 5) : $total_pages; - } - $u_previous_page = $u_next_page = ''; - if ($on_page != 1) - { - $u_previous_page = $this->generate_page_link($base_url, $on_page - 1, $start_name, $per_page); - $this->template->assign_block_vars($block_var_name, array( - 'PAGE_NUMBER' => '', - 'PAGE_URL' => $u_previous_page, - 'S_IS_CURRENT' => false, - 'S_IS_PREV' => true, - 'S_IS_NEXT' => false, - 'S_IS_ELLIPSIS' => false, - )); - } - - // This do...while exists purely to negate the need for start and end assign_block_vars, i.e. - // to display the first and last page in the list plus any ellipsis. We use this loop to jump - // around a little within the list depending on where we're starting (and ending). - $at_page = 1; - do + if ($total_pages > 1) { - // We decide whether to display the ellipsis during the loop. The ellipsis is always - // displayed as either the second or penultimate item in the list. So are we at either - // of those points and of course do we even need to display it, i.e. is the list starting - // on at least page 3 and ending three pages before the final item. - $this->template->assign_block_vars($block_var_name, array( - 'PAGE_NUMBER' => $at_page, - 'PAGE_URL' => $this->generate_page_link($base_url, $at_page, $start_name, $per_page), - 'S_IS_CURRENT' => (!$ignore_on_page && $at_page == $on_page), - 'S_IS_NEXT' => false, - 'S_IS_PREV' => false, - 'S_IS_ELLIPSIS' => ($at_page == 2 && $start_page > 2) || ($at_page == $total_pages - 1 && $end_page < $total_pages - 1), - )); - - // We may need to jump around in the list depending on whether we have or need to display - // the ellipsis. Are we on page 2 and are we more than one page away from the start - // of the list? Yes? Then we jump to the start of the list. Likewise are we at the end of - // the list and are there more than two pages left in total? Yes? Then jump to the penultimate - // page (so we can display the ellipsis next pass). Else, increment the counter and keep - // going - if ($at_page == 2 && $at_page < $start_page - 1) + if ($reverse_count) { - $at_page = $start_page; + $start_page = ($total_pages > 5) ? $total_pages - 4 : 1; + $end_page = $total_pages; } - else if ($at_page == $end_page && $end_page < $total_pages - 1) + else { - $at_page = $total_pages - 1; + // What we're doing here is calculating what the "start" and "end" pages should be. We + // do this by assuming pagination is "centered" around the currently active page with + // the three previous and three next page links displayed. Anything more than that and + // we display the ellipsis, likewise anything less. + // + // $start_page is the page at which we start creating the list. When we have five or less + // pages we start at page 1 since there will be no ellipsis displayed. Anymore than that + // and we calculate the start based on the active page. This is the min/max calculation. + // First (max) would we end up starting on a page less than 1? Next (min) would we end + // up starting so close to the end that we'd not display our minimum number of pages. + // + // $end_page is the last page in the list to display. Like $start_page we use a min/max to + // determine this number. Again at most five pages? Then just display them all. More than + // five and we first (min) determine whether we'd end up listing more pages than exist. + // We then (max) ensure we're displaying the minimum number of pages. + $start_page = ($total_pages > 5) ? min(max(1, $on_page - 3), $total_pages - 4) : 1; + $end_page = ($total_pages > 5) ? max(min($total_pages, $on_page + 3), 5) : $total_pages; } - else + + if ($on_page != 1) { - $at_page++; + $u_previous_page = $this->generate_page_link($base_url, $on_page - 1, $start_name, $per_page); + + $this->template->assign_block_vars($block_var_name, array( + 'PAGE_NUMBER' => '', + 'PAGE_URL' => $u_previous_page, + 'S_IS_CURRENT' => false, + 'S_IS_PREV' => true, + 'S_IS_NEXT' => false, + 'S_IS_ELLIPSIS' => false, + )); } - } - while ($at_page <= $total_pages); - if ($on_page != $total_pages) - { - $u_next_page = $this->generate_page_link($base_url, $on_page + 1, $start_name, $per_page); + // This do...while exists purely to negate the need for start and end assign_block_vars, i.e. + // to display the first and last page in the list plus any ellipsis. We use this loop to jump + // around a little within the list depending on where we're starting (and ending). + $at_page = 1; + do + { + // We decide whether to display the ellipsis during the loop. The ellipsis is always + // displayed as either the second or penultimate item in the list. So are we at either + // of those points and of course do we even need to display it, i.e. is the list starting + // on at least page 3 and ending three pages before the final item. + $this->template->assign_block_vars($block_var_name, array( + 'PAGE_NUMBER' => $at_page, + 'PAGE_URL' => $this->generate_page_link($base_url, $at_page, $start_name, $per_page), + 'S_IS_CURRENT' => (!$ignore_on_page && $at_page == $on_page), + 'S_IS_NEXT' => false, + 'S_IS_PREV' => false, + 'S_IS_ELLIPSIS' => ($at_page == 2 && $start_page > 2) || ($at_page == $total_pages - 1 && $end_page < $total_pages - 1), + )); - $this->template->assign_block_vars($block_var_name, array( - 'PAGE_NUMBER' => '', - 'PAGE_URL' => $u_next_page, - 'S_IS_CURRENT' => false, - 'S_IS_PREV' => false, - 'S_IS_NEXT' => true, - 'S_IS_ELLIPSIS' => false, - )); + // We may need to jump around in the list depending on whether we have or need to display + // the ellipsis. Are we on page 2 and are we more than one page away from the start + // of the list? Yes? Then we jump to the start of the list. Likewise are we at the end of + // the list and are there more than two pages left in total? Yes? Then jump to the penultimate + // page (so we can display the ellipsis next pass). Else, increment the counter and keep + // going + if ($at_page == 2 && $at_page < $start_page - 1) + { + $at_page = $start_page; + } + else if ($at_page == $end_page && $end_page < $total_pages - 1) + { + $at_page = $total_pages - 1; + } + else + { + $at_page++; + } + } + while ($at_page <= $total_pages); + + if ($on_page != $total_pages) + { + $u_next_page = $this->generate_page_link($base_url, $on_page + 1, $start_name, $per_page); + + $this->template->assign_block_vars($block_var_name, array( + 'PAGE_NUMBER' => '', + 'PAGE_URL' => $u_next_page, + 'S_IS_CURRENT' => false, + 'S_IS_PREV' => false, + 'S_IS_NEXT' => true, + 'S_IS_ELLIPSIS' => false, + )); + } } // If the block_var_name is a nested block, we will use the last (most @@ -203,6 +200,7 @@ class pagination 'U_' . $tpl_prefix . 'NEXT_PAGE' => ($on_page != $total_pages) ? $u_next_page : '', $tpl_prefix . 'TOTAL_PAGES' => $total_pages, $tpl_prefix . 'CURRENT_PAGE' => $on_page, + $tpl_prefix . 'PAGE_NUMBER' => $this->on_page($num_items, $per_page, $start), ); if ($tpl_block_name) @@ -229,24 +227,15 @@ class pagination /** * Return current page - * This function also sets certain specific template variables * - * @param string $base_url the base url used to call this page, used by Javascript for popup jump to page * @param int $num_items the total number of items, posts, topics, etc. * @param int $per_page the number of items, posts, etc. per page * @param int $start the item which should be considered currently active, used to determine the page we're on * @return string Descriptive pagination string (e.g. "page 1 of 10") */ - public function on_page($base_url, $num_items, $per_page, $start) + public function on_page($num_items, $per_page, $start) { $on_page = $this->get_on_page($per_page, $start); - - $this->template->assign_vars(array( - 'PER_PAGE' => $per_page, - 'ON_PAGE' => $on_page, - 'BASE_URL' => $base_url, - )); - return $this->user->lang('PAGE_OF', $on_page, max(ceil($num_items / $per_page), 1)); } @@ -262,7 +251,7 @@ class pagination { if ($start < 0 || $start >= $num_items) { - return ($start < 0) ? 0 : floor(($num_items - 1) / $per_page) * $per_page; + return ($start < 0 || $num_items <= 0) ? 0 : floor(($num_items - 1) / $per_page) * $per_page; } return $start; diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index b2ab187a70..2a7cc602da 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -183,7 +183,7 @@ class user extends \phpbb\session unset($lang_set_ext); $style_request = request_var('style', 0); - if ($style_request && $auth->acl_get('a_styles') && !defined('ADMIN_START')) + if ($style_request && (!$config['override_user_style'] || $auth->acl_get('a_styles')) && !defined('ADMIN_START')) { global $SID, $_EXTRA_URL; diff --git a/phpBB/styles/prosilver/template/pagination.html b/phpBB/styles/prosilver/template/pagination.html index 172bc952e4..cb54193c3f 100644 --- a/phpBB/styles/prosilver/template/pagination.html +++ b/phpBB/styles/prosilver/template/pagination.html @@ -1,4 +1,4 @@ - <a href="#" class="pagination-trigger" title="{L_JUMP_TO_PAGE}" data-lang-jump-page="{L_JUMP_PAGE|e('html_attr')}{L_COLON}" data-on-page="{ON_PAGE}" data-per-page="{PER_PAGE}" data-base-url="{BASE_URL|e('html_attr')}">{PAGE_NUMBER}</a> • + <a href="#" class="pagination-trigger" title="{L_JUMP_TO_PAGE}" data-lang-jump-page="{L_JUMP_PAGE|e('html_attr')}{L_COLON}" data-on-page="{CURRENT_PAGE}" data-per-page="{PER_PAGE}" data-base-url="{BASE_URL|e('html_attr')}">{PAGE_NUMBER}</a> • <ul> <!-- BEGIN pagination --> <!-- IF pagination.S_IS_PREV --> diff --git a/phpBB/styles/prosilver/template/plupload.html b/phpBB/styles/prosilver/template/plupload.html index 21acae1c44..fc663118c1 100644 --- a/phpBB/styles/prosilver/template/plupload.html +++ b/phpBB/styles/prosilver/template/plupload.html @@ -12,19 +12,19 @@ phpbb.plupload = { 'Close': '{LA_PLUPLOAD_CLOSE}', 'Drag files here.': '{LA_PLUPLOAD_DRAG}', 'Duplicate file error.': '{LA_PLUPLOAD_DUPLICATE_ERROR}', - 'Error: File too large:': '{LA_PLUPLOAD_ERR_FILE_TOO_LARGE}', - 'Error: Invalid file extension:': '{LA_PLUPLOAD_ERR_FILE_INVALID_EXT}', 'File: %s': '{LA_PLUPLOAD_FILE}', 'File: %s, size: %d, max file size: %d': '{LA_PLUPLOAD_FILE_DETAILS}', 'File count error.': '{LA_PLUPLOAD_ERR_FILE_COUNT}', 'File extension error.': '{LA_PLUPLOAD_EXTENSION_ERROR}', 'File size error.': '{LA_PLUPLOAD_SIZE_ERROR}', + 'File too large:': '{LA_PLUPLOAD_ERR_FILE_TOO_LARGE}', 'Filename': '{LA_PLUPLOAD_FILENAME}', 'Generic error.': '{LA_PLUPLOAD_GENERIC_ERROR}', 'HTTP Error.': '{LA_PLUPLOAD_HTTP_ERROR}', 'Image format either wrong or not supported.': '{LA_PLUPLOAD_IMAGE_FORMAT}', 'Init error.': '{LA_PLUPLOAD_INIT_ERROR}', 'IO error.': '{LA_PLUPLOAD_IO_ERROR}', + 'Invalid file extension:': '{LA_PLUPLOAD_ERR_FILE_INVALID_EXT}', 'N/A': '{LA_PLUPLOAD_NOT_APPLICABLE}', 'Runtime ran out of available memory.': '{LA_PLUPLOAD_ERR_RUNTIME_MEMORY}', 'Security error.': '{LA_PLUPLOAD_SECURITY_ERROR}', diff --git a/phpBB/styles/prosilver/template/quickreply_editor.html b/phpBB/styles/prosilver/template/quickreply_editor.html index 83d253384e..774d013cd3 100644 --- a/phpBB/styles/prosilver/template/quickreply_editor.html +++ b/phpBB/styles/prosilver/template/quickreply_editor.html @@ -7,9 +7,11 @@ <dt><label for="subject">{L_SUBJECT}{L_COLON}</label></dt> <dd><input type="text" name="subject" id="subject" size="45" maxlength="124" tabindex="2" value="{SUBJECT}" class="inputbox autowidth" /></dd> </dl> + <!-- EVENT quickreply_editor_message_before --> <div id="message-box"> <textarea style="height: 9em;" name="message" rows="7" cols="76" tabindex="3" class="inputbox"></textarea> </div> + <!-- EVENT quickreply_editor_message_after --> </fieldset> <fieldset class="submit-buttons"> {S_FORM_TOKEN} diff --git a/phpBB/styles/prosilver/template/ucp_groups_manage.html b/phpBB/styles/prosilver/template/ucp_groups_manage.html index 5772a735d3..df80135acb 100644 --- a/phpBB/styles/prosilver/template/ucp_groups_manage.html +++ b/phpBB/styles/prosilver/template/ucp_groups_manage.html @@ -164,7 +164,7 @@ <!-- IF .pagination --> <!-- INCLUDE pagination.html --> <!-- ELSE --> - {S_ON_PAGE} + {PAGE_NUMBER} <!-- ENDIF --> </li> </ul> diff --git a/phpBB/styles/prosilver/template/ucp_zebra_friends.html b/phpBB/styles/prosilver/template/ucp_zebra_friends.html index 583b911284..fac0a18706 100644 --- a/phpBB/styles/prosilver/template/ucp_zebra_friends.html +++ b/phpBB/styles/prosilver/template/ucp_zebra_friends.html @@ -11,6 +11,7 @@ <fieldset class="fields2"> <!-- IF ERROR --><p class="error">{ERROR}</p><!-- ENDIF --> + <!-- EVENT ucp_friend_list_before --> <dl> <dt><label <!-- IF S_USERNAME_OPTIONS -->for="usernames"<!-- ENDIF -->>{L_YOUR_FRIENDS}{L_COLON}</label><br /><span>{L_YOUR_FRIENDS_EXPLAIN}</span></dt> <dd> @@ -21,6 +22,7 @@ <!-- ENDIF --> </dd> </dl> + <!-- EVENT ucp_friend_list_after --> <dl> <dt><label for="add">{L_ADD_FRIENDS}{L_COLON}</label><br /><span>{L_ADD_FRIENDS_EXPLAIN}</span></dt> <dd><textarea name="add" id="add" rows="3" cols="30" class="inputbox">{USERNAMES}</textarea></dd> diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html index 9ca989ea8b..5da73bd70d 100644 --- a/phpBB/styles/subsilver2/template/overall_header.html +++ b/phpBB/styles/subsilver2/template/overall_header.html @@ -36,7 +36,7 @@ function popup(url, width, height, name) function jumpto() { - var page = prompt('{LA_JUMP_PAGE}{L_COLON}', '{ON_PAGE}'); + var page = prompt('{LA_JUMP_PAGE}{L_COLON}', '{CURRENT_PAGE}'); var per_page = '{PER_PAGE}'; var base_url = '{BASE_URL|e('js')}'; diff --git a/phpBB/styles/subsilver2/template/quickreply_editor.html b/phpBB/styles/subsilver2/template/quickreply_editor.html index 72dc5506bf..b2b7b1624e 100644 --- a/phpBB/styles/subsilver2/template/quickreply_editor.html +++ b/phpBB/styles/subsilver2/template/quickreply_editor.html @@ -8,10 +8,12 @@ <td class="row1" width="22%"><b class="genmed">{L_SUBJECT}{L_COLON}</b></td> <td class="row2" width="78%"><input class="post" style="width:450px" type="text" name="subject" size="45" maxlength="124" tabindex="2" value="{SUBJECT}" /></td> </tr> + <!-- EVENT quickreply_editor_message_before --> <tr> <td class="row1" width="22%"><b class="genmed">{L_MESSAGE}{L_COLON}</b></td> <td class="row2" valign="top" align="left" width="78%"><textarea name="message" rows="7" cols="76" tabindex="3" style="width: 700px; height: 130px; min-width: 98%; max-width: 98%;"></textarea> </td> </tr> + <!-- EVENT quickreply_editor_message_after --> <tr> <td class="cat" colspan="2" align="center"> <input class="btnlite" type="submit" accesskey="f" tabindex="6" name="preview" value="{L_FULL_EDITOR}" /> diff --git a/phpBB/styles/subsilver2/template/ucp_groups_manage.html b/phpBB/styles/subsilver2/template/ucp_groups_manage.html index 1499f90eaf..3099fcb1d8 100644 --- a/phpBB/styles/subsilver2/template/ucp_groups_manage.html +++ b/phpBB/styles/subsilver2/template/ucp_groups_manage.html @@ -161,7 +161,7 @@ <!-- IF .pagination --> <!-- INCLUDE pagination.html --> <!-- ELSE --> - {S_ON_PAGE} + {PAGE_NUMBER} <!-- ENDIF --> </div> diff --git a/phpBB/styles/subsilver2/template/ucp_zebra_friends.html b/phpBB/styles/subsilver2/template/ucp_zebra_friends.html index 45280a35c5..3e18af9969 100644 --- a/phpBB/styles/subsilver2/template/ucp_zebra_friends.html +++ b/phpBB/styles/subsilver2/template/ucp_zebra_friends.html @@ -4,6 +4,7 @@ <tr> <th colspan="2" valign="middle">{L_TITLE}</th> </tr> +<!-- EVENT ucp_friend_list_before --> <tr> <td class="row3" colspan="2"><span class="gensmall">{L_FRIENDS_EXPLAIN}</span></td> </tr> @@ -16,6 +17,7 @@ <td class="row1" width="40%"><b class="genmed">{L_YOUR_FRIENDS}{L_COLON}</b><br /><span class="gensmall">{L_YOUR_FRIENDS_EXPLAIN}</span></td> <td class="row2" align="center"><!-- IF S_USERNAME_OPTIONS --><select name="usernames[]" multiple="multiple" size="5">{S_USERNAME_OPTIONS}</select><!-- ELSE --><b class="genmed">{L_NO_FRIENDS}</b><!-- ENDIF --></td> </tr> +<!-- EVENT ucp_friend_list_after --> <tr> <td class="row1"><b class="genmed">{L_ADD_FRIENDS}{L_COLON}</b><br /><span class="gensmall">{L_ADD_FRIENDS_EXPLAIN} [ <a href="{U_FIND_USERNAME}" onclick="find_username(this.href); return false;">{L_FIND_USERNAME}</a> ]</span></td> <td class="row2" align="center"><textarea name="add" rows="5" cols="30">{USERNAMES}</textarea><br /></td> diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 9a229a0770..7f194bbcef 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -635,7 +635,6 @@ $base_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((s $pagination->generate_template_pagination($base_url, 'pagination', 'start', $topics_count, $config['topics_per_page'], $start); $template->assign_vars(array( - 'PAGE_NUMBER' => $pagination->on_page($base_url, $topics_count, $config['topics_per_page'], $start), 'TOTAL_TOPICS' => ($s_display_active) ? false : $user->lang('VIEW_FORUM_TOPICS', (int) $total_topic_count), )); diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index ef8bfb888b..68601b69b8 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -430,7 +430,6 @@ $template->assign_vars(array( 'TOTAL_REGISTERED_USERS_ONLINE' => $user->lang('REG_USERS_ONLINE', (int) $logged_visible_online, $user->lang('HIDDEN_USERS_ONLINE', (int) $logged_hidden_online)), 'TOTAL_GUEST_USERS_ONLINE' => $user->lang('GUEST_USERS_ONLINE', (int) $guest_counter), 'LEGEND' => $legend, - 'PAGE_NUMBER' => $pagination->on_page($base_url, $counter, $config['topics_per_page'], $start), 'U_SORT_USERNAME' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a') . '&sg=' . ((int) $show_guests)), 'U_SORT_UPDATED' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=b&sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a') . '&sg=' . ((int) $show_guests)), diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 7f4c65bd5e..86ef331ac0 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -605,7 +605,6 @@ $template->assign_vars(array( 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), 'TOPIC_AUTHOR' => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), - 'PAGE_NUMBER' => $pagination->on_page($base_url, $total_posts, $config['posts_per_page'], $start), 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total_posts), 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=topic_view&f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" : ''), true, $user->session_id) : '', 'MODERATORS' => (isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id])) ? implode($user->lang['COMMA_SEPARATOR'], $forum_moderators[$forum_id]) : '', diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 4e8083b47f..b7a4f101aa 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -38,6 +38,9 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case 10, 10, 'pagination + :per_page:10 + :current_page:2 + :base_url:page.php :previous::page.php :else:1:page.php :current:2:page.php?start=10 @@ -57,6 +60,9 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case 10, 20, 'pagination + :per_page:10 + :current_page:3 + :base_url:page.php :previous::page.php?start=10 :else:1:page.php :else:2:page.php?start=10 @@ -77,6 +83,9 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case 10, 10, 'pagination + :per_page:10 + :current_page:2 + :base_url:test/page/%d :previous::test :else:1:test :current:2:test/page/2 @@ -96,6 +105,9 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case 10, 20, 'pagination + :per_page:10 + :current_page:3 + :base_url:test/page/%d :previous::test/page/2 :else:1:test :else:2:test/page/2 @@ -127,15 +139,10 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case { return array( array( - 'page.php', 10, 10, 0, 'PAGE_OF-1-1', - 'on_page - per_page:10 - on_page:1 - base_url:page.php', ), ); } @@ -143,36 +150,47 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case /** * @dataProvider on_page_data */ - public function test_on_page($base_url, $num_items, $per_page, $start_item, $expect_return, $expect) + public function test_on_page($num_items, $per_page, $start_item, $expect_return) { - $this->assertEquals($expect_return, $this->pagination->on_page($base_url, $num_items, $per_page, $start_item)); - - $this->template->set_filenames(array('test' => 'on_page.html')); - - $this->assertEquals(str_replace("\t", '', $expect), $this->display('test')); + $this->assertEquals($expect_return, $this->pagination->on_page($num_items, $per_page, $start_item)); } public function validate_start_data() { return array( array( + 0, + 0, + 0, + ), + array( -1, + 20, 0, ), array( + 20, + -30, 0, + ), + array( + 0, + 20, 0, ), array( 10, + 20, 10, ), array( 20, + 20, 10, ), array( 30, + 20, 10, ), ); @@ -181,9 +199,9 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case /** * @dataProvider validate_start_data */ - public function test_validate_start($start, $expect) + public function test_validate_start($start, $num_items, $expect) { - $this->assertEquals($expect, $this->pagination->validate_start($start, 10, 20)); + $this->assertEquals($expect, $this->pagination->validate_start($start, 10, $num_items)); } public function reverse_start_data() diff --git a/tests/pagination/templates/on_page.html b/tests/pagination/templates/on_page.html deleted file mode 100644 index 364bcf9f5e..0000000000 --- a/tests/pagination/templates/on_page.html +++ /dev/null @@ -1,4 +0,0 @@ -on_page -per_page:{PER_PAGE} -on_page:{ON_PAGE} -base_url:{BASE_URL} diff --git a/tests/pagination/templates/pagination.html b/tests/pagination/templates/pagination.html index 7f2a329804..db63258585 100644 --- a/tests/pagination/templates/pagination.html +++ b/tests/pagination/templates/pagination.html @@ -1,4 +1,7 @@ pagination +:per_page:{PER_PAGE} +:current_page:{CURRENT_PAGE} +:base_url:{BASE_URL} <!-- BEGIN pagination --> <!-- IF pagination.S_IS_PREV -->:previous:{pagination.PAGE_NUMBER}:{pagination.PAGE_URL} <!-- ELSEIF pagination.S_IS_CURRENT -->:current:{pagination.PAGE_NUMBER}:{pagination.PAGE_URL} |