1fa47fbef1df79ae9013d63c731134cc20b0caec
[atutor.git] / mods / atutor_opencaps / opencaps / conversion_service / include / classes / core_CaptionCollection_class.php
1 <?php\r
2 \r
3 /**\r
4  * This class represents a collection of captions \r
5  * 1. Create an instance\r
6  * 2. load captions\r
7  */\r
8 class CaptionCollection\r
9 {\r
10         public $collectionName = ''; // The name that wraps the collection. \r
11         public $txtStylesGlobal = array(); // Holds any global text style. (e.g. $txtStylesGlobal['text-align'] = 'center', $txtStylesGlobal['text-font'] = 'Arial', $txtStylesGlobal['text-size'] = '14', etc...)\r
12         public $captionCollection = array(); // The collection of Caption objects\r
13         \r
14         /**\r
15         * Class Constructor \r
16         */\r
17         public function __construct()\r
18         {\r
19                 /*\r
20                  * empty for now... (we don't know what the caption will contain...)\r
21                  * It seems logical and much more practical \r
22                  * to create first an empty CaptionCollection  \r
23                  * and then add to it as needed, \r
24                  * finally, get the collection object\r
25                  */\r
26         }\r
27         \r
28         /**\r
29          * Adds a Caption Object to the $captionCollection array \r
30          * @param Object $theCcObject a Caption Object\r
31          * @return void\r
32          */     \r
33         public function addCaption($theCcObject)\r
34         {\r
35                 // add Caption to the Caption Collection \r
36                 $this->captionCollection[] = $theCcObject; // this a php-based approach... java will need a push/count solution \r
37                 \r
38         } // end addCaptions()\r
39 \r
40         /**\r
41          * Sets all the Global text style attributes\r
42          * @param Array $theGlobalStyles Array containing all the global text styles  \r
43          */\r
44         public function setTxtStylesGlobal($theGlobalStyles)\r
45         {\r
46                 $this->txtStylesGlobal = $theGlobalStyles;\r
47         }       \r
48         \r
49         /**\r
50          * Sets the value of a single Global text style attribute\r
51          * @param String $theAtt Attribute name\r
52          * @param String $theValue Attribute Value \r
53          */\r
54         public function setTxtStylesGlobalAtt($theAtt,$theValue)\r
55         {\r
56                 $this->txtStylesGlobal[$theAtt]=$theValue;\r
57         } // end setTxtStylesGlobalAtt()\r
58         \r
59         /**\r
60          * Sets the collection Name\r
61          *\r
62          * @param String $theCollectionName\r
63          */\r
64         public function setCollectionName($theCollectionName)\r
65         {\r
66                 $this->collectionName = $theCollectionName;\r
67         }\r
68         \r
69         /**\r
70          * Gets Collection Name\r
71          *\r
72          * @return String $collectionName\r
73          */\r
74         public function getCollectionName()\r
75         {\r
76                 return $this->collectionName;\r
77         }\r
78         \r
79         /**\r
80          * Returns this CaptionCollection object\r
81          *\r
82          * @return CaptionCollection \r
83          */\r
84         public function getCollection()\r
85         {\r
86                 return $this->captionCollection;\r
87         }  \r
88 \r
89         public function toString()\r
90         {\r
91                 $ccCount=0;\r
92                 echo '<br/><h3>Collection Name: '.$this->getCollectionName().'</h3>';\r
93                 echo 'Total Captions Found: '.count($this->captionCollection);\r
94 \r
95                 if (count($this->txtStylesGlobal)!=0)\r
96                 {\r
97                         echo '<br/><br/><b>[Global]  Styles</b>';\r
98                         \r
99                         foreach ($this->txtStylesGlobal as $txtStyleName => $txtStyleValue)\r
100                         {\r
101                                 echo '<br/> -----'.$txtStyleName.' = '.$txtStyleValue;\r
102                         }\r
103                 } \r
104                 \r
105                 echo '<br/><br/><b>Printing Captions in the collection... </b>';\r
106                 \r
107                 foreach ($this->captionCollection as $captionObj)\r
108                 {\r
109                         $ccCount++;\r
110 \r
111                         // call Caption's toString();\r
112                         echo '<br/><br/>'.$ccCount;\r
113                         $captionObj->toString();\r
114 \r
115                 } // foreach end \r
116 \r
117         } //toString() end\r
118 \r
119 } // end CaptionCollection Class  \r
120 ?>