|
1 | 1 | <?php |
2 | | -include_once($relPath."languages.inc"); // html_lang_header(); |
| 2 | +include_once($relPath."languages.inc"); // lang_html_header(); |
| 3 | +include_once($relPath."manifest.inc"); |
3 | 4 |
|
4 | 5 | define('NO_STATSBAR', false); |
5 | 6 | define('SHOW_STATSBAR', true); |
@@ -199,61 +200,3 @@ function get_local_file_browser_cache_key($url) |
199 | 200 |
|
200 | 201 | return $cache_fixer; |
201 | 202 | } |
202 | | - |
203 | | -/** |
204 | | - * @return string[] |
205 | | - */ |
206 | | -function get_js_manifest(string $basedir = ""): array |
207 | | -{ |
208 | | - global $code_dir; |
209 | | - |
210 | | - if (!$basedir) { |
211 | | - $basedir = $code_dir; |
212 | | - } |
213 | | - |
214 | | - // first, see if the PHP version of our manifest file exists, and if so |
215 | | - // load it and get the opcache-cached version without hitting the disk |
216 | | - if (is_file("$basedir/dist/manifest.php")) { |
217 | | - require_once("$basedir/dist/manifest.php"); |
218 | | - return get_cached_js_manifest(); // @phpstan-ignore function.notFound |
219 | | - } |
220 | | - |
221 | | - // if it doesn't exist, see if the JSON version exists and if so load |
222 | | - // and process it |
223 | | - if (is_file("$basedir/dist/manifest.json")) { |
224 | | - $raw_manifest = json_decode(file_get_contents("$basedir/dist/manifest.json"), true) ?? []; |
225 | | - // webpack puts "auto" in the pathname, no idea why |
226 | | - foreach ($raw_manifest as $filename => $path) { |
227 | | - $manifest[$filename] = str_replace("auto", "dist", $path); |
228 | | - } |
229 | | - return $manifest; |
230 | | - } |
231 | | - |
232 | | - // otherwise, just return an empty manifest |
233 | | - return []; |
234 | | -} |
235 | | - |
236 | | -/** |
237 | | - * @param string[] $manifest |
238 | | - */ |
239 | | -function generate_cached_js_manifest(string $basedir, array $manifest): void |
240 | | -{ |
241 | | - if (!$manifest) { |
242 | | - return; |
243 | | - } |
244 | | - |
245 | | - if (!is_dir("$basedir/dist")) { |
246 | | - throw new RuntimeException("Directory '$basedir/dist' does not exist."); |
247 | | - } |
248 | | - |
249 | | - $serialized_manifest = serialize($manifest); |
250 | | - $cached_php_file = <<<EOF |
251 | | - <?php |
252 | | - function get_cached_js_manifest(): array |
253 | | - { |
254 | | - return unserialize('$serialized_manifest'); |
255 | | - } |
256 | | - EOF; |
257 | | - |
258 | | - file_put_contents("$basedir/dist/manifest.php", $cached_php_file); |
259 | | -} |
0 commit comments