Skip to content

Commit 7786a92

Browse files
committed
Use table head instead of a special row for column headers
1 parent 97185bc commit 7786a92

13 files changed

Lines changed: 169 additions & 116 deletions

app/classes/Transvision/ShowResults.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,15 @@ public static function resultsTable($search_id, $search_results, $recherche, $lo
260260
}
261261

262262
$table = "<table class='collapsable results_table {$search_id}'>
263-
<tr class='column_headers'>
264-
<th>Entity</th>
265-
<th>{$locale1}</th>
266-
<th>{$locale2}</th>
267-
{$extra_column_header}
268-
</tr>";
263+
<thead>
264+
<tr class='column_headers'>
265+
<th>Entity</th>
266+
<th>{$locale1}</th>
267+
<th>{$locale2}</th>
268+
{$extra_column_header}
269+
</tr>
270+
</thead>
271+
<tbody>\n";
269272

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

471-
$table .= " </table>";
474+
$table .= " </tbody>\n</table>\n";
472475

473476
return $table;
474477
}

app/classes/Transvision/Utils.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ public static function printSimpleTable(
151151
} else {
152152
echo '<table>';
153153
}
154-
echo '<tr>' .
155-
"<th>{$titles[0]}</th><th>{$titles[1]}</th>";
154+
echo "<thead>\n <tr class='column_headers'>\n" .
155+
" <th>{$titles[0]}</th><th>{$titles[1]}</th>\n";
156156

157157
if ($arr2) {
158-
echo "<th>{$titles[2]}</th><th>{$titles[3]}</th>";
158+
echo " <th>{$titles[2]}</th><th>{$titles[3]}</th>\n";
159159
}
160160

161-
echo '</tr>';
161+
echo " </tr>\n</thead>\n<tbody>\n";
162162

163163
foreach ($arr as $key => $val) {
164164
echo '<tr>';
@@ -173,7 +173,7 @@ public static function printSimpleTable(
173173
}
174174
echo '</tr>';
175175
}
176-
echo '</table>';
176+
echo "</tbody>\n</table>\n";
177177
}
178178

179179
/**

app/models/unlocalized_words.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,13 @@
6060
Remove punctuation characters from the strings then explode them into
6161
words.
6262
*/
63+
$ref_words = strip_tags($ref_words);
6364
$ref_words = explode(
6465
' ',
6566
preg_replace('/\p{P}/u', '', $ref_words)
6667
);
68+
69+
$locale_words = strip_tags($locale_words);
6770
$locale_words = explode(
6871
' ',
6972
preg_replace('/\p{P}/u', '', $locale_words)

app/views/channelcomparison.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@
3434
echo "<h3>Comparison is empty</h3>\n" .
3535
"<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";
3636
} else {
37-
echo "\n<table class='collapsable'>" .
38-
" <tr>\n" .
39-
" <th colspan='3'>Locale: {$locale}</th>\n" .
40-
" </tr>\n" .
41-
" <tr>\n" .
42-
" <th>Key</th>\n" .
43-
" <th>{$chan1}</th>\n" .
44-
" <th>{$chan2}</th>\n" .
45-
" </tr>\n";
37+
echo "
38+
<h2>Locale: {$locale}</h2>
39+
<table class='collapsable'>
40+
<thead>
41+
<tr class='column_headers'>
42+
<th>Key</th>
43+
<th>{$chan1}</th>
44+
<th>{$chan2}</th>
45+
</tr>
46+
</thead>
47+
<tbody>\n";
4648

4749
foreach ($common_strings as $key => $value) {
4850
echo " <tr>"
@@ -51,5 +53,5 @@
5153
. " <td><span class='celltitle'>{$chan2}</span><div class='string'>" . ShowResults::highlight($strings[$chan2][$key]) . "</div></td>\n"
5254
. " </tr>\n";
5355
}
54-
echo "</table>\n";
56+
echo "</tbody>\n</table>\n";
5557
}

app/views/check_variables.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@
1818
"</div>\n";
1919
}
2020

