Completed
Pull Request — master (#12)
by
unknown
25s
created

index.php (1 issue)

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