From ba8137da9d19f2bec4f2e147ee03af6b230eb236 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Fri, 9 Dec 2022 12:37:55 +0300 Subject: [PATCH] Getting rid of obsolete functions and making files parsing more flexible --- metagen.inc.php | 27 +++++---------------------- parser.inc.php | 20 ++++++++++++-------- 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/metagen.inc.php b/metagen.inc.php index baa3634..0188846 100644 --- a/metagen.inc.php +++ b/metagen.inc.php @@ -1,26 +1,5 @@ name) & 0xFFFFFFF; } diff --git a/parser.inc.php b/parser.inc.php index 4871afe..c356acf 100644 --- a/parser.inc.php +++ b/parser.inc.php @@ -800,20 +800,24 @@ class mtgMetaInfoParser } } -function mtg_parse_meta(array $meta_srcs, $valid_tokens = null) +function mtg_parse_meta(array $meta_srcs, $valid_tokens = null, $inc_path = null) { - $meta_dirs = array(); - foreach($meta_srcs as $src) + if($inc_path === null) { - if(is_dir($src)) - $meta_dirs[] = $src; - else if(is_file($src)) - $meta_dirs[] = dirname($src); + //let's autodetect include path + $inc_path = array(); + foreach($meta_srcs as $src) + { + if(is_dir($src)) + $inc_path[] = $src; + else if(is_file($src)) + $inc_path[] = dirname($src); + } } $meta_parser = new mtgMetaInfoParser( array( - 'include_path' => $meta_dirs, + 'include_path' => $inc_path, 'valid_tokens' => $valid_tokens ) );