Commit 9d871fbb by Scott

Minor refactoring of number formatting code

Also changed function qa_private_translate_with_progress to
qa_recalc_progress_lang
parent 2fe81055
......@@ -2071,11 +2071,13 @@
$suffixes = array('', qa_lang_html('main/_thousands_suffix'), qa_lang_html('main/_millions_suffix'));
$suffix = isset($suffixes[$floorBase]) ? $suffixes[$floorBase] : '';
}
// If the decimal part is 0 then remove it
if ($number == (int) $number) {
$decimals = 0;
}
} else {
}
else {
$decimals = 0;
}
......
......@@ -338,7 +338,7 @@
'show_a_c_links' => 1,
'show_a_form_immediate' => 'if_no_as',
'show_c_reply_buttons' => 1,
'show_compact_numbers' => 0,
'show_compact_numbers' => 1,
'show_custom_welcome' => 0,
'show_post_update_meta' => 1,
'show_fewer_cs_count' => 5,
......
......@@ -611,14 +611,16 @@
/**
* Return the translated language ID string replacing the progress and total in it
* Return the translated language ID string replacing the progress and total in it.
* @access private
* @param string $langId Language string ID that contains 2 placeholders (^1 and ^2)
* @param int $progress Amount of processed elements
* @param int $total Total amount of elements
*
* @return string Returns the language string ID with their placeholders replaced with
* the formatted progress and total numbers
*/
function qa_private_translate_with_progress($langId, $progress, $total)
function qa_recalc_progress_lang($langId, $progress, $total)
{
return strtr(qa_lang($langId), array(
'^1' => qa_format_number($progress),
......@@ -648,11 +650,11 @@
break;
case 'doreindexcontent_pagereindex':
$message = qa_private_translate_with_progress('admin/reindex_pages_reindexed', $done, $length);
$message = qa_recalc_progress_lang('admin/reindex_pages_reindexed', $done, $length);
break;
case 'doreindexcontent_postreindex':
$message = qa_private_translate_with_progress('admin/reindex_posts_reindexed', $done, $length);
$message = qa_recalc_progress_lang('admin/reindex_posts_reindexed', $done, $length);
break;
case 'doreindexposts_complete':
......@@ -660,15 +662,15 @@
break;
case 'doreindexposts_wordcount':
$message = qa_private_translate_with_progress('admin/reindex_posts_wordcounted', $done, $length);
$message = qa_recalc_progress_lang('admin/reindex_posts_wordcounted', $done, $length);
break;
case 'dorecountposts_votecount':
$message = qa_private_translate_with_progress('admin/recount_posts_votes_recounted', $done, $length);
$message = qa_recalc_progress_lang('admin/recount_posts_votes_recounted', $done, $length);
break;
case 'dorecountposts_acount':
$message = qa_private_translate_with_progress('admin/recount_posts_as_recounted', $done, $length);
$message = qa_recalc_progress_lang('admin/recount_posts_as_recounted', $done, $length);
break;
case 'dorecountposts_complete':
......@@ -680,7 +682,7 @@
break;
case 'dorecalcpoints_recalc':
$message = qa_private_translate_with_progress('admin/recalc_points_recalced', $done, $length);
$message = qa_recalc_progress_lang('admin/recalc_points_recalced', $done, $length);
break;
case 'dorecalcpoints_complete':
......@@ -688,7 +690,7 @@
break;
case 'dorefillevents_refill':
$message = qa_private_translate_with_progress('admin/refill_events_refilled', $done, $length);
$message = qa_recalc_progress_lang('admin/refill_events_refilled', $done, $length);
break;
case 'dorefillevents_complete':
......@@ -696,15 +698,15 @@
break;
case 'dorecalccategories_postupdate':
$message = qa_private_translate_with_progress('admin/recalc_categories_updated', $done, $length);
$message = qa_recalc_progress_lang('admin/recalc_categories_updated', $done, $length);
break;
case 'dorecalccategories_recount':
$message = qa_private_translate_with_progress('admin/recalc_categories_recounting', $done, $length);
$message = qa_recalc_progress_lang('admin/recalc_categories_recounting', $done, $length);
break;
case 'dorecalccategories_backpaths':
$message = qa_private_translate_with_progress('admin/recalc_categories_backpaths', $done, $length);
$message = qa_recalc_progress_lang('admin/recalc_categories_backpaths', $done, $length);
break;
case 'dorecalccategories_complete':
......@@ -712,15 +714,15 @@
break;
case 'dodeletehidden_comments':
$message = qa_private_translate_with_progress('admin/hidden_comments_deleted', $done, $length);
$message = qa_recalc_progress_lang('admin/hidden_comments_deleted', $done, $length);
break;
case 'dodeletehidden_answers':
$message = qa_private_translate_with_progress('admin/hidden_answers_deleted', $done, $length);
$message = qa_recalc_progress_lang('admin/hidden_answers_deleted', $done, $length);
break;
case 'dodeletehidden_questions':
$message = qa_private_translate_with_progress('admin/hidden_questions_deleted', $done, $length);
$message = qa_recalc_progress_lang('admin/hidden_questions_deleted', $done, $length);
break;
case 'dodeletehidden_complete':
......@@ -729,7 +731,7 @@
case 'doblobstodisk_move':
case 'doblobstodb_move':
$message = qa_private_translate_with_progress('admin/blobs_move_moved', $done, $length);
$message = qa_recalc_progress_lang('admin/blobs_move_moved', $done, $length);
break;
case 'doblobstodisk_complete':
......
......@@ -33,11 +33,12 @@
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
$minphp = trim(ini_get('upload_max_filesize'));
$mindb = 16777215; // from MEDIUMBLOB column type
$minphp = trim(ini_get('upload_max_filesize'));
$minphp = convert_to_bytes(substr($minphp, -1), $minphp);
return min(16777215, $minphp); // 16777215 from MEDIUMBLOB column type
return min($mindb, $minphp);
}
......
......@@ -227,7 +227,7 @@
'show_a_form_immediate' => 'Show answer form immediately:',
'show_always' => 'Always',
'show_c_reply_buttons' => 'Show reply button on comments:',
'show_compact_numbers' => 'Show compact numbers (e.g., 1.3k):',
'show_compact_numbers' => 'Show compact numbers (e.g. 1.3k):',
'show_custom_answer' => 'Custom message on answer form - HTML allowed:',
'show_custom_ask' => 'Custom message on ask form - HTML allowed:',
'show_custom_comment' => 'Custom message on comment form - HTML allowed:',
......
......@@ -371,27 +371,37 @@
case 'viewing':
$subtitle = 'admin/viewing_title';
$showoptions = array('q_urls_title_length', 'q_urls_remove_accents', 'do_count_q_views', 'show_view_counts', 'show_view_count_q_page', '', 'voting_on_qs', 'voting_on_q_page_only', 'voting_on_as', 'votes_separated', '', 'show_url_links', 'links_in_new_window', 'show_when_created', 'show_full_date_days');
$showoptions = array(
'q_urls_title_length', 'q_urls_remove_accents', 'do_count_q_views', 'show_view_counts', 'show_view_count_q_page', '',
'voting_on_qs', 'voting_on_q_page_only', 'voting_on_as', 'votes_separated', '',
'show_url_links', 'links_in_new_window', 'show_when_created', 'show_full_date_days'
);
if (count(qa_get_points_to_titles()))
if (count(qa_get_points_to_titles())) {
$showoptions[] = 'show_user_titles';
}
array_push($showoptions, 'show_user_points', 'show_post_update_meta', '', 'sort_answers_by', 'show_selected_first', 'page_size_q_as', 'show_a_form_immediate');
array_push($showoptions,
'show_user_points', 'show_post_update_meta', 'show_compact_numbers', '',
'sort_answers_by', 'show_selected_first', 'page_size_q_as', 'show_a_form_immediate'
);
if (qa_opt('comment_on_qs') || qa_opt('comment_on_as'))
if (qa_opt('comment_on_qs') || qa_opt('comment_on_as')) {
array_push($showoptions, 'show_fewer_cs_from', 'show_fewer_cs_count', 'show_c_reply_buttons');
}
$showoptions[] = '';
$widgets = qa_db_single_select(qa_db_widgets_selectspec());
foreach ($widgets as $widget)
foreach ($widgets as $widget) {
if ($widget['title'] == 'Related Questions') {
array_push($showoptions, 'match_related_qs', 'page_size_related_qs', '');
break;
}
}
array_push($showoptions, 'pages_prev_next', '', 'show_compact_numbers');
$showoptions[] = 'pages_prev_next';
$formstyle = 'wide';
......
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