Skip to content

Commit 57b8143

Browse files
authored
Merge pull request #18 from JBlond/development
Development
2 parents b8b553b + 49e2c3a commit 57b8143

File tree

10 files changed

+31
-55
lines changed

10 files changed

+31
-55
lines changed

example/example.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,26 @@
33
<head>
44
<meta charset="utf-8"/>
55
<title>PHP LibDiff - Examples</title>
6-
<link rel="stylesheet" href="styles.css" type="text/css" charset="utf-8"/>
6+
<link rel="stylesheet" href="styles.css" type="text/css" />
77
</head>
88
<body>
99
<h1>PHP LibDiff - Examples</h1>
1010
<hr />
1111
<?php
1212
// include autoloader
13-
require dirname(__FILE__).'/../lib/Autoloader.php';
14-
new \jblond\Autoloader();
13+
use jblond\Autoloader;
14+
use jblond\Diff;
15+
use jblond\Diff\Renderer\Html\Inline;
16+
use jblond\Diff\Renderer\Html\SideBySide;
17+
use jblond\Diff\Renderer\Text\Context;
18+
use jblond\Diff\Renderer\Text\Unified;
19+
20+
require dirname(__FILE__) . '/../lib/Autoloader.php';
21+
new Autoloader();
1522

1623
// Include two sample files for comparison
17-
$a = explode("\n", file_get_contents(dirname(__FILE__).'/a.txt'));
18-
$b = explode("\n", file_get_contents(dirname(__FILE__).'/b.txt'));
24+
$a = explode("\n", file_get_contents(dirname(__FILE__) . '/a.txt'));
25+
$b = explode("\n", file_get_contents(dirname(__FILE__) . '/b.txt'));
1926

2027
// Options for generating the diff
2128
$options = array(
@@ -24,14 +31,16 @@
2431
);
2532

2633
// Initialize the diff class
27-
$diff = new \jblond\Diff($a, $b, $options);
34+
// \jblond\diff
35+
$diff = new Diff($a, $b, $options);
2836

2937
?>
3038
<h2>Side by Side Diff</h2>
3139
<?php
3240

