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