Commit d7b2c7f0 by Scott

Coding style

parent 5b11d31a
...@@ -69,8 +69,9 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl ...@@ -69,8 +69,9 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl
// Chop down to size, get user information for display // Chop down to size, get user information for display
if (isset($pagesize)) if (isset($pagesize)) {
$questions = array_slice($questions, 0, $pagesize); $questions = array_slice($questions, 0, $pagesize);
}
$usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions)); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
...@@ -93,8 +94,9 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl ...@@ -93,8 +94,9 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl
$qa_content['title'] = $sometitle; $qa_content['title'] = $sometitle;
$defaults = qa_post_html_defaults('Q'); $defaults = qa_post_html_defaults('Q');
if (isset($categorypathprefix)) if (isset($categorypathprefix)) {
$defaults['categorypathprefix'] = $categorypathprefix; $defaults['categorypathprefix'] = $categorypathprefix;
}
foreach ($questions as $question) { foreach ($questions as $question) {
$fields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults)); $fields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults));
...@@ -107,9 +109,9 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl ...@@ -107,9 +109,9 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl
$qa_content['q_list']['qs'][] = $fields; $qa_content['q_list']['qs'][] = $fields;
} }
} else {
} else
$qa_content['title'] = $nonetitle; $qa_content['title'] = $nonetitle;
}
if (isset($userid) && isset($categoryid)) { if (isset($userid) && isset($categoryid)) {
$favoritemap = qa_get_favorite_non_qs_map(); $favoritemap = qa_get_favorite_non_qs_map();
...@@ -119,20 +121,24 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl ...@@ -119,20 +121,24 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl
qa_lang_sub($categoryisfavorite ? 'main/remove_x_favorites' : 'main/add_category_x_favorites', $navcategories[$categoryid]['title'])); qa_lang_sub($categoryisfavorite ? 'main/remove_x_favorites' : 'main/add_category_x_favorites', $navcategories[$categoryid]['title']));
} }
if (isset($count) && isset($pagesize)) if (isset($count) && isset($pagesize)) {
$qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams); $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams);
}
if (empty($qa_content['page_links'])) if (empty($qa_content['page_links'])) {
$qa_content['suggest_next'] = $suggest; $qa_content['suggest_next'] = $suggest;
}
if (qa_using_categories() && count($navcategories) && isset($categorypathprefix)) if (qa_using_categories() && count($navcategories) && isset($categorypathprefix)) {
$qa_content['navigation']['cat'] = qa_category_navigation($navcategories, $categoryid, $categorypathprefix, $categoryqcount, $categoryparams); $qa_content['navigation']['cat'] = qa_category_navigation($navcategories, $categoryid, $categorypathprefix, $categoryqcount, $categoryparams);
}
if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid))) if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid))) {
$qa_content['feed'] = array( $qa_content['feed'] = array(
'url' => qa_path_html(qa_feed_request($feedpathprefix . (isset($categoryid) ? ('/' . qa_category_path_request($navcategories, $categoryid)) : ''))), 'url' => qa_path_html(qa_feed_request($feedpathprefix . (isset($categoryid) ? ('/' . qa_category_path_request($navcategories, $categoryid)) : ''))),
'label' => strip_tags($sometitle), 'label' => strip_tags($sometitle),
); );
}
return $qa_content; return $qa_content;
} }
...@@ -181,13 +187,15 @@ function qa_qs_sub_navigation($sort, $categoryslugs) ...@@ -181,13 +187,15 @@ function qa_qs_sub_navigation($sort, $categoryslugs)
), ),
); );
if (isset($navigation[$sort])) if (isset($navigation[$sort])) {
$navigation[$sort]['selected'] = true; $navigation[$sort]['selected'] = true;
else } else {
$navigation['recent']['selected'] = true; $navigation['recent']['selected'] = true;
}
if (!qa_opt('do_count_q_views')) if (!qa_opt('do_count_q_views')) {
unset($navigation['views']); unset($navigation['views']);
}
return $navigation; return $navigation;
} }
...@@ -226,13 +234,15 @@ function qa_unanswered_sub_navigation($by, $categoryslugs) ...@@ -226,13 +234,15 @@ function qa_unanswered_sub_navigation($by, $categoryslugs)
), ),
); );
if (isset($navigation['by-' . $by])) if (isset($navigation['by-' . $by])) {
$navigation['by-' . $by]['selected'] = true; $navigation['by-' . $by]['selected'] = true;
else } else {
$navigation['by-answers']['selected'] = true; $navigation['by-answers']['selected'] = true;
}
if (!qa_opt('voting_on_as')) if (!qa_opt('voting_on_as')) {
unset($navigation['by-upvotes']); unset($navigation['by-upvotes']);
}
return $navigation; return $navigation;
} }
...@@ -42,8 +42,9 @@ list($categories, $categoryid, $favoritecats) = qa_db_select_with_pending( ...@@ -42,8 +42,9 @@ list($categories, $categoryid, $favoritecats) = qa_db_select_with_pending(
isset($userid) ? qa_db_user_favorite_categories_selectspec($userid) : null isset($userid) ? qa_db_user_favorite_categories_selectspec($userid) : null
); );
if ($countslugs && !isset($categoryid)) if ($countslugs && !isset($categoryid)) {
return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
// Function for recursive display of categories // Function for recursive display of categories
...@@ -53,16 +54,17 @@ function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favo ...@@ -53,16 +54,17 @@ function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favo
foreach ($navigation as $key => $navlink) { foreach ($navigation as $key => $navlink) {
$category = $categories[$navlink['categoryid']]; $category = $categories[$navlink['categoryid']];
if (!$category['childcount']) if (!$category['childcount']) {
unset($navigation[$key]['url']); unset($navigation[$key]['url']);
elseif ($navlink['selected']) { } elseif ($navlink['selected']) {
$navigation[$key]['state'] = 'open'; $navigation[$key]['state'] = 'open';
$navigation[$key]['url'] = qa_path_html('categories/' . qa_category_path_request($categories, $category['parentid'])); $navigation[$key]['url'] = qa_path_html('categories/' . qa_category_path_request($categories, $category['parentid']));
} else } else
$navigation[$key]['state'] = 'closed'; $navigation[$key]['state'] = 'closed';
if (@$favoritemap[$navlink['categoryid']]) if (@$favoritemap[$navlink['categoryid']]) {
$navigation[$key]['favorited'] = true; $navigation[$key]['favorited'] = true;
}
$navigation[$key]['note'] = $navigation[$key]['note'] =
' - <a href="'.qa_path_html('questions/'.implode('/', array_reverse(explode('/', $category['backpath'])))).'">'.( ($category['qcount']==1) ' - <a href="'.qa_path_html('questions/'.implode('/', array_reverse(explode('/', $category['backpath'])))).'">'.( ($category['qcount']==1)
...@@ -91,9 +93,11 @@ if (count($categories)) { ...@@ -91,9 +93,11 @@ if (count($categories)) {
unset($navigation['all']); unset($navigation['all']);
$favoritemap = array(); $favoritemap = array();
if (isset($favoritecats)) if (isset($favoritecats)) {
foreach ($favoritecats as $category) foreach ($favoritecats as $category) {
$favoritemap[$category['categoryid']] = true; $favoritemap[$category['categoryid']] = true;
}
}
qa_category_nav_to_browse($navigation, $categories, $categoryid, $favoritemap); qa_category_nav_to_browse($navigation, $categories, $categoryid, $favoritemap);
......
...@@ -34,12 +34,13 @@ require_once QA_INCLUDE_DIR . 'app/format.php'; ...@@ -34,12 +34,13 @@ require_once QA_INCLUDE_DIR . 'app/format.php';
$requestparts = explode('/', qa_request()); $requestparts = explode('/', qa_request());
$explicitqa = (strtolower($requestparts[0]) == 'qa'); $explicitqa = (strtolower($requestparts[0]) == 'qa');
if ($explicitqa) if ($explicitqa) {
$slugs = array_slice($requestparts, 1); $slugs = array_slice($requestparts, 1);
elseif (strlen($requestparts[0])) } elseif (strlen($requestparts[0])) {
$slugs = $requestparts; $slugs = $requestparts;
else } else {
$slugs = array(); $slugs = array();
}
$countslugs = count($slugs); $countslugs = count($slugs);
...@@ -53,7 +54,7 @@ list($questions1, $questions2, $categories, $categoryid, $custompage) = qa_db_se ...@@ -53,7 +54,7 @@ list($questions1, $questions2, $categories, $categoryid, $custompage) = qa_db_se
qa_db_recent_a_qs_selectspec($userid, 0, $slugs), qa_db_recent_a_qs_selectspec($userid, 0, $slugs),
qa_db_category_nav_selectspec($slugs, false, false, true), qa_db_category_nav_selectspec($slugs, false, false, true),
$countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null, $countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null,
(($countslugs == 1) && !$explicitqa) ? qa_db_page_full_selectspec($slugs[0], false) : null ($countslugs == 1 && !$explicitqa) ? qa_db_page_full_selectspec($slugs[0], false) : null
); );
...@@ -79,8 +80,9 @@ if (isset($custompage) && !($custompage['flags'] & QA_PAGE_FLAGS_EXTERNAL)) { ...@@ -79,8 +80,9 @@ if (isset($custompage) && !($custompage['flags'] & QA_PAGE_FLAGS_EXTERNAL)) {
); );
} }
} else } else {
$qa_content['error'] = qa_lang_html('users/no_permission'); $qa_content['error'] = qa_lang_html('users/no_permission');
}
return $qa_content; return $qa_content;
} }
...@@ -88,8 +90,9 @@ if (isset($custompage) && !($custompage['flags'] & QA_PAGE_FLAGS_EXTERNAL)) { ...@@ -88,8 +90,9 @@ if (isset($custompage) && !($custompage['flags'] & QA_PAGE_FLAGS_EXTERNAL)) {
// Then, see if we should redirect because the 'qa' page is the same as the home page // Then, see if we should redirect because the 'qa' page is the same as the home page
if ($explicitqa && (!qa_is_http_post()) && !qa_has_custom_home()) if ($explicitqa && !qa_is_http_post() && !qa_has_custom_home()) {
qa_redirect(qa_category_path_request($categories, $categoryid), $_GET); qa_redirect(qa_category_path_request($categories, $categoryid), $_GET);
}
// Then, if there's a slug that matches no category, check page modules provided by plugins // Then, if there's a slug that matches no category, check page modules provided by plugins
...@@ -128,8 +131,9 @@ $questions = qa_any_sort_and_dedupe(array_merge($questions1, $questions2)); ...@@ -128,8 +131,9 @@ $questions = qa_any_sort_and_dedupe(array_merge($questions1, $questions2));
$pagesize = qa_opt('page_size_home'); $pagesize = qa_opt('page_size_home');
if ($countslugs) { if ($countslugs) {
if (!isset($categoryid)) if (!isset($categoryid)) {
return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
$categorytitlehtml = qa_html($categories[$categoryid]['title']); $categorytitlehtml = qa_html($categories[$categoryid]['title']);
$sometitle = qa_lang_html_sub('main/recent_qs_as_in_x', $categorytitlehtml); $sometitle = qa_lang_html_sub('main/recent_qs_as_in_x', $categorytitlehtml);
......
...@@ -68,8 +68,9 @@ list($questions, $categories, $categoryid) = qa_db_select_with_pending( ...@@ -68,8 +68,9 @@ list($questions, $categories, $categoryid) = qa_db_select_with_pending(
); );
if ($countslugs) { if ($countslugs) {
if (!isset($categoryid)) if (!isset($categoryid)) {
return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
$categorytitlehtml = qa_html($categories[$categoryid]['title']); $categorytitlehtml = qa_html($categories[$categoryid]['title']);
$nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml);
......
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