Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 82 lines (61 sloc) 2.182 kb
#!/opt/local/bin/php
<?php
header('Content-Type: text/plain');
// Make the final vanilla2export.php file from the other sources.
$Path = dirname(__FILE__) . '/vanilla2export.php';
if (file_exists($Path)) {
$r = unlink($Path);
if (!$r) {
echo "Could not delete $Path.\n";
die();
}
}
// Open the file.
echo "Opening $Path\n";
$fp = fopen($Path, 'w');
fwrite($fp, "<?php /* This file was automatically generated by make.php. DO NOT EDIT. */ ?>\n\n");
AddFile($fp, 'index.php');
fclose($fp);
echo "Make Complete.\n";
/// Functions ///
function AddFile($fp, $Filename) {
// Recursively build file
$Contents = GetFile($Filename);
// Include individual software porters (undo MAKESKIP)
$Paths = glob('packages/*.php');
$Exporters = '';
foreach ($Paths as $Path) {
$Exporters .= GetFile($Path);
}
$Contents = str_replace('// [EXPORTERS]', ' ?>' . $Exporters . '<?php ', $Contents);
// Write the all-in-one file
fwrite($fp, $Contents);
}
function GetFile($Filename, $EndPhp = false) {
$Path = dirname(__FILE__) . '/' . $Filename;
echo "Including file $Path\n";
$Contents = file_get_contents($Path);
// MAKESKIP
$Contents = preg_replace('/MAKESKIPSTART(.*)MAKESKIPEND/s', '[EXPORTERS]', $Contents);
// Inline any stylesheet includes.
$Contents = preg_replace_callback('/<link.*?href=[\'"](.*?)[\'"].*?\/>/i', 'ReplaceStyleCallback', $Contents);
// Inline any includes.
$Contents = preg_replace_callback('/include_once [\'"](.*?)[\'"]\;/', 'ReplaceIncludeCallback', $Contents);
// End and begin the php context.
if ($EndPhp) {
$Contents = "\n/* Contents included from $Filename */\n?>" . $Contents . "<?php\n";
}
return $Contents;
}
function ReplaceIncludeCallback($Matches) {
$Path = $Matches[1];
$Contents = GetFile($Path, true);
$Result = $Contents;
return $Result;
}
function ReplaceStyleCallback($Matches) {
$Path = $Matches[1];
$Contents = file_get_contents(dirname(__FILE__) . '/' . $Path);
$Result = "<!-- Contents included from $Path -->\n<style>\n" . $Contents . "\n</style>";
return $Result;
}
Jump to Line
Something went wrong with that request. Please try again.