5 class QTSMIL extends CaptionFormat
\r
8 private $textStyles = array();
\r
11 * Imports a caption string into a CaptionCollection
\r
13 * @param String $theCCString the caption file as string
\r
14 * @return CaptionCollection $myCcCollection A CaptionCollection Object
\r
16 public function importCC($theCCString) {
\r
17 //global $ins, $caps, $outs, $num_clips,$proj_caption;
\r
21 //$contents = file_get_contents($theCCFile);
\r
22 $contents = $theCCString;
\r
24 // clean malformed patterns creted when saving files on win notepad
\r
25 $toSearch = array(chr(13).chr(10));
\r
26 $toReplace = array(chr(10));
\r
27 $contents = str_replace($toSearch,$toReplace,$contents);
\r
29 // Defining QText known pattenrs;
\r
30 $pattern_QT_time_format = "\[([0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3})\]";
\r
31 $pattern_QT_time_format_magpie = "\[([0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{2})\]";
\r
33 $num_clips = preg_match_all("/$pattern_QT_time_format/", $contents, $clips);
\r
35 // if caption file is not QT and comes from MapPie time format
\r
36 if ($num_clips == 0)
\r
38 $num_clips = preg_match_all("/$pattern_QT_time_format_magpie/", $contents, $clips);
\r
41 //$num_clips = $num_clips/2; // this is not needed
\r
43 // create a collection object
\r
44 include_once('CaptionCollection.php');
\r
45 $myQTextCollection = new CaptionCollection();
\r
48 // build data arrays looing through $clips QT format: 1) Split using QT time format, Find all times
\r
49 for ($i=0; $i<$num_clips; $i=$i+2) {
\r
51 // 2) Find all content in between QT time START and END using /s flag to capture also break lines
\r
52 $match_this = '/\['.$clips[1][$i].'\]\n(.*)\n\['.$clips[1][$i+1].'\]\n/s';
\r
53 preg_match($match_this, $contents, $clip_bit);
\r
55 // add captions to the collection
\r
56 $myQTextCollection->addCaptions($clips[1][$i],$clip_bit[1],$clips[1][$i+1]);
\r
59 $ins[] = $clips[1][$i];
\r
60 $caps[] = $clip_bit[1];
\r
61 $outs[] = $clips[1][$i+1];
\r
66 return $myQTextCollection;
\r
71 * Exports a CaptionCollection object into a string
\r
73 * @param CaptionCollection $theCollection A CaptionCollection Object
\r
74 * @return String $captionString The caption as a String
\r
76 public function exportCC($theCollection)
\r
81 $myCollection = $theCollection->getCollection();
\r
83 foreach ($myCollection as $captionObj)
\r
91 * Verify if the caption file is a QText caption file
\r
93 public function checkFormat($theCCString)
\r
96 $patternCheck = "/({(QTtext)})/"; // RegExp to look for QText
\r
97 preg_match_all($patternCheck,$theCCString,$patternFound);
\r
99 if(count($patternFound)>0)
\r
106 } // end checkFormat()
\r
109 * Here functions to re-define
\r
111 public function getName()
\r
116 public function getAbout()
\r
121 public function getVersion()
\r
126 public function getFileExtension()
\r
131 public function getIdPattern()
\r
133 $idPattern = '/unknown/';
\r
138 public function allowsTextStyles()
\r
142 public function template()
\r
146 return $ccTemplate;
\r
149 } // end classQText
\r