/** * Browse path with language files and extract variables name * and their values (retrieve_lang_vars function). * Script used in extract_var_from_lang_files.php * * @author - Hugues Peeters <*****@*****.**> * @param - $dirPath - directory path * @param - $languageName - language name of the translation file */ function glance_through_dir_lang($dirPath, $languageName) { chdir($dirPath); $handle = opendir($dirPath); $fileList = array(); $dirList = array(); while ($element = readdir($handle)) { if ($element == "." || $element == ".." || strstr($element, "~") || strstr($element, "#")) { continue; // skip the current and parent directories and some files } // browse only old file name .php and LANG_COMPLETE_FILENAME (complete.lang.php) $pos = strpos($element, '.lang.php'); if (is_file($element) && $element != 'locale_settings.php' && substr(strrchr($element, '.'), 1) == 'php' && (strlen($element) != $pos + strlen('.lang.php') || $element == LANG_COMPLETE_FILENAME)) { $fileList[] = $dirPath . "/" . $element; } if (is_dir($element)) { $dirList[] = $dirPath . "/" . $element; } } if (sizeof($fileList) > 0) { echo "<ol>"; foreach ($fileList as $thisFile) { echo "<li>" . $thisFile . "</li>\n"; retrieve_lang_var($thisFile, $languageName); } echo "</ol>\n"; echo "<p>" . sizeof($fileList) . " file(s).</p>\n"; } if (sizeof($dirList) > 0) { foreach ($dirList as $thisDir) { glance_through_dir_lang($thisDir, $languageName); // recursion } } }
// drop table if exists $sql = "DROP TABLE IF EXISTS " . $tbl_translation . " "; claro_sql_query($sql); // create table $sql = "CREATE TABLE " . $tbl_translation . " (\n id INTEGER NOT NULL auto_increment,\n language VARCHAR(250) NOT NULL,\n varName VARCHAR(250) BINARY NOT NULL,\n varContent VARCHAR(250) NOT NULL,\n varFullContent TEXT NOT NULL,\n sourceFile VARCHAR(250) NOT NULL,\n used tinyint(4) default 0,\n INDEX index_language (language,varName),\n INDEX index_content (language,varContent),\n PRIMARY KEY(id))"; claro_sql_query($sql); // go to & browse lang path $path_lang = get_path('rootSys') . "claroline/lang"; $it = new DirectoryIterator($path_lang); echo '<ol>' . "\n"; foreach ($it as $file) { if ($file->isDir() && !$file->isDot() && $file->getFilename() != '.svn') { $completeFile = $file->getPathname() . '/' . LANG_COMPLETE_FILENAME; if (file_exists($completeFile)) { retrieve_lang_var($completeFile, $file->getFilename()); echo '<li>' . $completeFile . '</li>' . "\n"; } $installFile = $file->getPathname() . '/' . LANG_INSTALL_FILENAME; if (file_exists($installFile)) { retrieve_lang_var($installFile, $file->getFilename()); echo '<li>' . $installFile . '</li>' . "\n"; } } } echo '</ol>' . "\n"; // get and display end time $endtime = get_time(); $totaltime = $endtime - $starttime; echo "<p><em>Execution time: {$totaltime}</em></p>\n" . '<a href="' . $urlTranslation . '"><< Back</a>' . "\n"; // display footer include get_path('incRepositorySys') . '/claro_init_footer.inc.php';