Skip to content

Commit

Permalink
Use table head instead of a special row for column headers
Browse files Browse the repository at this point in the history
  • Loading branch information
flodolo committed Mar 11, 2016
1 parent 97185bc commit 7786a92
Show file tree
Hide file tree
Showing 13 changed files with 169 additions and 116 deletions.
17 changes: 10 additions & 7 deletions app/classes/Transvision/ShowResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,15 @@ public static function resultsTable($search_id, $search_results, $recherche, $lo
}

$table = "<table class='collapsable results_table {$search_id}'>
<tr class='column_headers'>
<th>Entity</th>
<th>{$locale1}</th>
<th>{$locale2}</th>
{$extra_column_header}
</tr>";
<thead>
<tr class='column_headers'>
<th>Entity</th>
<th>{$locale1}</th>
<th>{$locale2}</th>
{$extra_column_header}
</tr>
</thead>
<tbody>\n";

if (!$search_options['whole_word'] && !$search_options['perfect_match']) {
$recherche = Utils::uniqueWords($recherche);
Expand Down Expand Up @@ -468,7 +471,7 @@ public static function resultsTable($search_id, $search_results, $recherche, $lo
</tr>";
}

$table .= " </table>";
$table .= " </tbody>\n</table>\n";

return $table;
}
Expand Down
10 changes: 5 additions & 5 deletions app/classes/Transvision/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ public static function printSimpleTable(
} else {
echo '<table>';
}
echo '<tr>' .
"<th>{$titles[0]}</th><th>{$titles[1]}</th>";
echo "<thead>\n <tr class='column_headers'>\n" .
" <th>{$titles[0]}</th><th>{$titles[1]}</th>\n";

if ($arr2) {
echo "<th>{$titles[2]}</th><th>{$titles[3]}</th>";
echo " <th>{$titles[2]}</th><th>{$titles[3]}</th>\n";
}

echo '</tr>';
echo " </tr>\n</thead>\n<tbody>\n";

foreach ($arr as $key => $val) {
echo '<tr>';
Expand All @@ -173,7 +173,7 @@ public static function printSimpleTable(
}
echo '</tr>';
}
echo '</table>';
echo "</tbody>\n</table>\n";
}

/**
Expand Down
3 changes: 3 additions & 0 deletions app/models/unlocalized_words.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@
Remove punctuation characters from the strings then explode them into
words.
*/
$ref_words = strip_tags($ref_words);
$ref_words = explode(
' ',
preg_replace('/\p{P}/u', '', $ref_words)
);

$locale_words = strip_tags($locale_words);
$locale_words = explode(
' ',
preg_replace('/\p{P}/u', '', $locale_words)
Expand Down
22 changes: 12 additions & 10 deletions app/views/channelcomparison.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@
echo "<h3>Comparison is empty</h3>\n" .
"<p class='subtitle'>There are no string differences for this locale between the {$repos_nice_names[$chan1]} and {$repos_nice_names[$chan2]} channels.</p>\n";
} else {
echo "\n<table class='collapsable'>" .
" <tr>\n" .
" <th colspan='3'>Locale: {$locale}</th>\n" .
" </tr>\n" .
" <tr>\n" .
" <th>Key</th>\n" .
" <th>{$chan1}</th>\n" .
" <th>{$chan2}</th>\n" .
" </tr>\n";
echo "
<h2>Locale: {$locale}</h2>
<table class='collapsable'>
<thead>
<tr class='column_headers'>
<th>Key</th>
<th>{$chan1}</th>
<th>{$chan2}</th>
</tr>
</thead>
<tbody>\n";

foreach ($common_strings as $key => $value) {
echo " <tr>"
Expand All @@ -51,5 +53,5 @@
. " <td><span class='celltitle'>{$chan2}</span><div class='string'>" . ShowResults::highlight($strings[$chan2][$key]) . "</div></td>\n"
. " </tr>\n";
}
echo "</table>\n";
echo "</tbody>\n</table>\n";
}
18 changes: 11 additions & 7 deletions app/views/check_variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
"</div>\n";
}

