/** * Returns HTML to load registered libraries. Typically you'll output this HTML in the <head> of your page. * * @param (RequestHTTP) $po_request - The current request * @param array $pa_options Options include: * dontLoadAppAssets = don't load assets specified in the app asset.conf file [default is false] * @return string - HTML loading registered libraries */ static function getLoadHTML($po_request, $pa_options = null) { global $g_asset_config, $g_asset_load_list, $g_asset_complementary; $vs_baseurlpath = $po_request->getBaseUrlPath(); $vs_themeurlpath = $po_request->getThemeUrlPath(); $vs_default_themeurlpath = $po_request->getDefaultThemeUrlPath(); $vb_dont_load_app_assets = caGetOption('dontLoadAppAssets', $pa_options, false); $vs_themeDirectoryPath = $po_request->getThemeDirectoryPath(); $vs_default_themeDirectoryPath = $po_request->getDefaultThemeDirectoryPath(); if (!$g_asset_config) { AssetLoadManager::init(); } $vs_buf = ''; if (is_array($g_asset_load_list)) { ksort($g_asset_load_list); foreach ($g_asset_load_list as $vn_priority => $va_libs) { foreach ($va_libs as $vs_lib => $vs_type) { if ($vb_dont_load_app_assets && $vs_type == 'APP') { continue; } if (AssetLoadManager::useMinified()) { $va_tmp = explode(".", $vs_lib); array_splice($va_tmp, -1, 0, array('min')); $vs_lib = join('.', $va_tmp); } if (preg_match('!(http[s]{0,1}://.*)!', $vs_lib, $va_matches)) { $vs_url = $va_matches[1]; } else { if ($vs_type == 'THEME') { if (file_exists("{$vs_themeDirectoryPath}/assets/{$vs_lib}")) { $vs_url = "{$vs_themeurlpath}/assets/{$vs_lib}"; } elseif (file_exists("{$vs_default_themeDirectoryPath}/assets/{$vs_lib}")) { $vs_url = "{$vs_default_themeurlpath}/assets/{$vs_lib}"; } else { continue; } } else { $vs_url = "{$vs_baseurlpath}/assets/{$vs_lib}"; } } if (preg_match('!\\.css$!', $vs_lib)) { $vs_buf .= "<link rel='stylesheet' href='{$vs_url}' type='text/css' media='all'/>\n"; } elseif (preg_match('!\\.properties$!', $vs_lib)) { $vs_buf .= "<link rel='resource' href='{$vs_url}' type='application/l10n' />\n"; } else { $vs_buf .= "<script src='{$vs_url}' type='text/javascript'></script>\n"; } } } } if (is_array($g_asset_complementary)) { foreach ($g_asset_complementary as $vs_code) { $vs_buf .= "<script type='text/javascript'>\n{$vs_code}</script>\n"; } } return $vs_buf; }