Exemple #1
0
<?php

/**
 * Génère les formats détachés et le site statique basique sur Œuvres
 */
// cli usage
Oeuvres::deps();
set_time_limit(-1);
if (realpath($_SERVER['SCRIPT_FILENAME']) != realpath(__FILE__)) {
    // file is include do nothing
} else {
    if (php_sapi_name() == "cli") {
        Oeuvres::cli();
    }
}
class Oeuvres
{
    static $sets = array("dumas" => array("glob" => '../dumas/*.xml', "publisher" => 'Œuvres', "source" => "http://oeuvres.github.io/dumas/%s.xml"), "flaubert" => array("glob" => '../flaubert/*.xml', "publisher" => 'Œuvres', "source" => "http://oeuvres.github.io/flaubert/%s.xml"), "hugo" => array("glob" => '../hugo/*.xml', "publisher" => 'Œuvres', "source" => "http://oeuvres.github.io/hugo/%s.xml"), "stendhal" => array("glob" => '../stendhal/*.xml', "publisher" => 'Œuvres', "source" => "http://oeuvres.github.io/stendhal/%s.xml"), "textes" => array("glob" => '../textes/*.xml', "publisher" => 'Œuvres', "source" => "http://oeuvres.github.io/textes/%s.xml"), "zola" => array("glob" => '../zola/*.xml', "publisher" => 'Œuvres', "source" => "http://oeuvres.github.io/zola/%s.xml"));
    static $formats = array('epub' => array("ext" => '.epub', "mime" => "application/epub+zip", "title" => "Livre électronique"), 'kindle' => array("ext" => '.mobi', "mime" => "application/x-mobipocket-ebook", "title" => "Livre électronique"), 'markdown' => array("ext" => '.txt', "mime" => "text/markdown; charset=UTF-8", "title" => "Texte brut"), 'iramuteq' => array("ext" => '.txt', "mime" => "text/plain; charset=UTF-8", "title" => "Texte brut avec métadonnées au format Iramuteq"), 'html' => array("ext" => '.html', "mime" => "text/html; charset=UTF-8", "title" => "Page web complète avec table des matières"), 'article' => array("ext" => '.html', "mime" => "text/html; charset=UTF-8", "label" => "fragment html", "title" => "Page web insérable dans un site web"));
    /** petite base sqlite pour conserver la mémoire des doublons etc */
    static $create = "\nPRAGMA encoding = 'UTF-8';\nPRAGMA page_size = 8192;\n\nCREATE TABLE oeuvre (\n  -- un texte\n  id         INTEGER, -- rowid auto\n  code       TEXT,    -- nom de fichier sans extension\n  filemtime  INTEGER, -- date de dernière modification du fichier pour update\n  publisher  TEXT,    -- nom de l’institution qui publie\n  identifier TEXT,    -- uri chez le publisher\n  source     TEXT,    -- XML TEI source URL\n  author     TEXT,    -- auteur\n  title      TEXT,    -- titre\n  year       INTEGER, -- année de publication\n  PRIMARY KEY(id ASC)\n);\nCREATE UNIQUE INDEX oeuvre_code ON oeuvre(code);\nCREATE INDEX oeuvre_author_year ON oeuvre(author, year, title);\nCREATE INDEX oeuvre_year_author ON oeuvre(year, author, title);\n\n  ";
    /** Lien à une base SQLite */
    public $pdo;
    /** Requête d’insertion d’une pièce */
    private $_insert;
    /** Test de date d’une pièce */
    private $_sqlmtime;
    /** Pièce XML/TEI en cours de traitement */
    private $_dom;
    /** Processeur xpath */
    private $_xpath;