From 6b24b2ce77acb234a067b5f3b4fe8be736082b3e Mon Sep 17 00:00:00 2001 From: Casey Peel Date: Tue, 20 Feb 2024 06:31:37 +0000 Subject: [PATCH] Link "skip empty diffs" with "without formatting" When users are comparing diffs without formatting they expect "skip empty diffs" to skip pages that only differ by formatting. This links the two together so that it behaves the way that expect. --- tools/project_manager/diff.php | 57 +++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 12 deletions(-) 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") . ":