1
0
mirror of https://github.com/misterunknown/ifm.git synced 2025-08-18 13:51:16 +02:00

Merge branch 'fixes' into cryol-master

This commit is contained in:
Marco Dickert
2020-07-18 14:22:39 +02:00
6 changed files with 46 additions and 28 deletions

View File

@@ -6,7 +6,7 @@
* This script compiles all sources into one single file.
*/
chdir( realpath( dirname( __FILE__ ) ) );
chdir(realpath(dirname(__FILE__)));
// output files and common attrs
define( "IFM_CDN", false );
@@ -18,9 +18,8 @@ define( "IFM_LIB", "libifm.php" );
if( IFM_CDN ){
$IFM_ASSETS = "src/assets.cdn.part";
} else {
else
$IFM_ASSETS = "src/assets.part";
}
// php source files
$IFM_SRC_PHP = array(
@@ -30,14 +29,38 @@ $IFM_SRC_PHP = array(
);
// get options
$options = getopt( null, array( "language::" ) );
$options = getopt(null, array("language::", "languages::", "cdn::"));
// process languages
$vars['languages'] = isset( $options['language'] ) ? explode( ',', $options['language'] ) : array( "en", "ru" );
$langs = array_unique(array_merge(explode(",", join(",", [$options['language']])), explode(",", join(",", [$options['languages']]))));
print_r($langs);
if (in_array("all", $langs)) {
$available_languages = array_map(
function($i) { return str_replace("src/i18n/", "", str_replace(".json", "", $i)); },
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'] = "";
foreach( $vars['languages'] as $l ) {
if( file_exists( "src/i18n/".$l.".json" ) )
foreach ($vars['languages'] as $l)
if (file_exists("src/i18n/".$l.".json"))
$vars['languageincludes'] .=
'$i18n["'.$l.'"] = <<<\'f00bar\'' . "\n"
. file_get_contents( "src/i18n/".$l.".json" ) . "\n"
@@ -45,11 +68,8 @@ foreach( $vars['languages'] as $l ) {
. '$i18n["'.$l.'"] = json_decode( $i18n["'.$l.'"], true );' . "\n" ;
else
print "WARNING: Language file src/i18n/".$l.".json not found.\n";
}
/**
* Concat PHP Files
*/
// Concat PHP Files
$compiled = array( "<?php" );
foreach( $IFM_SRC_PHP as $phpfile ) {
$lines = file( $phpfile );
@@ -59,17 +79,14 @@ foreach( $IFM_SRC_PHP as $phpfile ) {
$compiled = join( $compiled );
$compiled = str_replace( "IFM_ASSETS", file_get_contents( $IFM_ASSETS ), $compiled );
/**
* Process file includes
*/
// Process file includes
$includes = NULL;
preg_match_all( "/\@\@\@file:([^\@]+)\@\@\@/", $compiled, $includes, PREG_SET_ORDER );
foreach( $includes as $file )
$compiled = str_replace( $file[0], file_get_contents( $file[1] ), $compiled );
/**
* Process ace includes
*/
// Process ace includes
$includes = NULL;
$vars['ace_includes'] = "";
preg_match_all( "/\@\@\@acedir:([^\@]+)\@\@\@/", $compiled, $includes, PREG_SET_ORDER );
@@ -84,9 +101,7 @@ foreach( $includes as $dir ) {
$compiled = str_replace( $dir[0], $dircontent, $compiled );
}
/**
* Process variable includes
*/
// Process variable includes
$includes = NULL;
preg_match_all( "/\@\@\@vars:([^\@]+)\@\@\@/", $compiled, $includes, PREG_SET_ORDER );
foreach( $includes as $var )