| 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 | { |
|---|
| 19 | $ret = array('content' => '', 'title' => ''); |
|---|
| 20 | |
|---|
| 21 | $args = func_get_args(); |
|---|
| 22 | if (empty($args)) { |
|---|
| 23 | return $ret; |
|---|
| 24 | }; |
|---|
| 25 | |
|---|
| 26 | global $__resources; |
|---|
| 27 | if (empty($__resources['help'])) { |
|---|
| 28 | return $ret; |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 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 | } |
|---|
| 39 | |
|---|
| 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 | } |
|---|
| 47 | |
|---|
| 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 | } |
|---|
| 58 | |
|---|
| 59 | if (trim($content) == '') { |
|---|
| 60 | return $ret; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | $ret['content'] = $content; |
|---|
| 64 | if ($title != '') { |
|---|
| 65 | $ret['title'] = $title; |
|---|
| 66 | } |
|---|
| 67 | return $ret; |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | $help_page = !empty($_GET['page']) ? html::escapeHTML($_GET['page']) : 'index'; |
|---|
| 71 | $content_array = helpPage($help_page); |
|---|
| 72 | if (($content_array['content'] == '') || ($help_page == 'index')) { |
|---|
| 73 | $content_array = helpPage('index'); |
|---|
| 74 | } |
|---|
| 75 | if ($content_array['title'] != '') { |
|---|
| 76 | $breadcrumb = dcPage::breadcrumb( |
|---|
| 77 | array( |
|---|
| 78 | __('Global help') => 'help.php', |
|---|
| 79 | '<span class="page-title">'.$content_array['title'].'</span>' => '' |
|---|
| 80 | )); |
|---|
| 81 | } else { |
|---|
| 82 | $breadcrumb = dcPage::breadcrumb( |
|---|
| 83 | array( |
|---|
| 84 | '<span class="page-title">'.__('Global help').'</span>' => '' |
|---|
| 85 | )); |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | /* DISPLAY |
|---|
| 89 | -------------------------------------------------------- */ |
|---|
| 90 | dcPage::open(__('Global help'), |
|---|
| 91 | # --BEHAVIOR-- adminPostHeaders |
|---|
| 92 | $core->callBehavior('adminPostHeaders'). |
|---|
| 93 | dcPage::jsPageTabs('first-step'), |
|---|
| 94 | $breadcrumb |
|---|
| 95 | ); |
|---|
| 96 | |
|---|
| 97 | echo $content_array['content']; |
|---|
| 98 | |
|---|
| 99 | // Prevents global help link display |
|---|
| 100 | $GLOBALS['__resources']['ctxhelp'] = true; |
|---|
| 101 | |
|---|
| 102 | dcPage::close(); |
|---|
| 103 | ?> |
|---|