echo "<input type='hidden' name='frame' value='update'>"; echo "<input type='hidden' name='pm' value='" . attr_safe($pm) . "'>"; echo "<input type='hidden' name='timeCutoff' value='{$timeCutoff}'>"; $projectsNeedingAttention = 0; // loop through the projects foreach ($projects as $projectid => $projectdata) { list($projectname, $projectstate) = $projectdata; $goodFileObject = get_project_word_file($projectid, "good"); // set the timeCutoff if ($timeCutoff == -1) { $timeCutoffActual = $goodFileObject->mod_time; } else { $timeCutoffActual = $timeCutoff; } // load suggestions since cutoff $suggestions = load_project_good_word_suggestions($projectid, $timeCutoffActual); // if there are no suggestions since the cutoff, skip it if (!count($suggestions)) { continue; } // get the data list($suggestions_w_freq, $suggestions_w_occurrences, $messages) = _get_word_list($projectid, $suggestions); // if no words are returned (probably because something was // suggested but is no longer in the text) skip this project if (count($suggestions_w_freq) == 0) { continue; } $projectsNeedingAttention++; echo "<hr>"; echo "<h3>{$projectname}</h3>"; echo "<p><b>" . _("State:") . "</b> {$projectstate}</p>";
function _get_word_list($projectid, $timeCutoff) { $messages = array(); // load the suggestions $suggestions = load_project_good_word_suggestions($projectid, $timeCutoff); if (!is_array($suggestions)) { $messages[] = sprintf(_("Unable to load suggestions: %s"), $suggestions); return array(array(), array(), array(), array(), array(), array(), $messages); } if (count($suggestions) == 0) { return array(array(), array(), array(), array(), array(), array(), $messages); } // load project good words $project_good_words = load_project_good_words($projectid); // load project bad words $project_bad_words = load_project_bad_words($projectid); // get the latest project text of all pages up to last possible round $last_possible_round = get_Round_for_round_number(MAX_NUM_PAGE_EDITING_ROUNDS); $pages_res = page_info_query($projectid, $last_possible_round->id, 'LE'); $all_words_w_freq = get_distinct_words_in_text(get_page_texts($pages_res)); // array to hold all words $all_suggestions = array(); $round_page_count = array(); // parse the suggestions complex array // it is in the format: $suggestions[$round][$pagenum]=$wordsArray foreach ($suggestions as $round => $pageArray) { $round_suggestions = array(); foreach ($pageArray as $page => $words) { // add the words to the per-round array $round_suggestions = array_merge($round_suggestions, $words); // add the words to the combined array too $all_suggestions = array_merge($all_suggestions, $words); @$round_page_count[$round]++; } // remove any words already on the project's good or bad words lists $round_suggestions = array_diff($round_suggestions, array_merge($project_good_words, $project_bad_words)); // get the suggestion occurrences $round_suggestions_w_occurrences[$round] = generate_frequencies($round_suggestions); // get suggestion with project word frequency $round_suggestions_w_freq[$round] = array_intersect_key($all_words_w_freq, array_flip($round_suggestions)); // multisort screws up all-numeric words so we need to preprocess first prep_numeric_keys_for_multisort($round_suggestions_w_freq[$round]); // sort the list by frequency, then by word array_multisort(array_values($round_suggestions_w_freq[$round]), SORT_DESC, array_map('strtolower', array_keys($round_suggestions_w_freq[$round])), SORT_ASC, $round_suggestions_w_freq[$round]); } // now, remove any words that are already on the project's good or bad words lists $all_suggestions = array_diff($all_suggestions, array_merge($project_good_words, $project_bad_words)); // get the number of suggestion occurrences $all_suggestions_w_occurrences = generate_frequencies($all_suggestions); // $all_suggestions doesn't have frequency info, // so start with the info in $all_words_w_freq, // and extract the items where the key matches a key in $all_suggestions. $all_suggestions_w_freq = array_intersect_key($all_words_w_freq, array_flip($all_suggestions)); // multisort screws up all-numeric words so we need to preprocess first prep_numeric_keys_for_multisort($all_suggestions_w_freq); // sort the list by frequency, then by word array_multisort(array_values($all_suggestions_w_freq), SORT_DESC, array_map('strtolower', array_keys($all_suggestions_w_freq)), SORT_ASC, $all_suggestions_w_freq); // get a list of all rounds $rounds = array_keys($round_suggestions_w_freq); return array($all_suggestions_w_freq, $all_suggestions_w_occurrences, $round_suggestions_w_freq, $round_suggestions_w_occurrences, $rounds, $round_page_count, $messages); }
function show_visible_controls() { $goodWordData = html_safe($this->good_words); $badWordData = html_safe($this->bad_words); $fields = array("projectid" => _("Project ID"), "nameofwork" => _("Name of Work"), "authorsname" => _("Author's Name"), "projectmanager" => _("Project Manager"), "checkedoutby" => _("Post-Processor"), "language" => _("Language")); foreach ($fields as $field => $label) { echo "<tr>"; echo "<td class='label'>{$label}</td>"; echo "<td>" . $this->{$field} . "</td>"; echo "</tr>"; } $exist_OCR_pages = $this->number_of_pages_in_round(null) > 0; $exist_pages_in_P1_or_later = $this->number_of_pages_in_round(get_Round_for_round_number(1)) > 0; // due to some special circumstances, not all projects may have pages in P1 // so we'll check to see if the project is in a state after P1 and count // that as just as good if (!$exist_pages_in_P1_or_later) { $current_project_round = get_Round_for_project_state($this->state); if ($current_project_round && $current_project_round->round_number > 1) { $exist_pages_in_P1_or_later = true; } } // if the project doesn't have any OCR pages and the project // has no P1 or later pages, report a message. The second criteria // is important for type-in projects that may have no OCR pages but // will have P1 or later pages if (!$exist_OCR_pages && !$exist_pages_in_P1_or_later) { echo "<tr>"; echo "<td colspan='2'>"; echo "<p class='error' style='text-align: center;'>"; echo _("There are no pages associated with this project."); echo "</p>"; echo "</td>"; echo "</tr>"; } else { echo "<tr>"; echo "<td class='label' style='text-align: center;' colspan='2'>"; echo _("WordCheck Tools and Reports"); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td class='label'>" . _("Ad Hoc Word Details") . "</td>"; echo "<td>" . new_window_link("show_adhoc_word_details.php?projectid={$this->projectid}", _("Show details for ad hoc words")) . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td class='label'>" . _("WordCheck Statistics") . "</td>"; echo "<td>" . new_window_link("show_project_wordcheck_stats.php?projectid={$this->projectid}", _("Show WordCheck flagged word statistics")) . "</td>"; echo "</tr>"; if ($exist_pages_in_P1_or_later) { echo "<tr>"; echo "<td class='label'>" . _("WordCheck Usage") . "</td>"; echo "<td>" . new_window_link("show_project_wordcheck_usage.php?projectid={$this->projectid}", _("Show WordCheck interface usage")) . "</td>"; echo "</tr>"; } echo "<tr>"; echo "<td class='label' style='text-align: center;' colspan='2'>"; echo _("Word List Suggestion Tools"); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='2'>"; echo "<table width='100%'>"; echo "<tr>"; echo "<td style='width: 50%; text-align: center;' valign='top'>"; echo "<p>"; echo "<b>" . _("Words that WordCheck would currently flag:") . "</b><br>"; echo new_window_link("show_current_flagged_words.php?projectid={$this->projectid}", _("Display")); echo " | "; echo "<a href='show_current_flagged_words.php?projectid={$this->projectid}&format=file'>" . _("Download") . "</a>"; echo "</p>"; $suggestions = load_project_good_word_suggestions($this->projectid); if (count($suggestions)) { echo "<p>"; echo "<b>" . _("Suggestions from proofreaders:") . "</b><br>"; echo new_window_link("show_good_word_suggestions.php?projectid={$this->projectid}", _("Display")); echo " | "; echo "<a href='show_good_word_suggestions.php?projectid={$this->projectid}&timeCutoff=0&format=file'>" . _("Download") . "</a>"; echo "</p>"; } echo "</td>"; echo "<td style='width: 50%; text-align: center;' valign='top'>"; // see if the site has Possible Bad Word files $possible_bad_words = load_site_possible_bad_words_given_project($this->projectid); if (count($possible_bad_words)) { echo "<p>"; echo "<b>" . _("Words in the Site's Possible bad words file:") . "</b><br>"; echo new_window_link("show_project_possible_bad_words.php?projectid={$this->projectid}", _("Display")); echo " | "; echo "<a href='show_project_possible_bad_words.php?projectid={$this->projectid}&format=file'>" . _("Download") . "</a>"; echo "</p>"; } // see if there are P1 (or later) and OCR pages before showing the link. // type-in projects may have P1 (or later) pages but no OCR pages // and the current show_project_stealth_scannos.php page only works // with projects that have OCR text if ($exist_pages_in_P1_or_later && $exist_OCR_pages) { echo "<p>"; echo "<b>" . _("Suggestions from diff analysis:") . "</b><br>"; echo new_window_link("show_project_stealth_scannos.php?projectid={$this->projectid}", _("Display")); echo " | "; echo "<a href='show_project_stealth_scannos.php?projectid={$this->projectid}&format=file'>" . _("Download") . "</a>"; echo "</p>"; } echo "</td>"; echo "</tr>"; echo "</table>"; echo "</td>"; echo "</tr>"; } echo "<tr>"; echo "<td class='label' style='text-align: center;' colspan='2'>"; echo _("Project Dictionary - Word Lists"); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='2'>"; echo "<table width='100%'>"; echo "<tr>"; echo "<td class='label' style='text-align: center;'>" . _("Good Words") . "</td>"; echo "<td class='label' style='text-align: center;'>" . _("Bad Words") . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td style='width: 50%;'>"; echo "<textarea class='mono' name='good_words' cols='40' rows='20'>{$goodWordData}</textarea>"; echo "</td>"; echo "<td style='width: 50%;'>"; echo "<textarea class='mono' name='bad_words' cols='40' rows='20'>{$badWordData}</textarea>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='2' style='text-align: center;'>"; echo sprintf(_("See the %s for more information on word lists."), new_window_link("../../faq/wordcheck-faq.php", _("WordCheck FAQ"))); echo "</td>"; echo "</tr>"; }