diff --git a/pinc/ProjectTransition.inc b/pinc/ProjectTransition.inc
index c9b6c9571..a292938b3 100644
--- a/pinc/ProjectTransition.inc
+++ b/pinc/ProjectTransition.inc
@@ -1227,7 +1227,7 @@ function proj_would_go_to_PP_out(Project $project, ProjectTransition $transition
function round_to_PP_avail_collateral(Project $old_project, Project $project, ProjectTransition $transition, string $who): void
{
$from_round = get_Round_for_project_state($transition->from_state);
- generate_post_files($project, $from_round->id, 'LE', false, '');
+ generate_post_files($project, $from_round, 'LE', false, '');
// Always notify the PM
configure_gettext_for_user($project->username);
@@ -1285,7 +1285,7 @@ function to_PP_available_collateral(Project $old_project, Project $project, Proj
function round_to_PP_out_collateral(Project $old_project, Project $project, ProjectTransition $transition, string $who): void
{
$from_round = get_Round_for_project_state($transition->from_state);
- generate_post_files($project, $from_round->id, 'LE', false, '');
+ generate_post_files($project, $from_round, 'LE', false, '');
// The project has been checked out to someone for PPing.
// We want to notify the PPer and the PM,
diff --git a/pinc/post_files.inc b/pinc/post_files.inc
index e9ccf4361..a3fe8fc99 100644
--- a/pinc/post_files.inc
+++ b/pinc/post_files.inc
@@ -8,7 +8,7 @@ include_once($relPath.'wordcheck_engine.inc');
*/
function generate_post_files(
Project $project,
- string $limit_round_id,
+ Round|stdclass $limit_round,
string $which_text,
bool $include_proofers,
string $base_extra
@@ -41,7 +41,7 @@ function generate_post_files(
}
}
- $pages_res = page_info_query($project->projectid, $limit_round_id, $which_text);
+ $pages_res = page_info_query($project, $limit_round, $which_text);
// Join all the page texts into a plain text file...
$plain_path = "{$pathbase}.txt";
@@ -67,7 +67,7 @@ function generate_post_files(
*/
function generate_interim_file(
Project $project,
- string $limit_round_id,
+ Round|stdclass $limit_round,
string $which_text,
bool $include_proofers
): void {
@@ -75,19 +75,14 @@ function generate_interim_file(
throw new Exception(_("Project table not found, it may have been deleted or archived."));
}
- $filename = $project->projectid;
- if ('[OCR]' == $limit_round_id) {
- $filename .= '_OCR';
+ $filename = $project->projectid . '_' . $limit_round->id;
+ if ('EQ' == $which_text) {
+ $filename .= '_saved';
} else {
- $filename .= '_' . $limit_round_id;
- if ('EQ' == $which_text) {
- $filename .= '_saved';
- } else {
- $filename .= '_latest';
- }
+ $filename .= '_latest';
}
- $pages_res = page_info_query($project->projectid, $limit_round_id, $which_text);
+ $pages_res = page_info_query($project, $limit_round, $which_text);
// join the page texts together
$filedata = join_proofed_text($pages_res, $include_proofers, null);
@@ -221,18 +216,13 @@ function join_proofed_text(mysqli_result $pages_res, bool $include_proofers, $fp
// -----------------------------------------------------------------------------
-function page_info_query(string $projectid, string $limit_round_id, string $which_text): mysqli_result
+function page_info_query(Project $project, Round|stdclass $limit_round, string $which_text): mysqli_result
{
- if ($limit_round_id == '[OCR]') { // somewhat kludgey
+ if ($limit_round->id == 'OCR') {
// doesn't matter what $which_text is.
- $text_column_expr = 'master_text';
+ $text_column_expr = $limit_round->text_column_name;
$user_fields = "";
} else {
- $limit_round = get_Round_for_round_id($limit_round_id);
- if (is_null($limit_round)) {
- throw new UnexpectedValueException("'$limit_round_id' is not a valid round-id\n");
- }
-
if ($which_text == 'EQ') {
// For each page, fetch the text (if any) saved in the selected round.
$text_column_expr = $limit_round->text_column_name;
@@ -284,12 +274,12 @@ function page_info_query(string $projectid, string $limit_round_id, string $whic
$res = DPDatabase::query("
SELECT $text_column_expr, image $user_fields
- FROM $projectid
+ FROM $project->projectid
ORDER BY image
", throw_on_failure: false);
if (!$res) {
- throw new Exception("Could not get $limit_round_id text for $projectid");
+ throw new Exception("Could not get {$limit_round->id} text for {$project->projectid}");
}
/** @var mysqli_result $res -- mysqli_query("SELECT") never returns true */
diff --git a/pinc/project_quick_check.inc b/pinc/project_quick_check.inc
index f3a789f03..6df95a049 100644
--- a/pinc/project_quick_check.inc
+++ b/pinc/project_quick_check.inc
@@ -475,7 +475,7 @@ function _test_project_for_bad_bytes(string $projectid): PQCResult
return new PQCResult($name, $description, $status, $summary, $details);
}
- $pages_res = page_info_query($projectid, 'F2', 'LE');
+ $pages_res = page_info_query($project, Rounds::get_by_id('F2'), 'LE');
$page_details_url = "$code_url/tools/project_manager/page_detail.php?project=$projectid";
$details_for_this_project = "
diff --git a/project.php b/project.php
index 7863c0834..3fb0e072e 100644
--- a/project.php
+++ b/project.php
@@ -1533,7 +1533,7 @@ function do_post_files(): void
echo "\n";
if (isset($highest_round_id)) {
- echo "[OCR] \n";
+ echo "OCR \n";
foreach (Rounds::get_all() as $round) {
$checked = ($round->id == $highest_round_id ? 'CHECKED' : '');
echo "$round->id \n";
@@ -1542,7 +1542,7 @@ function do_post_files(): void
}
}
} else {
- echo "[OCR] \n";
+ echo "OCR \n";
}
echo "
";
diff --git a/tools/project_manager/generate_post_files.php b/tools/project_manager/generate_post_files.php
index 5cbbaf670..40331f2c5 100644
--- a/tools/project_manager/generate_post_files.php
+++ b/tools/project_manager/generate_post_files.php
@@ -5,14 +5,11 @@
include_once($relPath.'slim_header.inc');
include_once($relPath.'post_files.inc');
-$valid_round_ids = Rounds::get_ids();
-array_unshift($valid_round_ids, '[OCR]');
-
$projectid = get_projectID_param($_REQUEST, 'projectid');
-$round_id = get_enumerated_param($_REQUEST, 'round_id', null, $valid_round_ids);
+$round = get_round_or_ocr_param($_REQUEST, 'round_id');
$which_text = get_enumerated_param($_REQUEST, 'which_text', null, ['EQ', 'LE']);
-$include_proofers = get_integer_param($_REQUEST, 'include_proofers', 0, 0, 1);
-$save_files = get_integer_param($_REQUEST, 'save_files', 0, 0, 1);
+$include_proofers = get_bool_param($_REQUEST, 'include_proofers', false);
+$save_files = get_bool_param($_REQUEST, 'save_files', false);
$errors = [];
@@ -45,10 +42,10 @@
try {
if ($save_files) {
flush();
- generate_post_files($project, $round_id, $which_text, (bool) $include_proofers, '');
+ generate_post_files($project, $round, $which_text, $include_proofers, '');
echo "
" . _("Done.") . "
"; } else { - generate_interim_file($project, $round_id, $which_text, (bool) $include_proofers); + generate_interim_file($project, $round, $which_text, $include_proofers); } } catch (Exception $exception) { $errors[] = $exception->getMessage(); @@ -66,7 +63,7 @@ function output_page_header(Project $project): void { - global $round_id, $which_text, $include_proofers, $save_files; + global $round, $which_text, $include_proofers, $save_files; // Allow this function to be called multiple times but only output // the contents once. @@ -82,9 +79,9 @@ function output_page_header(Project $project): void echo "" . sprintf(_("Generating files for '%s'."), html_safe($project->nameofwork)) . "
"; echo "";
echo "projectid = $project->projectid\n";
- echo "round_id = $round_id\n";
+ echo "round_id = $round->id\n";
echo "which_text = $which_text\n";
- echo "include_proofers = $include_proofers\n";
- echo "save_files = $save_files\n";
+ echo "include_proofers = " . ($include_proofers ? 1 : 0) . "\n";
+ echo "save_files = " . ($save_files ? 1 : 0) . "\n";
echo "";
}
diff --git a/tools/project_manager/show_adhoc_word_details.php b/tools/project_manager/show_adhoc_word_details.php
index e27eb091c..de9c3fa64 100644
--- a/tools/project_manager/show_adhoc_word_details.php
+++ b/tools/project_manager/show_adhoc_word_details.php
@@ -159,7 +159,7 @@ function _get_adhoc_word_list(string $projectid, array $queryWords): array
$messages = [];
// get the latest project text of all pages up to last possible round
- $pages_res = page_info_query($projectid, Rounds::get_last()->id, 'LE');
+ $pages_res = page_info_query(new Project($projectid), Rounds::get_last(), 'LE');
$page_texts = get_page_texts($pages_res);
// now run it through WordCheck
diff --git a/tools/project_manager/show_all_good_word_suggestions.php b/tools/project_manager/show_all_good_word_suggestions.php
index b2fc1c7ca..2d9f9b5c2 100644
--- a/tools/project_manager/show_all_good_word_suggestions.php
+++ b/tools/project_manager/show_all_good_word_suggestions.php
@@ -225,7 +225,7 @@ function _get_all_suggestions_word_list(string $projectid, int $time_cutoff): ar
}
// get the latest project text of all pages up to last possible round
- $pages_res = page_info_query($projectid, Rounds::get_last()->id, 'LE');
+ $pages_res = page_info_query(new Project($projectid), Rounds::get_last(), 'LE');
$all_words_w_freq = get_distinct_words_in_text(get_page_texts($pages_res));
// get the number of suggestion occurrences
diff --git a/tools/project_manager/show_current_flagged_words.php b/tools/project_manager/show_current_flagged_words.php
index 2a692f1bf..2869577c2 100644
--- a/tools/project_manager/show_current_flagged_words.php
+++ b/tools/project_manager/show_current_flagged_words.php
@@ -140,7 +140,7 @@
function _get_current_flagged_word_list(string $projectid): array
{
// get the latest project text of all pages up to last possible round
- $pages_res = page_info_query($projectid, Rounds::get_last()->id, 'LE');
+ $pages_res = page_info_query(new Project($projectid), Rounds::get_last(), 'LE');
$page_texts = get_page_texts($pages_res);
// now run it through WordCheck
diff --git a/tools/project_manager/show_good_word_suggestions.php b/tools/project_manager/show_good_word_suggestions.php
index f9912f8d6..5f1eb6b20 100644
--- a/tools/project_manager/show_good_word_suggestions.php
+++ b/tools/project_manager/show_good_word_suggestions.php
@@ -266,7 +266,7 @@ function _get_suggestions_word_list(string $projectid, int $timeCutoff): array
$project_bad_words = load_project_bad_words($projectid);
// get the latest project text of all pages up to last possible round
- $pages_res = page_info_query($projectid, Rounds::get_last()->id, 'LE');
+ $pages_res = page_info_query(new Project($projectid), Rounds::get_last(), 'LE');
$all_words_w_freq = get_distinct_words_in_text(get_page_texts($pages_res));
// array to hold all words
diff --git a/tools/project_manager/show_project_possible_bad_words.php b/tools/project_manager/show_project_possible_bad_words.php
index 24f74c182..f9abfbcf2 100644
--- a/tools/project_manager/show_project_possible_bad_words.php
+++ b/tools/project_manager/show_project_possible_bad_words.php
@@ -126,7 +126,7 @@ function _get_possible_bad_word_list(string $projectid): array
$messages = [];
// get the latest project text of all pages up to last possible round
- $pages_res = page_info_query($projectid, Rounds::get_last()->id, 'LE');
+ $pages_res = page_info_query(new Project($projectid), Rounds::get_last(), 'LE');
$all_words_w_freq = get_distinct_words_in_text(get_page_texts($pages_res));
// load site word lists for project languages
diff --git a/tools/project_manager/show_project_stealth_scannos.php b/tools/project_manager/show_project_stealth_scannos.php
index 2061658ce..4d3e7d971 100644
--- a/tools/project_manager/show_project_stealth_scannos.php
+++ b/tools/project_manager/show_project_stealth_scannos.php
@@ -183,7 +183,7 @@ function _get_stealth_scanno_word_list(string $projectid): array
// instead of just the OCR round, edit_project_word_lists.php should
// be updated to allow this page to be accessed for those type-in
// projects with no OCR text.
- $pages_res = page_info_query($projectid, '[OCR]', 'LE');
+ $pages_res = page_info_query(new Project($projectid), get_OCR_pseudoround(), 'LE');
$all_page_text = get_page_texts($pages_res);
// remove any formatting tags and add a final \r\n to each page-text
// to ensure that there is whitespace between pages so they don't run together
@@ -193,7 +193,7 @@ function _get_stealth_scanno_word_list(string $projectid): array
}
// get the latest project text of all pages up to last possible round
- $pages_res = page_info_query($projectid, Rounds::get_last()->id, 'LE');
+ $pages_res = page_info_query(new Project($projectid), Rounds::get_last(), 'LE');
$all_page_text = get_page_texts($pages_res);
// remove any formatting tags and add a final \r\n to each page-text
// to ensure that there is whitespace between pages so they don't run together
diff --git a/tools/project_manager/show_project_wordcheck_stats.php b/tools/project_manager/show_project_wordcheck_stats.php
index 3ade44c85..59dd061f9 100644
--- a/tools/project_manager/show_project_wordcheck_stats.php
+++ b/tools/project_manager/show_project_wordcheck_stats.php
@@ -24,7 +24,7 @@
// load bad words for the site for this project
$site_bad_words = load_site_bad_words_given_project($projectid);
-$pages_res = page_info_query($projectid, Rounds::get_last()->id, 'LE');
+$pages_res = page_info_query($project, Rounds::get_last(), 'LE');
// get the entire text
$page_texts = get_page_texts($pages_res);
@@ -57,7 +57,7 @@
// now run it again except we're going to count the words per page
// this time through
-$pages_res = page_info_query($projectid, Rounds::get_last()->id, 'LE');
+$pages_res = page_info_query($project, Rounds::get_last(), 'LE');
$page_stats = [];
// iterate through all the pages gathering stats
while (($row = page_info_fetch($pages_res)) !== false) {
diff --git a/tools/project_manager/show_word_context.php b/tools/project_manager/show_word_context.php
index 345729648..a59bfebf1 100644
--- a/tools/project_manager/show_word_context.php
+++ b/tools/project_manager/show_word_context.php
@@ -12,16 +12,16 @@
set_time_limit(0); // no time limit
-$projectid = get_projectID_param($_GET, 'projectid');
+$project = new Project(get_projectID_param($_GET, 'projectid'));
$encWord = @$_GET["word"];
$word = rtrim(decode_word($encWord));
-enforce_edit_authorization($projectid);
+enforce_edit_authorization($project->projectid);
$wordInstances = get_integer_param($_GET, 'wordInstances', 20, 0, MAX_WORD_INSTANCES);
$details = json_encode([
- "projectid" => $projectid,
+ "projectid" => $project->projectid,
'storageKey' => 'show_word_context',
], JSON_THROW_ON_ERROR);
@@ -38,13 +38,13 @@
echo "