8ec7e59909c4761a2d4fcfb08c0ae8331d9e541b
[atutor.git] / mods / atutor_opencaps / opencaps / conversion_service / include / classes / core_Caption_class.php
1 <?php\r
2 /**\r
3  * This class represents a sinlge caption and all the allowed features (time, text styles, etc.) \r
4  */\r
5 \r
6 class Caption\r
7 {\r
8         public $inTime;\r
9         public $outTime;\r
10         public $caption;\r
11         public $textStyles = array(); // \r
12         \r
13         /**\r
14          * Class Constructor: \r
15          * @param String $theInTime\r
16          * @param String $theOutTime\r
17          * @param String $theCaption\r
18          * @param Array $theTextStyles as a reference\r
19          * @return void\r
20          */\r
21         function __construct($theInTime, $theOutTime, $theCaption,$theTextStyles)\r
22         {\r
23                 $this->inTime = $theInTime;\r
24                 $this->outTime = $theOutTime;\r
25                 $this->caption = $theCaption;\r
26                 $this->textStyles= $theTextStyles;\r
27         } // __construct() end\r
28 \r
29                 // SET  Functions\r
30                 \r
31         /**\r
32          * Sets value of caption IN time\r
33          * @param String $theInTime\r
34          * @return void         \r
35          */\r
36         public function setInTime($theInTime)\r
37         {\r
38                 $this->inTime = $theInTime;\r
39         }\r
40         \r
41         /**\r
42          * Sets value of caption OUT time\r
43          * @param String $theOutTime\r
44          * @return void         \r
45          */\r
46         public function setOutTime($theOutTime)\r
47         {\r
48                 $this->outTime = $theOutTime;\r
49         }       \r
50 \r
51         /**\r
52          * Sets value of a caption (multiple lines allowed)\r
53          * @param String $theCaption\r
54          * @return void         \r
55          */\r
56         public function setCaption($theCaption)\r
57         {\r
58                 $this->caption = $theCaption;\r
59         }       \r
60 \r
61         /**\r
62          * Sets value of Caption text style attribute\r
63          * @param String $theAtt Attribute name\r
64          * @param String $theValue Attribute Value \r
65          */\r
66         public function setTextAtribute($theAtt,$theValue)\r
67         {\r
68                 $this->textStyles[$theAtt]=$theValue;\r
69         }\r
70 \r
71                 // GET  Functions\r
72                 \r
73         /**\r
74          * Gets value of Caption IN Time\r
75          * @return String inTime Caption        \r
76          */\r
77         public function getInTime()\r
78         {\r
79                 return $this->inTime;\r
80         }\r
81         \r
82         /**\r
83          * Gets value of Caption OUT Time\r
84          * @return String outTime Caption       \r
85          */     \r
86         public function getOutTime()\r
87         {\r
88                 return $this->outTime;\r
89         }\r
90         \r
91 \r
92         /**\r
93          * Gets value of Caption text\r
94          * @return String inTime Caption text   \r
95          */\r
96         public function getCaption()\r
97         {\r
98                 return $this->caption;\r
99         }\r
100                 \r
101         /**\r
102          * Gets text style array\r
103          * @return Array $theTextStyles Txt Styles Array        \r
104          */     \r
105         public function getTextStyles()\r
106         {\r
107                 return $this->textStyles;       \r
108         }\r
109 \r
110 \r
111         /**\r
112          * Gets value of Caption text style attribute\r
113          * @param String $theAtt Attribute name\r
114          * @return String $Value Attribute Value        \r
115          */     \r
116         public function getTextAtribute($theAtt)\r
117         {\r
118                 return $this->textStyles[$theAtt];\r
119         }\r
120 \r
121         /**\r
122          * Print all values of the Caption as a String\r
123          */     \r
124         public function toString()\r
125         {\r
126                 echo "<br/><b>In Time: </b>". $this->getInTime()."";\r
127                 echo "<br/><b>Out Time: </b>". $this->getOutTime()."";\r
128                 echo "<br/><b>Caption: </b>". $this->getCaption()."";\r
129                 \r
130                 if (count($this->textStyles!=0))\r
131                 {\r
132                         if (count($this->textStyles)==0)\r
133                         {\r
134                                 //echo '<br/>----(NO text styles found)';\r
135                         } else {\r
136                 \r
137                                 echo '<br/><b>------[Caption] Styles: </b>';\r
138                                 \r
139                                 // Display all text attributes in the caption\r
140                                 foreach ($this->textStyles as $styleName=>$styleValue)\r
141                                 {\r
142                                         echo '<br/> -----'.$styleName.' = '.$styleValue;\r
143                                 } // foreach end\r
144                         }// end if\r
145                         \r
146                 } //if end\r
147                 \r
148         }// toString() end \r
149         \r
150         // return this caption object\r
151         public function getThisCaption()\r
152         {\r
153                 return $this;\r
154         }\r
155 } // end class Caption\r
156 ?>