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));
$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);
}
-?>
\ No newline at end of file
+?>
# 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> </p>
- $content0=preg_replace("+<p> </p>+i","\n",$data0["content"]);
- $content0=preg_replace("+(".join("|",$htmlendings).")+","\n",$content0);
- $content=preg_replace("+<p> </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> </p>
+ $content0 = preg_replace('#(<p.*>( |\s+)</p>|<p.*></p>)#i', "\n", $content0);
+ $content = preg_replace('#(<p.*>( |\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"];
///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("+ +","",$html0[$i])));
-# if($linecontent) { // There is something !
- $txt0[]=$html0[$i];
-# }
- }
- for($i=0;$i<count($html2);$i++) {
-# $linecontent=trim(strip_tags(preg_replace("+ +","",$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) {
}
else {
if($wiki->htmlmode == 2) {
- $o .= "$line<br>\n";
+ $o .= "$line\n";
} else {
$o .= " $line<br>\n";
}
#-- 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) {
foreach ($sorted as $id=>$uu) {
$row = $files[$id];
- $o .= ewiki_entry_downloads($row, $section[0]=="*");
+ $o .= ewiki_entry_downloads($row, $section[0]=="*", true);
}
}
-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;
$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);
+ }
echo '<table border="0">';
echo '<tr>';
$tabs = array('view', 'edit','links','info');
- if ($binary) {
+ if ($wiki->ewikiacceptbinary) {
$tabs[] = 'attachments';
}
foreach ($tabs as $tab) {