[491] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
| 6 | # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear |
---|
| 7 | # Licensed under the GPL version 2.0 license. |
---|
| 8 | # See LICENSE file or |
---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 10 | # |
---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
| 12 | |
---|
| 13 | require dirname(__FILE__).'/../inc/admin/prepend.php'; |
---|
| 14 | |
---|
| 15 | dcPage::check('usage'); |
---|
| 16 | |
---|
| 17 | function helpPage() |
---|
| 18 | { |
---|
[1793] | 19 | $ret = array('content' => '', 'title' => ''); |
---|
| 20 | |
---|
[491] | 21 | $args = func_get_args(); |
---|
| 22 | if (empty($args)) { |
---|
[1793] | 23 | return $ret; |
---|
[491] | 24 | }; |
---|
[2566] | 25 | |
---|
[491] | 26 | global $__resources; |
---|
| 27 | if (empty($__resources['help'])) { |
---|
[1793] | 28 | return $ret; |
---|
[491] | 29 | } |
---|
[2566] | 30 | |
---|
[491] | 31 | $content = ''; |
---|
| 32 | $title = ''; |
---|
| 33 | foreach ($args as $v) |
---|
| 34 | { |
---|
| 35 | if (is_object($v) && isset($v->content)) { |
---|
| 36 | $content .= $v->content; |
---|
| 37 | continue; |
---|
| 38 | } |
---|
[2566] | 39 | |
---|
[491] | 40 | if (!isset($__resources['help'][$v])) { |
---|
| 41 | continue; |
---|
| 42 | } |
---|
| 43 | $f = $__resources['help'][$v]; |
---|
| 44 | if (!file_exists($f) || !is_readable($f)) { |
---|
| 45 | continue; |
---|
| 46 | } |
---|
[2566] | 47 | |
---|
[491] | 48 | $fc = file_get_contents($f); |
---|
| 49 | if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) { |
---|
| 50 | $content .= $matches[1]; |
---|
| 51 | if (preg_match('|<title[^>]*?>(.*?)</title>|ms',$fc,$matches)) { |
---|
| 52 | $title = $matches[1]; |
---|
| 53 | } |
---|
| 54 | } else { |
---|
| 55 | $content .= $fc; |
---|
| 56 | } |
---|
| 57 | } |
---|
[2566] | 58 | |
---|
[491] | 59 | if (trim($content) == '') { |
---|
[1793] | 60 | return $ret; |
---|
[491] | 61 | } |
---|
[2566] | 62 | |
---|
[1793] | 63 | $ret['content'] = $content; |
---|
[514] | 64 | if ($title != '') { |
---|
[1793] | 65 | $ret['title'] = $title; |
---|
[514] | 66 | } |
---|
[1793] | 67 | return $ret; |
---|
[491] | 68 | } |
---|
| 69 | |
---|
[1799] | 70 | $help_page = !empty($_GET['page']) ? html::escapeHTML($_GET['page']) : 'index'; |
---|
[1793] | 71 | $content_array = helpPage($help_page); |
---|
[1799] | 72 | if (($content_array['content'] == '') || ($help_page == 'index')) { |
---|
| 73 | $content_array = helpPage('index'); |
---|
[1793] | 74 | } |
---|
| 75 | if ($content_array['title'] != '') { |
---|
| 76 | $breadcrumb = dcPage::breadcrumb( |
---|
| 77 | array( |
---|
[2720] | 78 | __('Global help') => $core->adminurl->get("admin.help"), |
---|
[2166] | 79 | $content_array['title'] => '' |
---|
[1793] | 80 | )); |
---|
| 81 | } else { |
---|
| 82 | $breadcrumb = dcPage::breadcrumb( |
---|
| 83 | array( |
---|
[2166] | 84 | __('Global help') => '' |
---|
[1793] | 85 | )); |
---|
| 86 | } |
---|
[491] | 87 | |
---|
| 88 | /* DISPLAY |
---|
| 89 | -------------------------------------------------------- */ |
---|
| 90 | dcPage::open(__('Global help'), |
---|
[1839] | 91 | dcPage::jsPageTabs('first-step'), |
---|
[1793] | 92 | $breadcrumb |
---|
[491] | 93 | ); |
---|
| 94 | |
---|
[1793] | 95 | echo $content_array['content']; |
---|
[491] | 96 | |
---|
[1933] | 97 | // Prevents global help link display |
---|
| 98 | $GLOBALS['__resources']['ctxhelp'] = true; |
---|
| 99 | |
---|
[491] | 100 | dcPage::close(); |
---|