Commit d7b2c7f0 by Scott

Coding style

parent 5b11d31a
......@@ -69,8 +69,9 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl
// Chop down to size, get user information for display
if (isset($pagesize))
if (isset($pagesize)) {
$questions = array_slice($questions, 0, $pagesize);
}
$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
$qa_content['title'] = $sometitle;
$defaults = qa_post_html_defaults('Q');
if (isset($categorypathprefix))
if (isset($categorypathprefix)) {
$defaults['categorypathprefix'] = $categorypathprefix;
}
foreach ($questions as $question) {
$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
$qa_content['q_list']['qs'][] = $fields;
}
} else
} else {
$qa_content['title'] = $nonetitle;
}
if (isset($userid) && isset($categoryid)) {
$favoritemap = qa_get_favorite_non_qs_map();
......@@ -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']));
}
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);
}
if (empty($qa_content['page_links']))
if (empty($qa_content['page_links'])) {
$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);
}
if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid)))
if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid))) {
$qa_content['feed'] = array(
'url' => qa_path_html(qa_feed_request($feedpathprefix . (isset($categoryid) ? ('/' . qa_category_path_request($navcategories, $categoryid)) : ''))),
'label' => strip_tags($sometitle),
);
}
return $qa_content;
}
......@@ -181,13 +187,15 @@ function qa_qs_sub_navigation($sort, $categoryslugs)
),
);
if (isset($navigation[$sort]))
if (isset($navigation[$sort])) {
$navigation[$sort]['selected'] = true;
else
} else {
$navigation['recent']['selected'] = true;
}
if (!qa_opt('do_count_q_views'))
if (!qa_opt('do_count_q_views')) {
unset($navigation['views']);
}
return $navigation;
}
......@@ -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;
else
} else {
$navigation['by-answers']['selected'] = true;
}
if (!qa_opt('voting_on_as'))
if (!qa_opt('voting_on_as')) {
unset($navigation['by-upvotes']);
}
return $navigation;
}
......@@ -42,8 +42,9 @@ list($categories, $categoryid, $favoritecats) = qa_db_select_with_pending(
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';
}
// Function for recursive display of categories
......@@ -53,16 +54,17 @@ function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favo
foreach ($navigation as $key => $navlink) {
$category = $categories[$navlink['categoryid']];
if (!$category['childcount'])
if (!$category['childcount']) {
unset($navigation[$key]['url']);
elseif ($navlink['selected']) {
} elseif ($navlink['selected']) {
$navigation[$key]['state'] = 'open';
$navigation[$key]['url'] = qa_path_html('categories/' . qa_category_path_request($categories, $category['parentid']));
} else
$navigation[$key]['state'] = 'closed';
if (@$favoritemap[$navlink['categoryid']])
if (@$favoritemap[$navlink['categoryid']]) {
$navigation[$key]['favorited'] = true;
}
$navigation[$key]['note'] =
' - <a href="'.qa_path_html('questions/'.implode('/', array_reverse(explode('/', $category['backpath'])))).'">'.( ($category['qcount']==1)
......@@ -91,9 +93,11 @@ if (count($categories)) {
unset($navigation['all']);
$favoritemap = array();
if (isset($favoritecats))
foreach ($favoritecats as $category)
if (isset($favoritecats)) {
foreach ($favoritecats as $category) {
$favoritemap[$category['categoryid']] = true;
}
}
qa_category_nav_to_browse($navigation, $categories, $categoryid, $favoritemap);
......
......@@ -34,12 +34,13 @@ require_once QA_INCLUDE_DIR . 'app/format.php';
$requestparts = explode('/', qa_request());
$explicitqa = (strtolower($requestparts[0]) == 'qa');
if ($explicitqa)
if ($explicitqa) {
$slugs = array_slice($requestparts, 1);
elseif (strlen($requestparts[0]))
} elseif (strlen($requestparts[0])) {
$slugs = $requestparts;
else
} else {
$slugs = array();
}
$countslugs = count($slugs);
......@@ -53,7 +54,7 @@ list($questions1, $questions2, $categories, $categoryid, $custompage) = qa_db_se
qa_db_recent_a_qs_selectspec($userid, 0, $slugs),
qa_db_category_nav_selectspec($slugs, false, false, true),
$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)) {
);
}
} else
} else {
$qa_content['error'] = qa_lang_html('users/no_permission');
}
return $qa_content;
}
......@@ -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
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);
}
// 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));
$pagesize = qa_opt('page_size_home');
if ($countslugs) {
if (!isset($categoryid))
if (!isset($categoryid)) {
return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
$categorytitlehtml = qa_html($categories[$categoryid]['title']);
$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(
);
if ($countslugs) {
if (!isset($categoryid))
if (!isset($categoryid)) {
return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
}
$categorytitlehtml = qa_html($categories[$categoryid]['title']);
$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