/** * Produire les exports depuis le fichier XML */ public function add($srcfile, $setcode = null, $force = false) { $srcname = pathinfo($srcfile, PATHINFO_FILENAME); $srcmtime = filemtime($srcfile); $this->_sqlmtime->execute(array($srcname)); list($basemtime) = $this->_sqlmtime->fetch(); $teinte = null; if ($basemtime < $srcmtime) { $teinte = new Teinte_Doc($srcfile); $this->insert($teinte, $setcode); } $echo = ""; foreach (self::$formats as $format => $row) { $destfile = dirname(__FILE__) . '/' . $format . '/' . $srcname . $row["ext"]; if (!$force && file_exists($destfile) && $srcmtime < filemtime($destfile)) { continue; } if (!$teinte) { $teinte = new Teinte_Doc($srcfile); } // delete destfile if exists ? if (file_exists($destfile)) { unlink($destfile); } $echo .= " " . $format; // TODO git $destfile if ($format == 'html') { $teinte->html($destfile, 'http://oeuvres.github.io/Teinte/'); } if ($format == 'article') { $teinte->article($destfile); } else { if ($format == 'markdown') { $teinte->markdown($destfile); } else { if ($format == 'iramuteq') { $teinte->iramuteq($destfile); } else { if ($format == 'naked') { $teinte->naked($destfile); } else { if ($format == 'epub') { $livre = new Livrable_Tei2epub($srcfile, self::$_logger); $livre->epub($destfile); // transformation auto en mobi, toujours après epub $mobifile = dirname(__FILE__) . '/kindle/' . $srcname . ".mobi"; Livrable_Tei2epub::mobi($destfile, $mobifile); } else { if ($format == 'docx') { Toff_Tei2docx::docx($srcfile, $destfile); } } } } } } } if ($echo) { self::log(E_USER_NOTICE, $srcfile . $echo); } }
/** * Produire les exports depuis le fichier XML */ public function add($srcfile, $setcode = null, $force = false) { $set = self::$sets[$setcode]; if (!isset($set['predir'])) { $set['predir'] = ''; } // used for Théâtre Classique $srcname = pathinfo($srcfile, PATHINFO_FILENAME); $srcmtime = filemtime($srcfile); $this->_sqlmtime->execute(array($srcname)); list($basemtime) = $this->_sqlmtime->fetch(); // TODO optimize on dates $teinte = new Teinte_Doc($srcfile); // time compared if ($basemtime < $srcmtime) { $this->insert($teinte, $setcode); } // Specific Théâtre Classique if ($setcode == 'tc') { $teinte->pre(dirname(__FILE__) . '/tc-norm.xsl'); } $echo = ""; foreach (self::$formats as $format => $row) { $dir = $set['predir'] . $format; $destfile = dirname(__FILE__) . '/' . $dir . '/' . $srcname . $row["ext"]; if (!$force && file_exists($destfile) && $srcmtime < filemtime($destfile)) { continue; } if ($format == 'kindle') { continue; } // kindle mobi should be done just after epub // delete destfile if exists ? $echo .= " " . $format; // TODO git $destfile if ($format == 'html') { $teinte->html($destfile, 'http://oeuvres.github.io/Teinte/'); } else { if ($format == 'article') { $teinte->article($destfile); } else { if ($format == 'markdown') { $teinte->markdown($destfile); } else { if ($format == 'iramuteq') { $teinte->iramuteq($destfile); } else { if ($format == 'naked') { $teinte->naked($destfile); } else { if ($format == 'txm') { $teinte->txm($destfile); } else { if ($format == 'epub') { $livre = new Livrable_Tei2epub($teinte->dom(), self::$_logger); $livre->epub($destfile); // transformation auto en mobi, toujours après epub $mobifile = dirname(__FILE__) . '/' . $set['predir'] . 'kindle/' . $srcname . ".mobi"; Livrable_Tei2epub::mobi($destfile, $mobifile); } else { if ($format == 'docx') { $echo .= " docx"; Toff_Tei2docx::docx($srcfile, $destfile); } } } } } } } } } if ($echo) { self::log(E_USER_NOTICE, $srcfile . $echo . "\n"); } }