Example #1
0
 public function run()
 {
     $reader = new Reader();
     $render = new Render();
     if (Index::requireIndexing()) {
         $format = $render->attach(new Index());
         $reader->open(Config::xml_file());
         $render->execute($reader);
         $render->detach($format);
     }
     $render->attach($this->format);
     $reader->open(Config::xml_file());
     $render->execute($reader);
 }
Example #2
0
File: Index.php Project: philip/phd
 /**
  * Checks if indexing is needed.
  *
  * This is determined the following way:
  * 0. If no index file exists, indexing is required.
  * 1. If the config option --no-index is supplied, nothing is indexed
  * 2. If the config option --force-index is supplied, indexing is required
  * 3. If no option is given, the file modification time of the index and
  *    the manual docbook file are compared. If the index is older than
  *    the docbook file, indexing will be done.
  *
  * @return boolean True if indexing is required.
  */
 public static final function requireIndexing()
 {
     $indexfile = Config::output_dir() . 'index.sqlite';
     if (!file_exists($indexfile)) {
         return true;
     }
     if (Config::no_index()) {
         return false;
     }
     if (Config::force_index()) {
         return true;
     }
     $db = new \SQLite3($indexfile);
     $indexingCount = $db->query('SELECT COUNT(time) FROM indexing')->fetchArray(SQLITE3_NUM);
     if ($indexingCount[0] == 0) {
         return true;
     }
     $indexing = $db->query('SELECT time FROM indexing')->fetchArray(SQLITE3_ASSOC);
     $xmlLastModification = filemtime(Config::xml_file());
     if ($indexing['time'] > $xmlLastModification) {
         return false;
     }
     return true;
 }
Example #3
0
    $format = $render->attach(new Index());
    $reader->open(Config::xml_file(), NULL, $readerOpts);
    $render->execute($reader);
    $render->detach($format);
    v("Indexing done", VERBOSE_INDEXING);
} else {
    v("Skipping indexing", VERBOSE_INDEXING);
}
foreach ((array) Config::package() as $package) {
    $factory = Format_Factory::createFactory($package);
    // Default to all output formats specified by the package
    if (count(Config::output_format()) == 0) {
        Config::set_output_format((array) $factory->getOutputFormats());
    }
    // Register the formats
    foreach (Config::output_format() as $format) {
        $render->attach($factory->createFormat($format));
    }
}
// Render formats
$reader = make_reader();
$reader->open(Config::xml_file(), NULL, $readerOpts);
foreach ($render as $format) {
    $format->notify(Render::VERBOSE, true);
}
$render->execute($reader);
v("Finished rendering", VERBOSE_FORMAT_RENDERING);
/*
* vim600: sw=4 ts=4 syntax=php et
* vim<600: sw=4 ts=4
*/