4 * http://opencaps.atrc.utoronto.ca
\r
6 * Copyright 2009 Antonio Gamba Bari
\r
7 * Adaptive Technology Resource Centre, University of Toronto
\r
9 * Licensed under the Educational Community License (ECL), Version 2.0.
\r
10 * You may not use this file except in compliance with this License.
\r
11 * http://www.opensource.org/licenses/ecl2.php
\r
16 * This class represents a collection of captions
\r
17 * 1. Create an instance
\r
20 class CaptionCollection
\r
22 public $collectionName = ''; // the name that holds the entiry collection.. this particularly important for JSON export
\r
23 public $txtStylesGlobal = array(); // holds any global text style. (e.g. $txtStylesGlobal['text-align'] = 'center', $txtStylesGlobal['text-font'] = 'Arial', $txtStylesGlobal['text-size'] = '14', etc...)
\r
24 public $captionCollection = array(); // a collection of Caption objects
\r
27 * Class Constructor
\r
29 public function __construct()
\r
32 * empty for now... (we don't know what the caption will contain...)
\r
33 * It seems logical and much more practical
\r
34 * to create first an empty CaptionCollection
\r
35 * and then add to it as needed,
\r
36 * finally, get the collection object
\r
41 * Adds a Caption Object to the $captionCollection array
\r
42 * @param Object $theCcObject a Caption Object
\r
45 public function addCaption($theCcObject)
\r
47 // add Caption to the Caption Collection
\r
48 $this->captionCollection[] = $theCcObject; // this a php-based approach... java will need a push/count solution
\r
50 } // end addCaptions()
\r
53 * Sets all the Global text style attributes
\r
54 * @param Array $theGlobalStyles Array containing all the global text styles
\r
56 public function setTxtStylesGlobal($theGlobalStyles)
\r
58 $this->txtStylesGlobal = $theGlobalStyles;
\r
62 * Sets the value a single Global text style attribute
\r
63 * @param String $theAtt Attribute name
\r
64 * @param String $theValue Attribute Value
\r
66 public function setTxtStylesGlobalAtt($theAtt,$theValue)
\r
68 $this->txtStylesGlobal[$theAtt]=$theValue;
\r
69 } // end setTxtStylesGlobalAtt()
\r
72 * Return this object
\r
74 * @return CaptionCollection
\r
76 public function getCollection()
\r
78 return $this->captionCollection;
\r
81 public function toString()
\r
84 echo '<br/><h3>Printing a Rosetta Collection</h3>';
\r
85 echo 'Total Captions Found: '.count($this->captionCollection);
\r
87 echo '<br/><br/><b>[Global] Styles</b>';
\r
88 if (count($this->txtStylesGlobal)==0)
\r
90 echo ' (NO text styles found)';
\r
93 foreach ($this->txtStylesGlobal as $txtStyleName => $txtStyleValue)
\r
95 echo '<br/> -----'.$txtStyleName.' = '.$txtStyleValue;
\r
98 echo '<br/><br/><b>Printing Captions in the collection... </b>';
\r
99 foreach ($this->captionCollection as $captionObj)
\r
102 // building a new to string
\r
105 echo "<br><b>In Time: </b>". $captionObj->getInTime()."";
\r
106 echo "<br><b>Out Time: </b>". $captionObj->getOutTime()."";
\r
107 echo "<br><b>Caption: </b>". $captionObj->getCaption()."";
\r
109 // display text styles
\r
110 foreach ($captionStylesFound as $txtStyle)
\r
113 //$textStyles[] = $txtStyle;
\r
116 // call Caption's toString();
\r
117 echo '<br/><br/>'.$ccCount;
\r
118 $captionObj->toString();
\r
124 } // end CaptionCollection Class
\r