|
30 | 30 |
|
31 | 31 | // Get list of hottest questions, allow per-category if QA_ALLOW_UNINDEXED_QUERIES set in qa-config.php |
32 | 32 |
|
33 | | -$categoryslugs = QA_ALLOW_UNINDEXED_QUERIES ? qa_request_parts(1) : null; |
34 | | -$countslugs = $categoryslugs === null ? null : count($categoryslugs); |
| 33 | +$categoryslugs = qa_request_parts(1); |
| 34 | +$hasSlugs = !empty($categoryslugs); |
| 35 | +if (!QA_ALLOW_UNINDEXED_QUERIES && $hasSlugs) { |
| 36 | + qa_redirect('hot'); |
| 37 | +} |
35 | 38 |
|
36 | 39 | $start = qa_get_start(); |
37 | 40 | $userid = qa_get_logged_in_userid(); |
38 | 41 |
|
39 | 42 | list($questions, $categories, $categoryid) = qa_db_select_with_pending( |
40 | 43 | qa_db_qs_selectspec($userid, 'hotness', $start, $categoryslugs, null, false, false, qa_opt_if_loaded('page_size_hot_qs')), |
41 | 44 | qa_db_category_nav_selectspec($categoryslugs, false, false, true), |
42 | | - $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null |
| 45 | + $hasSlugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null |
43 | 46 | ); |
44 | 47 |
|
45 | | -if ($countslugs) { |
| 48 | +if ($hasSlugs) { |
46 | 49 | if (!isset($categoryid)) |
47 | 50 | return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; |
48 | 51 |
|
49 | 52 | $categorytitlehtml = qa_html($categories[$categoryid]['title']); |
50 | 53 | $sometitle = qa_lang_html_sub('main/hot_qs_in_x', $categorytitlehtml); |
51 | 54 | $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml); |
52 | | - |
53 | 55 | } else { |
54 | 56 | $sometitle = qa_lang_html('main/hot_qs_title'); |
55 | 57 | $nonetitle = qa_lang_html('main/no_questions_found'); |
56 | 58 | } |
57 | 59 |
|
| 60 | +if (isset($categoryid) && $categories[$categoryid]['backpath'] !== qa_db_slugs_to_backpath($categoryslugs)) { |
| 61 | + $expectedPathInUrl = implode('/', array_reverse(explode('/', $categories[$categoryid]['backpath']))); |
| 62 | + qa_redirect('hot/' . $expectedPathInUrl); |
| 63 | +} |
58 | 64 |
|
59 | 65 | // Prepare and return content for theme |
60 | 66 |
|
61 | 67 | return qa_q_list_page_content( |
62 | 68 | $questions, // questions |
63 | 69 | qa_opt('page_size_hot_qs'), // questions per page |
64 | 70 | $start, // start offset |
65 | | - $countslugs ? $categories[$categoryid]['qcount'] : qa_opt('cache_qcount'), // total count |
| 71 | + $hasSlugs ? $categories[$categoryid]['qcount'] : qa_opt('cache_qcount'), // total count |
66 | 72 | $sometitle, // title if some questions |
67 | 73 | $nonetitle, // title if no questions |
68 | | - QA_ALLOW_UNINDEXED_QUERIES ? $categories : array(), // categories for navigation |
| 74 | + $categories, // categories for navigation |
69 | 75 | $categoryid, // selected category id |
70 | 76 | true, // show question counts in category navigation |
71 | | - QA_ALLOW_UNINDEXED_QUERIES ? 'hot/' : null, // prefix for links in category navigation (null if no navigation) |
| 77 | + QA_ALLOW_UNINDEXED_QUERIES ? 'hot/' : null, // prefix for links in category navigation |
72 | 78 | qa_opt('feed_for_hot') ? 'hot' : null, // prefix for RSS feed paths (null to hide) |
73 | 79 | qa_html_suggest_ask() // suggest what to do next |
74 | 80 | ); |
0 commit comments