added charset detection using svn:mime-type to code_file and code_blame. need to add the same code to more views
This commit is contained in:
parent
7d5e336664
commit
50c68bbab3
@ -174,6 +174,10 @@ class SubversionModel extends Model
|
||||
$str = @svn_blame ($workurl, $rev);
|
||||
if ($str === FALSE) return FALSE;
|
||||
|
||||
$prop = @svn_proplist ($workurl, FALSE, $rev);
|
||||
if ($prop === FALSE) return FALSE;
|
||||
$fileinfo['properties'] = array_key_exists($orgurl, $prop)? $prop[$orgurl]: NULL;
|
||||
|
||||
$log = @svn_log ($workurl,
|
||||
$fileinfo['created_rev'],
|
||||
$fileinfo['created_rev'],
|
||||
|
@ -298,17 +298,40 @@ if ($login['settings'] != NULL &&
|
||||
|
||||
printf ('<code class="line-numbered-code prettyprint %s %s" id="code_blame_mainarea_result_code">', $prettyprint_linenums, $prettyprint_lang);
|
||||
|
||||
|
||||
|
||||
$charset = '';
|
||||
if (array_key_exists('properties', $file) && count($file['properties']) > 0)
|
||||
{
|
||||
$p = &$file['properties'];
|
||||
if (array_key_exists('svn:mime-type', $p))
|
||||
{
|
||||
if (@preg_match('|\s*[\w/+]+;\s*charset=(\S+)|i', $p['svn:mime-type'], $matches))
|
||||
{
|
||||
$charset = $matches[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($charset == '')
|
||||
{
|
||||
if (property_exists($project, 'codecharset') && strlen($project->codecharset))
|
||||
$charset = $project->codecharset;
|
||||
}
|
||||
|
||||
|
||||
for ($i = 0; $i < $len; $i++)
|
||||
{
|
||||
$line = &$content[$i];
|
||||
|
||||
if (property_exists($project, 'codecharset') && strlen($project->codecharset))
|
||||
if ($charset == '')
|
||||
{
|
||||
print htmlspecialchars (iconv($project->codecharset, 'UTF-8//IGNORE', $line['line']));
|
||||
print htmlspecialchars ($line['line']);
|
||||
}
|
||||
else
|
||||
{
|
||||
print htmlspecialchars ($line['line']);
|
||||
// ignore iconv error
|
||||
print htmlspecialchars (@iconv($charset, 'UTF-8//IGNORE', $line['line']));
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
|
@ -301,15 +301,34 @@ if ($login['settings'] != NULL &&
|
||||
|
||||
if (!$is_image_stream)
|
||||
{
|
||||
if (property_exists($project, 'codecharset') && strlen($project->codecharset))
|
||||
$charset = '';
|
||||
if (array_key_exists('properties', $file) && count($file['properties']) > 0)
|
||||
{
|
||||
print htmlspecialchars(iconv ($project->codecharset, 'UTF-8//IGNORE', $file['content']));
|
||||
$p = &$file['properties'];
|
||||
if (array_key_exists('svn:mime-type', $p))
|
||||
{
|
||||
if (@preg_match('|\s*[\w/+]+;\s*charset=(\S+)|i', $p['svn:mime-type'], $matches))
|
||||
{
|
||||
$charset = $matches[1];
|
||||
}
|
||||
else
|
||||
}
|
||||
}
|
||||
|
||||
if ($charset == '')
|
||||
{
|
||||
if (property_exists($project, 'codecharset') && strlen($project->codecharset))
|
||||
$charset = $project->codecharset;
|
||||
}
|
||||
|
||||
if ($charset == '')
|
||||
{
|
||||
print htmlspecialchars($file['content']);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// ignore iconv error
|
||||
print htmlspecialchars(@iconv ($charset, 'UTF-8//IGNORE', $file['content']));
|
||||
}
|
||||
}
|
||||
?>
|
||||
</pre>
|
||||
|
@ -527,11 +527,11 @@ $this->load->view (
|
||||
$f = $file->file_list[$i];
|
||||
|
||||
$xname = $this->converter->AsciiToHex($f->filename);
|
||||
print '<tr><td>';
|
||||
print anchor ("file/get/{$project->id}/{$xname}", htmlspecialchars($f->filename));
|
||||
print '</td><td>';
|
||||
print '<tr><td class="file-name-td">';
|
||||
print anchor ("file/get/{$project->id}/{$xname}", '<i class="fa fa-download" /> ' . htmlspecialchars($f->filename));
|
||||
print '</td><td class="file-description-td">';
|
||||
print htmlspecialchars($f->description);
|
||||
print '</td><td>';
|
||||
print '</td><td class="file-md5sum-td">';
|
||||
print " <tt>{$f->md5sum}</tt>";
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
@ -48,6 +48,12 @@
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
#file_show_mainarea_files td {
|
||||
padding-left: 0.5em;
|
||||
padding-right: 0.5em;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
#file_edit_mainarea_description {
|
||||
width: 100%;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user