$content .= "<table class='collapsable results_table {$search_id}'>\n" .
" <tr>\n" .
" <th>Entity</th>\n" .
" <th>{$source_locale}</th>\n" .
" <th>{$locale}</th>\n" .
" </tr>\n";
$content .= "
<table class='collapsable results_table {$search_id}'>
<thead>
<tr class='column_headers'>
<th>Entity</th>
<th>{$source_locale}</th>
<th>{$locale}</th>
</tr>
</thead>
<tbody>\n";

foreach ($var_errors as $string_id) {
// Link to entity
Expand Down Expand Up @@ -62,7 +66,7 @@
</td>
</tr>\n";
}
$content .= "</table>\n";
$content .= "</tbody>\n</table>\n";
} else {
$content = "<h2>Congratulations, no errors found.</h2>";
}
Expand Down
7 changes: 5 additions & 2 deletions app/views/consistency.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@
} else {
?>
<table>
<tr>
<thead>
<tr class="column_headers">
<th>English String</th>
<th>Available Translations</th>
</tr>
</thead>
<tbody>
<?php
foreach ($inconsistent_translations as $data) {
$search_link = "/?sourcelocale={$reference_locale}"
Expand All @@ -52,5 +55,5 @@
}
echo "</td>\n</tr>\n";
}
echo "</table>\n";
echo "</tbody>\n</table>\n";
}
84 changes: 49 additions & 35 deletions app/views/gaia.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@
// Overview of string count for the locale
$overview = function ($section_title, $columns, $rows, $anchor) {
// Titles
$html = '<table id="' . $anchor . '">'
. '<tr>'
. '<th colspan="3">' . $section_title . '</th>'
. '</tr>'
. '<tr>';
$html = "
<p class='section_title'>{$section_title}</p>
<table id='{$anchor}'>
<thead>
<tr class='column_headers'>";
foreach ($columns as $key => $value) {
$html .= '<th>' . $value . '</th>';
}
$html .= '</tr>';
$html .= "</tr>\n</thead>\n<tbody>\n";

// Rows
foreach ($rows as $key => $row) {
Expand All @@ -118,7 +118,7 @@
}
$html .= '</tr>';
}
$html .= '</table>';
$html .= "</tbody>\n</table>\n";

return $html;
};
Expand Down Expand Up @@ -174,17 +174,18 @@
$nb_sources = count($diverging_sources) + 1;
$width = 100 / $nb_sources;

$table = '<table id="' . $anchor . '" class="collapsable">'
. '<tr>'
. '<th colspan="' . $nb_sources . '">' . count($divergences) . ' diverging translations across repositories</th>'
. '</tr>'
. '<tr>';
$table .= "<th style=\"width:$width%\">Keys</th>";
$section_title = count($divergences) . ' diverging translations across repositories';
$table = "
<p class='section_title'>{$section_title}</p>
<table id='{$anchor}' class='collapsable'>
<thead>
<tr class='column_headers'>
<th style='width: {$width}%;'>Keys</th>";
foreach ($diverging_sources as $key => $repo_name) {
$table .= "<th style=\"width:$width%\">" . $repos_nice_names[$repo_name] . '</th>';
$table .= "<th style='width: $width%;'>{$repos_nice_names[$repo_name]}</th>\n";
}

$table .= '</tr>';
$table .= "</tr>\n</thead>\n<tbody>\n";

foreach ($divergences as $v) {
$table .= '<tr>'
Expand All @@ -195,7 +196,7 @@
$table .= '</tr>';
}

$table .= '</table>';
$table .= "</tbody>\n</table>\n";

return $table;
};
Expand All @@ -217,16 +218,21 @@

$repo_one = $repos_nice_names[$englishchanges[0]];
$repo_two = $repos_nice_names[$englishchanges[1]];
$table = '<table id="englishchanges" class="collapsable">'
. '<tr>'
. '<th colspan="3">Strings that have changed significantly in English between ' . $repo_one . ' and ' . $repo_two . ' but for which the entity name didn\'t change</th>'
. '</tr>'
. '<tr>'
. '<th>Key</th>'
. '<th>' . $repo_one . '</th>'
. '<th>' . $repo_two . '</th>'
. '</tr>';

