1
0
mirror of https://github.com/php/phd.git synced 2026-03-24 07:02:07 +01:00
Files
archived-phd/setup.php

59 lines
1.7 KiB
PHP

#!@php_bin@
<?php
/* $Id$ */
$base_revision = '$Revision$';
/* {{{ Find the $ROOT directory of PhD. @php_dir@ will be replaced by the PEAR
package manager. If for some reaosn this hasn't happened, fallback to the
dir containing this file */
$ROOT = "@php_dir@/phd";
if ($ROOT == "@php_dir"."@/phd") {
$ROOT = dirname(__FILE__);
}
/* }}} */
require_once $ROOT . "/config.php";
require_once $ROOT . "/include/PhDSetupOptions.class.php";
// We assume that the code in the option processors has checked for most of the obvious crap
if (!file_exists(PhDConfig::source_dir() . DIRECTORY_SEPARATOR . "manual.xml")) {
trigger_error("The source directory has no manual.xml file. It can not be used with PhD.", E_USER_ERROR);
}
$saved_options = array(
'output_format' => PhDConfig::output_format(),
'output_theme' => PhDConfig::output_theme(),
'intermediate_output_dir' => realpath(PhDConfig::intermediate_output_dir()),
'source_dir' => realpath(PhDConfig::source_dir()),
'date_format' => PhDConfig::date_format(),
);
$now = date(DATE_RFC2822);
$options_file = <<<BLOB
<?php
/* This file was automatically generated by phd-setup at {$now}. Do not edit it by hand. */
BLOB;
foreach ($saved_options as $option_name => $option_value) {
$v = var_export($option_value, 1);
$options_file .= <<<BLOB
PhDConfig::set_{$option_name}({$v});
BLOB;
}
$options_file .= <<<BLOB
?>
BLOB;
$config_file_path = PhDConfig::intermediate_output_dir() . DIRECTORY_SEPARATOR . "phd-config.php";
if (file_put_contents($config_file_path, $options_file) === FALSE) {
trigger_error("Unable to write the configuration file to the output directory.", E_USER_ERROR);
}
v("Configuration successfully written to " . $config_file_path, VERBOSE_DONE);
?>