aeb19f52b589d09618120cd69c393e9815400f38
[atutor.git] / mods / atutor_opencaps / opencaps / conversion_service / include / classes / static_CcUtilVital_class.php
1 <?php\r
2 class CcUtilVital\r
3 {\r
4 \r
5         /**\r
6          * Loads all Caption Formats and return an array with class names\r
7          * Essential !!\r
8          *\r
9          */\r
10         static public function ccFormatsLoad()\r
11         {\r
12                 global $rosettaCCSettings; // load global vars\r
13                 \r
14                 $ccFormats = array(); // stores all caption formats allowed\r
15                 \r
16                 $dir = $rosettaCCSettings['ccformats'];\r
17                 $ccFormatsString = '';\r
18                 $ccFileNameFormatRegex = '/cc_(.*?)_format/'; // (e.g. "cc_(QTtext)_format.php")\r
19                 $countCcFiles = 0;\r
20 \r
21                 // verify if the directory exists\r
22                 if ($handle = opendir($dir)) \r
23                 {\r
24                     // read all files in the dir and include Caption Format files\r
25                     while (false !== ($file = readdir($handle))) \r
26                     {\r
27                         if (!is_dir($file))\r
28                         {\r
29                                 // build a string with all file names\r
30                                 $ccFormatsString .= ''.$file.';';\r
31                                 \r
32                                 // include the caption format file\r
33                                         include_once($dir.'/'.$file);\r
34                                 \r
35                                 $countCcFiles++;\r
36                         }\r
37                         }\r
38                 } \r
39                         // close dir handler \r
40                         closedir($handle);\r
41 \r
42                         // get all Class names from the string using regex\r
43                         preg_match_all($ccFileNameFormatRegex, $ccFormatsString, $ccFormatsPat);\r
44                         \r
45                         // add Class names to $ccFormats global Array\r
46                         for ($j=0;$j<count($ccFormatsPat[1]);$j++)\r
47                         {\r
48                                 $ccFormats[] = $ccFormatsPat[1][$j];\r
49                         }\r
50                         // sort $ccFormats array \r
51                         asort($ccFormats);\r
52                         \r
53                         return $ccFormats;\r
54                          \r
55         } // ccFormatsLoad() end\r
56 \r
57         \r
58         \r
59         \r
60 } // end class CcUtilEssential  \r
61 ?>