21-
$content .= "<table class='collapsable results_table {$search_id}'>\n" .
22-
" <tr>\n" .
23-
" <th>Entity</th>\n" .
24-
" <th>{$source_locale}</th>\n" .
25-
" <th>{$locale}</th>\n" .
26-
" </tr>\n";
21+
$content .= "
22+
<table class='collapsable results_table {$search_id}'>
23+
<thead>
24+
<tr class='column_headers'>
25+
<th>Entity</th>
26+
<th>{$source_locale}</th>
27+
<th>{$locale}</th>
28+
</tr>
29+
</thead>
30+
<tbody>\n";
2731

2832
foreach ($var_errors as $string_id) {
2933
// Link to entity
@@ -62,7 +66,7 @@
6266
</td>
6367
</tr>\n";
6468
}
65-
$content .= "</table>\n";
69+
$content .= "</tbody>\n</table>\n";
6670
} else {
6771
$content = "<h2>Congratulations, no errors found.</h2>";
6872
}

app/views/consistency.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@
3333
} else {
3434
?>
3535
<table>
36-
<tr>
36+
<thead>
37+
<tr class="column_headers">
3738
<th>English String</th>
3839
<th>Available Translations</th>
3940
</tr>
41+
</thead>
42+
<tbody>
4043
<?php
4144
foreach ($inconsistent_translations as $data) {
4245
$search_link = "/?sourcelocale={$reference_locale}"
@@ -52,5 +55,5 @@
5255
}
5356
echo "</td>\n</tr>\n";
5457
}
55-
echo "</table>\n";
58+
echo "</tbody>\n</table>\n";
5659
}

app/views/gaia.php

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@
100100
// Overview of string count for the locale
101101
$overview = function ($section_title, $columns, $rows, $anchor) {
102102
// Titles
103-
$html = '<table id="' . $anchor . '">'
104-
. '<tr>'
105-
. '<th colspan="3">' . $section_title . '</th>'
106-
. '</tr>'
107-
. '<tr>';
103+
$html = "
104+
<p class='section_title'>{$section_title}</p>
105+
<table id='{$anchor}'>
106+
<thead>
107+
<tr class='column_headers'>";
108108
foreach ($columns as $key => $value) {
109109
$html .= '<th>' . $value . '</th>';
110110
}
111-
$html .= '</tr>';
111+
$html .= "</tr>\n</thead>\n<tbody>\n";
112112

113113
// Rows
114114
foreach ($rows as $key => $row) {
@@ -118,7 +118,7 @@
118118
}
119119
$html .= '</tr>';
120120
}
121-
$html .= '</table>';
121+
$html .= "</tbody>\n</table>\n";
122122

123123
return $html;
124124
};
@@ -174,17 +174,18 @@
174174
$nb_sources = count($diverging_sources) + 1;
175175
$width = 100 / $nb_sources;
176176

177-
$table = '<table id="' . $anchor . '" class="collapsable">'
178-
. '<tr>'
179-
. '<th colspan="' . $nb_sources . '">' . count($divergences) . ' diverging translations across repositories</th>'
180-
. '</tr>'
181-
. '<tr>';
182-
$table .= "<th style=\"width:$width%\">Keys</th>";
177+
$section_title = count($divergences) . ' diverging translations across repositories';
178+
$table = "
179+
<p class='section_title'>{$section_title}</p>
180+
<table id='{$anchor}' class='collapsable'>
181+
<thead>
182+
<tr class='column_headers'>
183+
<th style='width: {$width}%;'>Keys</th>";
183184
foreach ($diverging_sources as $key => $repo_name) {
184-
$table .= "<th style=\"width:$width%\">" . $repos_nice_names[$repo_name] . '</th>';
185+
$table .= "<th style='width: $width%;'>{$repos_nice_names[$repo_name]}</th>\n";
185186
}
186187

187-
$table .= '</tr>';
188+
$table .= "</tr>\n</thead>\n<tbody>\n";
188189

189190
foreach ($divergences as $v) {
190191
$table .= '<tr>'
@@ -195,7 +196,7 @@
195196
$table .= '</tr>';
196197
}
197198

198-
$table .= '</table>';
199+
$table .= "</tbody>\n</table>\n";
199200

200201
return $table;
201202
};
@@ -217,16 +218,21 @@
217218

