1 | <?php |
||
9 | class Scanner |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * @return array $phrases |
||
14 | */ |
||
15 | public function search() |
||
16 | { |
||
17 | $phrases = []; |
||
18 | $files_pattern = "/.*\\.(volt|php|phtml)$/"; |
||
19 | $files_plugins = $this->rsearch(APPLICATION_PATH . '/plugins', $files_pattern); |
||
20 | $files_modules = $this->rsearch(APPLICATION_PATH . '/modules', $files_pattern); |
||
21 | $files_views = $this->rsearch(APPLICATION_PATH . '/views', $files_pattern); |
||
22 | $files = array_merge($files_plugins, $files_views, $files_modules); |
||
23 | if (!empty($files)) { |
||
24 | foreach ($files as $file) { |
||
25 | if (file_exists($file)) { |
||
26 | $contents = file_get_contents($file); |
||
27 | $pattern = "/translate\('(.+?)'(?:.*)\)/"; |
||
28 | $matchesCount = preg_match_all($pattern, $contents, $matches); |
||
29 | if ($matchesCount) { |
||
30 | foreach ($matches[1] as $match) { |
||
31 | if (!in_array($match, $phrases)) { |
||
32 | $phrases[] = $match; |
||
33 | } |
||
34 | } |
||
35 | } |
||
36 | } |
||
37 | } |
||
38 | } |
||
39 | return $phrases; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @param string $folder |
||
44 | * @param string $pattern |
||
45 | * @return array $fileList |
||
46 | */ |
||
47 | private function rsearch($folder, $pattern) |
||
58 | |||
59 | } |
||
60 |