ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
27  $this->db = $DIC->database();
28  }
29 
35  public function getDeprecatedLangVars()
36  {
37  $this->getCandidates();
38  $this->parseCodeFiles();
39  return $this->candidates;
40  }
41 
46  protected function getCandidates()
47  {
48  $this->candidates = array();
49 
50  $log = array();
51  $set = $this->db->query("SELECT module, identifier FROM lng_log ");
52  while ($rec = $this->db->fetchAssoc($set))
53  {
54  $log[$rec["module"].":".$rec["identifier"]] = 1;
55  }
56  $set = $this->db->query("SELECT module, identifier FROM lng_data WHERE lang_key = ".
57  $this->db->quote("en", "text")." ORDER BY module, identifier");
58  while ($rec = $this->db->fetchAssoc($set))
59  {
60  if (!isset($log[$rec["module"].":".$rec["identifier"]]))
61  {
62  $this->candidates[$rec["identifier"]] = $rec["module"];
63  }
64  }
65  }
66 
70  protected function parseCodeFiles()
71  {
72  foreach ($this->getCodeFiles(ILIAS_ABSOLUTE_PATH) as $file)
73  {
74  $this->parseCodeFile($file->getPathname());
75  }
76  }
77 
82  protected function getCodeFiles($path)
83  {
84  foreach (
85  new \RegexIterator(
87  new \RecursiveDirectoryIterator($path),
88  \RecursiveIteratorIterator::SELF_FIRST,
89  \RecursiveIteratorIterator::CATCH_GET_CHILD
90  ), '/' . self::ILIAS_CLASS_FILE_RE . '/i'
91  ) as $file
92  ) {
93  yield $file;
94  }
95  }
96 
102  protected function parseCodeFile($file_path)
103  {
104  $tokens = token_get_all(file_get_contents($file_path));
105 
106  /*if (is_int(strpos($file_path, "TrackingItemsTableGUI")))
107  {
108  $transl = array_map(function($e) {
109  return array(token_name($e[0]), $e[1], $e[2]);
110  }, $tokens);
111 
112  var_dump($transl); exit;
113  }*/
114 
115  $num_tokens = count($tokens);
116 
117  for ($i = 0; $i < $num_tokens; $i++) {
118  if (is_string($tokens[$i])) {
119  continue;
120  }
121 
122  $token = $tokens[$i][0];
123  switch ($token) {
124 
125  case T_STRING:
126  case T_CONSTANT_ENCAPSED_STRING:
127  $lv = str_replace(array("'", '"'), "", $tokens[$i][1]);
128  if ($lv != "") {
129  unset($this->candidates[$lv]);
130  }
131  break;
132  }
133  }
134  }
135 
136 
137 }
138 
139 ?>
$path
Definition: aliased.php:25
__construct()
ilLangDeprecated constructor.
parseCodeFiles()
Parse Code Files.
Search for deprecated lang vars.
getDeprecatedLangVars()
Get deprecated lang vars.
getCandidates()
Get candidates from the db.
Create styles array
The data for the language used.
parseCodeFile($file_path)
Parse code file and reduce candidates.
global $DIC
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file