Init VERSION and improve requirement checking

This commit is contained in:
Ivan Lanin 2014-05-28 07:42:50 +07:00
parent d7f3d25b2a
commit 88f6518406
3 changed files with 26 additions and 15 deletions

1
VERSION Normal file
View File

@ -0,0 +1 @@
0.11.0

View File

@ -6,13 +6,13 @@ use PhpOffice\PhpWord\Autoloader;
use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Settings;
use PhpOffice\PhpWord\IOFactory; use PhpOffice\PhpWord\IOFactory;
error_reporting(E_ALL & ~E_DEPRECATED); error_reporting(E_ALL);
define('CLI', (PHP_SAPI == 'cli') ? true : false); define('CLI', (PHP_SAPI == 'cli') ? true : false);
define('EOL', CLI ? PHP_EOL : '<br />'); define('EOL', CLI ? PHP_EOL : '<br />');
define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php')); define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php'));
define('IS_INDEX', SCRIPT_FILENAME == 'index'); define('IS_INDEX', SCRIPT_FILENAME == 'index');
require_once '../src/PhpWord/Autoloader.php'; require_once __DIR__ . '/../src/PhpWord/Autoloader.php';
Autoloader::register(); Autoloader::register();
Settings::loadConfig(); Settings::loadConfig();

View File

@ -1,5 +1,13 @@
<?php <?php
include_once 'Sample_Header.php'; include_once 'Sample_Header.php';
$requirements = array(
'php' => array('PHP 5.3.0', version_compare(phpversion(), '5.3.0', '>=')),
'xml' => array('PHP extension XML', extension_loaded('xml')),
'zip' => array('PHP extension ZipArchive (optional)', extension_loaded('zip')),
'gd' => array('PHP extension GD (optional)', extension_loaded('gd')),
'xmlw' => array('PHP extension XMLWriter (optional)', extension_loaded('xmlwriter')),
'xsl' => array('PHP extension XSL (optional)', extension_loaded('xsl')),
);
if (!CLI) { if (!CLI) {
?> ?>
<div class="jumbotron"> <div class="jumbotron">
@ -11,20 +19,22 @@ if (!CLI) {
</p> </p>
</div> </div>
<?php <?php
$requirements = array(
'php' => array('PHP 5.3.0', version_compare(phpversion(), '5.3.0', '>=')),
'zip' => array('PHP extension ZipArchive', extension_loaded('zip')),
'xml' => array('PHP extension XML', extension_loaded('xml')),
'gd' => array('PHP extension GD (optional)', extension_loaded('gd')),
);
echo "<h3>Requirements</h3>";
echo "<ul>";
foreach ($requirements as $key => $value) {
$status = $value[1] ? 'passed' : 'failed';
echo "<li>{$value[0]} ... <span class='{$status}'>{$status}</span></li>";
}
echo "</ul>";
} }
if (!CLI) { if (!CLI) {
echo "<h3>Requirement check:</h3>";
echo "<ul>";
foreach ($requirements as $key => $value) {
list($label, $result) = $value;
$status = $result ? 'passed' : 'failed';
echo "<li>{$label} ... <span class='{$status}'>{$status}</span></li>";
}
echo "</ul>";
include_once 'Sample_Footer.php'; include_once 'Sample_Footer.php';
} else {
echo 'Requirement check:' . PHP_EOL;
foreach ($requirements as $key => $value) {
list($label, $result) = $value;
$status = $result ? '32m passed' : '31m failed';
echo "{$label} ... \033[{$status}\033[0m" . PHP_EOL;
}
} }