| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * @package Dotclear |
|---|
| 4 | * @subpackage Backend |
|---|
| 5 | * |
|---|
| 6 | * @copyright Olivier Meunier & Association Dotclear |
|---|
| 7 | * @copyright GPL-2.0-only |
|---|
| 8 | */ |
|---|
| 9 | |
|---|
| 10 | require dirname(__FILE__) . '/../inc/admin/prepend.php'; |
|---|
| 11 | |
|---|
| 12 | dcPage::check('usage,contentadmin'); |
|---|
| 13 | |
|---|
| 14 | $helpPage = function (...$args) { |
|---|
| 15 | $ret = ['content' => '', 'title' => '']; |
|---|
| 16 | |
|---|
| 17 | if (empty($args)) { |
|---|
| 18 | return $ret; |
|---|
| 19 | } |
|---|
| 20 | ; |
|---|
| 21 | |
|---|
| 22 | global $__resources; |
|---|
| 23 | if (empty($__resources['help'])) { |
|---|
| 24 | return $ret; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | $content = ''; |
|---|
| 28 | $title = ''; |
|---|
| 29 | foreach ($args as $v) { |
|---|
| 30 | if (is_object($v) && isset($v->content)) { |
|---|
| 31 | $content .= $v->content; |
|---|
| 32 | continue; |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | if (!isset($__resources['help'][$v])) { |
|---|
| 36 | continue; |
|---|
| 37 | } |
|---|
| 38 | $f = $__resources['help'][$v]; |
|---|
| 39 | if (!file_exists($f) || !is_readable($f)) { |
|---|
| 40 | continue; |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | $fc = file_get_contents($f); |
|---|
| 44 | if (preg_match('|<body[^>]*?>(.*?)</body>|ms', $fc, $matches)) { |
|---|
| 45 | $content .= $matches[1]; |
|---|
| 46 | if (preg_match('|<title[^>]*?>(.*?)</title>|ms', $fc, $matches)) { |
|---|
| 47 | $title = $matches[1]; |
|---|
| 48 | } |
|---|
| 49 | } else { |
|---|
| 50 | $content .= $fc; |
|---|
| 51 | } |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | if (trim($content) == '') { |
|---|
| 55 | return $ret; |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | $ret['content'] = $content; |
|---|
| 59 | if ($title != '') { |
|---|
| 60 | $ret['title'] = $title; |
|---|
| 61 | } |
|---|
| 62 | return $ret; |
|---|
| 63 | }; |
|---|
| 64 | |
|---|
| 65 | $help_page = !empty($_GET['page']) ? html::escapeHTML($_GET['page']) : 'index'; |
|---|
| 66 | $content_array = $helpPage($help_page); |
|---|
| 67 | if (($content_array['content'] == '') || ($help_page == 'index')) { |
|---|
| 68 | $content_array = $helpPage('index'); |
|---|
| 69 | } |
|---|
| 70 | if ($content_array['title'] != '') { |
|---|
| 71 | $breadcrumb = dcPage::breadcrumb( |
|---|
| 72 | [ |
|---|
| 73 | __('Global help') => $core->adminurl->get("admin.help"), |
|---|
| 74 | $content_array['title'] => '' |
|---|
| 75 | ]); |
|---|
| 76 | } else { |
|---|
| 77 | $breadcrumb = dcPage::breadcrumb( |
|---|
| 78 | [ |
|---|
| 79 | __('Global help') => '' |
|---|
| 80 | ]); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | /* DISPLAY |
|---|
| 84 | -------------------------------------------------------- */ |
|---|
| 85 | dcPage::open(__('Global help'), |
|---|
| 86 | dcPage::jsPageTabs('first-step'), |
|---|
| 87 | $breadcrumb |
|---|
| 88 | ); |
|---|
| 89 | |
|---|
| 90 | echo $content_array['content']; |
|---|
| 91 | |
|---|
| 92 | // Prevents global help link display |
|---|
| 93 | $GLOBALS['__resources']['ctxhelp'] = true; |
|---|
| 94 | |
|---|
| 95 | dcPage::close(); |
|---|