@@ -12,13 +12,13 @@ |
||
12 | 12 | } else { |
13 | 13 | echo "Received param ".Security::remove_XSS($_GET['doc'])."<br />"; |
14 | 14 | } |
15 | -$courses_list = CourseManager::get_courses_list(); |
|
15 | +$courses_list = CourseManager::get_courses_list(); |
|
16 | 16 | foreach ($courses_list as $course) { |
17 | 17 | $title = Database::escape_string($_GET['doc']); |
18 | 18 | $td = Database::get_course_table(TABLE_DOCUMENT); |
19 | 19 | $sql = "SELECT id, path FROM $td WHERE c_id = ".$course['id']." AND path LIKE '%$title%' OR title LIKE '%$title%'"; |
20 | 20 | $res = Database::query($sql); |
21 | - if (Database::num_rows($res)>0) { |
|
21 | + if (Database::num_rows($res) > 0) { |
|
22 | 22 | while ($row = Database::fetch_array($res)) { |
23 | 23 | echo "Found doc ".$row['id']."-> ".$row['path']." in course ".$course['code']."<br />"; |
24 | 24 | } |
@@ -8,19 +8,19 @@ |
||
8 | 8 | die(); |
9 | 9 | require '../../inc/global.inc.php'; |
10 | 10 | if (empty($_GET['doc'])) { |
11 | - echo "To add a document name to search, add ?doc=abc to the URL"; |
|
11 | + echo "To add a document name to search, add ?doc=abc to the URL"; |
|
12 | 12 | } else { |
13 | - echo "Received param ".Security::remove_XSS($_GET['doc'])."<br />"; |
|
13 | + echo "Received param ".Security::remove_XSS($_GET['doc'])."<br />"; |
|
14 | 14 | } |
15 | 15 | $courses_list = CourseManager::get_courses_list(); |
16 | 16 | foreach ($courses_list as $course) { |
17 | - $title = Database::escape_string($_GET['doc']); |
|
18 | - $td = Database::get_course_table(TABLE_DOCUMENT); |
|
19 | - $sql = "SELECT id, path FROM $td WHERE c_id = ".$course['id']." AND path LIKE '%$title%' OR title LIKE '%$title%'"; |
|
20 | - $res = Database::query($sql); |
|
21 | - if (Database::num_rows($res)>0) { |
|
17 | + $title = Database::escape_string($_GET['doc']); |
|
18 | + $td = Database::get_course_table(TABLE_DOCUMENT); |
|
19 | + $sql = "SELECT id, path FROM $td WHERE c_id = ".$course['id']." AND path LIKE '%$title%' OR title LIKE '%$title%'"; |
|
20 | + $res = Database::query($sql); |
|
21 | + if (Database::num_rows($res)>0) { |
|
22 | 22 | while ($row = Database::fetch_array($res)) { |
23 | - echo "Found doc ".$row['id']."-> ".$row['path']." in course ".$course['code']."<br />"; |
|
23 | + echo "Found doc ".$row['id']."-> ".$row['path']." in course ".$course['code']."<br />"; |
|
24 | + } |
|
24 | 25 | } |
25 | - } |
|
26 | 26 | } |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | FROM $users WHERE email = '$mail'\n"; |
35 | 35 | $res = Database::query($sql); |
36 | 36 | if ($res === false) { |
37 | - echo 'Error in database with email ' . $mail . "\n"; |
|
37 | + echo 'Error in database with email '.$mail."\n"; |
|
38 | 38 | } |
39 | 39 | if (Database::num_rows($res) == 0) { |
40 | - echo '[Error] Email not found in database: ' . $row['email'] . "\n"; |
|
40 | + echo '[Error] Email not found in database: '.$row['email']."\n"; |
|
41 | 41 | } else { |
42 | 42 | $row = Database::fetch_assoc($res); |
43 | - $pass = api_substr($row['username'], 0, 4) . rand(0, 9) . rand(0, 9); |
|
43 | + $pass = api_substr($row['username'], 0, 4).rand(0, 9).rand(0, 9); |
|
44 | 44 | |
45 | 45 | if ($user) { |
46 | 46 | |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | null, |
72 | 72 | PERSON_NAME_EMAIL_ADDRESS |
73 | 73 | ); |
74 | - $emailsubject = '[' . api_get_setting('siteName') . '] ' . get_lang('YourReg', null, $l) . ' ' . api_get_setting('siteName'); |
|
75 | - $emailbody = get_lang('Dear', null, $l) . ' ' . api_get_person_name($user['FirstName'], $user['LastName']) . ",\n\n" . get_lang('YouAreReg', null, $l) . " " . api_get_setting('siteName') . " " . get_lang('WithTheFollowingSettings', null, $l) . "\n\n" . get_lang('Username', null, $l) . " : " . $user['UserName'] . "\n" . get_lang('Pass', null, $l) . " : " . $user['Password'] . "\n\n" . get_lang('Address', null, $l) . " " . api_get_setting('siteName') . " " . get_lang('Is', null, $l) . " : " . api_get_path(WEB_PATH) . " \n\n" . get_lang('Problem', null, $l) . "\n\n" . get_lang('Formula', null, $l) . ",\n\n" . api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname')) . "\n" . get_lang('Manager', null, $l) . " " . api_get_setting('siteName') . "\nT. " . api_get_setting('administratorTelephone') . "\n" . get_lang('Email', null, $l) . " : " . api_get_setting('emailAdministrator') . ""; |
|
74 | + $emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg', null, $l).' '.api_get_setting('siteName'); |
|
75 | + $emailbody = get_lang('Dear', null, $l).' '.api_get_person_name($user['FirstName'], $user['LastName']).",\n\n".get_lang('YouAreReg', null, $l)." ".api_get_setting('siteName')." ".get_lang('WithTheFollowingSettings', null, $l)."\n\n".get_lang('Username', null, $l)." : ".$user['UserName']."\n".get_lang('Pass', null, $l)." : ".$user['Password']."\n\n".get_lang('Address', null, $l)." ".api_get_setting('siteName')." ".get_lang('Is', null, $l)." : ".api_get_path(WEB_PATH)." \n\n".get_lang('Problem', null, $l)."\n\n".get_lang('Formula', null, $l).",\n\n".api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))."\n".get_lang('Manager', null, $l)." ".api_get_setting('siteName')."\nT. ".api_get_setting('administratorTelephone')."\n".get_lang('Email', null, $l)." : ".api_get_setting('emailAdministrator').""; |
|
76 | 76 | $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); |
77 | 77 | $email_admin = api_get_setting('emailAdministrator'); |
78 | 78 | @api_mail_html( |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | $list = file('input.txt'); |
19 | 19 | require_once '../../inc/global.inc.php'; |
20 | 20 | $users = Database::get_main_table(TABLE_MAIN_USER); |
21 | -$string=''; |
|
21 | +$string = ''; |
|
22 | 22 | foreach ($list as $mail) { |
23 | 23 | $mail = trim($mail); |
24 | 24 | $sql = "SELECT user_id, official_code, firstname, lastname, email FROM $users WHERE email = '$mail'\n"; |
25 | 25 | $res = Database::query($sql); |
26 | - if ($res === false) { die(mysql_error());} |
|
26 | + if ($res === false) { die(mysql_error()); } |
|
27 | 27 | if (Database::num_rows($res) == 0) { |
28 | 28 | $string .= 'No encontrado;'.$row['email']; |
29 | 29 | } else { |
@@ -32,4 +32,4 @@ discard block |
||
32 | 32 | } |
33 | 33 | } |
34 | 34 | echo $string; |
35 | -file_put_contents('/tmp/list.txt',$string); |
|
35 | +file_put_contents('/tmp/list.txt', $string); |
@@ -20,16 +20,16 @@ |
||
20 | 20 | $users = Database::get_main_table(TABLE_MAIN_USER); |
21 | 21 | $string=''; |
22 | 22 | foreach ($list as $mail) { |
23 | - $mail = trim($mail); |
|
24 | - $sql = "SELECT user_id, official_code, firstname, lastname, email FROM $users WHERE email = '$mail'\n"; |
|
25 | - $res = Database::query($sql); |
|
26 | - if ($res === false) { die(mysql_error());} |
|
27 | - if (Database::num_rows($res) == 0) { |
|
23 | + $mail = trim($mail); |
|
24 | + $sql = "SELECT user_id, official_code, firstname, lastname, email FROM $users WHERE email = '$mail'\n"; |
|
25 | + $res = Database::query($sql); |
|
26 | + if ($res === false) { die(mysql_error());} |
|
27 | + if (Database::num_rows($res) == 0) { |
|
28 | 28 | $string .= 'No encontrado;'.$row['email']; |
29 | - } else { |
|
29 | + } else { |
|
30 | 30 | $row = Database::fetch_assoc($res); |
31 | - $string .= $row['user_id'].';'.$row['email'].';'.$row['firstname'].';'.$row['lastname'].';'.$row['official_code']."\r\n"; |
|
32 | - } |
|
31 | + $string .= $row['user_id'].';'.$row['email'].';'.$row['firstname'].';'.$row['lastname'].';'.$row['official_code']."\r\n"; |
|
32 | + } |
|
33 | 33 | } |
34 | 34 | echo $string; |
35 | 35 | file_put_contents('/tmp/list.txt',$string); |
@@ -14,7 +14,7 @@ |
||
14 | 14 | */ |
15 | 15 | require_once dirname(__FILE__).'/../../inc/global.inc.php'; |
16 | 16 | // check if this client has been called by php_cli (command line or cron) |
17 | -if (php_sapi_name()!='cli') { |
|
17 | +if (php_sapi_name() != 'cli') { |
|
18 | 18 | echo 'You can\'t call this service through a browser'; |
19 | 19 | die(); |
20 | 20 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | exit; //do not run from browser |
15 | 15 | } |
16 | 16 | |
17 | -require_once __DIR__ . "/../inc/global.inc.php"; |
|
17 | +require_once __DIR__."/../inc/global.inc.php"; |
|
18 | 18 | |
19 | 19 | // First day of the current month to create sessions and add courses for the next month (e.g. "07") |
20 | 20 | define("OFFSET", "15"); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | $startDate = $initialDate ? $initialDate : date("Y-m-01"); |
43 | 43 | $month = getQuarterFirstMonth(getQuarter(date('m', $startDate))); |
44 | - $startDate = substr($startDate, 0, 5) . $month . '-01'; |
|
44 | + $startDate = substr($startDate, 0, 5).$month.'-01'; |
|
45 | 45 | $nextQuarterStartDate = date('Y-m-d', api_strtotime($startDate.' + 3 month')); |
46 | 46 | $endDate = date('Y-m-d', api_strtotime($nextQuarterStartDate.' - 1 minute')); |
47 | 47 | return array('startDate' => $startDate, 'endDate' => $endDate); |
@@ -145,8 +145,7 @@ discard block |
||
145 | 145 | { |
146 | 146 | echo "\n"; |
147 | 147 | echo $courses ? |
148 | - "Creating sessions and adding courses for the period between ".$startDate." and ".$endDate : |
|
149 | - "Every course is already in session for the period between ".$startDate." and ".$endDate; |
|
148 | + "Creating sessions and adding courses for the period between ".$startDate." and ".$endDate : "Every course is already in session for the period between ".$startDate." and ".$endDate; |
|
150 | 149 | echo "\n=====================================================================================\n\n"; |
151 | 150 | // Loop through courses creating one session per each and adding them |
152 | 151 | foreach ($courses as $course) { |
@@ -155,8 +154,8 @@ discard block |
||
155 | 154 | $year = date("Y", api_strtotime($startDate)); |
156 | 155 | $quarter = getQuarter($month); |
157 | 156 | $quarter = getQuarterRoman($quarter); |
158 | - $period = $year . '-' . $quarter; |
|
159 | - $sessionName = '[' . $period . '] ' . $course['title']; |
|
157 | + $period = $year.'-'.$quarter; |
|
158 | + $sessionName = '['.$period.'] '.$course['title']; |
|
160 | 159 | $sessionId = SessionManager::create_session( |
161 | 160 | $sessionName, |
162 | 161 | $startDate, |
@@ -175,7 +174,7 @@ discard block |
||
175 | 174 | } |
176 | 175 | |
177 | 176 | // Starts the script |
178 | -echo "Starting process..." . PHP_EOL; |
|
177 | +echo "Starting process...".PHP_EOL; |
|
179 | 178 | // Get first active administrator |
180 | 179 | $administrators = array_reverse(UserManager::get_all_administrators()); |
181 | 180 | $lastingAdministrators = count($administrators); |
@@ -196,7 +195,7 @@ discard block |
||
196 | 195 | |
197 | 196 | // Creates course sessions for the following month |
198 | 197 | $offsetDay = intval(substr($dates['endDate'], 8, 2)) - OFFSET; |
199 | -if (date("Y-m-d") >= date(substr($dates['endDate'], 0, 8) . $offsetDay)) { |
|
198 | +if (date("Y-m-d") >= date(substr($dates['endDate'], 0, 8).$offsetDay)) { |
|
200 | 199 | $dates = getQuarterFirstAndLastDates(date("Y-m-d", api_strtotime(date("Y-m-01")." + 3 month"))); |
201 | 200 | // Get courses that don't have any session the next month |
202 | 201 | $courses = CourseManager::getCoursesWithoutSession($dates['startDate'], $dates['endDate']); |
@@ -32,16 +32,16 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Display |
34 | 34 | */ |
35 | -if (count($list)==0) { echo 'No terms loaded so far'; } |
|
36 | -if (count($list)>0) { |
|
35 | +if (count($list) == 0) { echo 'No terms loaded so far'; } |
|
36 | +if (count($list) > 0) { |
|
37 | 37 | $i = 1; |
38 | 38 | $j = 1; |
39 | 39 | $k = 0; |
40 | 40 | $files = array(); |
41 | 41 | $trans = array(); |
42 | 42 | echo 'Number of records: '.count($list).'<br />'; |
43 | - echo '<table><tr><th>Index</th><th>Registration order</th><th>Term</th>'.($output==1?'<th>Origin</th>':'').'<th>Count</th></tr>'; |
|
44 | - foreach($list as $elem) { |
|
43 | + echo '<table><tr><th>Index</th><th>Registration order</th><th>Term</th>'.($output == 1 ? '<th>Origin</th>' : '').'<th>Count</th></tr>'; |
|
44 | + foreach ($list as $elem) { |
|
45 | 45 | if ($k > $terms_limit) { break; } |
46 | 46 | $fixed_elem = $elem; |
47 | 47 | if ($output) { |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | $trans[$fixed_elem['term_name']] = $translation; |
58 | 58 | $j++; |
59 | 59 | } |
60 | - echo '<tr><td>',$i, |
|
61 | - '</td><td>',$fixed_elem['id'], |
|
62 | - '</td><td>',$fixed_elem['term_name']; |
|
60 | + echo '<tr><td>', $i, |
|
61 | + '</td><td>', $fixed_elem['id'], |
|
62 | + '</td><td>', $fixed_elem['term_name']; |
|
63 | 63 | if ($output) { |
64 | 64 | echo '</td><td>'.$variables_origin[$fixed_elem['term_name']]; |
65 | 65 | } |
66 | - echo '</td><td>',$fixed_elem['term_count'],'</td></tr>'; |
|
66 | + echo '</td><td>', $fixed_elem['term_count'], '</td></tr>'; |
|
67 | 67 | $i++; |
68 | 68 | } |
69 | 69 | echo '</table>'; |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | @mkdir('/tmp/lang'); |
72 | 72 | foreach ($files as $file => $terms) { |
73 | 73 | @touch('/tmp/lang/'.$file); |
74 | - file_put_contents('/tmp/lang/'.$file,"<?php".PHP_EOL); |
|
74 | + file_put_contents('/tmp/lang/'.$file, "<?php".PHP_EOL); |
|
75 | 75 | foreach ($terms as $term) { |
76 | - file_put_contents('/tmp/lang/'.$file,'$'.$term.' = "'.str_replace('"','\"',$trans[$term]).'";'.PHP_EOL, FILE_APPEND); |
|
76 | + file_put_contents('/tmp/lang/'.$file, '$'.$term.' = "'.str_replace('"', '\"', $trans[$term]).'";'.PHP_EOL, FILE_APPEND); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | } |
@@ -22,59 +22,59 @@ |
||
22 | 22 | $output = false; |
23 | 23 | $ls = new langstats(); |
24 | 24 | if ($ls === false) { |
25 | - exit($ls->error); |
|
25 | + exit($ls->error); |
|
26 | 26 | } |
27 | 27 | $list = $ls->get_popular_terms($x_most_popular); |
28 | 28 | if ($_GET['output'] == 1) { |
29 | - $output = true; |
|
30 | - $variables_origin = $ls->get_variables_origin(); |
|
29 | + $output = true; |
|
30 | + $variables_origin = $ls->get_variables_origin(); |
|
31 | 31 | } |
32 | 32 | /** |
33 | 33 | * Display |
34 | 34 | */ |
35 | 35 | if (count($list)==0) { echo 'No terms loaded so far'; } |
36 | 36 | if (count($list)>0) { |
37 | - $i = 1; |
|
38 | - $j = 1; |
|
39 | - $k = 0; |
|
40 | - $files = array(); |
|
41 | - $trans = array(); |
|
42 | - echo 'Number of records: '.count($list).'<br />'; |
|
43 | - echo '<table><tr><th>Index</th><th>Registration order</th><th>Term</th>'.($output==1?'<th>Origin</th>':'').'<th>Count</th></tr>'; |
|
44 | - foreach($list as $elem) { |
|
37 | + $i = 1; |
|
38 | + $j = 1; |
|
39 | + $k = 0; |
|
40 | + $files = array(); |
|
41 | + $trans = array(); |
|
42 | + echo 'Number of records: '.count($list).'<br />'; |
|
43 | + echo '<table><tr><th>Index</th><th>Registration order</th><th>Term</th>'.($output==1?'<th>Origin</th>':'').'<th>Count</th></tr>'; |
|
44 | + foreach($list as $elem) { |
|
45 | 45 | if ($k > $terms_limit) { break; } |
46 | 46 | $fixed_elem = $elem; |
47 | 47 | if ($output) { |
48 | - if (empty($variables_origin[$elem['term_name']]) && !empty($variables_origin['lang'.$elem['term_name']])) { |
|
48 | + if (empty($variables_origin[$elem['term_name']]) && !empty($variables_origin['lang'.$elem['term_name']])) { |
|
49 | 49 | $fixed_elem = array('id' => $elem['id'], 'term_name' => 'lang'.$elem['term_name'], 'term_count' => $elem['term_count']); |
50 | - } |
|
51 | - if (empty($variables_origin[$fixed_elem['term_name']])) { |
|
50 | + } |
|
51 | + if (empty($variables_origin[$fixed_elem['term_name']])) { |
|
52 | 52 | continue; |
53 | - } |
|
54 | - $files[$variables_origin[$fixed_elem['term_name']]][] = $fixed_elem['term_name']; |
|
55 | - $translation = get_lang($fixed_elem['term_name']); |
|
56 | - $k += str_word_count($translation); |
|
57 | - $trans[$fixed_elem['term_name']] = $translation; |
|
58 | - $j++; |
|
53 | + } |
|
54 | + $files[$variables_origin[$fixed_elem['term_name']]][] = $fixed_elem['term_name']; |
|
55 | + $translation = get_lang($fixed_elem['term_name']); |
|
56 | + $k += str_word_count($translation); |
|
57 | + $trans[$fixed_elem['term_name']] = $translation; |
|
58 | + $j++; |
|
59 | 59 | } |
60 | 60 | echo '<tr><td>',$i, |
61 | - '</td><td>',$fixed_elem['id'], |
|
62 | - '</td><td>',$fixed_elem['term_name']; |
|
61 | + '</td><td>',$fixed_elem['id'], |
|
62 | + '</td><td>',$fixed_elem['term_name']; |
|
63 | 63 | if ($output) { |
64 | - echo '</td><td>'.$variables_origin[$fixed_elem['term_name']]; |
|
64 | + echo '</td><td>'.$variables_origin[$fixed_elem['term_name']]; |
|
65 | 65 | } |
66 | 66 | echo '</td><td>',$fixed_elem['term_count'],'</td></tr>'; |
67 | 67 | $i++; |
68 | - } |
|
69 | - echo '</table>'; |
|
70 | - if ($output) { |
|
68 | + } |
|
69 | + echo '</table>'; |
|
70 | + if ($output) { |
|
71 | 71 | @mkdir('/tmp/lang'); |
72 | 72 | foreach ($files as $file => $terms) { |
73 | - @touch('/tmp/lang/'.$file); |
|
74 | - file_put_contents('/tmp/lang/'.$file,"<?php".PHP_EOL); |
|
75 | - foreach ($terms as $term) { |
|
73 | + @touch('/tmp/lang/'.$file); |
|
74 | + file_put_contents('/tmp/lang/'.$file,"<?php".PHP_EOL); |
|
75 | + foreach ($terms as $term) { |
|
76 | 76 | file_put_contents('/tmp/lang/'.$file,'$'.$term.' = "'.str_replace('"','\"',$trans[$term]).'";'.PHP_EOL, FILE_APPEND); |
77 | - } |
|
77 | + } |
|
78 | 78 | } |
79 | - } |
|
79 | + } |
|
80 | 80 | } |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | die(); |
10 | 10 | require_once '../../inc/global.inc.php'; |
11 | 11 | $path = api_get_path(SYS_LANG_PATH).'english'; |
12 | -ini_set('memory_limit','128M'); |
|
12 | +ini_set('memory_limit', '128M'); |
|
13 | 13 | /** |
14 | 14 | * Main code |
15 | 15 | */ |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | foreach ($list as $entry) { |
19 | 19 | $file = $path.'/'.$entry; |
20 | 20 | if (is_file($file)) { |
21 | - $terms = array_merge($terms,SubLanguageManager::get_all_language_variable_in_file($file,true)); |
|
21 | + $terms = array_merge($terms, SubLanguageManager::get_all_language_variable_in_file($file, true)); |
|
22 | 22 | } |
23 | 23 | } |
24 | 24 | // get only the array keys (the language variables defined in language files) |
@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | $files = get_all_php_files(api_get_path(SYS_PATH)); |
32 | 32 | foreach ($files as $file) { |
33 | 33 | //echo 'Analyzing '.$file."<br />"; |
34 | - $shortfile = substr($file,$l); |
|
34 | + $shortfile = substr($file, $l); |
|
35 | 35 | $lines = file($file); |
36 | 36 | foreach ($lines as $line) { |
37 | 37 | $myterms = array(); |
38 | - $res = preg_match_all('/get_lang\(\'(\\w*)\'\)/',$line,$myterms); |
|
38 | + $res = preg_match_all('/get_lang\(\'(\\w*)\'\)/', $line, $myterms); |
|
39 | 39 | if ($res > 0) { |
40 | - foreach($myterms[1] as $term) { |
|
40 | + foreach ($myterms[1] as $term) { |
|
41 | 41 | if (!isset($defined_terms[$term]) && !isset($defined_terms['lang'.$term])) { |
42 | 42 | $undefined_terms[$term] = $shortfile; |
43 | 43 | //echo "Undefined: $term<br />"; |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | } |
46 | 46 | } |
47 | 47 | $res = 0; |
48 | - $res = preg_match_all('/\{[\'"](\\w*)[\'"]\|get_lang\}/',$line,$myterms); |
|
48 | + $res = preg_match_all('/\{[\'"](\\w*)[\'"]\|get_lang\}/', $line, $myterms); |
|
49 | 49 | if ($res > 0) { |
50 | - foreach($myterms[1] as $term) { |
|
50 | + foreach ($myterms[1] as $term) { |
|
51 | 51 | if (!isset($defined_terms[$term]) && !isset($defined_terms['lang'.$term])) { |
52 | 52 | $undefined_terms[$term] = $shortfile; |
53 | 53 | //echo "Undefined: $term<br />"; |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | flush(); |
59 | 59 | } |
60 | 60 | //$undefined_terms = array_flip($undefined_terms); |
61 | -if (count($undefined_terms)<1) { die("No missing terms<br />\n"); } else { echo "The following terms were nowhere to be found: <br />\n<table>"; } |
|
61 | +if (count($undefined_terms) < 1) { die("No missing terms<br />\n"); } else { echo "The following terms were nowhere to be found: <br />\n<table>"; } |
|
62 | 62 | foreach ($undefined_terms as $term => $file) { |
63 | 63 | echo "<tr><td>$term</td><td>in $file"; |
64 | - if (substr($file,0,7)=='plugin/') { |
|
64 | + if (substr($file, 0, 7) == 'plugin/') { |
|
65 | 65 | echo " <span style=\"color: #00ff00;\">(this one should be taken care of by the plugin's language files)</span>"; |
66 | 66 | } |
67 | 67 | echo "</td></tr>\n"; |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | $list = scandir($base_path); |
74 | 74 | $files = array(); |
75 | 75 | foreach ($list as $item) { |
76 | - if (substr($item,0,1)=='.') {continue;} |
|
77 | - $special_dirs = array(api_get_path(SYS_TEST_PATH),api_get_path(SYS_COURSE_PATH),api_get_path(SYS_LANG_PATH),api_get_path(SYS_ARCHIVE_PATH)); |
|
78 | - if (in_array($base_path.$item.'/',$special_dirs)) {continue;} |
|
76 | + if (substr($item, 0, 1) == '.') {continue; } |
|
77 | + $special_dirs = array(api_get_path(SYS_TEST_PATH), api_get_path(SYS_COURSE_PATH), api_get_path(SYS_LANG_PATH), api_get_path(SYS_ARCHIVE_PATH)); |
|
78 | + if (in_array($base_path.$item.'/', $special_dirs)) {continue; } |
|
79 | 79 | if (is_dir($base_path.$item)) { |
80 | - $files = array_merge($files,get_all_php_files($base_path.$item.'/')); |
|
80 | + $files = array_merge($files, get_all_php_files($base_path.$item.'/')); |
|
81 | 81 | } else { |
82 | 82 | //only analyse php files |
83 | - $sub = substr($item,-4); |
|
83 | + $sub = substr($item, -4); |
|
84 | 84 | if ($sub == '.php' or $sub == '.tpl') { |
85 | 85 | $files[] = $base_path.$item; |
86 | 86 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $file = $path.'/'.$entry; |
20 | 20 | if (is_file($file)) { |
21 | 21 | $terms = array_merge($terms,SubLanguageManager::get_all_language_variable_in_file($file,true)); |
22 | - } |
|
22 | + } |
|
23 | 23 | } |
24 | 24 | // get only the array keys (the language variables defined in language files) |
25 | 25 | $defined_terms = array_flip(array_keys($terms)); |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | foreach ($files as $file) { |
33 | 33 | //echo 'Analyzing '.$file."<br />"; |
34 | 34 | $shortfile = substr($file,$l); |
35 | - $lines = file($file); |
|
35 | + $lines = file($file); |
|
36 | 36 | foreach ($lines as $line) { |
37 | - $myterms = array(); |
|
37 | + $myterms = array(); |
|
38 | 38 | $res = preg_match_all('/get_lang\(\'(\\w*)\'\)/',$line,$myterms); |
39 | 39 | if ($res > 0) { |
40 | 40 | foreach($myterms[1] as $term) { |
41 | 41 | if (!isset($defined_terms[$term]) && !isset($defined_terms['lang'.$term])) { |
42 | - $undefined_terms[$term] = $shortfile; |
|
42 | + $undefined_terms[$term] = $shortfile; |
|
43 | 43 | //echo "Undefined: $term<br />"; |
44 | 44 | } |
45 | 45 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | if ($res > 0) { |
50 | 50 | foreach($myterms[1] as $term) { |
51 | 51 | if (!isset($defined_terms[$term]) && !isset($defined_terms['lang'.$term])) { |
52 | - $undefined_terms[$term] = $shortfile; |
|
52 | + $undefined_terms[$term] = $shortfile; |
|
53 | 53 | //echo "Undefined: $term<br />"; |
54 | 54 | } |
55 | 55 | } |
@@ -73,17 +73,17 @@ discard block |
||
73 | 73 | $list = scandir($base_path); |
74 | 74 | $files = array(); |
75 | 75 | foreach ($list as $item) { |
76 | - if (substr($item,0,1)=='.') {continue;} |
|
76 | + if (substr($item,0,1)=='.') {continue;} |
|
77 | 77 | $special_dirs = array(api_get_path(SYS_TEST_PATH),api_get_path(SYS_COURSE_PATH),api_get_path(SYS_LANG_PATH),api_get_path(SYS_ARCHIVE_PATH)); |
78 | 78 | if (in_array($base_path.$item.'/',$special_dirs)) {continue;} |
79 | 79 | if (is_dir($base_path.$item)) { |
80 | - $files = array_merge($files,get_all_php_files($base_path.$item.'/')); |
|
80 | + $files = array_merge($files,get_all_php_files($base_path.$item.'/')); |
|
81 | 81 | } else { |
82 | 82 | //only analyse php files |
83 | 83 | $sub = substr($item,-4); |
84 | - if ($sub == '.php' or $sub == '.tpl') { |
|
84 | + if ($sub == '.php' or $sub == '.tpl') { |
|
85 | 85 | $files[] = $base_path.$item; |
86 | - } |
|
86 | + } |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | $list = null; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | //die(); |
10 | 10 | require_once '../../inc/global.inc.php'; |
11 | 11 | $path = api_get_path(SYS_LANG_PATH).'english'; |
12 | -ini_set('memory_limit','128M'); |
|
12 | +ini_set('memory_limit', '128M'); |
|
13 | 13 | /** |
14 | 14 | * Main code |
15 | 15 | */ |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | $langs = scandir(api_get_path(SYS_LANG_PATH)); |
19 | 19 | foreach ($langs as $lang) { |
20 | 20 | $dir = api_get_path(SYS_LANG_PATH).$lang; |
21 | - if (is_dir($dir) && substr($lang,0,1) != '.' && !empty($lang)) { |
|
21 | + if (is_dir($dir) && substr($lang, 0, 1) != '.' && !empty($lang)) { |
|
22 | 22 | echo "$lang..."; |
23 | 23 | $ok = true; |
24 | 24 | foreach ($list as $entry) { |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | $out = array(); |
27 | 27 | if (is_file($file)) { |
28 | 28 | //$terms = array_merge($terms,SubLanguageManager::get_all_language_variable_in_file($file,true)); |
29 | - @exec('php5 -l '.$file,$out); |
|
30 | - if (substr($out[0],0,2)!='No') { |
|
29 | + @exec('php5 -l '.$file, $out); |
|
30 | + if (substr($out[0], 0, 2) != 'No') { |
|
31 | 31 | echo $out[0]."\n"; |
32 | 32 | $ok = false; |
33 | 33 | } |
@@ -17,25 +17,25 @@ |
||
17 | 17 | $list = SubLanguageManager::get_lang_folder_files_list($path); |
18 | 18 | $langs = scandir(api_get_path(SYS_LANG_PATH)); |
19 | 19 | foreach ($langs as $lang) { |
20 | - $dir = api_get_path(SYS_LANG_PATH).$lang; |
|
21 | - if (is_dir($dir) && substr($lang,0,1) != '.' && !empty($lang)) { |
|
20 | + $dir = api_get_path(SYS_LANG_PATH).$lang; |
|
21 | + if (is_dir($dir) && substr($lang,0,1) != '.' && !empty($lang)) { |
|
22 | 22 | echo "$lang..."; |
23 | 23 | $ok = true; |
24 | 24 | foreach ($list as $entry) { |
25 | - $file = $dir.'/'.$entry; |
|
26 | - $out = array(); |
|
27 | - if (is_file($file)) { |
|
25 | + $file = $dir.'/'.$entry; |
|
26 | + $out = array(); |
|
27 | + if (is_file($file)) { |
|
28 | 28 | //$terms = array_merge($terms,SubLanguageManager::get_all_language_variable_in_file($file,true)); |
29 | 29 | @exec('php5 -l '.$file,$out); |
30 | 30 | if (substr($out[0],0,2)!='No') { |
31 | - echo $out[0]."\n"; |
|
32 | - $ok = false; |
|
31 | + echo $out[0]."\n"; |
|
32 | + $ok = false; |
|
33 | + } |
|
33 | 34 | } |
34 | - } |
|
35 | 35 | } |
36 | 36 | if ($ok) { |
37 | - echo "OK\n"; |
|
37 | + echo "OK\n"; |
|
38 | + } |
|
38 | 39 | } |
39 | - } |
|
40 | 40 | } |
41 | 41 | echo "Done\n"; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | foreach ($terms as $row) { |
36 | 36 | if ($words_counter > 10000) { break; } |
37 | - $words = str_word_count(get_lang($row['term_name'],null,$orig_lang)); |
|
37 | + $words = str_word_count(get_lang($row['term_name'], null, $orig_lang)); |
|
38 | 38 | $words_counter += $words; |
39 | 39 | $terms_in_limit[$row['term_name']] = $i; |
40 | 40 | //echo "Term <b>".$row['term_name']."</b> is <b>'".get_lang($row['term_name'],null,$orig_lang)."'</b> which means $words words<br /><br />\n"; |
@@ -59,37 +59,37 @@ discard block |
||
59 | 59 | $global_var = array(); //keep the combination of all vars |
60 | 60 | $terms_in_limit = array_flip($terms_in_limit); |
61 | 61 | foreach ($list_files as $file) { |
62 | - if (substr($file,0,1) == '.') {continue;} |
|
62 | + if (substr($file, 0, 1) == '.') {continue; } |
|
63 | 63 | //echo "'".substr($file,0,-8)."',<br />"; //print in a PHP array format |
64 | 64 | $vars = file($lang_dir.'/'.$orig_lang.'/'.$file); |
65 | 65 | $local_var = array(); |
66 | 66 | $file_string = '<?php'."\n"; |
67 | 67 | foreach ($vars as $line) { |
68 | 68 | $var = array(); |
69 | - $res = preg_match('/^(\$\w*)/',$line,$var); |
|
70 | - if ($res>0) { |
|
69 | + $res = preg_match('/^(\$\w*)/', $line, $var); |
|
70 | + if ($res > 0) { |
|
71 | 71 | //echo $var[1]."<br />"; |
72 | 72 | |
73 | - if (in_array(substr($var[1],1),$terms_in_limit)) { |
|
73 | + if (in_array(substr($var[1], 1), $terms_in_limit)) { |
|
74 | 74 | //echo "Var ".$var[1]." was in the limit<br />"; |
75 | 75 | $local_var[$var[1]] = $line; |
76 | 76 | $file_string .= $line; |
77 | - $terms_found[] = substr($var[1],1); //e.g. store Tools |
|
78 | - $words_found += str_word_count(get_lang($var[1],null,$orig_lang)); |
|
79 | - } elseif (in_array(substr($var[1],5),$terms_in_limit)) { |
|
77 | + $terms_found[] = substr($var[1], 1); //e.g. store Tools |
|
78 | + $words_found += str_word_count(get_lang($var[1], null, $orig_lang)); |
|
79 | + } elseif (in_array(substr($var[1], 5), $terms_in_limit)) { |
|
80 | 80 | //echo "Var ".$var[1]." was in the limit<br />"; |
81 | 81 | $local_var[$var[1]] = $line; |
82 | 82 | $file_string .= $line; |
83 | - $terms_found[] = substr($var[1],5); //e.g. store langTools |
|
84 | - $words_found += str_word_count(get_lang(substr($var[1],5),null,$orig_lang)); |
|
83 | + $terms_found[] = substr($var[1], 5); //e.g. store langTools |
|
84 | + $words_found += str_word_count(get_lang(substr($var[1], 5), null, $orig_lang)); |
|
85 | 85 | } //else do not care |
86 | 86 | } |
87 | 87 | } |
88 | 88 | echo "Writing ".$arch_dir.'/langstats/'.$orig_lang.'/'.$file."<br />\n"; |
89 | - file_put_contents($arch_dir.'/langstats/'.$orig_lang.'/'.$file,$file_string); |
|
89 | + file_put_contents($arch_dir.'/langstats/'.$orig_lang.'/'.$file, $file_string); |
|
90 | 90 | $global_var += $local_var; |
91 | 91 | }; |
92 | -$terms_diff = count($global_var)-count($terms_in_limit); |
|
92 | +$terms_diff = count($global_var) - count($terms_in_limit); |
|
93 | 93 | echo count($global_var)." terms found in English files (summing up to $words_found words). Some terms ($terms_diff in this case) might have appeared in two different files<br />"; |
94 | 94 | /** |
95 | 95 | * Display results |
@@ -97,5 +97,5 @@ discard block |
||
97 | 97 | |
98 | 98 | echo "Difference between filtered and found in English:<br />"; |
99 | 99 | //print_r($terms_found); |
100 | -echo "<pre>".print_r(array_diff($terms_in_limit,$terms_found),1)."</pre>"; |
|
100 | +echo "<pre>".print_r(array_diff($terms_in_limit, $terms_found), 1)."</pre>"; |
|
101 | 101 | echo "#"; |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | * Code run |
34 | 34 | */ |
35 | 35 | foreach ($terms as $row) { |
36 | - if ($words_counter > 10000) { break; } |
|
37 | - $words = str_word_count(get_lang($row['term_name'],null,$orig_lang)); |
|
38 | - $words_counter += $words; |
|
39 | - $terms_in_limit[$row['term_name']] = $i; |
|
40 | - //echo "Term <b>".$row['term_name']."</b> is <b>'".get_lang($row['term_name'],null,$orig_lang)."'</b> which means $words words<br /><br />\n"; |
|
41 | - //if ($words_counter%1000 >= 0) { |
|
36 | + if ($words_counter > 10000) { break; } |
|
37 | + $words = str_word_count(get_lang($row['term_name'],null,$orig_lang)); |
|
38 | + $words_counter += $words; |
|
39 | + $terms_in_limit[$row['term_name']] = $i; |
|
40 | + //echo "Term <b>".$row['term_name']."</b> is <b>'".get_lang($row['term_name'],null,$orig_lang)."'</b> which means $words words<br /><br />\n"; |
|
41 | + //if ($words_counter%1000 >= 0) { |
|
42 | 42 | //echo "Reached $words_counter words at term $i (".$row['term_name']." used ".$row['term_count']." times)...<br />\n"; |
43 | - //} |
|
44 | - $i++; |
|
43 | + //} |
|
44 | + $i++; |
|
45 | 45 | } |
46 | 46 | //echo $words_counter.'<br />'; |
47 | 47 | |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | |
50 | 50 | echo "Scanning English files, trying to find these terms...<br />\n"; |
51 | 51 | if (!is_dir($arch_dir.'/langstats')) { |
52 | - mkdir($arch_dir.'/langstats'); |
|
53 | - mkdir($arch_dir.'/langstats/'.$orig_lang); |
|
52 | + mkdir($arch_dir.'/langstats'); |
|
53 | + mkdir($arch_dir.'/langstats/'.$orig_lang); |
|
54 | 54 | } |
55 | 55 | $list_files = scandir($lang_dir.'/'.$orig_lang); |
56 | 56 | $j = 1; |
@@ -59,35 +59,35 @@ discard block |
||
59 | 59 | $global_var = array(); //keep the combination of all vars |
60 | 60 | $terms_in_limit = array_flip($terms_in_limit); |
61 | 61 | foreach ($list_files as $file) { |
62 | - if (substr($file,0,1) == '.') {continue;} |
|
63 | - //echo "'".substr($file,0,-8)."',<br />"; //print in a PHP array format |
|
64 | - $vars = file($lang_dir.'/'.$orig_lang.'/'.$file); |
|
65 | - $local_var = array(); |
|
66 | - $file_string = '<?php'."\n"; |
|
67 | - foreach ($vars as $line) { |
|
62 | + if (substr($file,0,1) == '.') {continue;} |
|
63 | + //echo "'".substr($file,0,-8)."',<br />"; //print in a PHP array format |
|
64 | + $vars = file($lang_dir.'/'.$orig_lang.'/'.$file); |
|
65 | + $local_var = array(); |
|
66 | + $file_string = '<?php'."\n"; |
|
67 | + foreach ($vars as $line) { |
|
68 | 68 | $var = array(); |
69 | 69 | $res = preg_match('/^(\$\w*)/',$line,$var); |
70 | 70 | if ($res>0) { |
71 | - //echo $var[1]."<br />"; |
|
71 | + //echo $var[1]."<br />"; |
|
72 | 72 | |
73 | - if (in_array(substr($var[1],1),$terms_in_limit)) { |
|
73 | + if (in_array(substr($var[1],1),$terms_in_limit)) { |
|
74 | 74 | //echo "Var ".$var[1]." was in the limit<br />"; |
75 | 75 | $local_var[$var[1]] = $line; |
76 | 76 | $file_string .= $line; |
77 | 77 | $terms_found[] = substr($var[1],1); //e.g. store Tools |
78 | 78 | $words_found += str_word_count(get_lang($var[1],null,$orig_lang)); |
79 | - } elseif (in_array(substr($var[1],5),$terms_in_limit)) { |
|
79 | + } elseif (in_array(substr($var[1],5),$terms_in_limit)) { |
|
80 | 80 | //echo "Var ".$var[1]." was in the limit<br />"; |
81 | 81 | $local_var[$var[1]] = $line; |
82 | 82 | $file_string .= $line; |
83 | 83 | $terms_found[] = substr($var[1],5); //e.g. store langTools |
84 | 84 | $words_found += str_word_count(get_lang(substr($var[1],5),null,$orig_lang)); |
85 | - } //else do not care |
|
85 | + } //else do not care |
|
86 | 86 | } |
87 | - } |
|
88 | - echo "Writing ".$arch_dir.'/langstats/'.$orig_lang.'/'.$file."<br />\n"; |
|
89 | - file_put_contents($arch_dir.'/langstats/'.$orig_lang.'/'.$file,$file_string); |
|
90 | - $global_var += $local_var; |
|
87 | + } |
|
88 | + echo "Writing ".$arch_dir.'/langstats/'.$orig_lang.'/'.$file."<br />\n"; |
|
89 | + file_put_contents($arch_dir.'/langstats/'.$orig_lang.'/'.$file,$file_string); |
|
90 | + $global_var += $local_var; |
|
91 | 91 | }; |
92 | 92 | $terms_diff = count($global_var)-count($terms_in_limit); |
93 | 93 | echo count($global_var)." terms found in English files (summing up to $words_found words). Some terms ($terms_diff in this case) might have appeared in two different files<br />"; |