218219
$repo_one = $repos_nice_names[$englishchanges[0]];
219220
$repo_two = $repos_nice_names[$englishchanges[1]];
220-
$table = '<table id="englishchanges" class="collapsable">'
221-
. '<tr>'
222-
. '<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>'
223-
. '</tr>'
224-
. '<tr>'
225-
. '<th>Key</th>'
226-
. '<th>' . $repo_one . '</th>'
227-
. '<th>' . $repo_two . '</th>'
228-
. '</tr>';
229221

222+
$section_title = "Strings that have changed significantly in English between {$repo_one} and {$repo_two} but for which the entity name didn’t change";
223+
$table = "
224+
<p class='section_title'>{$section_title}</p>
225+
<table id='englishchanges' class='collapsable'>
226+
<thead>
227+
<tr class='column_headers'>
228+
<th>Key</th>
229+
<th>{$repo_one}</th>
230+
<th>{$repo_two}</th>
231+
</tr>
232+
</thead>
233+
<tbody>\n";
234+
235+
$changed_strings = 0;
230236
foreach ($common_keys as $key => $val) {
231237
$get_localized_string = function ($id) use ($key, $strings) {
232238
// Avoid warnings if the string is not localized
@@ -246,9 +252,14 @@
246252
. ShowResults::highlight(Utils::secureText($strings[$englishchanges[1] . '-en-US'][$key]))
247253
. '<br><small>' . $get_localized_string($englishchanges[1]) . '</small></div></td>'
248254
. '</tr>';
255+
$changed_strings++;
249256
}
250257
}
251-
$table .= '</table>';
258+
259+
if ($changed_strings == 0) {
260+
$table .= "<tr><td colspan='3' class='no_highligth'>There are no changed strings.</td></tr>\n";
261+
}
262+
$table .= "</tbody>\n</table>\n";
252263

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

266-
$table = '<table id="' . $anchor . '" class="' . $cssclass . '">'
267-
. '<tr>'
268-
. '<th colspan="3">' . $comparison_type . ' between ' . $repos_nice_names[$repo_one] . ' and ' . $repos_nice_names[$repo_two] . '</th>'
269-
. '</tr>'
270-
. '<tr>'
271-
. '<th>Key</th>'
272-
. '<th>New strings</th>'
273-
. '</tr>';
277+
$section_title = "{$comparison_type} between {$repos_nice_names[$repo_one]} and {$repos_nice_names[$repo_two]}";
278+
$table = "
279+
<p class='section_title'>{$section_title}</p>
280+
<table id='{$anchor}' class='{$cssclass}'>
281+
<thead>
282+
<tr class='column_headers'>
283+
<th>Key</th>
284+
<th>New strings</th>
285+
</tr>
286+
</thead>
287+
<tbody>\n";
274288

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

289-
$table .= '</table>';
303+
$table .= "</tbody>\n</table>\n";
290304

291305
return $table;
292306
};

app/views/results_entities.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66

77
$table = "
88
<table class='collapsable'>
9-
<tr>
10-
<th>Entity</th>
11-
<th>{$source_locale}</th>
12-
<th>{$locale}</th>
13-
{$extra_column_header}
14-
</tr>";
9+
<thead>
10+
<tr class='column_headers'>
11+
<th>Entity</th>
12+
<th>{$source_locale}</th>
13+
<th>{$locale}</th>
14+
{$extra_column_header}
15+
</tr>
16+
</thead>
17+
<tbody>\n";
1518

1619
$current_repo = $check['repo'];
1720
// Display results
@@ -109,7 +112,7 @@
109112
</tr>\n";
110113
}
111114

112-
$table .= "</table>\n\n";
115+
$table .= "</tbody>\n</table>\n\n";
113116
if ($entities) {
114117
print $table;
115118
}

app/views/results_glossary.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414

1515
echo "<h2>Results</h2>
1616
<table class='collapsable'>
17-
<tr>
18-
<th>Localized string</th>
19-
<th>Source string</th>
20-
</tr>\n";
17+
<thead>
18+
<tr class='column_headers'>
19+
<th>Localized string</th>
20+
<th>Source string</th>
21+
</tr>
22+
</thead>
23+
<tbody>\n";
2124

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

0 commit comments

Comments
 (0)