From 946c862dc45f7b3517290e1ae1da19d9fd3451cd Mon Sep 17 00:00:00 2001 From: Daniel Lo Nigro Date: Tue, 19 Feb 2019 00:47:06 -0800 Subject: [PATCH] Add option to stop searching for header/footer files once the root is reached References https://github.com/lrsjng/h5ai/issues/669 --- src/_h5ai/private/conf/options.json | 7 ++++++- src/_h5ai/private/php/ext/class-custom.php | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/_h5ai/private/conf/options.json b/src/_h5ai/private/conf/options.json index 1ec53edc..c6f1b34e 100644 --- a/src/_h5ai/private/conf/options.json +++ b/src/_h5ai/private/conf/options.json @@ -108,9 +108,14 @@ Note the different filenames: "header" (only current) - "headers" (current and sub directories)! The file's content will be placed inside a
tag above/below the main content. If a file's extension is ".md" instead of ".html" its content will be interpreted as markdown. + + - stopSearchingAtRoot: boolean, only search for header and footer files until the web root + directory. if `false`, will search for header/footer up the entire directory structure, + even above the web root */ "custom": { - "enabled": true + "enabled": true, + "stopSearchingAtRoot": true }, /* diff --git a/src/_h5ai/private/php/ext/class-custom.php b/src/_h5ai/private/php/ext/class-custom.php index ab1628ed..1a84bd20 100644 --- a/src/_h5ai/private/php/ext/class-custom.php +++ b/src/_h5ai/private/php/ext/class-custom.php @@ -54,6 +54,14 @@ class Custom { if ($parent_path === $path) { break; } + + // Stop once we reach the root + if ( + $this->context->query_option('custom.stopSearchingAtRoot', true) && + $path === $this->context->get_setup()->get('ROOT_PATH') + ) { + break; + } $path = $parent_path; }