MDL-33204 use natural filename sorting when importing books form html
authorPetr Skoda <commits@skodak.org>
Sun, 10 Jun 2012 16:14:18 +0000 (18:14 +0200)
committerPetr Skoda <commits@skodak.org>
Tue, 12 Jun 2012 08:59:58 +0000 (10:59 +0200)
mod/book/tool/importhtml/locallib.php

index 7aa04ca..932054b 100644 (file)
@@ -298,10 +298,10 @@ function toolbook_importhtml_get_chapter_files($package, $type) {
             }
         }
     }
             }
         }
     }
-    // TODO: natural dir sorting would be nice here...
-    textlib::asort($tophtmlfiles);
-    textlib::asort($subhtmlfiles);
-    textlib::asort($topdirs);
+
+    collatorlib::ksort($tophtmlfiles, collatorlib::SORT_NATURAL);
+    collatorlib::ksort($subhtmlfiles, collatorlib::SORT_NATURAL);
+    collatorlib::ksort($topdirs, collatorlib::SORT_NATURAL);
 
     $chapterfiles = array();
 
 
     $chapterfiles = array();
 
@@ -313,7 +313,7 @@ function toolbook_importhtml_get_chapter_files($package, $type) {
             if (empty($htmlfiles)) {
                 continue;
             }
             if (empty($htmlfiles)) {
                 continue;
             }
-            textlib::asort($htmlfiles);
+            collatorlib::ksort($htmlfiles, collatorlib::SORT_NATURAL);
             if (isset($htmlfiles[$dir.'/index.html'])) {
                 $htmlfile = $htmlfiles[$dir.'/index.html'];
             } else if (isset($htmlfiles[$dir.'/index.htm'])) {
             if (isset($htmlfiles[$dir.'/index.html'])) {
                 $htmlfile = $htmlfiles[$dir.'/index.html'];
             } else if (isset($htmlfiles[$dir.'/index.htm'])) {