ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $log[$rec["module"] . ":" . $rec["identifier"]] = 1;
54 }
55 $set = $this->db->query("SELECT module, identifier FROM lng_data WHERE lang_key = " .
56 $this->db->quote("en", "text") . " ORDER BY module, identifier");
57 while ($rec = $this->db->fetchAssoc($set)) {
58 if (!isset($log[$rec["module"] . ":" . $rec["identifier"]])) {
59 $this->candidates[$rec["identifier"]] = $rec["module"];
60 }
61 }
62 }
63
67 protected function parseCodeFiles()
68 {
69 foreach ($this->getCodeFiles(ILIAS_ABSOLUTE_PATH) as $file) {
70 $this->parseCodeFile($file->getPathname());
71 }
72 }
73
78 protected function getCodeFiles($path)
79 {
80 foreach (
81 new \RegexIterator(
82 new \RecursiveIteratorIterator(
83 new \RecursiveDirectoryIterator($path),
84 \RecursiveIteratorIterator::SELF_FIRST,
85 \RecursiveIteratorIterator::CATCH_GET_CHILD
86 ),
87 '/' . self::ILIAS_CLASS_FILE_RE . '/i'
88 ) as $file
89 ) {
90 yield $file;
91 }
92 }
93
99 protected function parseCodeFile($file_path)
100 {
101 $tokens = token_get_all(file_get_contents($file_path));
102
103 /*if (is_int(strpos($file_path, "TrackingItemsTableGUI")))
104 {
105 $transl = array_map(function($e) {
106 return array(token_name($e[0]), $e[1], $e[2]);
107 }, $tokens);
108
109 var_dump($transl); exit;
110 }*/
111
112 $num_tokens = count($tokens);
113
114 for ($i = 0; $i < $num_tokens; $i++) {
115 if (is_string($tokens[$i])) {
116 continue;
117 }
118
119 $token = $tokens[$i][0];
120 switch ($token) {
121
122 case T_STRING:
123 case T_CONSTANT_ENCAPSED_STRING:
124 $lv = str_replace(array("'", '"'), "", $tokens[$i][1]);
125 if ($lv != "") {
126 unset($this->candidates[$lv]);
127 }
128 break;
129 }
130 }
131 }
132}
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
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
global $DIC
Definition: saml.php:7