Make WordPress Core


Ignore:
Timestamp:
09/11/2008 05:46:42 PM (16 years ago)
Author:
ryan
Message:

Inline docs for wp-diff.php. Props jacobsantos. fixes #7662

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/wp-diff.php

    r8581 r8866  
    11<?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 */
    210
    311if ( !class_exists( 'Text_Diff' ) ) {
     12    /** Text_Diff class */
    413    require( dirname(__FILE__).'/Text/Diff.php' );
     14    /** Text_Diff_Renderer class */
    515    require( dirname(__FILE__).'/Text/Diff/Renderer.php' );
     16    /** Text_Diff_Renderer_inline class */
    617    require( dirname(__FILE__).'/Text/Diff/Renderer/inline.php' );
    718}
    819
    9 
    10 /* Descendent of a bastard child of piece of an old MediaWiki Diff Formatter
     20/**
     21 * Table renderer to display the diff lines.
    1122 *
    12  * Basically all that remains is the table structure and some method names.
     23 * @since 2.6.0
     24 * @uses Text_Diff_Renderer Extends
    1325 */
    14 
    1526class 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     */
    1634    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     */
    1742    var $_trailing_context_lines = 10000;
     43
     44    /**
     45     * {@internal Missing Description}}
     46     *
     47     * @var float
     48     * @access protected
     49     * @since 2.6.0
     50     */
    1851    var $_diff_threshold = 0.6;
    1952
     53    /**
     54     * Inline display helper object name.
     55     *
     56     * @var string
     57     * @access protected
     58     * @since 2.6.0
     59     */
    2060    var $inline_diff_renderer = 'WP_Text_Diff_Renderer_inline';
    2161
     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     */
    2271    function Text_Diff_Renderer_Table( $params = array() ) {
    2372        $parent = get_parent_class($this);
     
    2574    }
    2675
     76    /**
     77     * @ignore
     78     *
     79     * @param string $header
     80     * @return string
     81     */
    2782    function _startBlock( $header ) {
    2883        return '';
    2984    }
    3085
     86    /**
     87     * @ignore
     88     *
     89     * @param array $lines
     90     * @param string $prefix
     91     */
    3192    function _lines( $lines, $prefix=' ' ) {
    3293    }
    3394
    34     // HTML-escape parameter before calling this
     95    /**
     96     * @ignore
     97     *
     98     * @param string $line HTML-escape the value.
     99     * @return string
     100     */
    35101    function addedLine( $line ) {
    36102        return "<td>+</td><td class='diff-addedline'>{$line}</td>";
    37103    }
    38104
    39     // HTML-escape parameter before calling this
     105    /**
     106     * @ignore
     107     *
     108     * @param string $line HTML-escape the value.
     109     * @return string
     110     */
    40111    function deletedLine( $line ) {
    41112        return "<td>-</td><td class='diff-deletedline'>{$line}</td>";
    42113    }
    43114
    44     // HTML-escape parameter before calling this
     115    /**
     116     * @ignore
     117     *
     118     * @param string $line HTML-escape the value.
     119     * @return string
     120     */
    45121    function contextLine( $line ) {
    46122        return "<td> </td><td class='diff-context'>{$line}</td>";
    47123    }
    48124
     125    /**
     126     * @ignore
     127     *
     128     * @return string
     129     */
    49130    function emptyLine() {
    50131        return '<td colspan="2">&nbsp;</td>';
    51132    }
    52133
     134    /**
     135     * @ignore
     136     * @access private
     137     *
     138     * @param array $lines
     139     * @param bool $encode
     140     * @return string
     141     */
    53142    function _added( $lines, $encode = true ) {
    54143        $r = '';
     
    61150    }
    62151
     152    /**
     153     * @ignore
     154     * @access private
     155     *
     156     * @param array $lines
     157     * @param bool $encode
     158     * @return string
     159     */
    63160    function _deleted( $lines, $encode = true ) {
    64161        $r = '';
     
    71168    }
    72169
     170    /**
     171     * @ignore
     172     * @access private
     173     *
     174     * @param array $lines
     175     * @param bool $encode
     176     * @return string
     177     */
    73178    function _context( $lines, $encode = true ) {
    74179        $r = '';
     
    82187    }
    83188
    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     */
    87202    function _changed( $orig, $final ) {
    88203        $r = '';
     
    152267    }
    153268
    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     */
    158283    function interleave_changed_lines( $orig, $final ) {
    159284
     
    280405    }
    281406
    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     */
    284416    function compute_string_distance( $string1, $string2 ) {
    285417        // Vectors containing character frequency for all chars in each string
     
    298430    }
    299431
     432    /**
     433     * @ignore
     434     * @since 2.6.0
     435     *
     436     * @param int $a
     437     * @param int $b
     438     * @return int
     439     */
    300440    function difference( $a, $b ) {
    301441        return abs( $a - $b );
     
    304444}
    305445
    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 */
    307452class WP_Text_Diff_Renderer_inline extends Text_Diff_Renderer_inline {
    308453
     454    /**
     455     * @ignore
     456     * @since 2.6.0
     457     *
     458     * @param string $string
     459     * @param string $newlineEscape
     460     * @return string
     461     */
    309462    function _splitOnWords($string, $newlineEscape = "\n") {
    310463        $string = str_replace("\0", '', $string);
Note: See TracChangeset for help on using the changeset viewer.