Completed
Push — master ( 010dca...92d20c )
by Adam
04:04
created

index.php (2 issues)

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
include_once('header.php');
8
?>
9
10
<h1>Search missing RC files</h1>
11
12
<div id="body">
13
<?php require_once('config.php'); ?>
14
15
<center>
16
    <legend>Please type your <a href="https://beta.wikiversity.org/wiki/List_of_ISO_639-1_codes">language code in ISO 639-1</a>. For example: pl for Polish, de for German</legend>
17
    <form method="GET" class="form-horizontal">
18
        <fieldset>
19
            <div class="form-group">
20
                <label class="col-md-4 control-label" for="lang">Language code:</label>
21
                <div class="col-md-4">
22
                    <input type="text" value="<?php echo isset($_SESSION['lang']) ? $_SESSION['lang'] : "" ?>" id="lang" name="lang" class="form-control input-md" required="required" autofocus="autofocus" pattern="[A-Za-z]{2}" title="Two letter language code"/>
23
                </div>
24
            </div>
25
            <button type="submit" class="btn btn-primary">Search</button>
26
        </fieldset>
27
    </form>
28
</center>
29
<br/>
30
31
<?php
32
if (isset($_GET["lang"]) && !empty($_GET["lang"]))
33
{
34
    $directory1 = new RecursiveDirectoryIterator($ROSDir. "base/applications");
35
    $directory2 = new RecursiveDirectoryIterator($ROSDir. "base/setup");
36
    $directory3 = new RecursiveDirectoryIterator($ROSDir. "base/shell");
37
    $directory4 = new RecursiveDirectoryIterator($ROSDir. "base/system");
38
    $directory5 = new RecursiveDirectoryIterator($ROSDir. "boot/freeldr/fdebug");
39
40
    $directory6 = new RecursiveDirectoryIterator($ROSDir. "dll/cpl");
41
    $directory7 = new RecursiveDirectoryIterator($ROSDir. "dll/shellext");
42
    $directory8 = new RecursiveDirectoryIterator($ROSDir. "dll/win32");
43
44
    $directory9 = new RecursiveDirectoryIterator($ROSDir. "media/themes");
45
    $directory10 = new RecursiveDirectoryIterator($ROSDir. "subsystems/mvdm/ntvdm");
46
    $directory11 = new RecursiveDirectoryIterator($ROSDir. "win32ss/user");
47
    // Search in source dir - only for test
48
    // $directory100 = new RecursiveDirectoryIterator($ROSDir);
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
49
50
    $it = new AppendIterator();
51
    $it->append(new RecursiveIteratorIterator( $directory1 ));
52
    $it->append(new RecursiveIteratorIterator( $directory2 ));
53
    $it->append(new RecursiveIteratorIterator( $directory3 ));
54
    $it->append(new RecursiveIteratorIterator( $directory4 ));
55
    $it->append(new RecursiveIteratorIterator( $directory5 ));
56
    $it->append(new RecursiveIteratorIterator( $directory6 ));
57
    $it->append(new RecursiveIteratorIterator( $directory7 ));
58
    $it->append(new RecursiveIteratorIterator( $directory8 ));
59
    $it->append(new RecursiveIteratorIterator( $directory9 ));
60
    $it->append(new RecursiveIteratorIterator( $directory10 ));
61
    $it->append(new RecursiveIteratorIterator( $directory11 ));
62
    // Search in source dir - only for test
63
    // $it->append(new RecursiveIteratorIterator( $directory100));
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
64
65
    $regex = new RegexIterator($it, '/^.+'. $langDir .'.+('. $originLang .')\.'. $fileExt .'$/i', RecursiveRegexIterator::GET_MATCH);
66
67
    $allEnglish = $missingFiles = 0;
68
69
    $lang = htmlspecialchars($_GET["lang"]);
70
    // Search for eg. PL,Pl,pl
71
    $fileSearch = strtoupper($lang) .",". ucfirst($lang) .",". strtolower($lang);
72
73
    $regex->rewind();
74
    while($regex->valid())
75
    {
76
        if (!$regex->isDot())
77
        {
78
            $file = glob($regex->getPathInfo() ."/*{". $fileSearch ."}*.". $fileExt, GLOB_BRACE);
79
80
            $isFile = array_filter($file);
81
            if (empty($isFile))
82
            {
83
                echo '<b>No translation</b> for path '. $regex->getPathInfo() .'<br/>';
84
                $missingFiles++;
85
            }
86
            $allEnglish++;
87
        }
88
        $regex->next();
89
    }
90
91
    echo "<h3>All translation RC files for english: $allEnglish</h3>";
92
    echo "<h3>Missing translations files for your language ($lang): $missingFiles</h3>";
93
}
94
95
include_once('footer.php');
96