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