$section_title = "Strings that have changed significantly in English between {$repo_one} and {$repo_two} but for which the entity name didn’t change";
$table = "
<p class='section_title'>{$section_title}</p>
<table id='englishchanges' class='collapsable'>
<thead>
<tr class='column_headers'>
<th>Key</th>
<th>{$repo_one}</th>
<th>{$repo_two}</th>
</tr>
</thead>
<tbody>\n";

$changed_strings = 0;
foreach ($common_keys as $key => $val) {
$get_localized_string = function ($id) use ($key, $strings) {
// Avoid warnings if the string is not localized
Expand All @@ -246,9 +252,14 @@
. ShowResults::highlight(Utils::secureText($strings[$englishchanges[1] . '-en-US'][$key]))
. '<br><small>' . $get_localized_string($englishchanges[1]) . '</small></div></td>'
. '</tr>';
$changed_strings++;
}
}
$table .= '</table>';

if ($changed_strings == 0) {
$table .= "<tr><td colspan='3' class='no_highligth'>There are no changed strings.</td></tr>\n";
}
$table .= "</tbody>\n</table>\n";

print $anchor_title('changed_english');
print $table;
Expand All @@ -263,14 +274,17 @@
$comparison_type = '<span class="deleted_string">' . $count . ' deleted strings</span>';
}

$table = '<table id="' . $anchor . '" class="' . $cssclass . '">'
. '<tr>'
. '<th colspan="3">' . $comparison_type . ' between ' . $repos_nice_names[$repo_one] . ' and ' . $repos_nice_names[$repo_two] . '</th>'
. '</tr>'
. '<tr>'
. '<th>Key</th>'
. '<th>New strings</th>'
. '</tr>';
$section_title = "{$comparison_type} between {$repos_nice_names[$repo_one]} and {$repos_nice_names[$repo_two]}";
$table = "
<p class='section_title'>{$section_title}</p>
<table id='{$anchor}' class='{$cssclass}'>
<thead>
<tr class='column_headers'>
<th>Key</th>
<th>New strings</th>
</tr>
</thead>
<tbody>\n";

foreach ($temp as $k => $v) {
$translation = array_key_exists($k, $strings[$repo_one])
Expand All @@ -286,7 +300,7 @@
. '</tr>';
}

$table .= '</table>';
$table .= "</tbody>\n</table>\n";

return $table;
};
Expand Down
17 changes: 10 additions & 7 deletions app/views/results_entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@

$table = "
<table class='collapsable'>
<tr>
<th>Entity</th>
<th>{$source_locale}</th>
<th>{$locale}</th>
{$extra_column_header}
</tr>";
<thead>
<tr class='column_headers'>
<th>Entity</th>
<th>{$source_locale}</th>
<th>{$locale}</th>
{$extra_column_header}
</tr>
</thead>
<tbody>\n";

$current_repo = $check['repo'];
// Display results
Expand Down Expand Up @@ -109,7 +112,7 @@
</tr>\n";
}

$table .= "</table>\n\n";
$table .= "</tbody>\n</table>\n\n";
if ($entities) {
print $table;
}
13 changes: 8 additions & 5 deletions app/views/results_glossary.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@

echo "<h2>Results</h2>
<table class='collapsable'>
<tr>
<th>Localized string</th>
<th>Source string</th>
</tr>\n";
<thead>
<tr class='column_headers'>
<th>Localized string</th>
<th>Source string</th>
</tr>
</thead>
<tbody>\n";

foreach ($imperfect_results as $string_id => $string_value) {
$entity_link = "/?sourcelocale={$source_locale}"
Expand All @@ -30,7 +33,7 @@
echo " <td dir='{$source_locale_dir}'><span class='celltitle'>Source string</span><div class='string'>" . Utils::secureText($tmx_source[$string_id]) . "</div></td>\n";
echo "</tr>\n";
}
echo "</table>\n";
echo "</tbody>\n</table>\n";
} else {
echo " <p>No perfect match found.</p>\n</div>\n";
}
Loading

0 comments on commit 7786a92

Please sign in to comment.