From 1bd9b44a33245ba2fd9d7c640f25484c1db125a0 Mon Sep 17 00:00:00 2001
From: mudrd8mz
Date: Wed, 28 Jun 2006 01:02:54 +0000
Subject: [PATCH] * Hide preview link when editing docs\ files. I have not
found any way how to display local documenation pages in 1.6. More comment
in bug 4972 * Hide the form when displaying non-editable files (like en_utf8
ones).
---
admin/langdoc.php | 71 ++++++++++++++++++++++++++++-------------------
1 file changed, 42 insertions(+), 29 deletions(-)
diff --git a/admin/langdoc.php b/admin/langdoc.php
index 604df51739..7530a9822a 100755
--- a/admin/langdoc.php
+++ b/admin/langdoc.php
@@ -1,14 +1,14 @@
";
echo htmlspecialchars(file_get_contents("$enlangdir/$currentfile"));
echo "\n";
//link_to_popup_window("/lang/en_utf8/$currentfile", "popup", get_string("preview"));
- link_to_popup_window(help_preview_url($currentfile).'&forcelang=en_utf8', 'popup', get_string('preview'));
+ $preview_url = langdoc_preview_url($currentfile);
+ if ($preview_url) {
+ link_to_popup_window($preview_url.'&forcelang=en_utf8', 'popup', get_string('preview'));
+ }
echo "\n";
if ($fileeditorinline == 1) {
echo "\n\n";
@@ -182,23 +185,25 @@ $langdir/$currentfile")."";
echo " \n";
- if ($editable) {
+ echo "\n";
+ if (file_exists("$langdir/$currentfile")) {
+ echo htmlspecialchars(file_get_contents("$langdir/$currentfile"));
+ } else {
+ echo ($filetemplate);
+ }
+ echo " \n";
+ $preview_url = langdoc_preview_url($currentfile);
+ if ($preview_url) {
+ link_to_popup_window($preview_url, 'popup', get_string('preview'));
+ }
echo '
';
echo '';
}
+ echo "\n\n";
+
+
error_reporting($CFG->debug);
}
@@ -240,18 +245,26 @@ function langdoc_save_file($path, $file, $content) {
return true;
}
-
-function help_preview_url($currentfile) {
+/**
+ * Return a preview URL for the file, if available.
+ *
+ * Documentation will be moved into moodle.org wiki and current version 1.6 does not
+ * seem to be able to display local documentation. Thus, return empty URL for doc files.
+ * See lib/moodlelib.php document_file() - it still relies on old pre-UTF8 lang/ location.
+ */
+function langdoc_preview_url($currentfile) {
if (substr($currentfile, 0, 5) == 'help/') {
$currentfile = substr($currentfile, 5);
- }
- $currentpathexp = explode('/', $currentfile);
- if (count($currentpathexp) > 1) {
- $url = '/help.php?module='.$currentpathexp[0].'&file='.$currentpathexp[1];
+ $currentpathexp = explode('/', $currentfile);
+ if (count($currentpathexp) > 1) {
+ $url = '/help.php?module='.$currentpathexp[0].'&file='.$currentpathexp[1];
+ } else {
+ $url = '/help.php?module=moodle&file='.$currentfile;
+ }
} else {
- $url = '/help.php?module=moodle&file='.$currentfile;
+ $url = '';
}
return $url;
}
-?>
\ No newline at end of file
+?>
--
2.39.5