changed git call from https to git readonly
[atutor.git] / mods / atutor_opencaps / opencaps / conversion_service / include / classes / core_CcService_class.php
1 <?php\r
2 class CcService\r
3 {       \r
4         // Unique Variables\r
5         private $ccResult; // $ccResult = 0 returns a caption string, $ccResult = 1 returns the caption URL\r
6         private $ccSourceURL; // The URL where the caption source file is located\r
7         \r
8         // variables to be passed to ConversionManager Class \r
9         private $ccStringTarget; // Caption Target file as String\r
10         private $ccSourceFileName; // File Name of the Source caption\r
11         private $ccTypeTarget; // Class name of the target caption format (e.g. 'Sami', or 'QTtext')\r
12         \r
13 \r
14         public function __construct($theCcResult,$theCcSourceURL,$theCcTypeTarget,$theFileName)\r
15         {\r
16                 // assign parameters to class members \r
17 \r
18                 $this->ccResult = $theCcResult;\r
19                 $this->ccSourceURL = $theCcSourceURL;\r
20                                 \r
21                 $this->ccStringTarget = '';\r
22                 $this->ccTypeTarget = $theCcTypeTarget;\r
23                 $this->ccSourceFileName = $theFileName;\r
24                         \r
25                 $this->_startService();\r
26         }\r
27         \r
28         private function _startService()\r
29         {\r
30                 global $rosettaCCSettings;\r
31                 \r
32                 // download remote caption file\r
33                 $myCCString = file_get_contents($this->ccSourceURL);\r
34                 \r
35                 $myCCString = stripslashes($myCCString);\r
36                 \r
37                         // Start a convertion Manager Instance\r
38                 $myCcManager = new ConversionManager($myCCString,$this->ccTypeTarget,$this->ccSourceFileName);\r
39                 \r
40                         // get the Caption Target URL\r
41         $ccTargetUrl = $myCcManager->getCcTargetUrl();\r
42                         \r
43         if($this->ccResult==0)\r
44         {\r
45                 // get the target file as a String\r
46                 $ccTargetString = TxtFileTools::fileToString($ccTargetUrl); \r
47                 echo $ccTargetString;\r
48         }\r
49         else if ($this->ccResult==1)\r
50         {\r
51                 echo $rosettaCCSettings['uploadDir'].'/'.$ccTargetUrl;\r
52         }\r
53         \r
54 \r
55         }\r
56 }\r
57 ?>