2 /****************************************************************/
\r
3 /* Atutor-OpenCaps Module
\r
4 /****************************************************************/
\r
5 /* Copyright (c) 2010
\r
6 /* Written by Antonio Gamba
\r
7 /* Adaptive Technology Resource Centre / University of Toronto
\r
9 /* This program is free software. You can redistribute it and/or
\r
10 /* modify it under the terms of the GNU General Public License
\r
11 /* as published by the Free Software Foundation.
\r
12 /****************************************************************/
\r
18 * @desc directoryToArray
\r
19 * @param String $directory
\r
20 * @param bool $recursive
\r
23 public function directoryToArray($directory, $recursive)
\r
25 global $ocAtSettings;
\r
27 $rex = '/^.*\.('.$ocAtSettings['supportedMedia'].')$/i';
\r
29 $array_items = array();
\r
30 if ($handle = opendir($directory)) {
\r
31 while (false !== ($file = readdir($handle))) {
\r
32 if ($file != "." && $file != "..") {
\r
33 if (is_dir($directory. $sep . $file)) {
\r
36 $array_items = array_merge($array_items,$this->directoryToArray($directory. $sep . $file, $recursive));
\r
38 //add if add only known files
\r
39 if (preg_match($rex, $file))
\r
41 //$file = $directory . $sep . $file;
\r
42 $array_items[] = preg_replace("/\/\//si", $sep, $file);
\r
43 //echo '<br/>'.$file;
\r
47 if (preg_match($rex, $file))
\r
49 $file = $directory . $sep . $file;
\r
50 //$file = $sep . $file;
\r
51 $file = str_replace(AT_CONTENT_DIR.''.$_SESSION['course_id'].$sep, '', $file);
\r
52 $file = str_replace('\\', '/', $file);
\r
53 $array_items[] = preg_replace("/\/\//si", $sep, $file);
\r
54 //echo '<br/>'.$file;
\r
61 return $array_items;
\r
62 } // end directoryToArray
\r
64 } // end class ServerFiles
\r