Changeset 8866 for trunk/wp-includes/wp-diff.php
- Timestamp:
- 09/11/2008 05:46:42 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/wp-diff.php
r8581 r8866 1 1 <?php 2 /** 3 * WordPress Diff bastard child of old MediaWiki Diff Formatter. 4 * 5 * Basically all that remains is the table structure and some method names. 6 * 7 * @package WordPress 8 * @subpackage Diff 9 */ 2 10 3 11 if ( !class_exists( 'Text_Diff' ) ) { 12 /** Text_Diff class */ 4 13 require( dirname(__FILE__).'/Text/Diff.php' ); 14 /** Text_Diff_Renderer class */ 5 15 require( dirname(__FILE__).'/Text/Diff/Renderer.php' ); 16 /** Text_Diff_Renderer_inline class */ 6 17 require( dirname(__FILE__).'/Text/Diff/Renderer/inline.php' ); 7 18 } 8 19 9 10 /* Descendent of a bastard child of piece of an old MediaWiki Diff Formatter 20 /** 21 * Table renderer to display the diff lines. 11 22 * 12 * Basically all that remains is the table structure and some method names. 23 * @since 2.6.0 24 * @uses Text_Diff_Renderer Extends 13 25 */ 14 15 26 class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { 27 28 /** 29 * @see Text_Diff_Renderer::_leading_context_lines 30 * @var int 31 * @access protected 32 * @since 2.6.0 33 */ 16 34 var $_leading_context_lines = 10000; 35 36 /** 37 * @see Text_Diff_Renderer::_trailing_context_lines 38 * @var int 39 * @access protected 40 * @since 2.6.0 41 */ 17 42 var $_trailing_context_lines = 10000; 43 44 /** 45 * {@internal Missing Description}} 46 * 47 * @var float 48 * @access protected 49 * @since 2.6.0 50 */ 18 51 var $_diff_threshold = 0.6; 19 52 53 /** 54 * Inline display helper object name. 55 * 56 * @var string 57 * @access protected 58 * @since 2.6.0 59 */ 20 60 var $inline_diff_renderer = 'WP_Text_Diff_Renderer_inline'; 21 61 62 /** 63 * PHP4 Constructor - Call parent constructor with params array. 64 * 65 * This will set class properties based on the key value pairs in the array. 66 * 67 * @since unknown 68 * 69 * @param array $params 70 */ 22 71 function Text_Diff_Renderer_Table( $params = array() ) { 23 72 $parent = get_parent_class($this); … … 25 74 } 26 75 76 /** 77 * @ignore 78 * 79 * @param string $header 80 * @return string 81 */ 27 82 function _startBlock( $header ) { 28 83 return ''; 29 84 } 30 85 86 /** 87 * @ignore 88 * 89 * @param array $lines 90 * @param string $prefix 91 */ 31 92 function _lines( $lines, $prefix=' ' ) { 32 93 } 33 94 34 // HTML-escape parameter before calling this 95 /** 96 * @ignore 97 * 98 * @param string $line HTML-escape the value. 99 * @return string 100 */ 35 101 function addedLine( $line ) { 36 102 return "<td>+</td><td class='diff-addedline'>{$line}</td>"; 37 103 } 38 104 39 // HTML-escape parameter before calling this 105 /** 106 * @ignore 107 * 108 * @param string $line HTML-escape the value. 109 * @return string 110 */ 40 111 function deletedLine( $line ) { 41 112 return "<td>-</td><td class='diff-deletedline'>{$line}</td>"; 42 113 } 43 114 44 // HTML-escape parameter before calling this 115 /** 116 * @ignore 117 * 118 * @param string $line HTML-escape the value. 119 * @return string 120 */ 45 121 function contextLine( $line ) { 46 122 return "<td> </td><td class='diff-context'>{$line}</td>"; 47 123 } 48 124 125 /** 126 * @ignore 127 * 128 * @return string 129 */ 49 130 function emptyLine() { 50 131 return '<td colspan="2"> </td>'; 51 132 } 52 133 134 /** 135 * @ignore 136 * @access private 137 * 138 * @param array $lines 139 * @param bool $encode 140 * @return string 141 */ 53 142 function _added( $lines, $encode = true ) { 54 143 $r = ''; … … 61 150 } 62 151 152 /** 153 * @ignore 154 * @access private 155 * 156 * @param array $lines 157 * @param bool $encode 158 * @return string 159 */ 63 160 function _deleted( $lines, $encode = true ) { 64 161 $r = ''; … … 71 168 } 72 169 170 /** 171 * @ignore 172 * @access private 173 * 174 * @param array $lines 175 * @param bool $encode 176 * @return string 177 */ 73 178 function _context( $lines, $encode = true ) { 74 179 $r = ''; … … 82 187 } 83 188 84 // Process changed lines to do word-by-word diffs for extra highlighting (TRAC style) 85 // sometimes these lines can actually be deleted or added rows - we do additional processing 86 // to figure that out 189 /** 190 * Process changed lines to do word-by-word diffs for extra highlighting. 191 * 192 * (TRAC style) sometimes these lines can actually be deleted or added rows. 193 * We do additional processing to figure that out 194 * 195 * @access private 196 * @since 2.6.0 197 * 198 * @param array $orig 199 * @param array $final 200 * @return string 201 */ 87 202 function _changed( $orig, $final ) { 88 203 $r = ''; … … 152 267 } 153 268 154 // Takes changed blocks and matches which rows in orig turned into which rows in final. 155 // Returns 156 // *_matches ( which rows match with which ) 157 // *_rows ( order of rows in each column interleaved with blank rows as necessary ) 269 /** 270 * Takes changed blocks and matches which rows in orig turned into which rows in final. 271 * 272 * Returns 273 * *_matches ( which rows match with which ) 274 * *_rows ( order of rows in each column interleaved with blank rows as 275 * necessary ) 276 * 277 * @since 2.6.0 278 * 279 * @param unknown_type $orig 280 * @param unknown_type $final 281 * @return unknown 282 */ 158 283 function interleave_changed_lines( $orig, $final ) { 159 284 … … 280 405 } 281 406 282 283 // Computes a number that is intended to reflect the "distance" between two strings. 407 /** 408 * Computes a number that is intended to reflect the "distance" between two strings. 409 * 410 * @since 2.6.0 411 * 412 * @param string $string1 413 * @param string $string2 414 * @return int 415 */ 284 416 function compute_string_distance( $string1, $string2 ) { 285 417 // Vectors containing character frequency for all chars in each string … … 298 430 } 299 431 432 /** 433 * @ignore 434 * @since 2.6.0 435 * 436 * @param int $a 437 * @param int $b 438 * @return int 439 */ 300 440 function difference( $a, $b ) { 301 441 return abs( $a - $b ); … … 304 444 } 305 445 306 // Better word splitting than the PEAR package provides 446 /** 447 * Better word splitting than the PEAR package provides. 448 * 449 * @since 2.6.0 450 * @uses Text_Diff_Renderer_inline Extends 451 */ 307 452 class WP_Text_Diff_Renderer_inline extends Text_Diff_Renderer_inline { 308 453 454 /** 455 * @ignore 456 * @since 2.6.0 457 * 458 * @param string $string 459 * @param string $newlineEscape 460 * @return string 461 */ 309 462 function _splitOnWords($string, $newlineEscape = "\n") { 310 463 $string = str_replace("\0", '', $string);
Note: See TracChangeset
for help on using the changeset viewer.