From 1290953e407e933136be60d8ef60e074e7317c7e Mon Sep 17 00:00:00 2001
From: moodler
Date: Thu, 26 Aug 2004 15:23:07 +0000
Subject: [PATCH] Merged changes from stable
---
mod/wiki/backuplib.php | 1 +
mod/wiki/ewiki/plugins/aview/downloads.php | 32 +++++++-----
mod/wiki/ewiki/plugins/moodle/diff.php | 54 +++++++++------------
mod/wiki/ewiki/plugins/moodle/downloads.php | 37 ++++++++++----
mod/wiki/view.php | 2 +-
5 files changed, 72 insertions(+), 54 deletions(-)
diff --git a/mod/wiki/backuplib.php b/mod/wiki/backuplib.php
index c16587e320..64ca2a954d 100644
--- a/mod/wiki/backuplib.php
+++ b/mod/wiki/backuplib.php
@@ -134,6 +134,7 @@
fwrite ($bf,full_tag("FLAGS",8,false,$page->flags));
fwrite ($bf,full_tag("CONTENT",8,false,$page->content));
fwrite ($bf,full_tag("AUTHOR",8,false,$page->author));
+ fwrite ($bf,full_tag("USERID",8,false,$page->userid));
fwrite ($bf,full_tag("CREATED",8,false,$page->created));
fwrite ($bf,full_tag("LASTMODIFIED",8,false,$page->lastmodified));
fwrite ($bf,full_tag("REFS",8,false,$page->refs));
diff --git a/mod/wiki/ewiki/plugins/aview/downloads.php b/mod/wiki/ewiki/plugins/aview/downloads.php
index d0455c49ea..c74e72ffdc 100644
--- a/mod/wiki/ewiki/plugins/aview/downloads.php
+++ b/mod/wiki/ewiki/plugins/aview/downloads.php
@@ -25,19 +25,25 @@ function ewiki_view_append_attachments($id, $data, $action) {
$scan = 's:7:"section";' . serialize($id);
$result = ewiki_database("SEARCH", array("meta" => $scan));
- $ord = array();
- while ($row = $result->get()) {
- $ord[$row["id"]] = $row["created"];
- }
- arsort($ord);
-
- foreach ($ord as $id => $uu) {
- $row = ewiki_database("GET", array("id"=>$id));
- if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $row, "view")) {
- continue;
- }
- $o .= ewiki_entry_downloads($row, "*");
+#### BEGIN MOODLE CHANGES - show attachments link only if there are attachments.
+#### - don't show the attachments on the content page.
+ if (count($result->entries) <= 0) {
+ $o = '';
}
+// $ord = array();
+// while ($row = $result->get()) {
+// $ord[$row["id"]] = $row["created"];
+// }
+// arsort($ord);
+//
+// foreach ($ord as $id => $uu) {
+// $row = ewiki_database("GET", array("id"=>$id));
+// if (EWIKI_PROTECTED_MODE && EWIKI_PROTECTED_MODE_HIDING && !ewiki_auth($row["id"], $row, "view")) {
+// continue;
+// }
+// $o .= ewiki_entry_downloads($row, "*");
+// }
+#### END MOODLE CHANGES
return($o);
}
@@ -52,4 +58,4 @@ function ewiki_attachments() {
-?>
\ No newline at end of file
+?>
diff --git a/mod/wiki/ewiki/plugins/moodle/diff.php b/mod/wiki/ewiki/plugins/moodle/diff.php
index bd09eba198..5e234167a2 100755
--- a/mod/wiki/ewiki/plugins/moodle/diff.php
+++ b/mod/wiki/ewiki/plugins/moodle/diff.php
@@ -34,12 +34,25 @@
# Different handling for html: closes Bug #1530 - Wiki diffs useless when using HTML editor
if($wiki->htmlmode==2) {
- $htmlendings=array("
","
","","
","","
","
","","");
- /// Replace
- $content0=preg_replace("+
+i","\n",$data0["content"]);
- $content0=preg_replace("+(".join("|",$htmlendings).")+","\n",$content0);
- $content=preg_replace("+
+i","\n",$data["content"]);
- $content=preg_replace("+(".join("|",$htmlendings).")+","\n",$content);
+ /// Remove all new line characters. They will be placed at HTML line breaks.
+ $content0 = preg_replace('/\n|\r/i', ' ', $data0['content']);
+ $content0 = preg_replace('/(\S)\s+(\S)/', '$1 $2', $content0); // Remove multiple spaces.
+ $content = preg_replace('/\n|\r/i', ' ', $data['content']);
+ $content = preg_replace('/(\S)\s+(\S)/', '$1 $2', $content);
+
+ /// Replace
+ $content0 = preg_replace('#(( |\s+)
|)#i', "\n", $content0);
+ $content = preg_replace('#(( |\s+)|)#i', "\n", $content);
+
+ /// Place new line characters at logical HTML positions.
+ $htmlendings = array('+()+iU', '+()+iU', '+()+i', '+()+iU', '+()+iU',
+ '+()+i', '+()+iU', '+()+i', '+()+iU', '+()+i',
+ '+()+i', '+()+iU', '+()+i');
+ $htmlrepl = array("\n\$1\n", "\n\$1\n", "\n\$1\n", "\n\$1\n", "\n\$1\n",
+ "\n\$1\n", "\n\$1\n", "\n\$1\n", "\n\$1\n", "\n\$1\n",
+ "\n\$1\n", "\n\$1\n", "\n\$1\n");
+ $content0 = preg_replace($htmlendings, $htmlrepl, $content0);
+ $content = preg_replace($htmlendings, $htmlrepl, $content);
} else {
$content0=$data0["content"];
$content=$data["content"];
@@ -58,34 +71,13 @@
///print "";
///exit;
- /// Remove empty lines in html
- if($wiki->htmlmode==2) {
- $html0=$txt0;
- $html2=$txt2;
- $txt0=array();
- $txt2=array();
-
- for($i=0;$i $line) {
- if($wiki->htmlmode != 2) {
- $line = htmlentities($line);
- }
+// if($wiki->htmlmode != 2) {
+// $line = htmlentities($line);
+// }
$i2 = $i;
while ($rm = $diff0[$i2++]) {
if($wiki->htmlmode == 2) {
@@ -105,7 +97,7 @@
}
else {
if($wiki->htmlmode == 2) {
- $o .= "$line
\n";
+ $o .= "$line\n";
} else {
$o .= " $line
\n";
}
diff --git a/mod/wiki/ewiki/plugins/moodle/downloads.php b/mod/wiki/ewiki/plugins/moodle/downloads.php
index e22ed6f9ee..628a12df09 100644
--- a/mod/wiki/ewiki/plugins/moodle/downloads.php
+++ b/mod/wiki/ewiki/plugins/moodle/downloads.php
@@ -223,7 +223,7 @@ function ewiki_page_filedownload($id, $data, $action, $def_sec="") {
#-- collect entries
$files = array();
$sorted = array();
- $result = ewiki_database("GETALL", array("flags", "meta", "created", "hits"));
+ $result = ewiki_database("GETALL", array("flags", "meta", "created", "hits", "userid"));
while ($row = $result->get()) {
if (($row["flags"] & EWIKI_DB_F_TYPE) == EWIKI_DB_F_BINARY) {
@@ -278,7 +278,7 @@ function ewiki_page_filedownload($id, $data, $action, $def_sec="") {
foreach ($sorted as $id=>$uu) {
$row = $files[$id];
- $o .= ewiki_entry_downloads($row, $section[0]=="*");
+ $o .= ewiki_entry_downloads($row, $section[0]=="*", true);
}
}
@@ -291,7 +291,7 @@ function ewiki_page_filedownload($id, $data, $action, $def_sec="") {
-function ewiki_entry_downloads($row, $show_section=0) {
+function ewiki_entry_downloads($row, $show_section=0, $fullinfo=false) {
global $ewiki_binary_icons, $ewiki_upload_sections;
@@ -343,12 +343,31 @@ function ewiki_entry_downloads($row, $show_section=0) {
$info->title = $p_title;
$info->comment = $p_comment;
-
- $o .= ''.$info->icon.$info->title.''.$info->size.'
'.
- get_string("uploadedon","wiki").": ".$info->time.", ".get_string("downloadtimes","wiki",$info->hits)."
".
- '('.$info->id.")
".
- $info->section." ".get_string("fileisoftype","wiki").": ".$info->type.
- "$info->comment
";
+ if ($fullinfo) {
+ if ($user = get_record('user', 'id', $row['userid'])) {
+ if (!isset($course->id)) {
+ $course->id = 1;
+ }
+ $picture = print_user_picture($user->id, $course->id, $user->picture, false, true, true);
+ $value = $picture." wwwroot/user/view.php?id=$user->id&course=$course->id\">".
+ fullname($user)."";
+ }
+
+ $o .= ''.$info->icon.$info->title.''.$info->size.'
'.
+ $info->comment.
+ $info->section." ".get_string("fileisoftype","wiki").": ".$info->type.'
'.
+ get_string("uploadedon","wiki").": ".$info->time.", ".
+ ' by '.$value.'
'.
+ get_string("downloadtimes","wiki",$info->hits)."
".
+// '('.$info->id.")
".
+ '
';
+ }
+ else {
+// global $moodle_format; // from wiki/view.php
+ $o .= ''.$info->icon.$info->title.''.$info->size.'
'.
+ $info->comment.'
';
+// $o = format_text($o, $moodle_format);
+ }
diff --git a/mod/wiki/view.php b/mod/wiki/view.php
index 85e66f862e..8c08d029f1 100644
--- a/mod/wiki/view.php
+++ b/mod/wiki/view.php
@@ -303,7 +303,7 @@
echo '';
echo '';
$tabs = array('view', 'edit','links','info');
- if ($binary) {
+ if ($wiki->ewikiacceptbinary) {
$tabs[] = 'attachments';
}
foreach ($tabs as $tab) {
--
2.39.5