View source
<?php
function hacked_reports_hacked_diff($project, $file) {
if (!module_exists('diff')) {
return t('The diff module is required to use this feature.');
}
$breadcrumb = array(
l('Home', '<front>'),
l('Administer', 'admin'),
l('Reports', 'admin/logs'),
l('Hacked', 'admin/logs/hacked'),
l($project['title'], 'admin/logs/hacked/' . $project['short_name']),
);
drupal_set_breadcrumb($breadcrumb);
$local_file = hacked_find_local_project_directory($project) . '/' . $file;
$this_release = $project['releases'][$project['existing_version']];
$dir = hacked_download_release($this_release['download_link'], $project['project_type'], $project['short_name'], $project['existing_version']);
if ($project['project_type'] == 'core') {
$original_file = $dir . '/' . $project['short_name'] . '-' . $project['existing_version'] . '/' . $file;
}
else {
$original_file = $dir . '/' . $project['short_name'] . '/' . $file;
}
if (!hacked_file_is_binary($original_file) && !hacked_file_is_binary($local_file)) {
return hacked_diff_changed($local_file, $original_file);
}
return t('Cannot hash binary file or file not found: %file', array(
'%file' => $file,
));
}
function hacked_diff_changed($installed_file, $original_file) {
require_once drupal_get_path('module', 'diff') . '/DiffEngine.php';
$formatter = new DrupalDiffFormatter();
$original_array = file_exists($original_file) ? file($original_file) : array();
$installed_array = file_exists($installed_file) ? file($installed_file) : array();
$diff = new Diff($original_array, $installed_array);
$output = theme('diff_table', array(
t('Orignal'),
'',
t('Current'),
'',
), $formatter
->format($diff), array(
'class' => 'diff hacked-diff',
));
return $output;
}