+++ /dev/null
-<?php\r
-/****************************************************************/\r
-/* Atutor-OpenCaps Module \r
-/****************************************************************/\r
-/* Copyright (c) 2010 \r
-/* Written by Antonio Gamba \r
-/* Adaptive Technology Resource Centre / University of Toronto\r
-/*\r
-/* This program is free software. You can redistribute it and/or\r
-/* modify it under the terms of the GNU General Public License\r
-/* as published by the Free Software Foundation.\r
-/****************************************************************/\r
-\r
-class ServerFiles\r
-{\r
- \r
- /**\r
- * @desc directoryToArray\r
- * @param String $directory\r
- * @param bool $recursive\r
- * @return Array\r
- */\r
- public function directoryToArray($directory, $recursive) \r
- {\r
- global $ocAtSettings;\r
- \r
- $rex = '/^.*\.('.$ocAtSettings['supportedMedia'].')$/i';\r
- $sep = '\\';\r
- $array_items = array();\r
- if ($handle = opendir($directory)) {\r
- while (false !== ($file = readdir($handle))) {\r
- if ($file != "." && $file != "..") {\r
- if (is_dir($directory. $sep . $file)) {\r
- if($recursive) \r
- {\r
- $array_items = array_merge($array_items,$this->directoryToArray($directory. $sep . $file, $recursive));\r
- }\r
- //add if add only known files\r
- if (preg_match($rex, $file))\r
- {\r
- //$file = $directory . $sep . $file;\r
- $array_items[] = preg_replace("/\/\//si", $sep, $file);\r
- //echo '<br/>'.$file; \r
- }\r
- \r
- } else {\r
- if (preg_match($rex, $file))\r
- {\r
- $file = $directory . $sep . $file;\r
- //$file = $sep . $file;\r
- $file = str_replace(AT_CONTENT_DIR.''.$_SESSION['course_id'].$sep, '', $file);\r
- $file = str_replace('\\', '/', $file);\r
- $array_items[] = preg_replace("/\/\//si", $sep, $file);\r
- //echo '<br/>'.$file; \r
- }\r
- }\r
- }\r
- }\r
- closedir($handle);\r
- }\r
- return $array_items;\r
- } // end directoryToArray\r
- \r
-} // end class ServerFiles\r
-?>\r