3636 * @author Chris Boulton <chris.boulton@interspire.com>
3737 * @copyright (c) 2009 Chris Boulton
3838 * @license New BSD License http://www.opensource.org/licenses/bsd-license.php
39- * @version 1.0
39+ * @version 1.1
4040 * @link http://github.com/chrisboulton/phpdiff
4141 */
4242
@@ -58,13 +58,13 @@ class Diff_Renderer_Html_Array extends Diff_Renderer_Abstract
5858 *
5959 * @return array An array of the generated chances, suitable for presentation in HTML.
6060 */
61- public function Render ()
61+ public function render ()
6262 {
6363 // As we'll be modifying a & b to include our change markers,
6464 // we need to get the contents and store them here. That way
6565 // we're not going to destroy the original data
66- $ a = $ this ->diff ->GetA ();
67- $ b = $ this ->diff ->GetB ();
66+ $ a = $ this ->diff ->getA ();
67+ $ b = $ this ->diff ->getB ();
6868
6969 $ changes = array ();
7070 $ opCodes = $ this ->diff ->getGroupedOpcodes ();
@@ -80,21 +80,20 @@ public function Render()
8080 $ fromLine = $ a [$ i1 + $ i ];
8181 $ toLine = $ b [$ j1 + $ i ];
8282
83- list ($ start , $ end ) = $ this ->GetChangeExtent ($ fromLine , $ toLine );
83+ list ($ start , $ end ) = $ this ->getChangeExtent ($ fromLine , $ toLine );
8484 if ($ start != 0 || $ end != 0 ) {
8585 $ last = $ end + strlen ($ fromLine );
8686 $ fromLine = substr_replace ($ fromLine , "\0" , $ start , 0 );
8787 $ fromLine = substr_replace ($ fromLine , "\1" , $ last + 1 , 0 );
8888 $ last = $ end + strlen ($ toLine );
8989 $ toLine = substr_replace ($ toLine , "\0" , $ start , 0 );
9090 $ toLine = substr_replace ($ toLine , "\1" , $ last + 1 , 0 );
91- $ a [$ i1 ] = $ fromLine ;
92- $ b [$ j1 ] = $ toLine ;
91+ $ a [$ i1 + $ i ] = $ fromLine ;
92+ $ b [$ j1 + $ i ] = $ toLine ;
9393 }
9494 }
9595 }
9696
97-
9897 if ($ tag != $ lastTag ) {
9998 $ blocks [] = array (
10099 'tag ' => $ tag ,
@@ -114,21 +113,21 @@ public function Render()
114113
115114 if ($ tag == 'equal ' ) {
116115 $ lines = array_slice ($ a , $ i1 , ($ i2 - $ i1 ));
117- $ blocks [$ lastBlock ]['base ' ]['lines ' ] += $ this ->FormatLines ($ lines );
116+ $ blocks [$ lastBlock ]['base ' ]['lines ' ] += $ this ->formatLines ($ lines );
118117 $ lines = array_slice ($ b , $ j1 , ($ j2 - $ j1 ));
119- $ blocks [$ lastBlock ]['changed ' ]['lines ' ] += $ this ->FormatLines ($ lines );
118+ $ blocks [$ lastBlock ]['changed ' ]['lines ' ] += $ this ->formatLines ($ lines );
120119 }
121120 else {
122121 if ($ tag == 'replace ' || $ tag == 'delete ' ) {
123122 $ lines = array_slice ($ a , $ i1 , ($ i2 - $ i1 ));
124- $ lines = $ this ->FormatLines ($ lines );
123+ $ lines = $ this ->formatLines ($ lines );
125124 $ lines = str_replace (array ("\0" , "\1" ), array ('<del> ' , '</del> ' ), $ lines );
126125 $ blocks [$ lastBlock ]['base ' ]['lines ' ] += $ lines ;
127126 }
128127
129128 if ($ tag == 'replace ' || $ tag == 'insert ' ) {
130129 $ lines = array_slice ($ b , $ j1 , ($ j2 - $ j1 ));
131- $ lines = $ this ->FormatLines ($ lines );
130+ $ lines = $ this ->formatLines ($ lines );
132131 $ lines = str_replace (array ("\0" , "\1" ), array ('<ins> ' , '</ins> ' ), $ lines );
133132 $ blocks [$ lastBlock ]['changed ' ]['lines ' ] += $ lines ;
134133 }
@@ -173,12 +172,12 @@ private function GetChangeExtent($fromLine, $toLine)
173172 * @param array $lines Array of lines to format.
174173 * @return array Array of the formatted lines.
175174 */
176- private function FormatLines ($ lines )
175+ private function formatLines ($ lines )
177176 {
178177 $ lines = array_map (array ($ this , 'ExpandTabs ' ), $ lines );
179178 $ lines = array_map (array ($ this , 'HtmlSafe ' ), $ lines );
180179 foreach ($ lines as &$ line ) {
181- $ line = preg_replace ('# ( +)|^ #e ' , "\$this->FixSpaces (' \\1') " , $ line );
180+ $ line = preg_replace ('# ( +)|^ #e ' , "\$this->fixSpaces (' \\1') " , $ line );
182181 }
183182 return $ lines ;
184183 }
@@ -189,7 +188,7 @@ private function FormatLines($lines)
189188 * @param string $spaces The string of spaces.
190189 * @return string The HTML representation of the string.
191190 */
192- function FixSpaces ($ spaces ='' )
191+ function fixSpaces ($ spaces ='' )
193192 {
194193 $ count = strlen ($ spaces );
195194 if ($ count == 0 ) {
@@ -207,7 +206,7 @@ function FixSpaces($spaces='')
207206 * @param string $line The containing tabs to convert.
208207 * @return string The line with the tabs converted to spaces.
209208 */
210- private function ExpandTabs ($ line )
209+ private function expandTabs ($ line )
211210 {
212211 return str_replace ("\t" , str_repeat (' ' , $ this ->options ['tabSize ' ]), $ line );
213212 }
@@ -218,7 +217,7 @@ private function ExpandTabs($line)
218217 * @param string $string The string.
219218 * @return string The string with the HTML characters replaced by entities.
220219 */
221- private function HtmlSafe ($ string )
220+ private function htmlSafe ($ string )
222221 {
223222 return htmlspecialchars ($ string , ENT_NOQUOTES , 'UTF-8 ' );
224223 }
0 commit comments