Completed
Push — master ( 394ecf...2ae0a1 )
by Adam
02:35 queued 01:17
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/* PROJECT:     ReactOS Translation Tool
3
 * LICENSE:     GPL
4
 * AUTHORS:     Adam Stachowicz <[email protected]>
5
 * AUTHOR URL:  http://it-maniak.pl/
6
 */
7
8
include_once 'header.php';
9
include_once 'langcodes.php';
10
?>
11
12
<h1>Search missing RC files</h1>
13
14
<div id="body">
15
<center>
16
    <form method="GET" class="form-horizontal">
17
        <fieldset>
18
            <legend>Please choose your language from the list below. </legend>
19
            <div class="form-group">
20
                <label class="col-md-4 control-label" for="lang">Language:</label>
21
                <div class="col-md-4">
22
                    <select id="lang" name="lang" class="form-control" required="required">
23
                        <?php
24 View Code Duplication
                        foreach ($langcodes as $language) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
                            echo '<option value="'.$language[0].'" ';
26
                            if (isset($_SESSION['lang']) && $language[0] == $_SESSION['lang']) {
27
                                echo 'selected';
28
                            }
29
                            echo '>'.$language[1].'</option>';
30
                        }?>
31
                    </select>
32
                </div>
33
            </div>
34
            <button type="submit" class="btn btn-primary">Search</button>
35
        </fieldset>
36
    </form>
37
</center>
38
<br>
39
40
<?php
41
if (isset($_GET['lang']) && !empty($_GET['lang'])) {
42
                            $it = new AppendIterator();
43
44
                            if ($test === false) {
45
                                $directories = [
46
                                    new RecursiveDirectoryIterator($ROSDir.'base/applications'),
47
                                    new RecursiveDirectoryIterator($ROSDir.'base/setup'),
48
                                    new RecursiveDirectoryIterator($ROSDir.'base/shell'),
49
                                    new RecursiveDirectoryIterator($ROSDir.'base/system'),
50
                                    new RecursiveDirectoryIterator($ROSDir.'boot/freeldr/fdebug'),
51
                                    new RecursiveDirectoryIterator($ROSDir.'dll/cpl'),
52
                                    new RecursiveDirectoryIterator($ROSDir.'dll/shellext'),
53
                                    new RecursiveDirectoryIterator($ROSDir.'dll/win32'),
54
                                    new RecursiveDirectoryIterator($ROSDir.'media/themes'),
55
                                    new RecursiveDirectoryIterator($ROSDir.'subsystems/mvdm/ntvdm'),
56
                                    new RecursiveDirectoryIterator($ROSDir.'win32ss/user'),
57
                                ];
58
                            } else {
59
                                // Search in source dir - only for test
60
                                $directories = [
61
                                    new RecursiveDirectoryIterator($ROSDir),
62
                                ];
63
                            }
64
65
                            foreach ($directories as $directory) {
66
                                $it->append(new RecursiveIteratorIterator($directory));
67
                            }
68
69
                            $regex = new RegexIterator($it, '/^.+'.$langDir.'.+('.$originLang.')\.'.$fileExt.'$/i', RecursiveRegexIterator::GET_MATCH);
70
71
                            $allEnglish = $missingFiles = 0;
72
73
                            $lang = htmlspecialchars($_GET['lang']);
74
                            // Search for eg. PL,Pl,pl
75
                            $fileSearch = strtoupper($lang).','.ucfirst($lang).','.strtolower($lang);
76
77
                            $regex->rewind();
78
                            while ($regex->valid()) {
79
                                if (!$regex->isDot()) {
80
                                    $file = glob($regex->getPathInfo().'/*{'.$fileSearch.'}*.'.$fileExt, GLOB_BRACE);
81
82
                                    $isFile = array_filter($file);
83
                                    if (empty($isFile)) {
84
                                        $pathFromRoot = str_replace($ROSDir, '', $regex->getPathInfo());
85
                                        echo '<b>No translation</b> for path '.$regex->getPathInfo().' <a href="https://github.com/reactos/reactos/tree/master/'.$pathFromRoot.'"><strong>Go to GitHub</strong></a><br>';
86
                                        $missingFiles++;
87
                                    }
88
                                    $allEnglish++;
89
                                }
90
                                $regex->next();
91
                            }
92
93
                            if ($missingFiles <= 0) {
94
                                echo '<h3><b>No</b> missing file translations found for your language!</h3>';
95
                            }
96
97
                            $languppercase = strtoupper($lang);
98
99
                            echo "<h3>All translation RC files for english: $allEnglish</h3>";
100
                            echo "<h3>Missing translations files for your language ($languppercase): $missingFiles</h3>";
101
                        }
102
103
include_once 'footer.php';
104