+++ /dev/null
-<?php\r
-/**\r
- * QTSMIL Class\r
- */\r
-class QTSMIL extends CaptionFormat\r
-{\r
-\r
- private $textStyles = array(); \r
- \r
- /**\r
- * Imports a caption string into a CaptionCollection \r
- *\r
- * @param String $theCCString the caption file as string\r
- * @return CaptionCollection $myCcCollection A CaptionCollection Object\r
- */\r
- public function importCC($theCCString) {\r
- //global $ins, $caps, $outs, $num_clips,$proj_caption;\r
- $clips = array();\r
- $clip_string = '';\r
- \r
- //$contents = file_get_contents($theCCFile);\r
- $contents = $theCCString;\r
- \r
- // clean malformed patterns creted when saving files on win notepad\r
- $toSearch = array(chr(13).chr(10));\r
- $toReplace = array(chr(10));\r
- $contents = str_replace($toSearch,$toReplace,$contents);\r
- \r
- // Defining QText known pattenrs;\r
- $pattern_QT_time_format = "\[([0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3})\]";\r
- $pattern_QT_time_format_magpie = "\[([0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{2})\]";\r
- \r
- $num_clips = preg_match_all("/$pattern_QT_time_format/", $contents, $clips);\r
- \r
- // if caption file is not QT and comes from MapPie time format\r
- if ($num_clips == 0)\r
- {\r
- $num_clips = preg_match_all("/$pattern_QT_time_format_magpie/", $contents, $clips);\r
- }\r
- \r
- //$num_clips = $num_clips/2; // this is not needed\r
- \r
- // create a collection object\r
- include_once('CaptionCollection.php');\r
- $myQTextCollection = new CaptionCollection();\r
- \r
- \r
- // build data arrays looing through $clips QT format: 1) Split using QT time format, Find all times\r
- for ($i=0; $i<$num_clips; $i=$i+2) { \r
- \r
- // 2) Find all content in between QT time START and END using /s flag to capture also break lines\r
- $match_this = '/\['.$clips[1][$i].'\]\n(.*)\n\['.$clips[1][$i+1].'\]\n/s'; \r
- preg_match($match_this, $contents, $clip_bit);\r
- \r
- // add captions to the collection\r
- $myQTextCollection->addCaptions($clips[1][$i],$clip_bit[1],$clips[1][$i+1]);\r
- \r
- /*\r
- $ins[] = $clips[1][$i];\r
- $caps[] = $clip_bit[1];\r
- $outs[] = $clips[1][$i+1];\r
- */\r
-\r
- } // end for \r
- \r
- return $myQTextCollection;\r
- \r
- } // end importCC()\r
-\r
- /**\r
- * Exports a CaptionCollection object into a string\r
- *\r
- * @param CaptionCollection $theCollection A CaptionCollection Object\r
- * @return String $captionString The caption as a String\r
- */\r
- public function exportCC($theCollection)\r
- {\r
- \r
- $ccExport = '';\r
- \r
- $myCollection = $theCollection->getCollection();\r
- \r
- foreach ($myCollection as $captionObj)\r
- {\r
- \r
- } // end foreach\r
- \r
- } // end exportCC()\r
- \r
- /**\r
- * Verify if the caption file is a QText caption file \r
- */\r
- public function checkFormat($theCCString)\r
- {\r
- $isValid = false;\r
- $patternCheck = "/({(QTtext)})/"; // RegExp to look for QText \r
- preg_match_all($patternCheck,$theCCString,$patternFound);\r
- \r
- if(count($patternFound)>0)\r
- {\r
- $isValid = true;\r
- }\r
-\r
- return $isValid;\r
- \r
- } // end checkFormat() \r
-\r
- /*\r
- * Here functions to re-define\r
- */\r
- public function getName()\r
- {\r
- return '';\r
- }\r
- \r
- public function getAbout()\r
- {\r
- return '';\r
- }\r
- \r
- public function getVersion()\r
- {\r
- return '';\r
- }\r
- \r
- public function getFileExtension()\r
- {\r
- return '';\r
- }\r
- \r
- public function getIdPattern()\r
- {\r
- $idPattern = '/unknown/';\r
- //\r
- return $idPattern;\r
- }\r
-\r
- public function allowsTextStyles()\r
- {\r
- return '1';\r
- }\r
- public function template()\r
- {\r
- $ccTemplate = '';\r
- \r
- return $ccTemplate;\r
- } \r
-\r
-} // end classQText \r
-?>
\ No newline at end of file