Commit deb08e2d by Scott

Coding style (various Code_Sniffer suggestions)

parent 03b45775
...@@ -196,4 +196,3 @@ ...@@ -196,4 +196,3 @@
And lastly... if you want to, you can predefine any constant from qa-db-maxima.php in this And lastly... if you want to, you can predefine any constant from qa-db-maxima.php in this
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!
*/ */
...@@ -45,7 +45,7 @@ class Q2A_Util_Metadata ...@@ -45,7 +45,7 @@ class Q2A_Util_Metadata
* @param string $url URL linking to a metadata.json file * @param string $url URL linking to a metadata.json file
* @return array The metadata fetched from the file * @return array The metadata fetched from the file
*/ */
public function fetchFromUrl($url, $type='Plugin') public function fetchFromUrl($url, $type = 'Plugin')
{ {
$contents = qa_retrieve_url($url); $contents = qa_retrieve_url($url);
$metadata = $this->getArrayFromJson($contents); $metadata = $this->getArrayFromJson($contents);
......
...@@ -107,6 +107,8 @@ class Q2A_Util_Usage ...@@ -107,6 +107,8 @@ class Q2A_Util_Usage
public function output() public function output()
{ {
$totaldelta = $this->delta($this->startUsage, $this->getCurrent()); $totaldelta = $this->delta($this->startUsage, $this->getCurrent());
$stages = $this->stages;
$stages['total'] = $totaldelta;
?> ?>
<style> <style>
.debug-table { border-collapse: collapse; width: auto; margin: 20px auto; } .debug-table { border-collapse: collapse; width: auto; margin: 20px auto; }
...@@ -153,31 +155,23 @@ class Q2A_Util_Usage ...@@ -153,31 +155,23 @@ class Q2A_Util_Usage
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php foreach ($stages as $stage => $stagedelta) : ?>
<?php <tr>
$stages = $this->stages; <td class="row-heading"><?php echo ucfirst($stage); ?></td>
$stages['total'] = $totaldelta; <td><?php echo sprintf('%.1f', $stagedelta['clock'] * 1000); ?></td>
<td><?php echo sprintf('%d%%', $stagedelta['clock'] * 100 / $totaldelta['clock']); ?></td>
foreach ($stages as $stage => $stagedelta): <td><?php echo sprintf('%.1f', $stagedelta['cpu'] * 1000); ?></td>
?> <td><?php echo sprintf('%d%%', $stagedelta['cpu'] * 100 / $totaldelta['clock']); ?></td>
<tr> <td><?php echo $stagedelta['files']; ?></td>
<td class="row-heading"><?php echo ucfirst($stage); ?></td> <td><?php echo sprintf('%.1f', $stagedelta['mysql'] * 1000); ?></td>
<td><?php echo sprintf('%.1f', $stagedelta['clock'] * 1000); ?></td> <td><?php echo sprintf('%d%%', $stagedelta['mysql'] * 100 / $totaldelta['clock']); ?></td>
<td><?php echo sprintf('%d%%', $stagedelta['clock'] * 100 / $totaldelta['clock']); ?></td> <td><?php echo $stagedelta['queries']; ?></td>
<td><?php echo sprintf('%.1f', $stagedelta['cpu'] * 1000); ?></td> <td><?php echo sprintf('%.1f', $stagedelta['other'] * 1000); ?></td>
<td><?php echo sprintf('%d%%', $stagedelta['cpu'] * 100 / $totaldelta['clock']); ?></td> <td><?php echo sprintf('%d%%', $stagedelta['other'] * 100 / $totaldelta['clock']); ?></td>
<td><?php echo $stagedelta['files']; ?></td> <td><?php echo sprintf('%dk', $stagedelta['ram'] / 1024); ?></td>
<td><?php echo sprintf('%.1f', $stagedelta['mysql'] * 1000); ?></td> <td><?php echo sprintf('%d%%', $stagedelta['ram'] ? ($stagedelta['ram'] * 100 / $totaldelta['ram']) : 0); ?></td>
<td><?php echo sprintf('%d%%', $stagedelta['mysql'] * 100 / $totaldelta['clock']); ?></td> </tr>
<td><?php echo $stagedelta['queries']; ?></td> <?php endforeach; ?>
<td><?php echo sprintf('%.1f', $stagedelta['other'] * 1000); ?></td>
<td><?php echo sprintf('%d%%', $stagedelta['other'] * 100 / $totaldelta['clock']); ?></td>
<td><?php echo sprintf('%dk', $stagedelta['ram'] / 1024); ?></td>
<td><?php echo sprintf('%d%%', $stagedelta['ram'] ? ($stagedelta['ram'] * 100 / $totaldelta['ram']) : 0); ?></td>
</tr>
<?php
endforeach;
?>
</tbody> </tbody>
</table> </table>
...@@ -215,5 +209,4 @@ class Q2A_Util_Usage ...@@ -215,5 +209,4 @@ class Q2A_Util_Usage
return $delta; return $delta;
} }
} }
...@@ -80,10 +80,11 @@ if (@$question['basetype'] == 'Q' && !isset($question['closedbyid']) && !qa_user ...@@ -80,10 +80,11 @@ if (@$question['basetype'] == 'Q' && !isset($question['closedbyid']) && !qa_user
$countanswers = $question['acount'] + 1; $countanswers = $question['acount'] + 1;
if ($countanswers == 1) if ($countanswers == 1) {
echo qa_lang_html('question/1_answer_title') . "\n"; echo qa_lang_html('question/1_answer_title') . "\n";
else } else {
echo qa_lang_html_sub('question/x_answers_title', $countanswers) . "\n"; echo qa_lang_html_sub('question/x_answers_title', $countanswers) . "\n";
}
// Send back the HTML // Send back the HTML
......
...@@ -1788,11 +1788,13 @@ function qa_set_up_category_field(&$qa_content, &$field, $fieldname, $navcategor ...@@ -1788,11 +1788,13 @@ function qa_set_up_category_field(&$qa_content, &$field, $fieldname, $navcategor
} else { } else {
$haschildren = false; $haschildren = false;
foreach ($navcategories as $navcategory) // check if it has any children foreach ($navcategories as $navcategory) {
// check if it has any children
if (!strcmp($navcategory['parentid'], $categoryid)) { if (!strcmp($navcategory['parentid'], $categoryid)) {
$haschildren = true; $haschildren = true;
break; break;
} }
}
if (!$haschildren) if (!$haschildren)
$keycategoryids[$categoryid] = true; // show this category if it has no children $keycategoryids[$categoryid] = true; // show this category if it has no children
...@@ -2004,13 +2006,14 @@ function qa_load_theme_class($theme, $template, $content, $request) ...@@ -2004,13 +2006,14 @@ function qa_load_theme_class($theme, $template, $content, $request)
'QA_HTML_THEME_LAYER_URLTOROOT' => "'" . qa_path_to_root() . $layer['urltoroot'] . "'", 'QA_HTML_THEME_LAYER_URLTOROOT' => "'" . qa_path_to_root() . $layer['urltoroot'] . "'",
); );
foreach ($searchwordreplace as $searchword => $replace) foreach ($searchwordreplace as $searchword => $replace) {
if (preg_match_all('/\W(' . preg_quote($searchword, '/') . ')\W/im', $layerphp, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE)) { if (preg_match_all('/\W(' . preg_quote($searchword, '/') . ')\W/im', $layerphp, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE)) {
$searchmatches = array_reverse($matches[1]); // don't use preg_replace due to complication of escaping replacement phrase $searchmatches = array_reverse($matches[1]); // don't use preg_replace due to complication of escaping replacement phrase
foreach ($searchmatches as $searchmatch) foreach ($searchmatches as $searchmatch)
$layerphp = substr_replace($layerphp, $replace, $searchmatch[1], strlen($searchmatch[0])); $layerphp = substr_replace($layerphp, $replace, $searchmatch[1], strlen($searchmatch[0]));
} }
}
// echo '<pre style="text-align:left;">'.htmlspecialchars($layerphp).'</pre>'; // to debug munged code // echo '<pre style="text-align:left;">'.htmlspecialchars($layerphp).'</pre>'; // to debug munged code
......
...@@ -268,23 +268,24 @@ function qa_output_content($qa_content) ...@@ -268,23 +268,24 @@ function qa_output_content($qa_content)
// Slide down notifications // Slide down notifications
if (!empty($qa_content['notices'])) if (!empty($qa_content['notices'])) {
foreach ($qa_content['notices'] as $notice) { foreach ($qa_content['notices'] as $notice) {
$qa_content['script_onloads'][] = array( $qa_content['script_onloads'][] = array(
"qa_reveal(document.getElementById(" . qa_js($notice['id']) . "), 'notice');", "qa_reveal(document.getElementById(" . qa_js($notice['id']) . "), 'notice');",
); );
} }
}
// Handle maintenance mode // Handle maintenance mode
if (qa_opt('site_maintenance') && ($requestlower != 'login')) { if (qa_opt('site_maintenance') && ($requestlower != 'login')) {
if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) { if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) {
if (!isset($qa_content['error'])) if (!isset($qa_content['error'])) {
$qa_content['error'] = strtr(qa_lang_html('admin/maintenance_admin_only'), array( $qa_content['error'] = strtr(qa_lang_html('admin/maintenance_admin_only'), array(
'^1' => '<a href="' . qa_path_html('admin/general') . '">', '^1' => '<a href="' . qa_path_html('admin/general') . '">',
'^2' => '</a>', '^2' => '</a>',
)); ));
}
} else { } else {
$qa_content = qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['error'] = qa_lang_html('misc/site_in_maintenance'); $qa_content['error'] = qa_lang_html('misc/site_in_maintenance');
...@@ -319,15 +320,18 @@ function qa_output_content($qa_content) ...@@ -319,15 +320,18 @@ function qa_output_content($qa_content)
$script = array('<script>'); $script = array('<script>');
if (isset($qa_content['script_var'])) if (isset($qa_content['script_var'])) {
foreach ($qa_content['script_var'] as $var => $value) foreach ($qa_content['script_var'] as $var => $value) {
$script[] = 'var ' . $var . ' = ' . qa_js($value) . ';'; $script[] = 'var ' . $var . ' = ' . qa_js($value) . ';';
}
}
if (isset($qa_content['script_lines'])) if (isset($qa_content['script_lines'])) {
foreach ($qa_content['script_lines'] as $scriptlines) { foreach ($qa_content['script_lines'] as $scriptlines) {
$script[] = ''; $script[] = '';
$script = array_merge($script, $scriptlines); $script = array_merge($script, $scriptlines);
} }
}
$script[] = '</script>'; $script[] = '</script>';
...@@ -739,11 +743,12 @@ function qa_content_prepare($voting = false, $categoryids = null) ...@@ -739,11 +743,12 @@ function qa_content_prepare($voting = false, $categoryids = null)
'label' => qa_lang_html('main/nav_updates'), 'label' => qa_lang_html('main/nav_updates'),
); );
if (!empty($userlinks['logout'])) if (!empty($userlinks['logout'])) {
$qa_content['navigation']['user']['logout'] = array( $qa_content['navigation']['user']['logout'] = array(
'url' => qa_html(@$userlinks['logout']), 'url' => qa_html(@$userlinks['logout']),
'label' => qa_lang_html('main/nav_logout'), 'label' => qa_lang_html('main/nav_logout'),
); );
}
if (!QA_FINAL_EXTERNAL_USERS) { if (!QA_FINAL_EXTERNAL_USERS) {
$source = qa_get_logged_in_source(); $source = qa_get_logged_in_source();
...@@ -751,12 +756,13 @@ function qa_content_prepare($voting = false, $categoryids = null) ...@@ -751,12 +756,13 @@ function qa_content_prepare($voting = false, $categoryids = null)
if (strlen($source)) { if (strlen($source)) {
$loginmodules = qa_load_modules_with('login', 'match_source'); $loginmodules = qa_load_modules_with('login', 'match_source');
foreach ($loginmodules as $module) foreach ($loginmodules as $module) {
if ($module->match_source($source) && method_exists($module, 'logout_html')) { if ($module->match_source($source) && method_exists($module, 'logout_html')) {
ob_start(); ob_start();
$module->logout_html(qa_path('logout', array(), qa_opt('site_url'))); $module->logout_html(qa_path('logout', array(), qa_opt('site_url')));
$qa_content['navigation']['user']['logout'] = array('label' => ob_get_clean()); $qa_content['navigation']['user']['logout'] = array('label' => ob_get_clean());
} }
}
} }
} }
......
...@@ -35,7 +35,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -35,7 +35,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
* @param bool $viewincrement * @param bool $viewincrement
* @return mixed * @return mixed
*/ */
function qa_db_hotness_update($firstpostid, $lastpostid=null, $viewincrement=false) function qa_db_hotness_update($firstpostid, $lastpostid = null, $viewincrement = false)
{ {
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); }
......
...@@ -641,13 +641,14 @@ function qa_db_check_tables() ...@@ -641,13 +641,14 @@ function qa_db_check_tables()
$datacount = 0; $datacount = 0;
$datamissing = 0; $datamissing = 0;
foreach ($definitions as $rawname => $definition) foreach ($definitions as $rawname => $definition) {
if (qa_db_add_table_prefix($rawname) == (QA_MYSQL_TABLE_PREFIX . $rawname)) { if (qa_db_add_table_prefix($rawname) == (QA_MYSQL_TABLE_PREFIX . $rawname)) {
$datacount++; $datacount++;
if (isset($missing[$rawname])) if (isset($missing[$rawname]))
$datamissing++; $datamissing++;
} }
}
if ($datacount == $datamissing && $datamissing == count($missing)) if ($datacount == $datamissing && $datamissing == count($missing))
return 'non-users-missing'; return 'non-users-missing';
...@@ -1548,7 +1549,7 @@ function qa_db_upgrade_tables() ...@@ -1548,7 +1549,7 @@ function qa_db_upgrade_tables()
// Perform any necessary recalculations, as determined by upgrade steps // Perform any necessary recalculations, as determined by upgrade steps
foreach ($keyrecalc as $state => $dummy) foreach ($keyrecalc as $state => $dummy) {
while ($state) { while ($state) {
set_time_limit(60); set_time_limit(60);
...@@ -1559,6 +1560,7 @@ function qa_db_upgrade_tables() ...@@ -1559,6 +1560,7 @@ function qa_db_upgrade_tables()
qa_db_upgrade_progress(qa_recalc_get_message($state)); qa_db_upgrade_progress(qa_recalc_get_message($state));
} }
}
} }
......
...@@ -168,7 +168,7 @@ else { ...@@ -168,7 +168,7 @@ else {
qa_logged_in_user_flush(); qa_logged_in_user_flush();
} }
} else if (qa_clicked('dosaveprofile') && $pending_confirmation) { } elseif (qa_clicked('dosaveprofile') && $pending_confirmation) {
// only allow user to update email if they are not confirmed yet // only allow user to update email if they are not confirmed yet
$inemail = qa_post_text('email'); $inemail = qa_post_text('email');
......
...@@ -274,7 +274,7 @@ $qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION; ...@@ -274,7 +274,7 @@ $qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
$qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning'); $qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning');
$qa_content['script_onloads'][] = array( $qa_content['script_onloads'][] = array(
"qa_version_check('https://raw.githubusercontent.com/q2a/question2answer/master/VERSION.txt', " . qa_js(qa_html(QA_VERSION), true) . ", 'q2a-version', true);" "qa_version_check('https://raw.githubusercontent.com/q2a/question2answer/master/VERSION.txt', " . qa_js(qa_html(QA_VERSION), true) . ", 'q2a-version', true);"
); );
$qa_content['navigation']['sub'] = qa_admin_sub_navigation(); $qa_content['navigation']['sub'] = qa_admin_sub_navigation();
......
...@@ -36,7 +36,7 @@ function qa_page_q_load_as($question, $childposts) ...@@ -36,7 +36,7 @@ function qa_page_q_load_as($question, $childposts)
{ {
$answers = array(); $answers = array();
foreach ($childposts as $postid => $post) foreach ($childposts as $postid => $post) {
switch ($post['type']) { switch ($post['type']) {
case 'A': case 'A':
case 'A_HIDDEN': case 'A_HIDDEN':
...@@ -44,6 +44,7 @@ function qa_page_q_load_as($question, $childposts) ...@@ -44,6 +44,7 @@ function qa_page_q_load_as($question, $childposts)
$answers[$postid] = $post; $answers[$postid] = $post;
break; break;
} }
}
return $answers; return $answers;
} }
......
...@@ -153,7 +153,7 @@ if (strlen($emailHandle) > 0) { ...@@ -153,7 +153,7 @@ if (strlen($emailHandle) > 0) {
// User input wrong code so show field with error // User input wrong code so show field with error
$fields['code']['error'] = qa_lang('users/email_code_wrong'); $fields['code']['error'] = qa_lang('users/email_code_wrong');
} }
} else if (qa_clicked('donext')) { } elseif (qa_clicked('donext')) {
// If user submitted the form with an empty code // If user submitted the form with an empty code
$fields['code']['error'] = qa_lang('users/email_code_wrong'); $fields['code']['error'] = qa_lang('users/email_code_wrong');
} }
......
...@@ -157,7 +157,7 @@ class qa_filter_basic ...@@ -157,7 +157,7 @@ class qa_filter_basic
if ($length < $minlength) { if ($length < $minlength) {
$errors[$errorKey] = $minlength == 1 ? qa_lang('main/field_required') : qa_lang_sub('main/min_length_x', $minlength); $errors[$errorKey] = $minlength == 1 ? qa_lang('main/field_required') : qa_lang_sub('main/min_length_x', $minlength);
} else if (isset($maxlength) && ($length > $maxlength)) { } elseif (isset($maxlength) && ($length > $maxlength)) {
$errors[$errorKey] = qa_lang_sub('main/max_length_x', $maxlength); $errors[$errorKey] = qa_lang_sub('main/max_length_x', $maxlength);
} }
} }
......
...@@ -219,7 +219,8 @@ function qa_initialize_constants_1() ...@@ -219,7 +219,8 @@ function qa_initialize_constants_1()
} else { } else {
$res = $str1 ^ $str2; $res = $str1 ^ $str2;
$ret = 0; $ret = 0;
for ($i = strlen($res) - 1; $i >= 0; $i--) $ret |= ord($res[$i]); for ($i = strlen($res) - 1; $i >= 0; $i--)
$ret |= ord($res[$i]);
return !$ret; return !$ret;
} }
} }
......
...@@ -53,10 +53,11 @@ function get_phrase_substitutions($phrase) ...@@ -53,10 +53,11 @@ function get_phrase_substitutions($phrase)
{ {
$substitutions = array(); $substitutions = array();
if (preg_match_all('/\^(([0-9]+)|([a-z_]+)|)/', $phrase, $matches)) if (preg_match_all('/\^(([0-9]+)|([a-z_]+)|)/', $phrase, $matches)) {
foreach ($matches[0] as $match) { foreach ($matches[0] as $match) {
@$substitutions[$match]++; @$substitutions[$match]++;
} }
}
return $substitutions; return $substitutions;
} }
...@@ -125,23 +126,26 @@ output_finish_includes(); ...@@ -125,23 +126,26 @@ output_finish_includes();
foreach ($definite as $key => $valuecount) { foreach ($definite as $key => $valuecount) {
foreach ($valuecount as $value => $count) { foreach ($valuecount as $value => $count) {
if (!@$defined[$key][$value]) if (!@$defined[$key][$value]) {
output_lang_issue($key, $value, 'used by ' . $count . ' file/s but not defined'); output_lang_issue($key, $value, 'used by ' . $count . ' file/s but not defined');
}
} }
} }
foreach ($defined as $key => $valuecount) { foreach ($defined as $key => $valuecount) {
foreach ($valuecount as $value => $count) { foreach ($valuecount as $value => $count) {
if (!@$definite[$key][$value] && !@$probable[$key][$value] && !@$possible[$value]) if (!@$definite[$key][$value] && !@$probable[$key][$value] && !@$possible[$value]) {
output_lang_issue($key, $value, 'defined but apparently not used'); output_lang_issue($key, $value, 'defined but apparently not used');
}
} }
} }
foreach ($backmap as $phrase => $where) { foreach ($backmap as $phrase => $where) {
if (count($where) > 1) if (count($where) > 1) {
foreach ($where as $onewhere) { foreach ($where as $onewhere) {
output_lang_issue($onewhere['prefix'], $onewhere['key'], 'contains the shared phrase "' . $phrase . '"', false); output_lang_issue($onewhere['prefix'], $onewhere['key'], 'contains the shared phrase "' . $phrase . '"', false);
} }
}
} }
require_once QA_INCLUDE_DIR . 'app/admin.php'; require_once QA_INCLUDE_DIR . 'app/admin.php';
...@@ -179,19 +183,20 @@ foreach ($languages as $code => $language) { ...@@ -179,19 +183,20 @@ foreach ($languages as $code => $language) {
foreach ($langdefined as $key => $valuecount) { foreach ($langdefined as $key => $valuecount) {
foreach ($valuecount as $value => $count) { foreach ($valuecount as $value => $count) {
if (!@$defined[$key][$value]) if (!@$defined[$key][$value]) {
output_lang_issue($key, $value, 'defined but not in US English files'); output_lang_issue($key, $value, 'defined but not in US English files');
elseif (!$langdifferent[$key][$value]) } elseif (!$langdifferent[$key][$value]) {
output_lang_issue($key, $value, 'identical to US English files', false); output_lang_issue($key, $value, 'identical to US English files', false);
else } else {
foreach ($substitutions[$key][$value] as $substitution => $subcount) { foreach ($substitutions[$key][$value] as $substitution => $subcount) {
if (!@$langsubstitutions[$key][$value][$substitution]) if (!@$langsubstitutions[$key][$value][$substitution])
output_lang_issue($key, $value, 'omitted the substitution ' . $substitution); output_lang_issue($key, $value, 'omitted the substitution ' . $substitution);
elseif ($subcount > @$langsubstitutions[$key][$value][$substitution]) elseif ($subcount > @$langsubstitutions[$key][$value][$substitution])
output_lang_issue($key, $value, 'has fewer of the substitution ' . $substitution); output_lang_issue($key, $value, 'has fewer of the substitution ' . $substitution);
} }
}
} }
} }
...@@ -202,15 +207,17 @@ foreach ($languages as $code => $language) { ...@@ -202,15 +207,17 @@ foreach ($languages as $code => $language) {
if (count($langdefined[$key]) < (count($valuecount) / 2)) { // only a few phrases defined if (count($langdefined[$key]) < (count($valuecount) / 2)) { // only a few phrases defined
output_lang_issue($key, null, 'few translations provided so will use US English defaults', $showaserror); output_lang_issue($key, null, 'few translations provided so will use US English defaults', $showaserror);
} else } else {
foreach ($valuecount as $value => $count) { foreach ($valuecount as $value => $count) {
if (!@$langdefined[$key][$value]) { if (!@$langdefined[$key][$value]) {
output_lang_issue($key, $value, 'undefined so will use US English defaults', $showaserror); output_lang_issue($key, $value, 'undefined so will use US English defaults', $showaserror);
$langnewphrases[$key][$value] = $english[$key][$value]; $langnewphrases[$key][$value] = $english[$key][$value];
} }
} }
} else }
} else {
output_lang_issue($key, null, 'no translations provided so will use US English defaults', $showaserror); output_lang_issue($key, null, 'no translations provided so will use US English defaults', $showaserror);
}
} }
foreach ($langnewphrases as $prefix => $phrases) { foreach ($langnewphrases as $prefix => $phrases) {
......
...@@ -223,7 +223,7 @@ if (qa_db_connection(false) !== null && !@$pass_failure_from_install) { ...@@ -223,7 +223,7 @@ if (qa_db_connection(false) !== null && !@$pass_failure_from_install) {
$errorhtml .= "\n\nWhen you click below, your Question2Answer site will be set up to integrate with the users of your WordPress site <a href=\"".qa_html(get_option('home'))."\" target=\"_blank\">".qa_html(get_option('blogname'))."</a>. Please consult the online documentation for more information."; $errorhtml .= "\n\nWhen you click below, your Question2Answer site will be set up to integrate with the users of your WordPress site <a href=\"".qa_html(get_option('home'))."\" target=\"_blank\">".qa_html(get_option('blogname'))."</a>. Please consult the online documentation for more information.";
} }
elseif (defined('QA_FINAL_JOOMLA_INTEGRATE_PATH')) { elseif (defined('QA_FINAL_JOOMLA_INTEGRATE_PATH')) {
$jconfig = new JConfig(); $jconfig = new JConfig();
$errorhtml .= "\n\nWhen you click below, your Question2Answer site will be set up to integrate with the users of your Joomla! site <a href=\"../\" target=\"_blank\">".$jconfig->sitename."</a>. It's also recommended to install the Joomla QAIntegration plugin for additional user-access control. Please consult the online documentation for more information."; $errorhtml .= "\n\nWhen you click below, your Question2Answer site will be set up to integrate with the users of your Joomla! site <a href=\"../\" target=\"_blank\">".$jconfig->sitename."</a>. It's also recommended to install the Joomla QAIntegration plugin for additional user-access control. Please consult the online documentation for more information.";
} }
else { else {
......
...@@ -78,11 +78,11 @@ function qa_get_logged_in_user() ...@@ -78,11 +78,11 @@ function qa_get_logged_in_user()
'level' => $level, 'level' => $level,
); );
if ($user->block) { if ($user->block) {
$qa_user['blocked'] = true; $qa_user['blocked'] = true;
} }
return $qa_user; return $qa_user;
} }
return null; return null;
......
...@@ -773,7 +773,7 @@ function qa_strtolower($string) ...@@ -773,7 +773,7 @@ function qa_strtolower($string)
* @param int $length * @param int $length
* @return mixed|string * @return mixed|string
*/ */
function qa_substr($string, $start, $length=2147483647) function qa_substr($string, $start, $length = 2147483647)
{ {
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); }
......
...@@ -139,7 +139,7 @@ class qa_recaptcha_captcha ...@@ -139,7 +139,7 @@ class qa_recaptcha_captcha
if (ini_get('allow_url_fopen')) if (ini_get('allow_url_fopen'))
$recaptcha = new ReCaptcha(qa_opt('recaptcha_private_key')); $recaptcha = new ReCaptcha(qa_opt('recaptcha_private_key'));
else else
$recaptcha = new ReCaptcha(qa_opt('recaptcha_private_key') , new ReCaptchaSocketPostRequestMethod()); $recaptcha = new ReCaptcha(qa_opt('recaptcha_private_key'), new ReCaptchaSocketPostRequestMethod());
$remoteIp = qa_remote_ip_address(); $remoteIp = qa_remote_ip_address();
$userResponse = qa_post_text('g-recaptcha-response'); $userResponse = qa_post_text('g-recaptcha-response');
......
...@@ -16,16 +16,16 @@ class AppFormatTest extends PHPUnit_Framework_TestCase ...@@ -16,16 +16,16 @@ class AppFormatTest extends PHPUnit_Framework_TestCase
$qa_phrases_full['main']['_decimal_point'] = '.'; $qa_phrases_full['main']['_decimal_point'] = '.';
$qa_phrases_full['main']['_thousands_separator'] = ','; $qa_phrases_full['main']['_thousands_separator'] = ',';
$this->assertSame('5.5', qa_format_number(5.452, 1)); $this->assertSame('5.5', qa_format_number(5.452, 1));
$this->assertSame('5', qa_format_number(5.452, 0)); $this->assertSame('5', qa_format_number(5.452, 0));
$this->assertSame('5', qa_format_number(4.5, 0)); $this->assertSame('5', qa_format_number(4.5, 0));
$this->assertSame('9,123', qa_format_number(9123, 0)); $this->assertSame('9,123', qa_format_number(9123, 0));
$this->assertSame('9,123.0', qa_format_number(9123, 1)); $this->assertSame('9,123.0', qa_format_number(9123, 1));
// not shortened unless 'show_compact_numbers' is true // not shortened unless 'show_compact_numbers' is true
$this->assertSame('5.0', qa_format_number(5, 1, true)); $this->assertSame('5.0', qa_format_number(5, 1, true));
$this->assertSame('5.5', qa_format_number(5.452, 1, true)); $this->assertSame('5.5', qa_format_number(5.452, 1, true));
$this->assertSame('5', qa_format_number(5.452, 0, true)); $this->assertSame('5', qa_format_number(5.452, 0, true));
$this->assertSame('9,123', qa_format_number(9123, 0, true)); $this->assertSame('9,123', qa_format_number(9123, 0, true));
$this->assertSame('123,456,789', qa_format_number(123456789, 0, true)); $this->assertSame('123,456,789', qa_format_number(123456789, 0, true));
...@@ -33,9 +33,9 @@ class AppFormatTest extends PHPUnit_Framework_TestCase ...@@ -33,9 +33,9 @@ class AppFormatTest extends PHPUnit_Framework_TestCase
$qa_phrases_full['main']['_decimal_point'] = ','; $qa_phrases_full['main']['_decimal_point'] = ',';
$qa_phrases_full['main']['_thousands_separator'] = '.'; $qa_phrases_full['main']['_thousands_separator'] = '.';
$this->assertSame('5,5', qa_format_number(5.452, 1)); $this->assertSame('5,5', qa_format_number(5.452, 1));
$this->assertSame('5', qa_format_number(5.452, 0)); $this->assertSame('5', qa_format_number(5.452, 0));
$this->assertSame('9.123', qa_format_number(9123, 0)); $this->assertSame('9.123', qa_format_number(9123, 0));
$this->assertSame('9.123,0', qa_format_number(9123, 1)); $this->assertSame('9.123,0', qa_format_number(9123, 1));
} }
...@@ -56,22 +56,22 @@ class AppFormatTest extends PHPUnit_Framework_TestCase ...@@ -56,22 +56,22 @@ class AppFormatTest extends PHPUnit_Framework_TestCase
// $decimal parameter ignored when 'show_compact_numbers' is true // $decimal parameter ignored when 'show_compact_numbers' is true
$this->assertSame('5.5', qa_format_number(5.452, 0, true)); $this->assertSame('5.5', qa_format_number(5.452, 0, true));
$this->assertSame('5.5', qa_format_number(5.452, 1, true)); $this->assertSame('5.5', qa_format_number(5.452, 1, true));
$this->assertSame('5', qa_format_number(5, 1, true)); $this->assertSame('5', qa_format_number(5, 1, true));
$this->assertSame('9.1k', qa_format_number(9123, 0, true)); $this->assertSame('9.1k', qa_format_number(9123, 0, true));
$this->assertSame('9.1k', qa_format_number(9123, 1, true)); $this->assertSame('9.1k', qa_format_number(9123, 1, true));
$this->assertSame('9k', qa_format_number(9040, 0, true)); $this->assertSame('9k', qa_format_number(9040, 0, true));
$this->assertSame('9k', qa_format_number(9040, 1, true)); $this->assertSame('9k', qa_format_number(9040, 1, true));
$this->assertSame('9.1k', qa_format_number(9050, 0, true)); $this->assertSame('9.1k', qa_format_number(9050, 0, true));
$this->assertSame('123m', qa_format_number(123456789, 0, true)); $this->assertSame('123m', qa_format_number(123456789, 0, true));
$this->assertSame('23.5m', qa_format_number(23456789, 1, true)); $this->assertSame('23.5m', qa_format_number(23456789, 1, true));
$this->assertSame('123m', qa_format_number(123456789, 1, true)); $this->assertSame('123m', qa_format_number(123456789, 1, true));
$this->assertSame('235m', qa_format_number(234567891, 1, true)); $this->assertSame('235m', qa_format_number(234567891, 1, true));
$this->assertSame('1,223m', qa_format_number(1223456789, 0, true)); $this->assertSame('1,223m', qa_format_number(1223456789, 0, true));
$this->assertSame('9,000', qa_format_number(9000, 0, false)); $this->assertSame('9,000', qa_format_number(9000, 0, false));
$this->assertSame('912.3', qa_format_number(912.3, 1, false)); $this->assertSame('912.3', qa_format_number(912.3, 1, false));
$this->assertSame('123,456,789', qa_format_number(123456789, 0, false)); $this->assertSame('123,456,789', qa_format_number(123456789, 0, false));
// change separators and compact suffixes // change separators and compact suffixes
......
...@@ -7,25 +7,25 @@ class BaseTest extends PHPUnit_Framework_TestCase ...@@ -7,25 +7,25 @@ class BaseTest extends PHPUnit_Framework_TestCase
$this->assertSame("'test'", qa_js('test')); $this->assertSame("'test'", qa_js('test'));
$this->assertSame("'test'", qa_js('test', true)); $this->assertSame("'test'", qa_js('test', true));
$this->assertSame(123, qa_js(123)); $this->assertSame(123, qa_js(123));
$this->assertSame("'123'", qa_js(123, true)); $this->assertSame("'123'", qa_js(123, true));
$this->assertSame('true', qa_js(true)); $this->assertSame('true', qa_js(true));
$this->assertSame("'true'", qa_js(true, true)); $this->assertSame("'true'", qa_js(true, true));
} }
public function test__convert_to_bytes() public function test__convert_to_bytes()
{ {
$this->assertSame( 102400, convert_to_bytes('k', 100)); $this->assertSame(102400, convert_to_bytes('k', 100));
$this->assertSame( 104857600, convert_to_bytes('m', 100)); $this->assertSame(104857600, convert_to_bytes('m', 100));
$this->assertSame(107374182400, convert_to_bytes('g', 100)); $this->assertSame(107374182400, convert_to_bytes('g', 100));
$this->assertSame( 102400, convert_to_bytes('K', 100)); $this->assertSame(102400, convert_to_bytes('K', 100));
$this->assertSame( 104857600, convert_to_bytes('M', 100)); $this->assertSame(104857600, convert_to_bytes('M', 100));
$this->assertSame(107374182400, convert_to_bytes('G', 100)); $this->assertSame(107374182400, convert_to_bytes('G', 100));
$this->assertSame( 100, convert_to_bytes('', 100)); $this->assertSame(100, convert_to_bytes('', 100));
$this->assertSame( 1048576, convert_to_bytes('k', 1024)); $this->assertSame(1048576, convert_to_bytes('k', 1024));
} }
public function test__qa_q_request() public function test__qa_q_request()
......
...@@ -411,7 +411,10 @@ class qa_html_theme extends qa_html_theme_base ...@@ -411,7 +411,10 @@ class qa_html_theme extends qa_html_theme_base
* @since Snow 1.4 * @since Snow 1.4
* @param type $q_item * @param type $q_item
*/ */
public function view_count($q_item) {} public function view_count($q_item)
{
// do nothing
}
/** /**
* Add view counter to question view * Add view counter to question view
......
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