PDA

View Full Version : Administrative and Maintenance Tools - Template Editing: Show Difference


tdev1
03-09-2013, 11:00 PM
This little php code will show the difference of your template to the default one: it can help you maintaining the modifications you did to the templates


How to install:

a) make a backup of the file admincp/template.php:
cp admincp/template.php admincp/template_original.php

b) apply the attached patch:
patch -p0 < template_mod.diff.txt
c) install Text_Diff via pear:
pear install Text_Diff

Dr.CustUmz
10-08-2020, 04:00 PM
I know this is older but I have adapted it to vB3 but the differences aren't displaying, I have gone through the diff files and I'm not catching what needs to be changed, I have tried replacing all &$ with $ I didn't see any splits to explode, and my logs aren't reporting any error

I know the author has not been on in years, but I was just hoping someone would be able to help me with this. Running vb3.8.11 on php 5.4.60 (i believe)

below are the edits I made to work with vb3, and the files required for this edit.

$masterstyleid = '-1'; //vb4 defines this as -1 or -2 (default or mobile) /vb3 master is -1
$templateo = $db->query_first("
SELECT templateid, styleid, title, template_un
FROM " . TABLE_PREFIX . "template
WHERE styleid IN ($masterstyleid,0)
AND title = '" . $db->escape_string($template['title']) . "'
");
$texto = $templateo['template_un'];
if(trim($texto) != '') {
print_textarea_row('<span style="color:green;font-weight:bold;">Default '.$vbphrase['template'].'</span>', 'templateo', $texto, 22, '75" style="width:99%', true, false, 'ltr', 'code');
@include_once 'Text/Diff.php';
@include_once 'Text/Diff/Renderer/inline.php';
if(class_exists('Text_Diff') && class_exists('Text_Diff_Renderer_inline')) {
$diff = new Text_Diff('auto', array(explode("\n", $texto), explode("\n", $text)));
$renderer = new Text_Diff_Renderer_inline(array('ins_prefix' => '<span style="color:green;font-weight:bold;">','ins_suffix' => '</span>','del_prefix' => '<span style="color:red;font-weight:bold;">','del_suffix' => '</span>'));
$fdiff = $renderer->render($diff);
print_label_row('<span style="color:orange;font-weight:bold;">Difference</span><br/><small>red=removed,<br/>green=added</small>', '<div style="background-color:white;font-size:0.9em;border:1px solid black;white-space: pre;font-family: "Courier New", monospace;">'.$fdiff.'</div>');
} else {
print_label_row('<span style="color:orange;font-weight:bold;">Difference</span>', 'For this feature to work, please install <a href="http://pear.php.net/package/Text_Diff">PEAR Text_Diff</a>:<br/><pre>$ sudo pear install Text_Diff</pre>');
}
} else {
print_label_row('Original', 'There is no original version for this template.');
}

And have placed it under line 2116:
'template', $template['template_un'], 22, '75" style="width:100%', true, true, 'ltr', 'code');

I have placed the Text folder in my root

Its displaying how it should, BUT it is not showing differences.
157758