mirror of
https://github.com/misterunknown/ifm.git
synced 2025-01-17 20:58:23 +01:00
Add option for CDN build, tweak language detection
Signed-off-by: Marco Dickert <marco@misterunknown.de>
This commit is contained in:
parent
1c05108a9d
commit
526f3c50e3
53
compiler.php
53
compiler.php
@ -9,18 +9,12 @@
|
|||||||
chdir(realpath(dirname(__FILE__)));
|
chdir(realpath(dirname(__FILE__)));
|
||||||
|
|
||||||
// output files and common attrs
|
// output files and common attrs
|
||||||
define( "IFM_CDN", false );
|
|
||||||
define( "IFM_VERSION", "v2.6.2" );
|
define( "IFM_VERSION", "v2.6.2" );
|
||||||
define( "IFM_RELEASE_DIR", "dist/");
|
define( "IFM_RELEASE_DIR", "dist/");
|
||||||
define( "IFM_STANDALONE", "ifm.php" );
|
define( "IFM_STANDALONE", "ifm.php" );
|
||||||
define( "IFM_STANDALONE_GZ", "ifm.min.php" );
|
define( "IFM_STANDALONE_GZ", "ifm.min.php" );
|
||||||
define( "IFM_LIB", "libifm.php" );
|
define( "IFM_LIB", "libifm.php" );
|
||||||
|
|
||||||
if( IFM_CDN ){
|
|
||||||
$IFM_ASSETS = "src/assets.cdn.part";
|
|
||||||
else
|
|
||||||
$IFM_ASSETS = "src/assets.part";
|
|
||||||
|
|
||||||
// php source files
|
// php source files
|
||||||
$IFM_SRC_PHP = array(
|
$IFM_SRC_PHP = array(
|
||||||
0 => "src/main.php",
|
0 => "src/main.php",
|
||||||
@ -29,37 +23,30 @@ $IFM_SRC_PHP = array(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// get options
|
// get options
|
||||||
$options = getopt(null, array("language::", "languages::", "cdn::"));
|
$options = getopt(null, array("language::", "languages::", "lang::", "cdn"));
|
||||||
|
|
||||||
|
// build CDN version?
|
||||||
|
if (isset($options['cdn']))
|
||||||
|
define("IFM_CDN", true);
|
||||||
|
else
|
||||||
|
define("IFM_CDN", false);
|
||||||
|
|
||||||
// process languages
|
// process languages
|
||||||
$langs = array_unique(array_merge(explode(",", join(",", [$options['language']])), explode(",", join(",", [$options['languages']]))));
|
$langs = [];
|
||||||
print_r($langs);
|
foreach ($options as $key => $value)
|
||||||
if (in_array("all", $langs)) {
|
if (substr($key, 0, 4) == "lang")
|
||||||
$available_languages = array_map(
|
$langs = array_merge($langs, explode(",", $value));
|
||||||
|
$langs = array_unique($langs);
|
||||||
|
$vars['default_lang'] = ($langs[0] == "all") ? "en" : $langs[0];
|
||||||
|
|
||||||
|
if (in_array("all", $langs))
|
||||||
|
$langs = array_map(
|
||||||
function($i) { return str_replace("src/i18n/", "", str_replace(".json", "", $i)); },
|
function($i) { return str_replace("src/i18n/", "", str_replace(".json", "", $i)); },
|
||||||
glob("src/i18n/*.json")
|
glob("src/i18n/*.json")
|
||||||
);
|
);
|
||||||
// default language is english, if not given
|
|
||||||
if ($langs[0] == 'all' || !file_exists($lang[0]))
|
|
||||||
$default_lang = "en";
|
|
||||||
else
|
|
||||||
$default_lang = $lang[0];
|
|
||||||
|
|
||||||
unset($available_langs[array_search($default_lang, $available_langs)]);
|
|
||||||
$include_langs = array_merge($default_lang, $available_langs);
|
|
||||||
}
|
|
||||||
|
|
||||||
print_r($options['language']);
|
|
||||||
print_r($include_langs);
|
|
||||||
die();
|
|
||||||
|
|
||||||
|
|
||||||
// process languages
|
|
||||||
$vars['languages'] = isset($options['language']) ? explode(',', $options['language']) : ["all"];
|
|
||||||
$vars['defaultlanguage'] = $vars['languages'][0];
|
|
||||||
|
|
||||||
$vars['languageincludes'] = "";
|
$vars['languageincludes'] = "";
|
||||||
foreach ($vars['languages'] as $l)
|
foreach ($langs as $l)
|
||||||
if (file_exists("src/i18n/".$l.".json"))
|
if (file_exists("src/i18n/".$l.".json"))
|
||||||
$vars['languageincludes'] .=
|
$vars['languageincludes'] .=
|
||||||
'$i18n["'.$l.'"] = <<<\'f00bar\'' . "\n"
|
'$i18n["'.$l.'"] = <<<\'f00bar\'' . "\n"
|
||||||
@ -78,7 +65,11 @@ foreach( $IFM_SRC_PHP as $phpfile ) {
|
|||||||
}
|
}
|
||||||
$compiled = join( $compiled );
|
$compiled = join( $compiled );
|
||||||
|
|
||||||
$compiled = str_replace( "IFM_ASSETS", file_get_contents( $IFM_ASSETS ), $compiled );
|
if( IFM_CDN )
|
||||||
|
$IFM_ASSETS = "src/assets.cdn.part";
|
||||||
|
else
|
||||||
|
$IFM_ASSETS = "src/assets.part";
|
||||||
|
$compiled = str_replace( "IFM_ASSETS", file_get_contents("src/assets".(IFM_CDN?".cdn":"").".part"), $compiled );
|
||||||
|
|
||||||
// Process file includes
|
// Process file includes
|
||||||
$includes = NULL;
|
$includes = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user