2013-09-08 23:30:44 +00:00
|
|
|
<?php
|
2013-10-01 01:19:08 +00:00
|
|
|
date_default_timezone_set('Europe/London');
|
|
|
|
|
2013-09-19 03:45:08 +00:00
|
|
|
// Get the version number
|
|
|
|
// VERSION: '1.0.5',
|
2013-10-01 01:19:08 +00:00
|
|
|
$vf = file_get_contents(dirname(__FILE__) . '/../src/Phaser.js');
|
2013-09-19 03:45:08 +00:00
|
|
|
$version = substr($vf, strpos($vf, 'VERSION: ') + 10, 5);
|
2013-10-01 01:19:08 +00:00
|
|
|
$buildLog = "Building version $version \n\n";
|
|
|
|
$header = "";
|
2013-09-19 03:45:08 +00:00
|
|
|
|
2013-10-01 01:19:08 +00:00
|
|
|
$js = file(dirname(__FILE__) . '/../examples/js.php');
|
2013-09-08 23:30:44 +00:00
|
|
|
$output = "";
|
|
|
|
|
|
|
|
for ($i = 0; $i < count($js); $i++)
|
|
|
|
{
|
|
|
|
// <script src="../src/Phaser.js"></script>
|
|
|
|
$line = trim($js[$i]);
|
|
|
|
|
|
|
|
if (strpos($line, '<script') !== false)
|
|
|
|
{
|
|
|
|
$line = str_replace('<script src="', '', $line);
|
2013-10-01 01:19:08 +00:00
|
|
|
$line = dirname(__FILE__) . DIRECTORY_SEPARATOR . str_replace('"></script>', '', $line);
|
2013-09-19 03:45:08 +00:00
|
|
|
$filename = substr($line, strrpos($line, '/') + 1);
|
2013-09-08 23:30:44 +00:00
|
|
|
|
2013-10-01 01:19:08 +00:00
|
|
|
$buildLog .= $line . "\n";
|
2013-09-19 03:45:08 +00:00
|
|
|
// echo $filename . "\n";
|
2013-09-08 23:30:44 +00:00
|
|
|
|
|
|
|
// Read the file in
|
2013-10-10 08:03:38 +00:00
|
|
|
if (file_exists($line))
|
2013-09-08 23:30:44 +00:00
|
|
|
{
|
2013-10-10 08:03:38 +00:00
|
|
|
$source = file_get_contents($line);
|
|
|
|
|
|
|
|
if ($filename == 'Intro.js')
|
|
|
|
{
|
|
|
|
// Built at: {buildDate}
|
|
|
|
$source = str_replace('{buildDate}', date('r'), $source);
|
2013-09-19 03:45:08 +00:00
|
|
|
|
2013-10-10 08:03:38 +00:00
|
|
|
// {version}
|
|
|
|
$source = str_replace('{version}', $version, $source);
|
2013-09-08 23:30:44 +00:00
|
|
|
|
2013-10-10 08:03:38 +00:00
|
|
|
// Set the header
|
|
|
|
$header = $source;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$output .= $source . "\n";
|
|
|
|
}
|
2013-10-01 01:19:08 +00:00
|
|
|
}
|
2013-09-08 23:30:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-01 01:19:08 +00:00
|
|
|
// Create a UMD wrapper, to allow Phaser to be exposed to AMD, Node and Browsers
|
|
|
|
$template = <<<EOT
|
|
|
|
%s(function (root, factory) {
|
|
|
|
if (typeof define === 'function' && define.amd) {
|
|
|
|
define(factory);
|
|
|
|
} else if (typeof exports === 'object') {
|
|
|
|
module.exports = factory();
|
|
|
|
} else {
|
|
|
|
root.Phaser = factory();
|
|
|
|
}
|
|
|
|
}(this, function (b) {
|
|
|
|
%s
|
|
|
|
return Phaser;
|
|
|
|
}));
|
|
|
|
EOT;
|
2013-09-08 23:30:44 +00:00
|
|
|
|
2013-10-01 01:19:08 +00:00
|
|
|
file_put_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'phaser.js', sprintf($template, $header, $output));
|
2013-09-08 23:30:44 +00:00
|
|
|
|
2013-10-01 01:19:08 +00:00
|
|
|
if(php_sapi_name() == 'cli' || empty($_SERVER['REMOTE_ADDR'])) {
|
|
|
|
echo "\ndone\n\n";
|
|
|
|
return;
|
|
|
|
}
|
2013-09-08 23:30:44 +00:00
|
|
|
?>
|
2013-10-01 01:19:08 +00:00
|
|
|
<a href="http://yui.2clics.net/">Minify it</a><br />
|
|
|
|
|
|
|
|
<textarea style="width: 800px; height: 800px">
|
|
|
|
<?php echo $buildLog; ?>
|
2013-09-08 23:30:44 +00:00
|
|
|
</textarea>
|