Make WordPress Core


Ignore:
Timestamp:
02/19/2010 01:25:26 AM (15 years ago)
Author:
nacin
Message:

Update Text_Diff. Props simek. Fixes #9467

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/Text/Diff.php

    r8581 r13211  
    77 * <dairiki@dairiki.org>, and is used/adapted with his permission.
    88 *
    9  * $Horde: framework/Text_Diff/Diff.php,v 1.26 2008/01/04 10:07:49 jan Exp $
    10  *
    119 * Copyright 2004 Geoffrey T. Dairiki <dairiki@dairiki.org>
    12  * Copyright 2004-2008 The Horde Project (http://www.horde.org/)
     10 * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
    1311 *
    1412 * See the enclosed file COPYING for license information (LGPL). If you did
     
    6462    {
    6563        return $this->_edits;
     64    }
     65
     66    /**
     67     * returns the number of new (added) lines in a given diff.
     68     *
     69     * @since Text_Diff 1.1.0
     70     *
     71     * @return integer The number of new lines
     72     */
     73    function countAddedLines()
     74    {
     75        $count = 0;
     76        foreach ($this->_edits as $edit) {
     77            if (is_a($edit, 'Text_Diff_Op_add') ||
     78                is_a($edit, 'Text_Diff_Op_change')) {
     79                $count += $edit->nfinal();
     80            }
     81        }
     82        return $count;
     83    }
     84
     85    /**
     86     * Returns the number of deleted (removed) lines in a given diff.
     87     *
     88     * @since Text_Diff 1.1.0
     89     *
     90     * @return integer The number of deleted lines
     91     */
     92    function countDeletedLines()
     93    {
     94        $count = 0;
     95        foreach ($this->_edits as $edit) {
     96            if (is_a($edit, 'Text_Diff_Op_delete') ||
     97                is_a($edit, 'Text_Diff_Op_change')) {
     98                $count += $edit->norig();
     99            }
     100        }
     101        return $count;
    66102    }
    67103
Note: See TracChangeset for help on using the changeset viewer.