|
1 | 1 | <?php |
2 | 2 | namespace Transvision; |
3 | 3 |
|
4 | | -require_once INC . 'l10n-init.php'; |
5 | | - |
6 | | -$strings[$repo] = Utils::getRepoStrings($locale, $repo); |
7 | | -$strings_english[$repo] = Utils::getRepoStrings('en-US', $repo); |
8 | | - |
9 | | -$channel_selector = Utils::getHtmlSelectOptions( |
10 | | - array_intersect_key( |
11 | | - $repos_nice_names, |
12 | | - array_flip($desktop_repos) |
13 | | - ), |
14 | | - $repo, |
15 | | - true |
16 | | -); |
17 | | - |
18 | | -// Get the locale list |
19 | | -$loc_list = Project::getRepositoryLocales($repo); |
20 | | - |
21 | | -// Build the target locale switcher |
22 | | -$target_locales_list = Utils::getHtmlSelectOptions($loc_list, $locale); |
23 | | - |
24 | | -$akeys = array_filter( |
25 | | - array_keys($strings[$repo]), |
26 | | - function ($entity) { |
27 | | - return substr($entity, -9) == 'accesskey'; |
| 4 | +// Include the common simple search form |
| 5 | +include __DIR__ . '/simplesearchform.php'; |
| 6 | + |
| 7 | +if (! empty($ak_results)) { |
| 8 | + $search_id = 'accesskeys'; |
| 9 | + $content = ''; |
| 10 | + if (! empty($error_messages)) { |
| 11 | + $content .= '<p class="error">' . |
| 12 | + implode('<br/>', $error_messages) . |
| 13 | + '</p>'; |
28 | 14 | } |
29 | | -); |
30 | | - |
31 | | -$ak_labels = ['.label', '.title', '.title2']; |
32 | | -$ak_results = []; |
33 | | - |
34 | | -foreach ($akeys as $akey) { |
35 | | - $entity = substr($akey, 0, -10); |
36 | | - $akey_value = $strings[$repo][$akey]; |
37 | | - |
38 | | - foreach ($ak_labels as $ak_label) { |
39 | | - if (isset($strings[$repo][$entity . $ak_label]) |
40 | | - && !empty($strings[$repo][$entity . $ak_label]) |
41 | | - && isset($strings_english[$repo][$akey]) |
42 | | - && !empty($strings_english[$repo][$akey]) |
43 | | - ) { |
44 | | - if ($akey_value == '') { |
45 | | - $ak_results[$akey] = $entity . $ak_label; |
46 | | - } elseif (mb_stripos($strings[$repo][$entity . $ak_label], $akey_value) === false) { |
47 | | - $ak_results[$akey] = $entity . $ak_label; |
48 | | - } else { |
49 | | - break; |
50 | | - } |
51 | | - } |
| 15 | + $content .= "<h2><span class=\"results_count_{$search_id}\">" |
| 16 | + . Utils::pluralize(count($ak_results), 'potential access key error') |
| 17 | + . "</span> found</h2>\n"; |
| 18 | + |
| 19 | + if (isset($filter_block)) { |
| 20 | + $content .= "<div id='filters'>" . |
| 21 | + " <h4>Filter by folder:</h4>\n" . |
| 22 | + " <a href='#showall' id='showall' class='filter'>Show all results</a>\n" . |
| 23 | + $filter_block . |
| 24 | + "</div>\n"; |
| 25 | + } |
| 26 | + |
| 27 | + $content .= " |
| 28 | + <table class='collapsable results_table sortable {$search_id}'> |
| 29 | + <thead> |
| 30 | + <tr class='column_headers'> |
| 31 | + <th>Entity</th> |
| 32 | + <th>Label</th> |
| 33 | + <th>Access key</th> |
| 34 | + <th>Access key entity</th> |
| 35 | + </tr> |
| 36 | + </thead> |
| 37 | + <tbody>\n"; |
| 38 | + |
| 39 | + // Get the tool used to edit strings for the target locale |
| 40 | + $toolUsedByTargetLocale = Project::getLocaleTool($locale); |
| 41 | + |
| 42 | + foreach ($ak_results as $ak_string => $ak_label) { |
| 43 | + // Link to entity |
| 44 | + $ak_link = "?sourcelocale={$reference_locale}" . |
| 45 | + "&locale={$locale}" . |
| 46 | + "&repo={$repo}" . |
| 47 | + "&search_type=entities&recherche={$ak_string}" . |
| 48 | + '&entire_string=entire_string'; |
| 49 | + $label_link = "?sourcelocale={$reference_locale}" . |
| 50 | + "&locale={$locale}" . |
| 51 | + "&repo={$repo}" . |
| 52 | + "&search_type=entities&recherche={$ak_label}" . |
| 53 | + '&entire_string=entire_string'; |
| 54 | + |
| 55 | + $path_ak = VersionControl::hgPath($locale, $repo, $ak_string); |
| 56 | + $path_label = VersionControl::hgPath($locale, $repo, $ak_label); |
| 57 | + |
| 58 | + $edit_link_ak = $toolUsedByTargetLocale != '' |
| 59 | + ? ShowResults::getEditLink($toolUsedByTargetLocale, $repo, $ak_string, $target[$ak_string], $locale) |
| 60 | + : ''; |
| 61 | + $edit_link_label = $toolUsedByTargetLocale != '' |
| 62 | + ? ShowResults::getEditLink($toolUsedByTargetLocale, $repo, $ak_label, $target[$ak_label], $locale) |
| 63 | + : ''; |
| 64 | + |
| 65 | + $ak_value = ! empty($target[$ak_string]) |
| 66 | + ? Utils::secureText($target[$ak_string]) |
| 67 | + : '<em class="error">(empty)</em>'; |
| 68 | + $label_value = ! empty($target[$ak_label]) |
| 69 | + ? Utils::secureText($target[$ak_label]) |
| 70 | + : '<em class="error">(empty)</em>'; |
| 71 | + |
| 72 | + $component = explode('/', $ak_string)[0]; |
| 73 | + $content .= "<tr class='{$component} {$search_id}'> |
| 74 | + <td> |
| 75 | + <span class='celltitle'>Entity</span> |
| 76 | + <span class='link_to_entity'> |
| 77 | + <a href=\"/{$label_link}\">" . ShowResults::formatEntity($ak_label) . "</a> |
| 78 | + </span> |
| 79 | + </td> |
| 80 | + <td dir='{$direction}'> |
| 81 | + <span class='celltitle'>Label</span> |
| 82 | + <div class='string'>{$label_value}</div> |
| 83 | + <div dir='ltr' class='result_meta_link'> |
| 84 | + <a class='source_link' href='{$path_label}'><source></a> |
| 85 | + {$edit_link_label} |
| 86 | + </div> |
| 87 | + </td> |
| 88 | + <td dir='{$direction}'> |
| 89 | + <span class='celltitle'>Access key</span> |
| 90 | + <div class='string'>{$ak_value}</div> |
| 91 | + <div dir='ltr' class='result_meta_link'> |
| 92 | + <a class='source_link' href='{$path_ak}'><source></a> |
| 93 | + {$edit_link_ak} |
| 94 | + </div> |
| 95 | + </td> |
| 96 | + <td> |
| 97 | + <span class='celltitle'>Access key entity</span> |
| 98 | + <span class='link_to_entity'> |
| 99 | + <a href=\"/{$ak_link}\">" . ShowResults::formatEntity($ak_string) . "</a> |
| 100 | + </span> |
| 101 | + </td> |
| 102 | + </tr>\n"; |
52 | 103 | } |
| 104 | + $content .= "</tbody>\n</table>\n"; |
| 105 | +} else { |
| 106 | + $content = '<h2>Congratulations, no errors found.</h2>'; |
53 | 107 | } |
54 | | -// Include the common simple search form |
55 | | -include __DIR__ . '/simplesearchform.php'; |
56 | 108 |
|
57 | | -echo '<h2>' . count($ak_results) . ' potential accesskey errors</h2>'; |
58 | | -Utils::printSimpleTable( |
59 | | - $ak_results, |
60 | | - $strings[$repo], |
61 | | - ['Label entity', 'Label value', 'Access key', 'Access key entity'], |
62 | | - 'collapsable sortable' |
63 | | -); |
| 109 | +print $content; |
0 commit comments