ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilLangDeprecated.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
13 const ILIAS_CLASS_FILE_RE = 'class\..*\.php$';
14
18 protected $candidates = array();
19
23 public function __construct()
24 {
25 global $DIC;
26 $this->db = $DIC->database();
27 }
28
34 public function getDeprecatedLangVars()
35 {
36 $this->getCandidates();
37 $this->parseCodeFiles();
38 return $this->candidates;
39 }
40
45 protected function getCandidates()
46 {
47 $this->candidates = array();
48
49 $log = array();
50 $set = $this->db->query("SELECT module, identifier FROM lng_log ");
51 while ($rec = $this->db->fetchAssoc($set)) {
52 $log[$rec["module"] . ":" . $rec["identifier"]] = 1;
53 }
54 $set = $this->db->query("SELECT module, identifier FROM lng_data WHERE lang_key = " .
55 $this->db->quote("en", "text") . " ORDER BY module, identifier");
56 while ($rec = $this->db->fetchAssoc($set)) {
57 if (!isset($log[$rec["module"] . ":" . $rec["identifier"]])) {
58 $this->candidates[$rec["identifier"]] = $rec["module"];
59 }
60 }
61 }
62
66 protected function parseCodeFiles()
67 {
68 foreach ($this->getCodeFiles(ILIAS_ABSOLUTE_PATH) as $file) {
69 $this->parseCodeFile($file->getPathname());
70 }
71 }
72
77 protected function getCodeFiles($path)
78 {
79 foreach (
80 new \RegexIterator(
81 new \RecursiveIteratorIterator(
82 new \RecursiveDirectoryIterator($path),
83 \RecursiveIteratorIterator::SELF_FIRST,
84 \RecursiveIteratorIterator::CATCH_GET_CHILD
85 ),
86 '/' . self::ILIAS_CLASS_FILE_RE . '/i'
87 ) as $file
88 ) {
89 yield $file;
90 }
91 }
92
98 protected function parseCodeFile($file_path)
99 {
100 $tokens = token_get_all(file_get_contents($file_path));
101
102 /*if (is_int(strpos($file_path, "TrackingItemsTableGUI")))
103 {
104 $transl = array_map(function($e) {
105 return array(token_name($e[0]), $e[1], $e[2]);
106 }, $tokens);
107
108 var_dump($transl); exit;
109 }*/
110
111 $num_tokens = count($tokens);
112
113 for ($i = 0; $i < $num_tokens; $i++) {
114 if (is_string($tokens[$i])) {
115 continue;
116 }
117
118 $token = $tokens[$i][0];
119 switch ($token) {
120
121 case T_STRING:
122 case T_CONSTANT_ENCAPSED_STRING:
123 $lv = str_replace(array("'", '"'), "", $tokens[$i][1]);
124 if ($lv != "") {
125 unset($this->candidates[$lv]);
126 }
127 break;
128 }
129 }
130 }
131}
$path
Definition: aliased.php:25
An exception for terminatinating execution or to throw for unit testing.
Search for deprecated lang vars.
parseCodeFiles()
Parse Code Files.
getDeprecatedLangVars()
Get deprecated lang vars.
parseCodeFile($file_path)
Parse code file and reduce candidates.
__construct()
ilLangDeprecated constructor.
getCandidates()
Get candidates from the db.
$i
Definition: disco.tpl.php:19
$log
Definition: sabredav.php:21
global $DIC
Definition: saml.php:7