summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/AbuseFilter/includes/TableDiffFormatterFullContext.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/AbuseFilter/includes/TableDiffFormatterFullContext.php')
-rw-r--r--www/wiki/extensions/AbuseFilter/includes/TableDiffFormatterFullContext.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/www/wiki/extensions/AbuseFilter/includes/TableDiffFormatterFullContext.php b/www/wiki/extensions/AbuseFilter/includes/TableDiffFormatterFullContext.php
new file mode 100644
index 00000000..f88b953f
--- /dev/null
+++ b/www/wiki/extensions/AbuseFilter/includes/TableDiffFormatterFullContext.php
@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * Like TableDiffFormatter, but will always render the full context
+ * (even for empty diffs).
+ *
+ * @private
+ */
+class TableDiffFormatterFullContext extends TableDiffFormatter {
+ /**
+ * Format a diff.
+ *
+ * @param Diff $diff
+ * @return string The formatted output.
+ */
+ function format( $diff ) {
+ $xlen = $ylen = 0;
+
+ // Calculate the length of the left and the right side
+ foreach ( $diff->edits as $edit ) {
+ if ( $edit->orig ) {
+ $xlen += count( $edit->orig );
+ }
+ if ( $edit->closing ) {
+ $ylen += count( $edit->closing );
+ }
+ }
+
+ // Just render the diff with no preprocessing
+ $this->startDiff();
+ $this->block( 1, $xlen, 1, $ylen, $diff->edits );
+ $end = $this->endDiff();
+
+ return $end;
+ }
+}