|
1 | 1 | <?php |
2 | 2 | namespace Transvision; |
3 | 3 |
|
4 | | -// Promote API view |
5 | | -include VIEWS . 'templates/api_promotion.php'; |
6 | | - |
7 | 4 | $table = " |
8 | 5 | <table class='collapsable'> |
9 | 6 | <thead> |
|
19 | 16 | $current_repo = $search->getRepository(); |
20 | 17 | $extra_locale = $url['path'] == '3locales'; |
21 | 18 |
|
| 19 | +$components = []; |
22 | 20 | // Display results |
23 | 21 | foreach ($entities as $entity) { |
| 22 | + $component = explode('/', $entity)[0]; |
| 23 | + $components[] = $component; |
24 | 24 | if (in_array($current_repo, ['firefox_ios', 'mozilla_org'])) { |
25 | 25 | $path_locale1 = VersionControl::gitPath($source_locale, $current_repo, $entity); |
26 | 26 | $path_locale2 = VersionControl::gitPath($locale, $current_repo, $entity); |
|
164 | 164 | } |
165 | 165 |
|
166 | 166 | $table .= " |
167 | | - <tr> |
| 167 | + <tr class='{$component}'> |
168 | 168 | <td> |
169 | 169 | <span class='celltitle'>Entity</span> |
170 | 170 | <a class='resultpermalink tag' id='{$anchor_name}' href='#{$anchor_name}' title='Permalink to this result'>#</a> |
|
198 | 198 | </tr>\n"; |
199 | 199 | } |
200 | 200 |
|
| 201 | +// Remove duplicated components |
| 202 | +$components = array_unique($components); |
| 203 | +if (Project::isDesktopRepository($search->getRepository())) { |
| 204 | + // Build logic to filter components |
| 205 | + $filter_block = ''; |
| 206 | + foreach ($components as $value) { |
| 207 | + $filter_block .= " <a href='#{$value}' id='{$value}' class='filter'>{$value}</a>"; |
| 208 | + } |
| 209 | +} |
| 210 | +if (isset($filter_block)): |
| 211 | +?> |
| 212 | +<div id="filters"> |
| 213 | + <h4>Filter by folder:</h4> |
| 214 | + <a href="#showall" id="showall" class="filter">Show all results</a> |
| 215 | + <?=$filter_block;?> |
| 216 | +</div> |
| 217 | +<?php |
| 218 | +endif; |
| 219 | + |
201 | 220 | $table .= "</tbody>\n</table>\n\n"; |
202 | 221 | if ($entities) { |
203 | 222 | print $table; |
204 | 223 | } |
| 224 | + |
| 225 | +// Promote API view |
| 226 | +include VIEWS . 'templates/api_promotion.php'; |
0 commit comments