97 $extensionPath = static::getPath($extName);
98 if ($extensionPath ===
null)
104 if (!File::isFileExists($configFile))
109 $config = include($configFile);
111 if (is_array($config))
113 if (isset($config[
'js']))
115 $config[
'js'] = static::normalizeAssetPath($config[
'js'], $extensionPath);
118 if (isset($config[
'css']))
120 $config[
'css'] = static::normalizeAssetPath($config[
'css'], $extensionPath);
127 if (isset($config[
"lang"]))
129 $config[
"lang"] = static::normalizeAssetPath($config[
"lang"], $extensionPath);
131 if (is_array($config[
"lang"]))
133 $config[
"lang"][] = $extensionPath.
"/config.php";
137 $config[
"lang"] = [$config[
"lang"], $extensionPath.
"/config.php"];
142 $config[
"lang"] = $extensionPath.
"/config.php";
146 if (!isset($config[
'settings']) || !is_array($config[
'settings']))
148 $config[
'settings'] = [];
153 return is_array($config) ? $config :
null;
163 $extensionPath = static::getPath($extName);
165 if ($extensionPath ===
null)
171 $configFile =
new File($configFilePath);
173 if (!$configFile->isExists())
178 $fileContent = str_replace(
"module.exports = ",
"", $configFile->getContents());
179 $fileContent = str_replace(
"};",
"}", $fileContent);
181 return \CUtil::JsObjectToPhp($fileContent);
236 $assets = [
'js' => [],
'css' => []];
238 if (is_array($extName))
240 foreach ($extName as $key => $name)
242 $currentAssets = static::getAssets($name);
243 $assets[
'js'] = array_merge($assets[
'js'], $currentAssets[
'js']);
244 $assets[
'css'] = array_merge($assets[
'css'], $currentAssets[
'css']);
250 if (is_string($extName))
252 $config = static::getConfig($extName);
256 $config = \CJSCore::getExtInfo($extName);
259 if (isset($config[
'rel']))
261 $relAssets = static::getAssets($config[
'rel']);
262 $assets[
'js'] = array_merge($assets[
'js'], $relAssets[
'js']);
263 $assets[
'css'] = array_merge($assets[
'css'], $relAssets[
'css']);
266 if (isset($config[
'js']))
268 if (is_array($config[
'js']))
270 $assets[
'js'] = array_merge($assets[
'js'], $config[
'js']);
273 if (is_string($config[
'js']) && $config[
'js'] !==
'')
275 $assets[
'js'][] = $config[
'js'];
279 if (isset($config[
'css']))
281 if (is_array($config[
'css']))
283 $assets[
'css'] = array_merge($assets[
'css'], $config[
'css']);
286 if (is_string($config[
'css']) && $config[
'css'] !==
'')
288 $assets[
'css'][] = $config[
'css'];
292 if (isset($config[
'post_rel']))
294 $relAssets = static::getAssets($config[
'post_rel']);
295 $assets[
'js'] = array_merge($assets[
'js'], $relAssets[
'js']);
296 $assets[
'css'] = array_merge($assets[
'css'], $relAssets[
'css']);
300 $assets[
'js'] = array_unique($assets[
'js']);
301 $assets[
'css'] = array_unique($assets[
'css']);
322 $skipCoreJS = isset($option[
'skip_core_js']) && $option[
'skip_core_js'] ===
true;
323 $withDependency = !(isset($option[
'with_dependency']) && $option[
'with_dependency'] ===
false);
324 $skipExtensions = $option[
'skip_extensions'] ?? [];
325 $getResolvedExtensionList = isset($option[
'get_resolved_extension_list']) && $option[
'get_resolved_extension_list'] ===
true;
329 $alreadyResolved = $skipExtensions;
332 $alreadyResolved[] =
'core';
338 $extNameList = is_array($extName)? $extName: [$extName];
339 foreach ($extNameList as $extName)
341 if (in_array($extName, $alreadyResolved))
346 self::getDependencyListRecursive($extName,
true,
true, $extensions, $alreadyResolved);
351 $extNameList = is_array($extName)? $extName: [$extName];
352 foreach ($extNameList as $extName)
354 if (in_array($extName, $alreadyResolved))
360 $alreadyResolved[] = $extName;
367 foreach ($extensions as $index => $extension)
369 if(isset($extension[1][
'oninit']) && is_callable($extension[1][
'oninit']))
371 $callbackResult = call_user_func_array(
372 $extension[1][
'oninit'],
376 if(is_array($callbackResult))
378 foreach($callbackResult as $option => $value)
380 if(!is_array($value))
382 $value = array($value);
385 if(!isset($extension[1][$option]))
387 $extension[1][$option] = array();
389 elseif(!is_array($extension[1][$option]))
391 $extension[1][$option] = array($extension[1][$option]);
394 $extensions[$index][1][$option] = array_merge($extension[1][$option], $value);
398 unset($extensions[$index][1][
'oninit']);
406 'lang_additional' => [],
412 if ($getResolvedExtensionList)
414 $result[
'resolved_extension'] = array_diff($alreadyResolved, $skipExtensions);
417 $options = array_keys($result);
418 foreach ($extensions as $extension)
420 $extensionName = $extension[0];
421 $config = $extension[1];
423 foreach ($options as $option)
425 if (is_array($config) && array_key_exists($option, $config))
427 if ($option ===
'settings' && is_array($config[$option]) && !empty($config[$option]))
429 $result[$option][$extensionName] = $config[$option];
431 else if (is_array($config[$option]))
433 $result[$option] = array_merge($result[$option], $config[$option]);
437 $result[$option][] = $config[$option];
454 private static function getDependencyListRecursive($name, $storeConfig =
false, $storeSelf =
false, &$resultList = [], &$alreadyResolved = [])
462 $config = self::getCoreConfigForDependencyList($name, $storeConfig, $resultList, $alreadyResolved);
480 self::getDependencyListRecursive($dependencyName, $storeConfig,
true, $resultList, $alreadyResolved);
503 self::getDependencyListRecursive($dependencyName, $storeConfig,
true, $resultList, $alreadyResolved);
528 private static function getCoreConfigForDependencyList($name, $storeConfig =
false, &$resultList = [], &$alreadyResolved = [])