shortname: $stredithelpdocs: $currentfile", "$site->fullname", "$stradministration -> ". "$strconfiguration -> $strlanguage -> $stredithelpdocs", 'choosefile.popup', '', true); $currentlang = current_language(); $langdir = "$CFG->dirroot/lang/$currentlang"; $enlangdir = "$CFG->dirroot/lang/en"; // Shall I save POSTed data? if (isset($_POST['currentfile'])) { if (confirm_sesskey()) { if (langdoc_save_file($langdir, $currentfile, $_POST['filedata'])) { notify(get_string("changessaved")." ($langdir/$currentfile)", "green"); } else { error("Could not save the file '$currentfile'!", "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey"); } } } error_reporting(0); // Error reporting turned off due to non-existing files // Generate selection for all help and documentation files // Get all files from /docs directory if (! $files = get_directory_list("$CFG->dirroot/lang/en/docs", "CVS")) { error("Could not find English language docs files!"); } $options = array(); foreach ($files as $filekey => $file) { // check all the docs files. $options["docs/$file"] = "docs/$file"; // add mark if file doesn't exist or is empty if (( !file_exists("$langdir/docs/$file")) || (filesize("$langdir/docs/$file") == 0)) { $options["docs/$file"] .= "$filemissingmark"; } else { if (filemtime("$langdir/docs/$file") < filemtime("$CFG->dirroot/lang/en/docs/$file")) { $options["docs/$file"] .= "$fileoldmark"; } } } // Get all files from /help directory if (! $files = get_directory_list("$CFG->dirroot/lang/en/help", "CVS")) { error("Could not find English language help files!"); } foreach ($files as $filekey => $file) { // check all the help files. $options["help/$file"] = "help/$file"; if (( !file_exists("$langdir/help/$file")) || (filesize("$CFG->dirroot/lang/en/help/$file") == 0)) { $options["help/$file"] .= "$filemissingmark"; } else { if (filemtime("$langdir/help/$file") < filemtime("$langdir/help/$file")) { $options["help/$file"] .= "$fileoldmark"; } } } echo "
"; echo popup_form ("$CFG->wwwroot/$CFG->admin/langdoc.php?sesskey=$USER->sesskey&currentfile=", $options, "choosefile", $currentfile, "", "", "", true); echo "
"; // Generate textareas if (!empty($currentfile)) { if (!file_exists("$langdir/$currentfile")) { //check if directory exist $pathparts = explode('/',$currentfile); $checkpath = $langdir; for ($a=0; $a < count($pathparts)-1 ; $a++) { $checkpath .= "/".$pathparts[$a]; if(!file_exists($checkpath)){ if(!mkdir($checkpath)){ echo ("Cannot create directory: $checkpath"); } } } // // file doesn't exist - let's check webserver's permission to create it // if (!touch("$langdir/$currentfile")) { // // webserver is unable to create new file // echo "

".get_string("filemissing", "", " $langdir/$currentfile")."

"; $editable = false; } else { // // webserver can create new file - we can delete it now and let // the langdoc_save_file() create it again if its filesize() > 0 // $editable = true; unlink("$langdir/$currentfile"); } } elseif ($f = fopen("$langdir/$currentfile","r+")) { // // file exists and is writeable - good for you, translator ;-) // $editable = true; fclose($f); } else { // // file exists but it is not writeable by web server process :-( // $editable = false; echo "

".get_string("makeeditable", "", "$langdir/$currentfile") ."

"; } echo "\n"; if ($fileeditorinline == 1) { echo "\n\n"; } echo "\n\n
\n"; echo "\n"; link_to_popup_window("/lang/en/$currentfile", "popup", get_string("preview")); echo "
\n"; if ($editable) { echo "
"; echo ''; echo ''; } echo "\n"; link_to_popup_window("/lang/$currentlang/$currentfile", "popup", get_string("preview")); echo "
"; if ($editable) { echo '
'; echo ''; } error_reporting($CFG->debug); } print_footer(); ////////////////////////////////////////////////////////////////////// function langdoc_save_file($path, $file, $content) { // $path is a full pathname to the file // $file is the file to overwrite. // $content are data to write global $CFG, $USER; error_reporting(0); if (!$f = fopen("$path/$file","w")) { error_reporting($CFG->debug); return false; } error_reporting($CFG->debug); $content = str_replace("\r", "",$content); // Remove linefeed characters $content = preg_replace("/\n{3,}/", "\n\n", $content); // Collapse runs of blank lines $content = str_replace("\\","",$content); // Delete all slashes $content = str_replace("%%","%",$content); $content = trim($content); // Delete leading/trailing whitespace fwrite($f, $content); fclose($f); // Remove file if its empty if (filesize("$path/$file") == 0) { unlink("$path/$file"); } return true; } ?>