Exemple #1
0
     echo $e->getUsageMessage();
     exit;
 }
 $outputFormat = $opts->getOption('output-format');
 $outputFormat = strtolower($outputFormat);
 if (!in_array($outputFormat, $outputFormats)) {
     echo $opts->getUsageMessage();
     exit;
 }
 // -------------------------------------------------------------------------
 touch(FILENAME_LOCK);
 // -------------------------------------------------------------------------
 $path = new DirectoryIterator(PATH_INPUT);
 $inputFormats = $phpLiveDocx->getTemplateFormats();
 foreach ($path as $file) {
     $inputFormat = Tis_Service_LiveDocx::getFormat($file->getFilename());
     if (in_array($inputFormat, $inputFormats)) {
         $inputFilename = PATH_INPUT . DIRECTORY_SEPARATOR . $file->getFilename();
         $inputDoneFilename = PATH_INPUT_DONE . DIRECTORY_SEPARATOR . $file->getFilename();
         $outputFilename = PATH_OUTPUT . DIRECTORY_SEPARATOR . Converter::getFilename($file->getFilename(), $outputFormat);
         printf('Converting %s to %s... ', basename($inputFilename), basename($outputFilename));
         if ($inputFormat === $outputFormat) {
             rename($inputFilename, $inputDoneFilename);
             print "SKIPPED.\n";
         } else {
             $convertedDocument = Converter::convert($inputFilename, $outputFormat);
             if (false !== $convertedDocument) {
                 file_put_contents($outputFilename, $convertedDocument);
                 rename($inputFilename, $inputDoneFilename);
                 print "DONE.\n";
             } else {
Exemple #2
0
 /**
  * Helper method to return the filename of the converted document
  *
  * @param string $filename File to convert
  * @param string $format   Format into which to convert (docx, doc, rtf, txd, pdf, txt)
  * @return string
  */
 public static function getFilename($filename, $format)
 {
     $pattern = sprintf('\\.%s$', Tis_Service_LiveDocx::getFormat($filename));
     $replace = '.' . $format;
     return preg_replace("/{$pattern}/", $replace, $filename);
 }
 /**
  * Clean up and log out of LiveDocx service
  *
  * @return boolean
  */
 public function __destruct()
 {
     return parent::__destruct();
 }