Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Library two change the values "old and new version" at SideBySideHtml #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

// Generate a side by side diff
require_once dirname(__FILE__).'/../lib/Diff/Renderer/Html/SideBySide.php';
$renderer = new Diff_Renderer_Html_SideBySide;
$renderer = new Diff_Renderer_Html_SideBySide("a.txt","b.txt");
echo $diff->Render($renderer);

?>
Expand Down Expand Up @@ -66,4 +66,4 @@
?>
</pre>
</body>
</html>
</html>
17 changes: 14 additions & 3 deletions lib/Diff/Renderer/Html/SideBySide.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@

class Diff_Renderer_Html_SideBySide extends Diff_Renderer_Html_Array
{
/**** show at the top of the table like title **/
private $first = "";
private $second = "";

/** we recieved 2 vars with the title **/
public function __construct($a='Old Version',$b='New Version') {

$this->first = $a;
$this->second = $b;
}

/**
* Render a and return diff with changes between the two sequences
* displayed side by side.
Expand All @@ -62,8 +73,8 @@ public function render()
$html .= '<table class="Differences DifferencesSideBySide">';
$html .= '<thead>';
$html .= '<tr>';
$html .= '<th colspan="2">Old Version</th>';
$html .= '<th colspan="2">New Version</th>';
$html .= '<th colspan="2">'.$this->first.'</th>';
$html .= '<th colspan="2">'.$this->second.'</th>';
$html .= '</tr>';
$html .= '</thead>';
foreach($changes as $i => $blocks) {
Expand Down Expand Up @@ -160,4 +171,4 @@ public function render()
$html .= '</table>';
return $html;
}
}
}