Commit 2089b48f by Scott

Coding style (misc)

parent c1b82ae1
......@@ -108,7 +108,7 @@
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.
$QA_CONST_PATH_MAP=array(
$QA_CONST_PATH_MAP = array(
'questions' => 'topics',
'categories' => 'sections',
'users' => 'contributors',
......@@ -197,7 +197,3 @@
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)
$missing = array();
foreach ($definition as $colname => $coldefn)
if ((!is_int($colname)) && !isset($keycolumns[$colname]))
if (!is_int($colname) && !isset($keycolumns[$colname]))
$missing[$colname] = $coldefn;
return $missing;
......@@ -649,7 +649,7 @@ function qa_db_check_tables()
$datamissing++;
}
if (($datacount == $datamissing) && ($datamissing == count($missing)))
if ($datacount == $datamissing && $datamissing == count($missing))
return 'non-users-missing';
}
......
......@@ -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_should_update_counts() && isset($userid)) {
require_once QA_INCLUDE_DIR.'app/options.php';
require_once QA_INCLUDE_DIR.'app/cookies.php';
require_once QA_INCLUDE_DIR . 'app/options.php';
require_once QA_INCLUDE_DIR . 'app/cookies.php';
$calculations=qa_db_points_calculations();
$calculations = qa_db_points_calculations();
if ($columns===true)
$keycolumns=$calculations;
if ($columns === true)
$keycolumns = $calculations;
elseif (empty($columns))
$keycolumns=array();
$keycolumns = array();
elseif (is_array($columns))
$keycolumns=array_flip($columns);
$keycolumns = array_flip($columns);
else
$keycolumns=array($columns => true);
$keycolumns = array($columns => true);
$insertfields='userid, ';
$insertvalues='$, ';
$insertpoints=(int)qa_opt('points_base');
$insertfields = 'userid, ';
$insertvalues = '$, ';
$insertpoints = (int)qa_opt('points_base');
$updates='';
$updatepoints=$insertpoints;
$updates = '';
$updatepoints = $insertpoints;
foreach ($calculations as $field => $calculation) {
$multiple=(int)$calculation['multiple'];
$multiple = (int)$calculation['multiple'];
if (isset($keycolumns[$field])) {
$insertfields.=$field.', ';
$insertvalues.='@_'.$field.':=(SELECT '.$calculation['formula'].'), ';
$updates.=$field.'=@_'.$field.', ';
$insertpoints.='+('.(int)$multiple.'*@_'.$field.')';
$insertfields .= $field . ', ';
$insertvalues .= '@_' . $field . ':=(SELECT ' . $calculation['formula'] . '), ';
$updates .= $field . '=@_' . $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.') '.
'ON DUPLICATE KEY UPDATE '.$updates.'points='.$updatepoints.'+bonus';
$query = 'INSERT INTO ^userpoints (' . $insertfields . 'points) VALUES (' . $insertvalues . $insertpoints . ') ' .
'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
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())
qa_db_userpointscount_update();
......
......@@ -190,7 +190,7 @@ if (qa_clicked('docancel')) {
$errors['slug'] = qa_lang_sub('main/max_length_x', QA_DB_MAX_CAT_PAGE_TAGS_LENGTH);
elseif (preg_match('/[\\+\\/]/', $inslug))
$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');
elseif (isset($matchcategoryid) && strcmp($matchcategoryid, @$editcategory['categoryid']))
$errors['slug'] = qa_lang('admin/category_already_used');
......
......@@ -1300,7 +1300,7 @@ foreach ($showoptions as $optionname) {
foreach ($searchmodules as $modulename => $module) {
$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>';
}
}
......
......@@ -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
$buttons['delete'] = array(
'tags' => 'name="admin_' . qa_html($qhiddenpostid[$key]) . '_delete" onclick="return qa_admin_click(this);"',
......
......@@ -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);
$positionoptions[$nav . (isset($previous) ? (1 + $maxposition) : 1)] = $positionvalue;
}
......
......@@ -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
if ((!$explicitqa) && $countslugs && !isset($categoryid)) {
if (!$explicitqa && $countslugs && !isset($categoryid)) {
$pagemodules = qa_load_modules_with('page', 'match_request');
$request = qa_request();
......@@ -110,7 +110,7 @@ if ((!$explicitqa) && $countslugs && !isset($categoryid)) {
// 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_content = qa_content_prepare();
$qa_content['title'] = qa_html(qa_opt('custom_home_heading'));
......
......@@ -98,7 +98,7 @@ if ($question['closeable']) {
else
$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';
}
......@@ -220,7 +220,7 @@ foreach ($commentsfollows as $commentid => $comment) {
$formtype = 'c_edit';
$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';
$formpostid = $commentid;
}
......
......@@ -468,7 +468,7 @@ function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptch
$testwords = implode(' ', qa_string_to_words($in['content']));
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) {
$errors['content'] = qa_lang_html('question/duplicate_content');
break;
......
......@@ -198,10 +198,10 @@ if (qa_is_http_post() || strlen($pagestate))
$formrequested = isset($formtype);
if ((!$formrequested) && $question['answerbutton']) {
if (!$formrequested && $question['answerbutton']) {
$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
}
......@@ -275,7 +275,7 @@ if ($formtype == 'a_edit') {
$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);
if ($formrequested) {
......@@ -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);
$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,
$captchareason, @$cnewin[$questionid], @$cnewerrors[$questionid], $formtype == 'c_add');
if (($formtype == 'c_add') && ($formpostid == $questionid)) {
if ($formtype == 'c_add' && $formpostid == $questionid) {
$jumptoanchor = 'c' . $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],
@$ceditin[$formpostid], @$cediterrors[$formpostid]);
......@@ -470,8 +470,3 @@ if (
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
}
}
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);
$unsubscribed = true;
}
......
......@@ -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
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';
$userid = $useraccount['userid'];
......@@ -435,7 +435,7 @@ if (!QA_FINAL_EXTERNAL_USERS) {
if (qa_using_categories()) {
$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(
'^1' => '<a href="' . qa_path_html(qa_request(), array('state' => 'edit', 'catleveladd' => 1)) . '">',
'^2' => '</a>',
......
......@@ -1843,7 +1843,7 @@ function qa_suspend_event_reports($suspend = true)
* @param array $params
* @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); }
......
......@@ -40,7 +40,7 @@ if (!function_exists('qa_install_db_fail_handler')) {
* @param string $error
* @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;
......
......@@ -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
// 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:
// search() outputs <div class="qa-search">, q_list() outputs <div class="qa-q-list">, etc...
// 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,
// 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...
public function doctype()
{
......
......@@ -127,7 +127,7 @@ function qa_image_constrain(&$width, &$height, $maxwidth, $maxheight = null)
if (!isset($maxheight))
$maxheight = $maxwidth;
if (($width > $maxwidth) || ($height > $maxheight)) {
if ($width > $maxwidth || $height > $maxheight) {
$multiplier = min($maxwidth / $width, $maxheight / $height);
$width = floor($width * $multiplier);
$height = floor($height * $multiplier);
......
......@@ -52,7 +52,7 @@ class qa_facebook_login
public function facebook_html($tourl, $logout, $context)
{
if (($context == 'login') || ($context == 'register'))
if ($context == 'login' || $context == 'register')
$size = 'large';
else
$size = 'medium';
......
......@@ -173,7 +173,7 @@ class qa_xml_sitemap
// 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;
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