Skip to content

Commit

Permalink
Updated manual build to follow ZF CS
Browse files Browse the repository at this point in the history
- No underscore-separated varnames or func names
- realpath() requires a valid path; build $tmpDir from $topDir
  • Loading branch information
weierophinney committed Aug 22, 2011
1 parent 5c21f81 commit cc743e6
Showing 1 changed file with 36 additions and 40 deletions.
76 changes: 36 additions & 40 deletions working/build-manual2.php
Original file line number Diff line number Diff line change
@@ -1,69 +1,66 @@
<?php
namespace cli;

$top_dir = realpath(__DIR__ . '/../');
$temp_dir = realpath(__DIR__ . '/../tmp');
$topDir = realpath(__DIR__ . '/../');
$tempDir = $topDir . '/tmp';

$output = null;


if (!file_exists($temp_dir)) {
cli_print('Creating a tmp directory at ' . $temp_dir . ' to work in ... ', 'green');
mkdir($temp_dir);
if (!file_exists($tempDir)) {
colorPrint('Creating a tmp directory at ' . $tempDir . ' to work in ... ', 'green');
mkdir($tempDir);
}

$output = null;
exec('which svn', $output);
if (empty($output)) {
cli_print('Error: svn is required to check out the Phd tools!', 'red');
colorPrint('Error: svn is required to check out the Phd tools!', 'red');
}

if (!file_exists($temp_dir . '/phd')) {
cli_print('Checking out PhD via SVN ...', 'green');
exec('svn co http://framework.zend.com/svn/framework/build-tools/trunk/build-tools/docs/ ' . $temp_dir . '/phd', $output);
cli_nl();
if (!file_exists($tempDir . '/phd')) {
colorPrint('Checking out PhD via SVN ...', 'green');
exec('svn co http://framework.zend.com/svn/framework/build-tools/trunk/build-tools/docs/ ' . $tempDir . '/phd', $output);
nl();
}

$output = null;
exec('which xsltproc', $output);
if (empty($output)) {
cli_print('Error: xsltproc is required!', 'red');
colorPrint('Error: xsltproc is required!', 'red');
}

$command = 'xsltproc --xinclude ' . $temp_dir . '/phd/db4-upgrade.xsl '
. $top_dir . '/documentation/manual/en/manual2.xml.in > '
. $temp_dir . '/manual2.full.xml | tee -a '
. $temp_dir . '/manual2-err.txt';
cli_print('Running: ' . $command, 'green');
cli_nl();
$command = 'xsltproc --xinclude ' . $tempDir . '/phd/db4-upgrade.xsl '
. $topDir . '/documentation/manual/en/manual2.xml.in > '
. $tempDir . '/manual2.full.xml | tee -a '
. $tempDir . '/manual2-err.txt';
colorPrint('Running: ' . $command, 'green');
nl();
system($command);
cli_nl();
nl();


$command = $temp_dir . '/phd/pear/phd -g \'phpdotnet\phd\Highlighter_GeSHi\' --xinclude -f zfpackage -d '
. $temp_dir . '/manual2.full.xml -o ' . $temp_dir . '/manual-html';
cli_print('Running: ' . $command, 'green');
cli_nl();
$command = $tempDir . '/phd/pear/phd -g \'phpdotnet\phd\Highlighter_GeSHi\' --xinclude -f zfpackage -d '
. $tempDir . '/manual2.full.xml -o ' . $tempDir . '/manual-html';
colorPrint('Running: ' . $command, 'green');
nl();
system($command);
cli_nl();

cli_print('[DONE]', 'green');
cli_nl();

cli_print('HTML Manual located in ' . $temp_dir . '/manual-html/zf-package-chunked-xhtml/manual.html', 'green');
cli_nl();

nl();

colorPrint('[DONE]', 'green');
nl();

colorPrint('HTML Manual located in ' . $tempDir . '/manual-html/zf-package-chunked-xhtml/manual.html', 'green');
nl();

/** FUNCTIONS **/

function cli_print($message, $color) {
static $is_color = null;
if ($is_color === null) $is_color = (function_exists('posix_isatty'));
function colorPrint($message, $color) {
static $isColor = null;
if ($isColor === null) {
$isColor = (function_exists('posix_isatty'));
}

list($prefix, $postfix) = array('', '');

if ($is_color) {
if ($isColor) {
switch ($color) {
case 'green':
list($prefix, $postfix) = array("\033[32m", "\033[37m");
Expand All @@ -75,9 +72,8 @@ function cli_print($message, $color) {
}

echo $prefix . $message . $postfix;

}

function cli_nl() {
function nl() {
echo "\r\n";
}
}

0 comments on commit cc743e6

Please sign in to comment.