Commit 6625017e by Scott

Fix favorite pagination

And display of links on favorites main page
parent 222c300e
......@@ -1481,13 +1481,14 @@
function qa_db_user_favorite_qs_selectspec($userid, $limit=null, $start=0)
/*
Return the selectspec to retrieve an array of $userid's favorited questions, with the usual information.
Returns $limit questions, or all of them if $limit is null (used in qa_db_selectspec_count).
*/
{
require_once QA_INCLUDE_DIR.'qa-app-updates.php';
$selectspec = qa_db_posts_basic_selectspec($userid);
$selectspec['source'] .= ' JOIN ^userfavorites AS selectfave ON ^posts.postid=selectfave.entityid WHERE selectfave.userid=$ AND selectfave.entitytype=$ AND ^posts.type="Q" ORDER BY created DESC';
$selectspec['source'] .= ' JOIN ^userfavorites AS selectfave ON ^posts.postid=selectfave.entityid WHERE selectfave.userid=$ AND selectfave.entitytype=$ AND ^posts.type="Q" ORDER BY ^posts.created DESC';
$selectspec['arguments'][] = $userid;
$selectspec['arguments'][] = QA_ENTITY_QUESTION;
......@@ -1507,11 +1508,12 @@
function qa_db_user_favorite_users_selectspec($userid, $limit=null, $start=0)
/*
Return the selectspec to retrieve an array of $userid's favorited users, with information about those users' accounts.
Returns $limit users, or all of them if $limit is null (used in qa_db_selectspec_count).
*/
{
require_once QA_INCLUDE_DIR.'qa-app-updates.php';
$source = '^users JOIN ^userpoints ON ^users.userid=^userpoints.userid JOIN ^userfavorites ON ^users.userid=^userfavorites.entityid WHERE ^userfavorites.userid=$ AND ^userfavorites.entitytype=$ ORDER BY handle';
$source = '^users JOIN ^userpoints ON ^users.userid=^userpoints.userid JOIN ^userfavorites ON ^users.userid=^userfavorites.entityid WHERE ^userfavorites.userid=$ AND ^userfavorites.entitytype=$ ORDER BY ^users.handle';
$arguments = array($userid, QA_ENTITY_USER);
if (isset($limit)) {
......@@ -1533,11 +1535,12 @@
function qa_db_user_favorite_tags_selectspec($userid, $limit=null, $start=0)
/*
Return the selectspec to retrieve an array of $userid's favorited tags, with information about those tags.
Returns $limit tags, or all of them if $limit is null (used in qa_db_selectspec_count).
*/
{
require_once QA_INCLUDE_DIR.'qa-app-updates.php';
$source = '^words JOIN ^userfavorites ON ^words.wordid=^userfavorites.entityid WHERE ^userfavorites.userid=$ AND ^userfavorites.entitytype=$ ORDER BY tagcount DESC';
$source = '^words JOIN ^userfavorites ON ^words.wordid=^userfavorites.entityid WHERE ^userfavorites.userid=$ AND ^userfavorites.entitytype=$ ORDER BY ^words.tagcount DESC';
$arguments = array($userid, QA_ENTITY_TAG);
if (isset($limit)) {
......
......@@ -76,9 +76,12 @@
extract($favswitch[$favtype]); // get switch variables
$pagesize = qa_opt($page_opt);
$items = qa_db_select_with_pending(
list($totalItems, $items) = qa_db_select_with_pending(
qa_db_selectspec_count($fn_spec($userid)),
$fn_spec($userid, $pagesize, $start)
);
$count = $totalItems['count'];
$usershtml = qa_userids_handles_html($items);
......@@ -95,7 +98,7 @@
$qa_content['suggest_next'] = qa_lang_html_sub('misc/suggest_favorites_add', '<span class="qa-favorite-image">&nbsp;</span>');
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, 100, qa_opt('pages_prev_next'));
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'));
$qa_content['navigation']['sub'] = qa_user_sub_navigation(qa_get_logged_in_handle(), 'favorites', true);
......
......@@ -48,10 +48,16 @@
$pagesize_users = qa_opt('page_size_users');
$pagesize_tags = qa_opt('page_size_tags');
list($questions, $users, $tags, $categories) = qa_db_select_with_pending(
list($numQs, $questions, $numUsers, $users, $numTags, $tags, $categories) = qa_db_select_with_pending(
qa_db_selectspec_count( qa_db_user_favorite_qs_selectspec($userid) ),
qa_db_user_favorite_qs_selectspec($userid, $pagesize_qs),
QA_FINAL_EXTERNAL_USERS ? null : qa_db_selectspec_count( qa_db_user_favorite_users_selectspec($userid) ),
QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_favorite_users_selectspec($userid, $pagesize_users),
qa_db_selectspec_count( qa_db_user_favorite_tags_selectspec($userid) ),
qa_db_user_favorite_tags_selectspec($userid, $pagesize_tags),
qa_db_user_favorite_categories_selectspec($userid)
);
......@@ -69,8 +75,10 @@
$qa_content['q_list'] = qa_favorite_q_list_view($questions, $usershtml);
$qa_content['q_list']['title'] = count($questions) ? qa_lang_html('main/nav_qs') : qa_lang_html('misc/no_favorite_qs');
if ($numQs['count'] > count($questions)) {
$url = qa_path_html('favorites/questions', array('start'=>$pagesize_qs));
$qa_content['q_list']['footer'] = '<p class="qa-link-next"><a href="'.$url.'">'.qa_lang_html('misc/more_favorite_qs').'</a></p>';
}
// Favorite users
......@@ -78,9 +86,11 @@
if (!QA_FINAL_EXTERNAL_USERS) {
$qa_content['ranking_users'] = qa_favorite_users_view($users, $usershtml);
$qa_content['ranking_users']['title'] = count($users) ? qa_lang_html('main/nav_users') : qa_lang_html('misc/no_favorite_users');
if ($numUsers['count'] > count($users)) {
$url = qa_path_html('favorites/users', array('start'=>$pagesize_users));
$qa_content['ranking_users']['footer'] = '<p class="qa-link-next"><a href="'.$url.'">'.qa_lang_html('misc/more_favorite_users').'</a></p>';
}
}
// Favorite tags
......@@ -88,9 +98,11 @@
if (qa_using_tags()) {
$qa_content['ranking_tags'] = qa_favorite_tags_view($tags);
$qa_content['ranking_tags']['title'] = count($tags) ? qa_lang_html('main/nav_tags') : qa_lang_html('misc/no_favorite_tags');
if ($numTags['count'] > count($tags)) {
$url = qa_path_html('favorites/tags', array('start'=>$pagesize_tags));
$qa_content['ranking_tags']['footer'] = '<p class="qa-link-next"><a href="'.$url.'">'.qa_lang_html('misc/more_favorite_tags').'</a></p>';
}
}
// Favorite categories (no pagination)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment