diff --git a/main/cron/lang/list_undefined_langvars.php b/main/cron/lang/list_undefined_langvars.php
index 207d3a13a7..d65084ec5f 100755
--- a/main/cron/lang/list_undefined_langvars.php
+++ b/main/cron/lang/list_undefined_langvars.php
@@ -8,7 +8,7 @@
* Includes and declarations.
*/
die();
-require_once '../../inc/global.inc.php';
+require_once __DIR__.'/../../inc/global.inc.php';
$path = api_get_path(SYS_LANG_PATH).'english';
ini_set('memory_limit', '128M');
/**
@@ -29,7 +29,7 @@ $terms = null;
// now get all terms found in all PHP files of Chamilo (this takes some time and memory)
$undefined_terms = [];
$l = strlen(api_get_path(SYS_PATH));
-$files = get_all_php_files(api_get_path(SYS_PATH));
+$files = getAllPhpFiles(api_get_path(SYS_PATH));
foreach ($files as $file) {
//echo 'Analyzing '.$file."
";
$shortfile = substr($file, $l);
@@ -73,29 +73,3 @@ foreach ($undefined_terms as $term => $file) {
}
echo "\n";
-function get_all_php_files($base_path)
-{
- $list = scandir($base_path);
- $files = [];
- foreach ($list as $item) {
- if (substr($item, 0, 1) == '.') {
- continue;
- }
- $special_dirs = [api_get_path(SYS_TEST_PATH), api_get_path(SYS_COURSE_PATH), api_get_path(SYS_LANG_PATH), api_get_path(SYS_ARCHIVE_PATH)];
- if (in_array($base_path.$item.'/', $special_dirs)) {
- continue;
- }
- if (is_dir($base_path.$item)) {
- $files = array_merge($files, get_all_php_files($base_path.$item.'/'));
- } else {
- //only analyse php files
- $sub = substr($item, -4);
- if ($sub == '.php' or $sub == '.tpl') {
- $files[] = $base_path.$item;
- }
- }
- }
- $list = null;
-
- return $files;
-}
diff --git a/main/cron/lang/list_unused_langvars.php b/main/cron/lang/list_unused_langvars.php
index 6d2bee6e07..319194ab18 100755
--- a/main/cron/lang/list_unused_langvars.php
+++ b/main/cron/lang/list_unused_langvars.php
@@ -8,7 +8,7 @@
* Includes and declarations.
*/
die();
-require_once '../../inc/global.inc.php';
+require_once __DIR__.'/../../inc/global.inc.php';
$path = api_get_path(SYS_LANG_PATH).'english';
ini_set('memory_limit', '128M');
/**
@@ -31,7 +31,7 @@ echo count($defined_terms)." terms were found in language files
";
// time and memory)
$usedTerms = [];
$l = strlen(api_get_path(SYS_PATH));
-$files = get_all_php_files(api_get_path(SYS_PATH));
+$files = getAllPhpFiles(api_get_path(SYS_PATH));
// Browse files
foreach ($files as $file) {
//echo 'Analyzing '.$file."
";
@@ -86,29 +86,3 @@ foreach ($defined_terms as $term => $file) {
}
echo "\n";
-function get_all_php_files($base_path)
-{
- $list = scandir($base_path);
- $files = [];
- foreach ($list as $item) {
- if (substr($item, 0, 1) == '.') {
- continue;
- }
- $special_dirs = [api_get_path(SYS_TEST_PATH), api_get_path(SYS_COURSE_PATH), api_get_path(SYS_LANG_PATH), api_get_path(SYS_ARCHIVE_PATH)];
- if (in_array($base_path.$item.'/', $special_dirs)) {
- continue;
- }
- if (is_dir($base_path.$item)) {
- $files = array_merge($files, get_all_php_files($base_path.$item.'/'));
- } else {
- //only analyse php files
- $sub = substr($item, -4);
- if ($sub == '.php' or $sub == '.tpl') {
- $files[] = $base_path.$item;
- }
- }
- }
- $list = null;
-
- return $files;
-}
diff --git a/main/cron/lang/switch_files_to_gettext.php b/main/cron/lang/switch_files_to_gettext.php
new file mode 100755
index 0000000000..fc315fa876
--- /dev/null
+++ b/main/cron/lang/switch_files_to_gettext.php
@@ -0,0 +1,91 @@
+ $translation) {
+ $terms[$index] = trim(rtrim($translation, ';'), '"');
+}
+// get only the array keys (the language variables defined in language files)
+$defined_terms = array_flip(array_keys($terms));
+echo count($defined_terms)." terms were found in language files".PHP_EOL;
+
+// now get all terms found in all PHP files of Chamilo (this takes some
+// time and memory)
+$usedTerms = [];
+$l = strlen(api_get_path(SYS_PATH));
+$files = getAllPhpFiles(api_get_path(SYS_PATH));
+$rootLength = strlen(api_get_path(SYS_PATH));
+$countFiles = 0;
+$countReplaces = 0;
+// Browse files
+foreach ($files as $file) {
+ if (substr($file, $rootLength, 6) === 'vendor' || substr($file, $rootLength, 3) === 'web') {
+ continue;
+ }
+ //echo 'Analyzing '.$file.PHP_EOL;
+ $shortFile = substr($file, $l);
+ //echo 'Analyzing '.$shortFile.PHP_EOL;
+ $lines = file($file);
+ // Browse lines inside file $file
+ foreach ($lines as $line) {
+ $myTerms = [];
+ $res = preg_match_all('/get_lang\(([\'"](\\w*)[\'"])\)/m', $line, $myTerms);
+ if ($res > 0) {
+ foreach ($myTerms[2] as $term) {
+ echo "Found term $term - ".print_r($myTerms, 1).PHP_EOL;
+ if (substr($term, 0, 4) == 'lang') {
+ $term = substr($term, 4);
+ }
+ if (!empty($terms[$term])) {
+ $translation = $terms[$term];
+ $quotedTerm = $myTerms[1][0];
+ //echo "Would do sed -i \"s#$quotedTerm#'$translation'#g\" $file here\n";
+ system("sed -i \"s#$term#'$translation'#g\" $file");
+ $countReplaces++;
+ }
+ }
+ } else {
+ $res = 0;
+ $res = preg_match_all('/\{\s*([\'"](\\w*)[\'"])\s*\|get_lang\}/m', $line, $myTerms);
+ if ($res > 0) {
+ foreach ($myTerms[2] as $term) {
+ echo "Found term $term".PHP_EOL;
+ if (substr($term, 0, 4) == 'lang') {
+ $term = substr($term, 4);
+ }
+ if (!empty($terms[$term])) {
+ $translation = $terms[$term];
+ $quotedTerm = $myTerms[1][0];
+ //echo "Would do sed -i \"s#$quotedTerm#'$translation'#g\" $file here\n";
+ system("sed -i \"s#$term#'$translation'#g\" $file");
+ $countReplaces++;
+ }
+ }
+ }
+ }
+ }
+ $countFiles++;
+ flush();
+}
+
+echo "Done analyzing $countFiles files, with $countReplaces replacements!\n";
diff --git a/main/inc/lib/fileManage.lib.php b/main/inc/lib/fileManage.lib.php
index eedfd91ca5..3c71744b5a 100755
--- a/main/inc/lib/fileManage.lib.php
+++ b/main/inc/lib/fileManage.lib.php
@@ -63,9 +63,8 @@ function my_delete($file)
return true;
}
- } else {
- return false; // no file or directory to delete
}
+ return false; // no file or directory to delete
}
/**
@@ -258,9 +257,8 @@ function move($source, $target, $forceMove = true, $moveContent = false)
return true;
}
- } else {
- return false;
}
+ return false;
}
/**
@@ -270,6 +268,7 @@ function move($source, $target, $forceMove = true, $moveContent = false)
*
* @param string $source the path of the directory to move
* @param string $destination the path of the new area
+ * @param bool $move Whether we want to remove the source at the end
*
* @return bool false on error
*/
@@ -344,3 +343,42 @@ function getextension($filename)
return [array_pop($bouts), implode('.', $bouts)];
}
+
+/**
+ * Get a list of all PHP (.php) files in a given directory. Includes .tpl files
+ * @param string $base_path The base path in which to find the corresponding files
+ * @param bool $includeStatic Include static .html, .htm and .css files
+ * @return array
+ */
+function getAllPhpFiles($base_path, $includeStatic = false)
+{
+ $list = scandir($base_path);
+ $files = [];
+ $extensionsArray = ['.php', '.tpl'];
+ if ($includeStatic) {
+ $extensionsArray[] = 'html';
+ $extensionsArray[] = '.htm';
+ $extensionsArray[] = '.css';
+ }
+ foreach ($list as $item) {
+ if (substr($item, 0, 1) == '.') {
+ continue;
+ }
+ $special_dirs = [api_get_path(SYS_TEST_PATH), api_get_path(SYS_COURSE_PATH), api_get_path(SYS_LANG_PATH), api_get_path(SYS_ARCHIVE_PATH)];
+ if (in_array($base_path.$item.'/', $special_dirs)) {
+ continue;
+ }
+ if (is_dir($base_path.$item)) {
+ $files = array_merge($files, getAllPhpFiles($base_path.$item.'/', $includeStatic));
+ } else {
+ //only analyse php files
+ $sub = substr($item, -4);
+ if (in_array($sub, $extensionsArray)) {
+ $files[] = $base_path.$item;
+ }
+ }
+ }
+ $list = null;
+
+ return $files;
+}
\ No newline at end of file
diff --git a/main/inc/lib/statistics.lib.php b/main/inc/lib/statistics.lib.php
index cb87f958ea..a3d38fa9f9 100644
--- a/main/inc/lib/statistics.lib.php
+++ b/main/inc/lib/statistics.lib.php
@@ -300,7 +300,7 @@ class Statistics
WHERE track_default.default_user_id = user.user_id ";
}
- if (isset($_GET['keyword'])) {
+ if (!empty($_GET['keyword'])) {
$keyword = Database::escape_string(trim($_GET['keyword']));
$sql .= " AND (user.username LIKE '%".$keyword."%' OR
default_event_type LIKE '%".$keyword."%' OR
diff --git a/main/lang/english/trad4all.inc.php b/main/lang/english/trad4all.inc.php
index ed739ce063..f2bc0d8826 100644
--- a/main/lang/english/trad4all.inc.php
+++ b/main/lang/english/trad4all.inc.php
@@ -8121,4 +8121,7 @@ $HottestSessions = "Most popular sessions";
$LPItemCanBeAccessed = "Item can be viewed - Prerequisites completed";
$ItemXBlocksThisElement = "Item %s blocks this step";
$YourResultAtXBlocksThisElement = "Your result at %s blocks this step";
+$RegistrationRoleWhatDoYouWantToDo = "What do you want to do?";
+$RegistrationRoleFollowCourses = "Follow courses";
+$RegistrationRoleTeachCourses = "Teach courses";
?>
\ No newline at end of file
diff --git a/main/lang/french/trad4all.inc.php b/main/lang/french/trad4all.inc.php
index d3c0598e87..6897f9ada6 100644
--- a/main/lang/french/trad4all.inc.php
+++ b/main/lang/french/trad4all.inc.php
@@ -8058,4 +8058,7 @@ $HottestSessions = "Sessions les plus populaires";
$LPItemCanBeAccessed = "Etape accessible";
$ItemXBlocksThisElement = "L'absence de consultation de l'étape \"%s\" ne vous permet pas d'accéder à celle-ci";
$YourResultAtXBlocksThisElement = "Votre score à l'étape \"%s\" ne vous permet d'accéder à celle-ci";
+$RegistrationRoleWhatDoYouWantToDo = "Que souhaitez-vous faire?";
+$RegistrationRoleFollowCourses = "Suivre des cours";
+$RegistrationRoleTeachCourses = "Enseigner";
?>
\ No newline at end of file
diff --git a/main/lang/spanish/trad4all.inc.php b/main/lang/spanish/trad4all.inc.php
index d02f767f39..625c6c64cb 100644
--- a/main/lang/spanish/trad4all.inc.php
+++ b/main/lang/spanish/trad4all.inc.php
@@ -3019,7 +3019,7 @@ $Archive = "archivo";
$CourseCode = "Código del curso";
$NoDescription = "Sin descripción";
$OfficialCode = "Código oficial";
-$FirstName = "Nombre";
+$FirstName = "Nombres";
$LastName = "Apellidos";
$Status = "Estado";
$Email = "Correo electrónico";
@@ -7000,7 +7000,7 @@ $Configure = "Configurar";
$Regions = "Regiones";
$CourseList = "Lista de cursos";
$NumberAbbreviation = "N°";
-$FirstnameAndLastname = "Nombre y apellidos";
+$FirstnameAndLastname = "Nombres y apellidos";
$LastnameAndFirstname = "Apellidos y nombre";
$Plugins = "Plugins";
$Detailed = "Detallado";
@@ -8145,4 +8145,7 @@ $HottestSessions = "Sesiones más populares";
$LPItemCanBeAccessed = "Item accesible - prerequisitos completados.";
$ItemXBlocksThisElement = "El item \"%s\" bloquea este paso";
$YourResultAtXBlocksThisElement = "El resultado en el item \"%s\" bloquea esta etapa.";
+$RegistrationRoleWhatDoYouWantToDo = "¿Qué deseas hacer?";
+$RegistrationRoleFollowCourses = "Seguir cursos";
+$RegistrationRoleTeachCourses = "Dictar cursos";
?>
\ No newline at end of file
diff --git a/main/lp/lp_edit.php b/main/lp/lp_edit.php
index ad8b93f35e..9af3b5c9ee 100755
--- a/main/lp/lp_edit.php
+++ b/main/lp/lp_edit.php
@@ -8,7 +8,7 @@ use ChamiloSession as Session;
*
* @package chamilo.learnpath
*
- * @author Yannick Warnier
+ * @author Yannick Warnier
*/
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
@@ -106,7 +106,8 @@ $form->applyFilter('lp_author', 'html_filter');
// LP image
if (strlen($learnPath->get_preview_image()) > 0) {
- $show_preview_image = '
get_preview_image().'>';
+ $show_preview_image = '
get_preview_image().'>';
$form->addElement('label', get_lang('ImagePreview'), $show_preview_image);
$form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
}
@@ -241,8 +242,12 @@ if ($enableLpExtraFields) {
';
}
-$defaults['publicated_on'] = !empty($publicated_on) && $publicated_on !== '0000-00-00 00:00:00' ? api_get_local_time($publicated_on) : null;
-$defaults['expired_on'] = (!empty($expired_on)) ? api_get_local_time($expired_on) : date('Y-m-d 12:00:00', time() + 84600);
+$defaults['publicated_on'] = !empty($publicated_on) && $publicated_on !== '0000-00-00 00:00:00'
+ ? api_get_local_time($publicated_on)
+ : null;
+$defaults['expired_on'] = (!empty($expired_on))
+ ? api_get_local_time($expired_on)
+ : date('Y-m-d 12:00:00', time() + 84600);
$defaults['subscribe_users'] = $learnPath->getSubscribeUsers();
$defaults['skills'] = array_keys($skillList);
$form->setDefaults($defaults);
diff --git a/tests/scripts/img/list_unused_img.php b/tests/scripts/img/list_unused_img.php
index 76848a51b9..b37a556123 100644
--- a/tests/scripts/img/list_unused_img.php
+++ b/tests/scripts/img/list_unused_img.php
@@ -9,7 +9,7 @@
if (PHP_SAPI!='cli') {
die('Run this script through the command line or comment this line in the code');
}
-require_once '../../inc/global.inc.php';
+require_once __DIR__.'/../../../main/inc/global.inc.php';
$path = api_get_path(SYS_CODE_PATH).'img/';
ini_set('memory_limit', '128M');
ini_set('max_execution_time', '240');
@@ -64,41 +64,6 @@ foreach ($unused as $term => $path) {
}
echo "\n";
-/**
- * @param $base_path
- * @return array
- */
-function get_all_php_files($base_path)
-{
- $list = scandir($base_path);
- $files = array();
- foreach ($list as $item) {
- if (substr($item, 0, 1)=='.') {
- continue;
- }
- $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)
- );
- if (in_array($base_path.$item.'/', $special_dirs)) {
- continue;
- }
- if (is_dir($base_path.$item)) {
- $files = array_merge($files, get_all_php_files($base_path.$item.'/'));
- } else {
- //only analyse php files
- $ext = substr($item, -4);
- if (in_array($ext, array('.php', 'html', '.htm', '.css'))) {
- $files[] = $base_path.$item;
- }
- }
- }
- $list = null;
- return $files;
-}
-
/**
* Get the list of available images
* @param string $path The path to start the scan from
diff --git a/tests/scripts/img/list_used_img.php b/tests/scripts/img/list_used_img.php
index 007910c22a..664b9b55a7 100644
--- a/tests/scripts/img/list_used_img.php
+++ b/tests/scripts/img/list_used_img.php
@@ -7,7 +7,7 @@
* Includes and declarations
*/
if (PHP_SAPI!='cli') { die('Run this script through the command line or comment this line in the code'); }
-require_once '../../inc/global.inc.php';
+require_once __DIR__.'/../../../main/inc/global.inc.php';
$path = api_get_path(SYS_CODE_PATH).'img/';
ini_set('memory_limit','128M');
ini_set('max_execution_time','240');
@@ -19,8 +19,9 @@ $found_img = get_img_files($path);
// now get all terms found in all PHP files of Chamilo (this takes some time and memory)
$unexisting_img = array();
$l = strlen(api_get_path(SYS_PATH));
-$files = get_all_php_files(api_get_path(SYS_PATH));
+$files = getAllPhpFiles(api_get_path(SYS_PATH), true);
$counter = 0;
+$used_icons = [];
foreach ($files as $file) {
$shortfile = substr($file,$l);
$lines = file($file);
@@ -77,27 +78,6 @@ echo "\n";
echo "Analysed files:
\n";
print_r($files);
-
-function get_all_php_files($base_path) {
- $list = scandir($base_path);
- $files = array();
- foreach ($list as $item) {
- if (substr($item,0,1)=='.') {continue;}
- $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));
- if (in_array($base_path.$item.'/',$special_dirs)) {continue;}
- if (is_dir($base_path.$item)) {
- $files = array_merge($files,get_all_php_files($base_path.$item.'/'));
- } else {
- //only analyse php files
- $ext = substr($item,-4);
- if (in_array($ext,array('.php','html','.htm','.css'))) {
- $files[] = $base_path.$item;
- }
- }
- }
- $list = null;
- return $files;
-}
function get_img_files($path) {
$files = array();
//We know there are max 3 levels