Skip to content

Handle side by side title customization #2

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

Merged
merged 1 commit into from
Jan 23, 2018
Merged
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
5 changes: 4 additions & 1 deletion example/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@

// 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(array(
'title_a' => 'Custom title for OLD version',
'title_b' => 'Custom title for NEW version',
));
echo $diff->Render($renderer);

?>
Expand Down
2 changes: 0 additions & 2 deletions lib/Diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ class Diff
'ignoreNewLines' => false,
'ignoreWhitespace' => false,
'ignoreCase' => false,
'title_a'=>'Old Version',
'title_b'=>'New Version',
'labelDifferences'=>'Differences'
);

Expand Down
5 changes: 4 additions & 1 deletion lib/Diff/Renderer/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ abstract class Diff_Renderer_Abstract
/**
* @var array Array of the default options that apply to this renderer.
*/
protected $defaultOptions = array();
protected $defaultOptions = array(
'title_a' => 'Old Version',
'title_b' => 'New Version',
);

/**
* @var array Array containing the user applied and merged default options for the renderer.
Expand Down
4 changes: 3 additions & 1 deletion lib/Diff/Renderer/Html/Array.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ class Diff_Renderer_Html_Array extends Diff_Renderer_Abstract
* @var array Array of the default options that apply to this renderer.
*/
protected $defaultOptions = array(
'tabSize' => 4
'tabSize' => 4,
'title_a' => 'Old Version',
'title_b' => 'New Version',
);

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Diff/Renderer/Html/SideBySide.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,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->options['title_a'].'</th>';
$html .= '<th colspan="2">'.$this->options['title_b'].'</th>';
$html .= '</tr>';
$html .= '</thead>';
foreach($changes as $i => $blocks) {
Expand Down