Merged changes from stable

This commit is contained in:
moodler
2004-08-26 15:23:07 +00:00
parent 359f27588b
commit 1290953e40
5 changed files with 72 additions and 54 deletions
+1
View File
@@ -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));
+19 -13
View File
@@ -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() {
?>
?>
+23 -31
View File
@@ -34,12 +34,25 @@
# Different handling for html: closes Bug #1530 - Wiki diffs useless when using HTML editor
if($wiki->htmlmode==2) {
$htmlendings=array("<br />","<br>","<p>","</p>","<p />","<hr />","<hr>","</li>","</tr>");
/// Replace <p>&nbsp;</p>
$content0=preg_replace("+<p>&nbsp;</p>+i","\n",$data0["content"]);
$content0=preg_replace("+(".join("|",$htmlendings).")+","\n",$content0);
$content=preg_replace("+<p>&nbsp;</p>+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 <p>&nbsp;</p>
$content0 = preg_replace('#(<p.*>(&nbsp;|\s+)</p>|<p.*></p>)#i', "\n", $content0);
$content = preg_replace('#(<p.*>(&nbsp;|\s+)</p>|<p.*></p>)#i', "\n", $content);
/// Place new line characters at logical HTML positions.
$htmlendings = array('+(<br.*>)+iU', '+(<p.*>)+iU', '+(</p>)+i', '+(<hr.*>)+iU', '+(<ol.*>)+iU',
'+(</ol>)+i', '+(<ul.*>)+iU', '+(</ul>)+i', '+(<li.*>)+iU', '+(</li>)+i',
'+(</tr>)+i', '+(<div.*>)+iU', '+(</div>)+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 "</pre>";
///exit;
/// Remove empty lines in html
if($wiki->htmlmode==2) {
$html0=$txt0;
$html2=$txt2;
$txt0=array();
$txt2=array();
for($i=0;$i<count($html0);$i++) {
# $linecontent=trim(strip_tags(preg_replace("+&nbsp;+","",$html0[$i])));
# if($linecontent) { // There is something !
$txt0[]=$html0[$i];
# }
}
for($i=0;$i<count($html2);$i++) {
# $linecontent=trim(strip_tags(preg_replace("+&nbsp;+","",$html2[$i])));
# if($linecontent) { // There is something !
$txt2[]=$html2[$i];
# }
}
}
$diff0 = array_diff($txt0, $txt2);
$diff2 = array_diff($txt2, $txt0);
foreach ($txt2 as $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<br>\n";
$o .= "$line\n";
} else {
$o .= "&nbsp; $line<br>\n";
}
+28 -9
View File
@@ -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 .= '<a href="'.$info->url.'">'.$info->icon.$info->title.'</a>'.$info->size.'<br>'.
get_string("uploadedon","wiki").": ".$info->time.", ".get_string("downloadtimes","wiki",$info->hits)."<br>".
'(<a href="'.$info->url.'">'.$info->id."</a>)<br>".
$info->section." ".get_string("fileisoftype","wiki").": ".$info->type.
"$info->comment<br><br>";
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." <a href=\"$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id\">".
fullname($user)."</a>";
}
$o .= '<a href="'.$info->url.'">'.$info->icon.$info->title.'</a>'.$info->size.'<br>'.
$info->comment.
$info->section." ".get_string("fileisoftype","wiki").": ".$info->type.'<br>'.
get_string("uploadedon","wiki").": ".$info->time.", ".
' by '.$value.'<br>'.
get_string("downloadtimes","wiki",$info->hits)."<br>".
// '(<a href="'.$info->url.'">'.$info->id."</a>)<br>".
'<br><br>';
}
else {
// global $moodle_format; // from wiki/view.php
$o .= '<a href="'.$info->url.'">'.$info->icon.$info->title.'</a>'.$info->size.'<br>'.
$info->comment.'<br><br>';
// $o = format_text($o, $moodle_format);
}
+1 -1
View File
@@ -303,7 +303,7 @@
echo '<table border="0">';
echo '<tr>';
$tabs = array('view', 'edit','links','info');
if ($binary) {
if ($wiki->ewikiacceptbinary) {
$tabs[] = 'attachments';
}
foreach ($tabs as $tab) {