diff --git a/tools/project_manager/diff.php b/tools/project_manager/diff.php index 2587f2c5ab..3dd7b25386 100644 --- a/tools/project_manager/diff.php +++ b/tools/project_manager/diff.php @@ -171,6 +171,42 @@ function copyToClip(textstring) { echo $navigation_text; } +// Load an associative array for which pages in the project have diffs. +function load_page_diff_array(Project $project, $L_round, $R_round, bool $include_no_format = false): array +{ + if ($include_no_format) { + $un_formatter = new PageUnformatter(); + $text_columns = " + $L_round->text_column_name as L_text, + $R_round->text_column_name as R_text, + "; + } else { + $text_columns = ""; + } + $sql = " + SELECT image, + $L_round->user_column_name as username, + $text_columns + CAST($L_round->text_column_name AS BINARY) = CAST($R_round->text_column_name AS BINARY) AS is_same + FROM $project->projectid + ORDER BY image ASC + "; + $res = DPDatabase::query($sql); + $result = []; + while ($row = mysqli_fetch_assoc($res)) { + $result[$row["image"]] = [ + "username" => $row["username"], + "is_diff" => ! $row["is_same"], + ]; + if ($include_no_format) { + $L_text = $un_formatter->remove_formatting($row["L_text"], false); + $R_text = $un_formatter->remove_formatting($row["R_text"], false); + $result[$row["image"]]["is_diff_without_formatting"] = $L_text != $R_text; + } + } + return $result; +} + /** * Build up the text for the navigation bit, so we can repeat it * again at the bottom of the page @@ -199,27 +235,24 @@ function get_navigation( } $navigation_text .= "\n" . _("Jump to") . ":