3341
// Generate a side by side diff
34-
$renderer = new \jblond\Diff\Renderer\Html\SideBySide(array(
42+
// \jblond\Diff\Renderer\Html
43+
$renderer = new SideBySide(array(
3544
'title_a' => 'Custom title for OLD version',
3645
'title_b' => 'Custom title for NEW version',
3746
));
@@ -42,15 +51,17 @@
4251
<?php
4352

4453
// Generate an inline diff
45-
$renderer = new \jblond\Diff\Renderer\Html\Inline;
54+
// \jblond\Diff\Renderer\Html
55+
$renderer = new Inline();
4656
echo $diff->render($renderer);
4757

4858
?>
4959
<h2>Unified Diff</h2>
5060
<pre><?php
5161

5262
// Generate a unified diff
53-
$renderer = new \jblond\Diff\Renderer\Text\Unified();
63+
// \jblond\Diff\Renderer\Text
64+
$renderer = new Unified();
5465
echo htmlspecialchars($diff->render($renderer));
5566

5667
?>
@@ -59,7 +70,8 @@
5970
<pre><?php
6071

6172
// Generate a context diff
62-
$renderer = new \jblond\Diff\Renderer\Text\Context;
73+
// jblond\Diff\Renderer\Text\Context
74+
$renderer = new Context();
6375
echo htmlspecialchars($diff->render($renderer));
6476
?>
6577
</pre>

example/styles.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ body {
6565
background: #fc0;
6666
}
6767

68-
.Differences .Skipped {
69-
background: #f7f7f7;
70-
}
71-
7268
.DifferencesInline .ChangeReplace .Left,
7369
.DifferencesInline .ChangeDelete .Left {
7470
background: #fdd;
@@ -90,4 +86,4 @@ body {
9086
pre {
9187
width: 100%;
9288
overflow: auto;
93-
}
89+
}

lib/jblond/Diff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* @author Chris Boulton <[email protected]>
1919
* @copyright (c) 2009 Chris Boulton
2020
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
21-
* @version 1.13
21+
* @version 1.14
2222
* @link https://github.com/JBlond/php-diff
2323
*/
2424
class Diff

lib/jblond/Diff/Renderer/Html/HtmlArray.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @author Chris Boulton <[email protected]>
1616
* @copyright (c) 2009 Chris Boulton
1717
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
18-
* @version 1.13
18+
* @version 1.14
1919
* @link https://github.com/JBlond/php-diff
2020
*/
2121
class HtmlArray extends RendererAbstract
@@ -47,9 +47,6 @@ public function renderHtml($changes, $object)
4747
// If this is a separate block, we're condensing code so output ...,
4848
// indicating a significant portion of the code has been collapsed as
4949
// it is the same
50-
if ($i > 0) {
51-
$html .= $object->generateSkippedTable();
52-
}
5350

5451
foreach ($blocks as $change) {
5552
$html .= '<tbody class="Change' . ucfirst($change['tag']) . '">';

lib/jblond/Diff/Renderer/Html/Inline.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @author Chris Boulton <[email protected]>
1414
* @copyright (c) 2009 Chris Boulton
1515
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
16-
* @version 1.13
16+
* @version 1.14
1717
* @link https://github.com/JBlond/php-diff
1818
*/
1919
class Inline extends HtmlArray
@@ -50,21 +50,6 @@ public function generateTableHeader(): string
5050
return $html;
5151
}
5252

53-
/**
54-
* Generates a string representation of empty table body.
55-
*
56-
* @return string Html code representing empty table body.
57-
*/
58-
public function generateSkippedTable(): string
59-
{
60-
$html = '<tbody class="Skipped">';
61-
$html .= '<th>&hellip;</th>';
62-
$html .= '<th>&hellip;</th>';
63-
$html .= '<td>&#xA0;</td>';
64-
$html .= '</tbody>';
65-
return $html;
66-
}
67-
6853
/**
6954
* Generates a string representation of one or more rows of a table of lines of text with no difference.
7055
*

lib/jblond/Diff/Renderer/Html/SideBySide.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @author Chris Boulton <[email protected]>
1414
* @copyright (c) 2009 Chris Boulton
1515
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
16-
* @version 1.13
16+
* @version 1.14
1717
* @link https://github.com/JBlond/php-diff
1818
*/
1919
class SideBySide extends HtmlArray
@@ -48,20 +48,6 @@ public function generateTableHeader(): string
4848
return $html;
4949
}
5050

51-
/**
52-
* Generates a string representation of empty table body.
53-
*
54-
* @return string Html code representing empty table body.
55-
*/
56-
public function generateSkippedTable(): string
57-
{
58-
$html = '<tbody class="Skipped">';
59-
$html .= '<th>&hellip;</th><td>&#xA0;</td>';
60-
$html .= '<th>&hellip;</th><td>&#xA0;</td>';
61-
$html .= '</tbody>';
62-
return $html;
63-
}
64-
6551
/**
6652
* Generates a string representation of one or more rows of a table of lines of text with no difference.
6753
*

lib/jblond/Diff/Renderer/RendererAbstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @author Chris Boulton <[email protected]>
1616
* @copyright (c) 2009 Chris Boulton
1717
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
18-
* @version 1.13
18+
* @version 1.14
1919
* @link https://github.com/JBlond/php-diff
2020
*/
2121
abstract class RendererAbstract

lib/jblond/Diff/Renderer/Text/Context.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @author Chris Boulton <[email protected]>
1616
* @copyright (c) 2009 Chris Boulton
1717
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
18-
* @version 1.13
18+
* @version 1.14
1919
* @link https://github.com/JBlond/php-diff
2020
*/
2121
class Context extends RendererAbstract

lib/jblond/Diff/Renderer/Text/Unified.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @author Chris Boulton <[email protected]>
1616
* @copyright (c) 2009 Chris Boulton
1717
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
18-
* @version 1.13
18+
* @version 1.14
1919
* @link https://github.com/JBlond/php-diff
2020
*/
2121

lib/jblond/Diff/SequenceMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @author Chris Boulton <[email protected]>
1414
* @copyright (c) 2009 Chris Boulton
1515
* @license New BSD License http://www.opensource.org/licenses/bsd-license.php
16-
* @version 1.13
16+
* @version 1.14
1717
* @link https://github.com/JBlond/php-diff
1818
*/
1919
class SequenceMatcher

0 commit comments

Comments
 (0)