mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Merge remote-tracking branch 'nickvergessen/feature/pagination-class' into develop
# By Joas Schilling # Via Joas Schilling * nickvergessen/feature/pagination-class: [ticket/11849] Fix more function calls [ticket/11849] Update more MCP calls to pagination class [ticket/11849] Update some ACP modules with new pagination [ticket/11849] Update rest of the UCP modules [ticket/11849] Update UCP notifications and pm folder [ticket/11849] Update search and memberlist [ticket/11849] Update pagination in viewonline.php [ticket/11849] Remove old pagination test [ticket/11849] Update pagination code in viewtopic.php [ticket/11849] Replace pagination in viewforum.php with class [ticket/11849] Add service definition [ticket/11849] Remove pagination functions [ticket/11849] Test validate_start and on_page [ticket/11849] Move pagination code to class
This commit is contained in:
@@ -26,7 +26,7 @@ class ucp_attachments
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
global $template, $user, $db, $config, $phpEx, $phpbb_root_path;
|
||||
global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $phpbb_container;
|
||||
|
||||
$start = request_var('start', 0);
|
||||
$sort_key = request_var('sk', 'a');
|
||||
@@ -119,6 +119,10 @@ class ucp_attachments
|
||||
$num_attachments = $db->sql_fetchfield('num_attachments');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
// Ensure start is a valid value
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
$start = $pagination->validate_start($start, $config['topics_per_page'], $num_attachments);
|
||||
|
||||
$sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title
|
||||
FROM ' . ATTACHMENTS_TABLE . ' a
|
||||
LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0)
|
||||
@@ -171,10 +175,10 @@ class ucp_attachments
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$base_url = $this->u_action . "&sk=$sort_key&sd=$sort_dir";
|
||||
phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start);
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $num_attachments, $config['topics_per_page'], $start),
|
||||
'PAGE_NUMBER' => $pagination->on_page($base_url, $num_attachments, $config['topics_per_page'], $start),
|
||||
'TOTAL_ATTACHMENTS' => $num_attachments,
|
||||
|
||||
'L_TITLE' => $user->lang['UCP_ATTACHMENTS'],
|
||||
|
@@ -813,13 +813,15 @@ class ucp_groups
|
||||
$s_action_options .= '<option value="' . $option . '">' . $user->lang['GROUP_' . $lang] . '</option>';
|
||||
}
|
||||
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
$base_url = $this->u_action . "&action=$action&g=$group_id";
|
||||
phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total_members, $config['topics_per_page'], $start);
|
||||
$start = $pagination->validate_start($start, $config['topics_per_page'], $total_members);
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_members, $config['topics_per_page'], $start);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'S_LIST' => true,
|
||||
'S_ACTION_OPTIONS' => $s_action_options,
|
||||
'S_ON_PAGE' => phpbb_on_page($template, $user, $base_url, $total_members, $config['topics_per_page'], $start),
|
||||
'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",
|
||||
|
@@ -646,6 +646,7 @@ class ucp_main
|
||||
|
||||
$table = ($mode == 'subscribed') ? TOPICS_WATCH_TABLE : BOOKMARKS_TABLE;
|
||||
$start = request_var('start', 0);
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
|
||||
// Grab icons
|
||||
$icons = $cache->obtain_icons();
|
||||
@@ -669,10 +670,11 @@ class ucp_main
|
||||
|
||||
if ($topics_count)
|
||||
{
|
||||
phpbb_generate_template_pagination($template, $this->u_action, 'pagination', 'start', $topics_count, $config['topics_per_page'], $start);
|
||||
$start = $pagination->validate_start($start, $config['topics_per_page'], $topics_count);
|
||||
$pagination->generate_template_pagination($this->u_action, 'pagination', 'start', $topics_count, $config['topics_per_page'], $start);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'PAGE_NUMBER' => phpbb_on_page($template, $user, $this->u_action, $topics_count, $config['topics_per_page'], $start),
|
||||
'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),
|
||||
));
|
||||
}
|
||||
@@ -839,7 +841,7 @@ class ucp_main
|
||||
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
|
||||
));
|
||||
|
||||
phpbb_generate_template_pagination($template, append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . "&t=$topic_id"), 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true);
|
||||
$pagination->generate_template_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . "&t=$topic_id"), 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ class ucp_notifications
|
||||
$form_time = ($form_time <= 0 || $form_time > time()) ? time() : $form_time;
|
||||
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
@@ -137,10 +138,11 @@ class ucp_notifications
|
||||
}
|
||||
|
||||
$base_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=ucp_notifications&mode=notification_list");
|
||||
phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $notifications['total_count'], $config['topics_per_page'], $start);
|
||||
$start = $pagination->validate_start($start, $config['topics_per_page'], $notifications['total_count']);
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $notifications['total_count'], $config['topics_per_page'], $start);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $notifications['total_count'], $config['topics_per_page'], $start),
|
||||
'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'),
|
||||
));
|
||||
|
@@ -393,7 +393,7 @@ function view_folder($id, $mode, $folder_id, $folder)
|
||||
*/
|
||||
function get_pm_from($folder_id, $folder, $user_id)
|
||||
{
|
||||
global $user, $db, $template, $config, $auth, $phpbb_root_path, $phpEx;
|
||||
global $user, $db, $template, $config, $auth, $phpbb_container, $phpbb_root_path, $phpEx;
|
||||
|
||||
$start = request_var('start', 0);
|
||||
|
||||
@@ -402,6 +402,8 @@ function get_pm_from($folder_id, $folder, $user_id)
|
||||
$sort_key = request_var('sk', 't');
|
||||
$sort_dir = request_var('sd', 'd');
|
||||
|
||||
$pagination = $phpbb_container->get('pagination');
|
||||
|
||||
// PM ordering options
|
||||
$limit_days = array(0 => $user->lang['ALL_MESSAGES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
|
||||
|
||||
@@ -452,10 +454,11 @@ function get_pm_from($folder_id, $folder, $user_id)
|
||||
}
|
||||
|
||||
$base_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&action=view_folder&f=$folder_id&$u_sort_param");
|
||||
phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $pm_count, $config['topics_per_page'], $start);
|
||||
$start = $pagination->validate_start($start, $config['topics_per_page'], $pm_count);
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $pm_count, $config['topics_per_page'], $start);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $pm_count, $config['topics_per_page'], $start),
|
||||
'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'),
|
||||
@@ -481,14 +484,10 @@ function get_pm_from($folder_id, $folder, $user_id)
|
||||
{
|
||||
$store_reverse = true;
|
||||
|
||||
if ($start + $config['topics_per_page'] > $pm_count)
|
||||
{
|
||||
$sql_limit = min($config['topics_per_page'], max(1, $pm_count - $start));
|
||||
}
|
||||
|
||||
// Select the sort order
|
||||
$direction = ($sort_dir == 'd') ? 'ASC' : 'DESC';
|
||||
$sql_start = max(0, $pm_count - $sql_limit - $start);
|
||||
$sql_limit = $pagination->reverse_limit($start, $sql_limit, $pm_count);
|
||||
$sql_start = $pagination->reverse_start($start, $sql_limit, $pm_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user