Commit 2089b48f by Scott

Coding style (misc)

parent c1b82ae1
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
and the value should be the replacement for that standard part, e.g. 'topics'. If you edit this and the value should be the replacement for that standard part, e.g. 'topics'. If you edit this
file in UTF-8 encoding you can also use non-ASCII characters in these URLs. file in UTF-8 encoding you can also use non-ASCII characters in these URLs.
$QA_CONST_PATH_MAP=array( $QA_CONST_PATH_MAP = array(
'questions' => 'topics', 'questions' => 'topics',
'categories' => 'sections', 'categories' => 'sections',
'users' => 'contributors', 'users' => 'contributors',
...@@ -197,7 +197,3 @@ ...@@ -197,7 +197,3 @@
file to override the default setting. Just make sure you know what you're doing! file to override the default setting. Just make sure you know what you're doing!
*/ */
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -573,7 +573,7 @@ function qa_db_missing_columns($table, $definition) ...@@ -573,7 +573,7 @@ function qa_db_missing_columns($table, $definition)
$missing = array(); $missing = array();
foreach ($definition as $colname => $coldefn) foreach ($definition as $colname => $coldefn)
if ((!is_int($colname)) && !isset($keycolumns[$colname])) if (!is_int($colname) && !isset($keycolumns[$colname]))
$missing[$colname] = $coldefn; $missing[$colname] = $coldefn;
return $missing; return $missing;
...@@ -649,7 +649,7 @@ function qa_db_check_tables() ...@@ -649,7 +649,7 @@ function qa_db_check_tables()
$datamissing++; $datamissing++;
} }
if (($datacount == $datamissing) && ($datamissing == count($missing))) if ($datacount == $datamissing && $datamissing == count($missing))
return 'non-users-missing'; return 'non-users-missing';
} }
......
...@@ -148,45 +148,45 @@ function qa_db_points_update_ifuser($userid, $columns) ...@@ -148,45 +148,45 @@ function qa_db_points_update_ifuser($userid, $columns)
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
if (qa_should_update_counts() && isset($userid)) { if (qa_should_update_counts() && isset($userid)) {
require_once QA_INCLUDE_DIR.'app/options.php'; require_once QA_INCLUDE_DIR . 'app/options.php';
require_once QA_INCLUDE_DIR.'app/cookies.php'; require_once QA_INCLUDE_DIR . 'app/cookies.php';
$calculations=qa_db_points_calculations(); $calculations = qa_db_points_calculations();
if ($columns===true) if ($columns === true)
$keycolumns=$calculations; $keycolumns = $calculations;
elseif (empty($columns)) elseif (empty($columns))
$keycolumns=array(); $keycolumns = array();
elseif (is_array($columns)) elseif (is_array($columns))
$keycolumns=array_flip($columns); $keycolumns = array_flip($columns);
else else
$keycolumns=array($columns => true); $keycolumns = array($columns => true);
$insertfields='userid, '; $insertfields = 'userid, ';
$insertvalues='$, '; $insertvalues = '$, ';
$insertpoints=(int)qa_opt('points_base'); $insertpoints = (int)qa_opt('points_base');
$updates=''; $updates = '';
$updatepoints=$insertpoints; $updatepoints = $insertpoints;
foreach ($calculations as $field => $calculation) { foreach ($calculations as $field => $calculation) {
$multiple=(int)$calculation['multiple']; $multiple = (int)$calculation['multiple'];
if (isset($keycolumns[$field])) { if (isset($keycolumns[$field])) {
$insertfields.=$field.', '; $insertfields .= $field . ', ';
$insertvalues.='@_'.$field.':=(SELECT '.$calculation['formula'].'), '; $insertvalues .= '@_' . $field . ':=(SELECT ' . $calculation['formula'] . '), ';
$updates.=$field.'=@_'.$field.', '; $updates .= $field . '=@_' . $field . ', ';
$insertpoints.='+('.(int)$multiple.'*@_'.$field.')'; $insertpoints .= '+(' . (int)$multiple . '*@_' . $field . ')';
} }
$updatepoints.='+('.$multiple.'*'.(isset($keycolumns[$field]) ? '@_' : '').$field.')'; $updatepoints .= '+(' . $multiple . '*' . (isset($keycolumns[$field]) ? '@_' : '') . $field . ')';
} }
$query='INSERT INTO ^userpoints ('.$insertfields.'points) VALUES ('.$insertvalues.$insertpoints.') '. $query = 'INSERT INTO ^userpoints (' . $insertfields . 'points) VALUES (' . $insertvalues . $insertpoints . ') ' .
'ON DUPLICATE KEY UPDATE '.$updates.'points='.$updatepoints.'+bonus'; 'ON DUPLICATE KEY UPDATE ' . $updates . 'points=' . $updatepoints . '+bonus';
qa_db_query_raw(str_replace('~', "='".qa_db_escape_string($userid)."'", qa_db_apply_sub($query, array($userid))));
// build like this so that a #, $ or ^ character in the $userid (if external integration) isn't substituted // build like this so that a #, $ or ^ character in the $userid (if external integration) isn't substituted
qa_db_query_raw(str_replace('~', "='" . qa_db_escape_string($userid) . "'", qa_db_apply_sub($query, array($userid))));
if (qa_db_insert_on_duplicate_inserted()) if (qa_db_insert_on_duplicate_inserted())
qa_db_userpointscount_update(); qa_db_userpointscount_update();
......
...@@ -190,7 +190,7 @@ if (qa_clicked('docancel')) { ...@@ -190,7 +190,7 @@ if (qa_clicked('docancel')) {
$errors['slug'] = qa_lang_sub('main/max_length_x', QA_DB_MAX_CAT_PAGE_TAGS_LENGTH); $errors['slug'] = qa_lang_sub('main/max_length_x', QA_DB_MAX_CAT_PAGE_TAGS_LENGTH);
elseif (preg_match('/[\\+\\/]/', $inslug)) elseif (preg_match('/[\\+\\/]/', $inslug))
$errors['slug'] = qa_lang_sub('admin/slug_bad_chars', '+ /'); $errors['slug'] = qa_lang_sub('admin/slug_bad_chars', '+ /');
elseif ((!isset($inparentid)) && qa_admin_is_slug_reserved($inslug)) // only top level is a problem elseif (!isset($inparentid) && qa_admin_is_slug_reserved($inslug)) // only top level is a problem
$errors['slug'] = qa_lang('admin/slug_reserved'); $errors['slug'] = qa_lang('admin/slug_reserved');
elseif (isset($matchcategoryid) && strcmp($matchcategoryid, @$editcategory['categoryid'])) elseif (isset($matchcategoryid) && strcmp($matchcategoryid, @$editcategory['categoryid']))
$errors['slug'] = qa_lang('admin/category_already_used'); $errors['slug'] = qa_lang('admin/category_already_used');
......
...@@ -1300,7 +1300,7 @@ foreach ($showoptions as $optionname) { ...@@ -1300,7 +1300,7 @@ foreach ($showoptions as $optionname) {
foreach ($searchmodules as $modulename => $module) { foreach ($searchmodules as $modulename => $module) {
$selectoptions[qa_html($modulename)] = strlen($modulename) ? qa_html($modulename) : qa_lang_html('options/option_default'); $selectoptions[qa_html($modulename)] = strlen($modulename) ? qa_html($modulename) : qa_lang_html('options/option_default');
if (($modulename == $value) && method_exists($module, 'admin_form')) { if ($modulename == $value && method_exists($module, 'admin_form')) {
$optionfield['note'] = '<a href="' . qa_admin_module_options_path('search', $modulename) . '">' . qa_lang_html('admin/options') . '</a>'; $optionfield['note'] = '<a href="' . qa_admin_module_options_path('search', $modulename) . '">' . qa_lang_html('admin/options') . '</a>';
} }
} }
......
...@@ -142,7 +142,7 @@ if (count($questions)) { ...@@ -142,7 +142,7 @@ if (count($questions)) {
); );
} }
if ((!qa_user_post_permit_error('permit_delete_hidden', $question)) && !$dependcounts[$qhiddenpostid[$key]]) { if (!qa_user_post_permit_error('permit_delete_hidden', $question) && !$dependcounts[$qhiddenpostid[$key]]) {
// Possible values for popup: delete_q_popup, delete_a_popup, delete_c_popup // Possible values for popup: delete_q_popup, delete_a_popup, delete_c_popup
$buttons['delete'] = array( $buttons['delete'] = array(
'tags' => 'name="admin_' . qa_html($qhiddenpostid[$key]) . '_delete" onclick="return qa_admin_click(this);"', 'tags' => 'name="admin_' . qa_html($qhiddenpostid[$key]) . '_delete" onclick="return qa_admin_click(this);"',
......
...@@ -319,7 +319,7 @@ if (isset($editpage)) { ...@@ -319,7 +319,7 @@ if (isset($editpage)) {
} }
} }
if ((!isset($editpage['pageid'])) || $nav != @$editpage['nav']) { if (!isset($editpage['pageid']) || $nav != @$editpage['nav']) {
$positionvalue = isset($previous) ? qa_lang_html_sub('admin/after_x_tab', qa_html($previous['title'])) : qa_lang_html($langkey); $positionvalue = isset($previous) ? qa_lang_html_sub('admin/after_x_tab', qa_html($previous['title'])) : qa_lang_html($langkey);
$positionoptions[$nav . (isset($previous) ? (1 + $maxposition) : 1)] = $positionvalue; $positionoptions[$nav . (isset($previous) ? (1 + $maxposition) : 1)] = $positionvalue;
} }
......
...@@ -94,7 +94,7 @@ if ($explicitqa && (!qa_is_http_post()) && !qa_has_custom_home()) ...@@ -94,7 +94,7 @@ if ($explicitqa && (!qa_is_http_post()) && !qa_has_custom_home())
// 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
if ((!$explicitqa) && $countslugs && !isset($categoryid)) { if (!$explicitqa && $countslugs && !isset($categoryid)) {
$pagemodules = qa_load_modules_with('page', 'match_request'); $pagemodules = qa_load_modules_with('page', 'match_request');
$request = qa_request(); $request = qa_request();
...@@ -110,7 +110,7 @@ if ((!$explicitqa) && $countslugs && !isset($categoryid)) { ...@@ -110,7 +110,7 @@ if ((!$explicitqa) && $countslugs && !isset($categoryid)) {
// Then, check whether we are showing a custom home page // Then, check whether we are showing a custom home page
if ((!$explicitqa) && (!$countslugs) && qa_opt('show_custom_home')) { if (!$explicitqa && !$countslugs && qa_opt('show_custom_home')) {
qa_set_template('custom'); qa_set_template('custom');
$qa_content = qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title'] = qa_html(qa_opt('custom_home_heading')); $qa_content['title'] = qa_html(qa_opt('custom_home_heading'));
......
...@@ -98,7 +98,7 @@ if ($question['closeable']) { ...@@ -98,7 +98,7 @@ if ($question['closeable']) {
else else
$formtype = 'q_close'; // keep editing if an error $formtype = 'q_close'; // keep editing if an error
} elseif (($pagestate == 'close') && qa_page_q_permit_edit($question, 'permit_close_q', $pageerror)) } elseif ($pagestate == 'close' && qa_page_q_permit_edit($question, 'permit_close_q', $pageerror))
$formtype = 'q_close'; $formtype = 'q_close';
} }
...@@ -220,7 +220,7 @@ foreach ($commentsfollows as $commentid => $comment) { ...@@ -220,7 +220,7 @@ foreach ($commentsfollows as $commentid => $comment) {
$formtype = 'c_edit'; $formtype = 'c_edit';
$formpostid = $commentid; // keep editing if an error $formpostid = $commentid; // keep editing if an error
} }
} elseif (($pagestate == ('edit-' . $commentid)) && qa_page_q_permit_edit($comment, 'permit_edit_c', $pageerror)) { } elseif ($pagestate == ('edit-' . $commentid) && qa_page_q_permit_edit($comment, 'permit_edit_c', $pageerror)) {
$formtype = 'c_edit'; $formtype = 'c_edit';
$formpostid = $commentid; $formpostid = $commentid;
} }
......
...@@ -468,7 +468,7 @@ function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptch ...@@ -468,7 +468,7 @@ function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptch
$testwords = implode(' ', qa_string_to_words($in['content'])); $testwords = implode(' ', qa_string_to_words($in['content']));
foreach ($commentsfollows as $comment) { foreach ($commentsfollows as $comment) {
if (($comment['basetype'] == 'C') && ($comment['parentid'] == $parentid) && !$comment['hidden']) { if ($comment['basetype'] == 'C' && $comment['parentid'] == $parentid && !$comment['hidden']) {
if (implode(' ', qa_string_to_words($comment['content'])) == $testwords) { if (implode(' ', qa_string_to_words($comment['content'])) == $testwords) {
$errors['content'] = qa_lang_html('question/duplicate_content'); $errors['content'] = qa_lang_html('question/duplicate_content');
break; break;
......
...@@ -198,10 +198,10 @@ if (qa_is_http_post() || strlen($pagestate)) ...@@ -198,10 +198,10 @@ if (qa_is_http_post() || strlen($pagestate))
$formrequested = isset($formtype); $formrequested = isset($formtype);
if ((!$formrequested) && $question['answerbutton']) { if (!$formrequested && $question['answerbutton']) {
$immedoption = qa_opt('show_a_form_immediate'); $immedoption = qa_opt('show_a_form_immediate');
if (($immedoption == 'always') || (($immedoption == 'if_no_as') && (!$question['isbyuser']) && (!$question['acount']))) if ($immedoption == 'always' || ($immedoption == 'if_no_as' && !$question['isbyuser'] && !$question['acount']))
$formtype = 'a_add'; // show answer form by default $formtype = 'a_add'; // show answer form by default
} }
...@@ -275,7 +275,7 @@ if ($formtype == 'a_edit') { ...@@ -275,7 +275,7 @@ if ($formtype == 'a_edit') {
$jumptoanchor = 'a' . $formpostid; $jumptoanchor = 'a' . $formpostid;
} elseif (($formtype == 'a_add') || ($question['answerbutton'] && !$formrequested)) { } elseif ($formtype == 'a_add' || ($question['answerbutton'] && !$formrequested)) {
$qa_content['a_form'] = qa_page_q_add_a_form($qa_content, 'anew', $captchareason, $question, @$anewin, @$anewerrors, $formtype == 'a_add', $formrequested); $qa_content['a_form'] = qa_page_q_add_a_form($qa_content, 'anew', $captchareason, $question, @$anewin, @$anewerrors, $formtype == 'a_add', $formrequested);
if ($formrequested) { if ($formrequested) {
...@@ -294,16 +294,16 @@ if ($formtype == 'q_close') { ...@@ -294,16 +294,16 @@ if ($formtype == 'q_close') {
$qa_content['q_view']['c_form'] = qa_page_q_close_q_form($qa_content, $question, 'close', @$closein, @$closeerrors); $qa_content['q_view']['c_form'] = qa_page_q_close_q_form($qa_content, $question, 'close', @$closein, @$closeerrors);
$jumptoanchor = 'close'; $jumptoanchor = 'close';
} elseif ((($formtype == 'c_add') && ($formpostid == $questionid)) || ($question['commentbutton'] && !$formrequested)) { // ...to be added } elseif (($formtype == 'c_add' && $formpostid == $questionid) || ($question['commentbutton'] && !$formrequested)) { // ...to be added
$qa_content['q_view']['c_form'] = qa_page_q_add_c_form($qa_content, $question, $question, 'c' . $questionid, $qa_content['q_view']['c_form'] = qa_page_q_add_c_form($qa_content, $question, $question, 'c' . $questionid,
$captchareason, @$cnewin[$questionid], @$cnewerrors[$questionid], $formtype == 'c_add'); $captchareason, @$cnewin[$questionid], @$cnewerrors[$questionid], $formtype == 'c_add');
if (($formtype == 'c_add') && ($formpostid == $questionid)) { if ($formtype == 'c_add' && $formpostid == $questionid) {
$jumptoanchor = 'c' . $questionid; $jumptoanchor = 'c' . $questionid;
$commentsall = $questionid; $commentsall = $questionid;
} }
} elseif (($formtype == 'c_edit') && (@$commentsfollows[$formpostid]['parentid'] == $questionid)) { // ...being edited } elseif ($formtype == 'c_edit' && @$commentsfollows[$formpostid]['parentid'] == $questionid) { // ...being edited
$qa_content['q_view']['c_form'] = qa_page_q_edit_c_form($qa_content, 'c' . $formpostid, $commentsfollows[$formpostid], $qa_content['q_view']['c_form'] = qa_page_q_edit_c_form($qa_content, 'c' . $formpostid, $commentsfollows[$formpostid],
@$ceditin[$formpostid], @$cediterrors[$formpostid]); @$ceditin[$formpostid], @$cediterrors[$formpostid]);
...@@ -470,8 +470,3 @@ if ( ...@@ -470,8 +470,3 @@ if (
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
...@@ -51,7 +51,7 @@ if (!empty($inhandle)) { // match based on code and handle provided on URL ...@@ -51,7 +51,7 @@ if (!empty($inhandle)) { // match based on code and handle provided on URL
} }
} }
if ((!$unsubscribed) && isset($loginuserid)) { // as a backup, also unsubscribe logged in user if (!$unsubscribed && isset($loginuserid)) { // as a backup, also unsubscribe logged in user
qa_db_user_set_flag($loginuserid, QA_USER_FLAGS_NO_MAILINGS, true); qa_db_user_set_flag($loginuserid, QA_USER_FLAGS_NO_MAILINGS, true);
$unsubscribed = true; $unsubscribed = true;
} }
......
...@@ -75,7 +75,7 @@ $loginlevel = qa_get_logged_in_level(); ...@@ -75,7 +75,7 @@ $loginlevel = qa_get_logged_in_level();
if (!QA_FINAL_EXTERNAL_USERS) { // if we're using integrated user management, we can know and show more if (!QA_FINAL_EXTERNAL_USERS) { // if we're using integrated user management, we can know and show more
require_once QA_INCLUDE_DIR . 'app/messages.php'; require_once QA_INCLUDE_DIR . 'app/messages.php';
if ((!is_array($userpoints)) && !is_array($useraccount)) if (!is_array($userpoints) && !is_array($useraccount))
return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
$userid = $useraccount['userid']; $userid = $useraccount['userid'];
...@@ -435,7 +435,7 @@ if (!QA_FINAL_EXTERNAL_USERS) { ...@@ -435,7 +435,7 @@ if (!QA_FINAL_EXTERNAL_USERS) {
if (qa_using_categories()) { if (qa_using_categories()) {
$catleveladd = strlen(qa_get('catleveladd')) > 0; $catleveladd = strlen(qa_get('catleveladd')) > 0;
if ((!$catleveladd) && !count($userlevels)) { if (!$catleveladd && !count($userlevels)) {
$qa_content['form_profile']['fields']['level']['suffix'] = strtr(qa_lang_html('users/category_level_add'), array( $qa_content['form_profile']['fields']['level']['suffix'] = strtr(qa_lang_html('users/category_level_add'), array(
'^1' => '<a href="' . qa_path_html(qa_request(), array('state' => 'edit', 'catleveladd' => 1)) . '">', '^1' => '<a href="' . qa_path_html(qa_request(), array('state' => 'edit', 'catleveladd' => 1)) . '">',
'^2' => '</a>', '^2' => '</a>',
......
...@@ -1843,7 +1843,7 @@ function qa_suspend_event_reports($suspend = true) ...@@ -1843,7 +1843,7 @@ function qa_suspend_event_reports($suspend = true)
* @param array $params * @param array $params
* @return mixed|void * @return mixed|void
*/ */
function qa_report_event($event, $userid, $handle, $cookieid, $params=array()) function qa_report_event($event, $userid, $handle, $cookieid, $params = array())
{ {
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
......
...@@ -40,7 +40,7 @@ if (!function_exists('qa_install_db_fail_handler')) { ...@@ -40,7 +40,7 @@ if (!function_exists('qa_install_db_fail_handler')) {
* @param string $error * @param string $error
* @param string $query * @param string $query
*/ */
function qa_install_db_fail_handler($type, $errno=null, $error=null, $query=null) function qa_install_db_fail_handler($type, $errno = null, $error = null, $query = null)
{ {
global $pass_failure_from_install; global $pass_failure_from_install;
......
...@@ -244,10 +244,10 @@ class qa_html_theme_base ...@@ -244,10 +244,10 @@ class qa_html_theme_base
} }
// From here on, we have a large number of class methods which output particular pieces of HTML markup // From here on, we have a large number of class methods which output particular pieces of HTML markup
// The calling chain is initiated from qa-page.php, or qa-ajax-*.php for refreshing parts of a page, // The calling chain is initiated from qa-page.php, or qa-ajax-*.php for refreshing parts of a page,
// For most HTML elements, the name of the function is similar to the element's CSS class, for example: // For most HTML elements, the name of the function is similar to the element's CSS class, for example:
// search() outputs <div class="qa-search">, q_list() outputs <div class="qa-q-list">, etc... // search() outputs <div class="qa-search">, q_list() outputs <div class="qa-q-list">, etc...
public function doctype() public function doctype()
{ {
......
...@@ -127,7 +127,7 @@ function qa_image_constrain(&$width, &$height, $maxwidth, $maxheight = null) ...@@ -127,7 +127,7 @@ function qa_image_constrain(&$width, &$height, $maxwidth, $maxheight = null)
if (!isset($maxheight)) if (!isset($maxheight))
$maxheight = $maxwidth; $maxheight = $maxwidth;
if (($width > $maxwidth) || ($height > $maxheight)) { if ($width > $maxwidth || $height > $maxheight) {
$multiplier = min($maxwidth / $width, $maxheight / $height); $multiplier = min($maxwidth / $width, $maxheight / $height);
$width = floor($width * $multiplier); $width = floor($width * $multiplier);
$height = floor($height * $multiplier); $height = floor($height * $multiplier);
......
...@@ -52,7 +52,7 @@ class qa_facebook_login ...@@ -52,7 +52,7 @@ class qa_facebook_login
public function facebook_html($tourl, $logout, $context) public function facebook_html($tourl, $logout, $context)
{ {
if (($context == 'login') || ($context == 'register')) if ($context == 'login' || $context == 'register')
$size = 'large'; $size = 'large';
else else
$size = 'medium'; $size = 'medium';
......
...@@ -173,7 +173,7 @@ class qa_xml_sitemap ...@@ -173,7 +173,7 @@ class qa_xml_sitemap
// User pages // User pages
if ((!QA_FINAL_EXTERNAL_USERS) && qa_opt('xml_sitemap_show_users')) { if (!QA_FINAL_EXTERNAL_USERS && qa_opt('xml_sitemap_show_users')) {
$nextuserid = 0; $nextuserid = 0;
while (1) { while (1) {
......
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