From 7c34a3676d294c9a1acc69f71ab3061074509160 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 30 Apr 2024 06:59:19 +0000 Subject: Rework Help module + begin tests for Setup module --- Zotlabs/Lib/Traits/HelpHelper.php | 68 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Zotlabs/Lib/Traits/HelpHelper.php (limited to 'Zotlabs/Lib/Traits') diff --git a/Zotlabs/Lib/Traits/HelpHelper.php b/Zotlabs/Lib/Traits/HelpHelper.php new file mode 100644 index 000000000..f0dca35d0 --- /dev/null +++ b/Zotlabs/Lib/Traits/HelpHelper.php @@ -0,0 +1,68 @@ +getList(); + + if(array_key_exists(argv(1), $languages)) { + $lang = argv(1); + $from_url = true; + } else { + $lang = \App::$language; + if(! isset($lang)) + $lang = 'en'; + + $from_url = false; + } + + $this->lang = array('language' => $lang, 'from_url' => $from_url); + } + + /** + * Find the full path name of the file, given it's base path and + * the language of the request. + * + * @param string $base_path The path of the file to find, relative to the + * doc root path, and without the extension. + */ + private function find_help_file(string $base_path, string $lang): void { + + // Use local variable until we can use trait constants. + $valid_file_ext = ['md', 'bb', 'html']; + + $base_path = "doc/{$lang}/${base_path}"; + + foreach ($valid_file_ext as $ext) { + $path = "{$base_path}.{$ext}"; + if (file_exists($path)) { + $this->file_name = $path; + $this->file_type = $ext; + + break; + } + } + } +} -- cgit v1.2.3