fclose($fileHandle); } function encapsulateJavascriptFile($outputFilename) { $fileContents = file_get_contents($outputFilename); $fileContents = "(function(){\n" . $fileContents . "})();\n"; file_put_contents($outputFilename, $fileContents); } foreach ($filesToConvert as $outputFilename => $inputFileList) { $phpToJavascript = new PHPToJavascript\PHPToJavascript(); // $phpToJavascript->setTrace(true); $phpToJavascript->setEchoConversionFunction(PHPToJavascript\PHPToJavascript::$ECHO_TO_ALERT); $inputFilename = ""; if (is_array($inputFileList) == TRUE) { foreach ($inputFileList as $inputFile) { $phpToJavascript->addFromFile($inputFile); $inputFilename = $inputFile . " "; } } else { $phpToJavascript->addFromFile($inputFileList); $inputFilename = $inputFileList; } $phpToJavascript->addPostConversionReplace("//JS", ""); $phpToJavascript->generateFile("output/" . $outputFilename, $inputFilename); encapsulateJavascriptFile("output/" . $outputFilename); $convertedFiles[] = $outputFilename; } generateTestPage($convertedFiles); function testEnd() { }
fclose($fileHandle); } function encapsulateJavascriptFile($outputFilename) { $fileContents = file_get_contents($outputFilename); $fileContents = "(function(){\n" . $fileContents . "})();\n"; file_put_contents($outputFilename, $fileContents); } foreach ($filesToConvert as $outputFilename => $inputFileList) { $phpToJavascript = new PHPToJavascript\PHPToJavascript(); // $phpToJavascript->setTrace(true); $phpToJavascript->setEchoConversionFunction(PHPToJavascript\PHPToJavascript::$ECHO_TO_ALERT); $inputFilename = ""; if (is_array($inputFileList) == TRUE) { foreach ($inputFileList as $inputFile) { $phpToJavascript->addFromFile($inputFile); $inputFilename = $inputFile . " "; } } else { $phpToJavascript->addFromFile($inputFileList); $inputFilename = $inputFileList; } $phpToJavascript->addPostConversionReplace("//JS", ""); $phpToJavascript->generateFile($output_folder . "/" . $outputFilename, $inputFilename); encapsulateJavascriptFile($output_folder . "/" . $outputFilename); $convertedFiles[] = $outputFilename; } generateTestPage($convertedFiles); function testEnd() { }