Exemple #1
0
   /**
    * Apply code from Cli
    */
   public static function cli()
   {
       $formats = 'odtx|tei|html';
       array_shift($_SERVER['argv']);
       // shift first arg, the script filepath
       if (!count($_SERVER['argv'])) {
           exit('
   usage    : php -f Odt.php $formats ? src.odt
   format?  : optional dest format, default tei, others may be odtx, html
   src.odt  : glob patterns are allowed, but in quotes, to not be expanded by shell "folder/*.odt"
 ');
       }
       $format = "tei";
       while ($arg = array_shift($_SERVER['argv'])) {
           if ($arg[0] == '-') {
               $format = substr($arg, 1);
           } else {
               if (preg_match("/^({$formats})\$/", $arg)) {
                   $format = $arg;
               } else {
                   if (!isset($srcGlob)) {
                       $srcGlob = $arg;
                   }
               }
           }
           /*
           $destdir=array_shift($_SERVER['argv']);
           if (!$destdir) $destdir='';
           $destdir=rtrim($destdir, '/').'/';
           if (!file_exists($destdir)) mkdir($destdir, 0775, true);
           */
       }
       $ext = ".{$format}";
       if ($ext == '.tei') {
           $ext = ".xml";
       }
       $count = 0;
       foreach (glob($srcGlob) as $srcfile) {
           $count++;
           $destfile = dirname($srcfile) . '/' . basename($srcfile, ".odt") . $ext;
           _log("{$count}. {$srcfile} > {$destfile}");
           if (file_exists($destfile)) {
               _log("  {$destfile} already exists, it will not be overwritten");
               continue;
           }
           $odt = new Odette_Odt2tei($srcfile);
           $odt->save($destfile, $format);
       }
   }
Exemple #2
0
<?php

// le code pilotant la transformation
include dirname(__FILE__) . '/Odt2tei.php';
// Soumission en post
if (isset($_POST['post'])) {
    Odette_Odt2tei::doPost();
    exit;
}
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"/>
    <title>Odette : Open Document Text &gt; XML/TEI</title>
    <link rel="stylesheet" type="text/css" href="//svn.code.sf.net/p/obvil/code/theme/obvil.css" />
  </head>
  <body>
    <div id="center">
      <header id="header">
        <h1>
          <a href="../">Développements</a>
        </h1>
        <a class="logo" href="//obvil.paris-sorbonne.fr/developpements/"><img class="logo" src="//svn.code.sf.net/p/obvil/code/theme/img/logo-obvil.png" alt="OBVIL"></a>
      </header>
      <div id="contenu">
      
    <h1>Odette, convertissez vos textes bureautiques (odt) en <a href="//www.tei-c.org/release/doc/tei-p5-doc/fr/html/REF-ELEMENTS.html">TEI</a></h1>
    <p class="byline">par <a onmouseover="this.href='mailto'+'\x3A'+'frederic.glorieux'+'\x40'+'fictif.org'" href="#">Frédéric Glorieux</a></p>
    <!--
    <ul>