Build Adminer and Editor together

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1172 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2009-10-06 11:49:31 +00:00
parent ad237d3071
commit 12d2c6db84

View file

@ -17,8 +17,6 @@ function remove_lang($match) {
return ($match[1] && $match[4] ? $s : "$match[1]'" . add_apo_slashes($s) . "'$match[4]");
}
$lang_ids = array(); // global variable simplifies usage in a callback function
function lang_ids($match) {
global $lang_ids;
$lang_id = &$lang_ids[stripslashes($match[1])];
@ -80,7 +78,7 @@ function short_identifier($number, $chars) {
// based on http://latrine.dgx.cz/jak-zredukovat-php-skripty
function php_shrink($input) {
$special_variables = array_flip(array('$this', '$GLOBALS', '$_GET', '$_POST', '$_FILES', '$_COOKIE', '$_SESSION', '$_SERVER'));
static $short_variables = array();
$short_variables = array();
$shortening = true;
$tokens = token_get_all($input);
@ -159,22 +157,19 @@ function compile_file($match) {
return call_user_func($match[2], file_get_contents(dirname(__FILE__) . "/$project/$match[1]"));
}
$project = "adminer";
if (file_exists(dirname(__FILE__) . "/" . $_SERVER["argv"][1] . "/index.php")) {
$project = $_SERVER["argv"][1];
array_shift($_SERVER["argv"]);
}
unset($_COOKIE["adminer_lang"]);
$_SESSION["lang"] = $_SERVER["argv"][1]; // Adminer functions read language from session
if (isset($_SESSION["lang"])) {
include dirname(__FILE__) . "/adminer/include/lang.inc.php";
if (isset($_SERVER["argv"][2]) || !isset($langs[$_SESSION["lang"]])) {
echo "Usage: php compile.php [adminer] [lang]\nPurpose: Compile adminer[-lang].php from adminer/index.php.\n";
echo "Usage: php compile.php [lang]\nPurpose: Compile adminer[-lang].php and editor[-lang].php.\n";
exit(1);
}
include dirname(__FILE__) . "/adminer/lang/$_SESSION[lang].inc.php";
}
foreach (array("adminer", "editor") as $project) {
$lang_ids = array(); // global variable simplifies usage in a callback function
$file = file_get_contents(dirname(__FILE__) . "/$project/index.php");
$file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file);
$file = str_replace('include "../adminer/include/coverage.inc.php";', '', $file);
@ -199,3 +194,4 @@ $file = php_shrink($file);
$filename = $project . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php";
fwrite(fopen($filename, "w"), $file); // file_put_contents() since PHP 5
echo "$filename created.\n";
}