]> git.mjollnir.org Git - moodle.git/commitdiff
Merged changes from stable
authormoodler <moodler>
Thu, 26 Aug 2004 15:23:07 +0000 (15:23 +0000)
committermoodler <moodler>
Thu, 26 Aug 2004 15:23:07 +0000 (15:23 +0000)
mod/wiki/backuplib.php
mod/wiki/ewiki/plugins/aview/downloads.php
mod/wiki/ewiki/plugins/moodle/diff.php
mod/wiki/ewiki/plugins/moodle/downloads.php
mod/wiki/view.php

index c16587e320c98d408ebcfb3fe3bdc24cee759f33..64ca2a954d79359257f8299bc6d0a744dffcba5a 100644 (file)
                 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));
index d0455c49ead4ba6cfddc78c6ba9bfbf140afbe6a..c74e72ffdcfe4390fbb128356e4948cfd211eeb6 100644 (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() {
 
 
 
-?>
\ No newline at end of file
+?>
index bd09eba1983f659a16d2c3ca571e00b58755610f..5e234167a2a33ffde531bb983776a6db58159cf3 100755 (executable)
 
     # 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"];
     ///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) {
        }
        else {
           if($wiki->htmlmode == 2) {
-            $o .= "$line<br>\n";
+            $o .= "$line\n";
           } else {
             $o .= "&nbsp; $line<br>\n";
           }
index e22ed6f9eee3e779ce3719d5954995fdd839a392..628a12df09e697f3615fdaf8b48d5be0eda87f2e 100644 (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);
+   }
 
    
    
index 85e66f862e12d527387323873ffc09dff981155c..8c08d029f18c6f829c866605f0a627a5f981205a 100644 (file)
         echo '<table border="0">';
         echo '<tr>';
         $tabs = array('view', 'edit','links','info');
-        if ($binary) {
+        if ($wiki->ewikiacceptbinary) {
             $tabs[] = 'attachments';
         }
         foreach ($tabs as $tab) {