removed mods directory from the ATutor codebase
[atutor.git] / mods / atutor_opencaps / opencaps / conversion_service / include / classes / ccformats / cc_QTtext_format.php
diff --git a/mods/atutor_opencaps/opencaps/conversion_service/include/classes/ccformats/cc_QTtext_format.php b/mods/atutor_opencaps/opencaps/conversion_service/include/classes/ccformats/cc_QTtext_format.php
deleted file mode 100755 (executable)
index f3c466c..0000000
+++ /dev/null
@@ -1,517 +0,0 @@
-<?php\r
-/**\r
- * QTtext Class\r
- */\r
-class QTtext extends CaptionFormat\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
-       {\r
-               //echo 'show the replaced TQtext:<form><textarea name="textarea" cols="120" rows="5">'. $theCCString. '</textarea></form>';\r
-               \r
-               // clean malformed patterns creted when files were saved on win notepad\r
-        //$toSearch = array(chr(13).chr(10));\r
-        //$toReplace = array(chr(10));\r
-               \r
-               $toSearch = array(chr(13).chr(10),chr(13),chr(10).chr(32).chr(10),chr(10).chr(10) ); // this default break line in Capscribe Desktop - Mac OS\r
-        $toReplace = array(chr(10),chr(10),chr(10),chr(10));\r
-               \r
-        //$toSearch = chr(13); // this default break line in Capscribe Desktop - Mac OS\r
-        //$toReplace = chr(10);\r
-               \r
-               $theCCString = str_replace($toSearch,$toReplace,$theCCString);\r
-       \r
-               // get all lines in array\r
-               $allLines = split(chr(10),$theCCString);\r
-               $controlTime = 0; // control time marks IN and OUT\r
-               $controlCaptionLines = 0; // control the number of lines of one caption \r
-               $addCaptionControl = 0; //Start Adding caption when = 1\r
-               $isTime=0;\r
-               $captionCounter = 0; // Total number of captions found\r
-               \r
-               $timesIn = array();\r
-               $timesOut = array();\r
-               $captions = array();\r
-               \r
-        // Defining QText known pattenrs;\r
-               $qtPatternRegEx = "/({(.*?)})/";  \r
-               $pattern_QT_time_format_000 = "\[([0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3})\]";\r
-        $pattern_QT_time_format_00 = "\[([0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{2})\]";\r
-        $pattern_QT_time_format_selected = '';\r
-           \r
-        // determine if miliseconds are in 2 of 3 digit format \r
-        if (preg_match("/$pattern_QT_time_format_000/", $theCCString))\r
-        {\r
-               $pattern_QT_time_format_selected = $pattern_QT_time_format_000;\r
-        } \r
-        else if (preg_match("/$pattern_QT_time_format_00/", $theCCString)) \r
-        {\r
-               $pattern_QT_time_format_selected = $pattern_QT_time_format_00;\r
-        }\r
-               \r
-        //  loop through caption lines\r
-        for ($i=0; $i<count($allLines);$i++)\r
-        {\r
-               //echo '<br/>';\r
-               //echo '<br/>Line ('.$i.') *** '.($allLines[$i]).'';\r
-               \r
-               // is this a time mark ?\r
-               $isTime = preg_match("/$pattern_QT_time_format_selected/", $allLines[$i]);\r
-               \r
-               // if it is a time mark, start converting else is a caption n lines\r
-               if ($isTime==1)\r
-               {\r
-                       // clean up time mark '[]' characters\r
-                       $allLines[$i] = str_replace('[','',$allLines[$i]);\r
-                       $allLines[$i] = str_replace(']','',$allLines[$i]);\r
-                       \r
-                       // Is this the First time mark?\r
-                       if ($controlTime == 0)\r
-                       {\r
-                               // ok get the first time mark and wait for the time out mark \r
-                               $timesIn[] = $allLines[$i]; // mm this is not java style... FIX ME!!\r
-                               $controlTime = 2;\r
-                               // start caption text and wait for n lines\r
-                               $captions[$captionCounter]= '';\r
-                                       $addCaptionControl = 1;\r
-                               $currentIndex = $captionCounter;\r
-                               $captionCounter++;\r
-                                       //echo '------ This The first time TIME MARK';\r
-                       }\r
-                       \r
-                   // Is this the Time IN of the caption?\r
-                       else if ($controlTime == 1)\r
-                       {\r
-                               // add time in\r
-                               $timesIn[] = $allLines[$i]; // mm this is not java style... FIX ME!!\r
-                               $controlTime = 2;\r
-                               // start caption text and wait for n lines\r
-                               $captions[$captionCounter]= '';\r
-                               $addCaptionControl = 1;\r
-                               $currentIndex = $captionCounter;\r
-                               $captionCounter++;\r
-                                       //echo '------ This is IN TIME MARK';\r
-                       }\r
-\r
-                   // Is this the Time Out of the caption?\r
-                       else if ($controlTime == 2)\r
-                       {\r
-                               // add time in\r
-                               $timesOut[] = $allLines[$i]; // mm this is not java style... FIX ME!!\r
-                               $controlTime = 1;\r
-                               $addCaptionControl = 0;\r
-                                       //echo '------ This is OUT TIME MARK';\r
-                       }\r
-                       \r
-               } else {\r
-                       \r
-                       // start adding captions\r
-                       if ($addCaptionControl==1)\r
-                       {\r
-                               // add new line to the current caption\r
-                               $captions[$currentIndex] .= $allLines[$i].chr(10);\r
-                               //echo '------ The caption'.$captions[$currentIndex];\r
-                       }\r
-               } // end if\r
-               \r
-        } // end for \r
-        \r
-        // create a collection object\r
-        $myQTextCollection = new CaptionCollection();\r
-        \r
-        /*\r
-        echo '<br/><br/>Total Captions Found:  '.$captionCounter;\r
-        echo '<br/><br/>Total TIME IN:  '.count($timesIn);\r
-        echo '<br/><br/>Total TIME OUT:  '.count($timesOut);\r
-        echo '<br/><br/>Total CAPTIONS:  '.count($captions);\r
-        */\r
-        \r
-        // test in a text area\r
-               //echo '<form><textarea cols="100" rows="10">';\r
-           ///*\r
-        for ($j=0;$j<$captionCounter;$j++)\r
-           {\r
-            \r
-            // get all QT styles found in caption text\r
-            preg_match_all($qtPatternRegEx,$captions[$j],$captionStylesFound);\r
-\r
-            // clean all QT styles from the caption  \r
-            $captions[$j] = str_replace($captionStylesFound[0], "", $captions[$j]);\r
-            \r
-            // show the plain text Caption\r
-            //echo '<br/><br/>'.$captions[$j];\r
-            \r
-            /*\r
-            // show all QT found in caption line\r
-            foreach ($captionStylesFound[0] as $allStyleAttrib => $allStyleValue)\r
-            {\r
-               echo '<br/>'.$allStyleAttrib.' = '.$allStyleValue;\r
-            }\r
-            */        \r
-\r
-                       $textStyles = Array();\r
-                       \r
-            // add text styles features to caption text styles array\r
-            if (isset($captionStylesFound[0]))\r
-            {\r
-                foreach ($captionStylesFound[0] as $txtStyle)\r
-                {\r
-                       //$textStyles[] = $txtStyle;\r
-                       //echo '<br/>'.$txtStyle;\r
-                       \r
-                       //adding only known text styles\r
-                       if ($txtStyle == '{justify:center}')\r
-                       {\r
-                               $textStyles['text-align'] = 'center';\r
-                       } else if ($txtStyle == '{justify:left}')\r
-                       {\r
-                               $textStyles['text-align'] = 'left';\r
-                       }                                       \r
-                       else if ($txtStyle == '{justify:right}')\r
-                       {\r
-                               $textStyles['text-align'] = 'right';\r
-                       } else {\r
-                               // adding QT formats\r
-                               //$textStyles['QT'.$txtStyle] = $txtStyle.'-- NOT used yet';\r
-                       } // end if else\r
-                } // end for each\r
-            } // end if\r
-\r
-            // add a capton only if all values are set\r
-                \r
-                       if (isset($timesIn[$j]) && isset($timesOut[$j]) && isset($captions[$j]))\r
-                       {\r
-                               // Create a Caption Object\r
-                               $newCaption = new Caption($timesIn[$j],$timesOut[$j],$captions[$j],$textStyles);\r
-                \r
-                // print added caption\r
-                //echo $newCaption->toString(); \r
-\r
-                // add caption object to the collection\r
-                $myQTextCollection->addCaption($newCaption);\r
-                }\r
-            \r
-            /*\r
-            echo chr(10).'IN:  '.$timesIn[$j];\r
-               echo chr(10).'OUT:  '.$timesOut[$j];\r
-               echo chr(10).'Caption:  '.$captions[$j];\r
-               */\r
-                //echo chr(10).'Caption:  '.$captions[$j];\r
-                \r
-           }// end for    \r
-           //*/\r
-\r
-                       //echo '</textarea></form>';         \r
-        \r
-                       \r
-        // print for test\r
-        //echo $myQTextCollection->toString();\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
-               // add QT header\r
-               $ccExport .= $this->getHeader()."\r\n";\r
-               \r
-               foreach ($myCollection as $captionObj)\r
-               {\r
-                       // add time in\r
-                       $ccExport .= '['.$captionObj->getInTime().']'."\r\n";\r
-                       \r
-                       // Convert <br/> into \n character\r
-                       $fixCaption = str_replace('<BR />',"\r\n",$captionObj->getCaption());\r
-                       //echo '<br/>'.$fixCaption;\r
-                       \r
-                       // get getTextStyles array from caption object\r
-                       $ccTxtStyles = $captionObj->getTextStyles();\r
-                       \r
-                               //$ccTxtStyles = $this->getDefaultStyles($captionObj->getTextAtribute('text-align'));\r
-                       \r
-                       //  check if the caption has text styles\r
-                       if (count($ccTxtStyles)!=0)\r
-                       {\r
-                               // loop all txt styles\r
-                               foreach ($ccTxtStyles as $txtAttrib => $txtValue)\r
-                               {\r
-                                       // HERE parse any known txt style and apply it to the caption\r
-                                       \r
-                                       // only for text alignment in QT\r
-                                       if ($txtValue=='center' || $txtValue=='left' || $txtValue=='right')\r
-                                       {\r
-                                               // get the txt align default values\r
-                                               $thisTxtAlign = $this->getDefaultStyles($txtValue,strlen($fixCaption));\r
-                                                       //echo '<br/>'.$fixCaption;\r
-                                                       //echo '<br/> Lenght: '.strlen($fixCaption);\r
-                                               \r
-                                               // add default text styles to the caption \r
-                                               $fixCaption = $thisTxtAlign.$fixCaption;\r
-                                       } // end if\r
-                                       \r
-                               } // end for\r
-                                       \r
-                       } // end if txt styles\r
-                       \r
-                       // add caption(s) to export string \r
-                       //$ccExport .= $fixCaption;\r
-                       $ccExport .= $fixCaption."\r\n";\r
-                       \r
-                       // add time out\r
-                       $ccExport .= '['.$captionObj->getOutTime().']'."\r\n";\r
-                       \r
-               } // end foreach\r
-               \r
-               \r
-               // Remove any doble break line (already done in import string.. but just in case captions lines bring this issue;) \r
-               //-- $ccExport = str_replace(chr(10).chr(10),chr(10),$ccExport);\r
-               \r
-               return $ccExport;\r
-               \r
-       } // end  exportCC()\r
-       \r
-       /**\r
-        * Verify if the caption file is a QText caption file\r
-        *\r
-        * @param String $theCCString A caption file as text = string\r
-        * @return Boolean\r
-        */\r
-       public function checkFormat($theCCString)\r
-       {\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
-        * Get the name of the Caption Format Class\r
-        *\r
-        * @return String $captionFormatname The name of the Caption Format\r
-        */\r
-       public function getName()\r
-       {\r
-               $captionFormatname = 'Quick Time Text';\r
-               \r
-               return $captionFormatname;\r
-       }\r
-       \r
-       /**\r
-        * Get the Description of the Caption Format\r
-        *\r
-        * @return String $captionAbout Description of the Caption Format\r
-        */\r
-       public function getAbout()\r
-       {\r
-               $captionAbout = 'This format can be used by Quick Time Player.\r
-               This is the native format of CAPSCRIBE !!! \r
-               Additional information can be found at <a href="http://www.apple.com/quicktime/tutorials/texttracks.html">Apple Website</a>';\r
-               \r
-               return $captionAbout;\r
-               \r
-               \r
-       }\r
-       \r
-       /**\r
-        * Get the version of the caption format class\r
-        *\r
-        * @return String $theVersion The Version of the Caption Format as String\r
-        */\r
-       public function getVersion()\r
-       {\r
-               $theVersion = '1.0';\r
-                \r
-               return $theVersion;\r
-       }\r
-               \r
-       public function getFileExtension()\r
-       {\r
-               $theExtension = 'txt';\r
-                \r
-               return $theExtension;\r
-       }\r
-       \r
-       public function getIdPattern()\r
-       {\r
-               $idPattern = '/({QTtext})/';\r
-               //$idPattern = "/({(.*?)})/";\r
-               //$qtPatternRegEx = "/({(.*?)})/";\r
-               \r
-               return $idPattern;\r
-       }\r
-       \r
-       public function allowsTextStyles()\r
-       {\r
-               return '1';\r
-       }       \r
-\r
-       public function template()\r
-       {\r
-               $ccTemplate = '\r
-{QTtext}{font: Comic Sans MS}{italic}{size:18}{textColor: 65280,65280,65280}{backColor: 0,0,0}{justify:center}{timeScale: 1000}{timeStamps:absolute}{keyedtext:on}{language:0}{height:156}{width:383}{textEncoding:0}\r
-[00:00:00.002]\r
-caption 1 line1\r
-caption 1 line2\r
-[00:00:02.849]\r
-[00:00:02.851]\r
-caption 2 line1\r
-caption 2 line2\r
-[00:00:04.950]\r
-[00:00:04.952]\r
-caption 3\r
-[00:00:06.082]\r
-\r
-... or ...\r
-\r
-{QTtext} {font:Tahoma}\r
-{plain} {size:20}\r
-{timeScale:30}\r
-{width:160} {height:32}\r
-{timeStamps:absolute} {language:0}\r
-[00:00:00.00]\r
-caption 1 - using Bold style?\r
-[00:00:02.84]\r
\r
-[00:00:02.85]\r
-caption 2\r
-[00:00:04.95]\r
\r
-[00:00:04.95]\r
-caption 3\r
-[00:00:06.08]\r
-\r
-';\r
-               \r
-               return $ccTemplate;\r
-       }\r
-\r
-/*////////////////////////////////////////////////////////\r
-        Functions for QText conversion\r
-//////////////////////////////////////////////////////*/\r
-       \r
-       /**\r
-        * Creates the QText default header.. soon this method will receive all the needed parameters\r
-        *\r
-        * @return String $myHeader The QText default header\r
-        */\r
-       private function getHeader()\r
-       {\r
-               /*\r
-               {font: Tahoma}\r
-               {plain}\r
-               {size:18}\r
-               {textColor: 45824,45824,45824}\r
-               {backColor: 0,0,0}\r
-               {justify:center}\r
-               {timeScale: 1000}\r
-               {timeStamps:absolute}\r
-               {keyedtext:on}\r
-               {language:0}\r
-               {height:114}\r
-               {width:334}\r
-               {textEncoding:0}\r
-                */\r
-               \r
-               // common vars\r
-               $textFont = "Comic Sans MS";\r
-               $textSize = "18";\r
-               $textJustify = "center";\r
-\r
-               // Unique QText header Variables                \r
-               $myHeader = '{QTtext}';\r
-               $myHeader .= '{font: '.$textFont.'}';\r
-               //$myHeader .= '{plain}';\r
-               //$myHeader .= '{size: '.$textSize.'}';\r
-               $myHeader .= '{textColor: 65280,65280,0}';\r
-               $myHeader .= '{backColor: 0,0,0}';\r
-               $myHeader .= '{justify:'.$textJustify.'}';\r
-               $myHeader .= '{timeScale: 1000}';\r
-               $myHeader .= '{timeStamps:absolute}';\r
-               $myHeader .= '{keyedtext:on}'; ///  WHAT IS THIS????? FIX ME\r
-               $myHeader .= '{language:0}'; // working on ...\r
-               $myHeader .= '{width:114}'; // working on ...\r
-               $myHeader .= '{height:334}'; // working on ...\r
-               $myHeader .= '{textEncoding:0}';\r
-               // ... and much more can be set here acording to QT specification ...\r
-               \r
-               /*\r
-               {anti-alias: onOrOff }\r
-               {doNotDisplay: onOrOff }\r
-               {doNotAutoScale: onOrOff }\r
-               */\r
-               \r
-               $myHeader = '{QTtext}{font: Tahoma}{plain}{size:18}{textColor: 45824,45824,45824}{backColor: 0,0,0}{justify:center}{timeScale: 1000}{timeStamps:absolute}{keyedtext:on}{language:0}{height:114}{width:334}{textEncoding:0}';\r
-               \r
-               return $myHeader;\r
-       }       // end getHeader\r
-       \r
-       /**\r
-        * Sets default QT text styles at the caption level. No text style implemented yet at the word level \r
-        * @param String $txtAlign The text alignment, (e.g. 'left', 'right') if null assumed center\r
-        * @return String $myStyles the QText styles to be added before the caption text.\r
-        */\r
-       private function getDefaultStyles($txtAlign,$txtLength )\r
-       {\r
-               // {hilitecolor:3000,0,0}{hilite:0,103}{font:Tahoma}{size:18}{textcolor:45824,45824,45824}{backcolor:0,0,0}{justify:center}{plain}( \r
-               $myStyles = '';\r
-               //$myStyles .= '{hilitecolor:3000,0,0}{hilite:0,139}{font:Tahoma}';\r
-               $myStyles .= '{hilitecolor:3000,0,0}{hilite:0,'.$txtLength.'}{font:Tahoma}{size:18}{backcolor:0,0,0}';\r
-               \r
-               if ($txtAlign == 'left')\r
-               {\r
-                       $myStyles .= '{textcolor:65280,55040,18432}{justify:'.$txtAlign.'}';\r
-               } \r
-               else if ($txtAlign == 'right')\r
-               {\r
-                       $myStyles .= '{textcolor:26112,65280,65280}{justify:'.$txtAlign.'}';\r
-               }\r
-               else \r
-               {\r
-                       $myStyles .= '{textcolor:45824,45824,45824}{justify:center}';\r
-               }\r
-               // and much more to be added here... !! \r
-               \r
-               /**\r
-               {plain} Plain text.\r
-               {bold} Bold text.\r
-               {italic} Italic text.\r
-               {underline} Underlined text.\r
-               {outline} Outlined text.\r
-               {shadow} Text with a drop shadow.\r
-               {condense} Text with spacing between characters decreased.\r
-               {extend} Text with spacing between characters increased. \r
-                */\r
-               //$myStyles .= '{plain}';\r
-               \r
-               return $myStyles;\r
-       \r
-       }\r
-}  // end classQText \r
-?>
\ No newline at end of file