| 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 | $args = func_get_args(); |
|---|
| 20 | if (empty($args)) { |
|---|
| 21 | return; |
|---|
| 22 | }; |
|---|
| 23 | |
|---|
| 24 | global $__resources; |
|---|
| 25 | if (empty($__resources['help'])) { |
|---|
| 26 | return; |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | $content = ''; |
|---|
| 30 | $title = ''; |
|---|
| 31 | foreach ($args as $v) |
|---|
| 32 | { |
|---|
| 33 | if (is_object($v) && isset($v->content)) { |
|---|
| 34 | $content .= $v->content; |
|---|
| 35 | continue; |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | if (!isset($__resources['help'][$v])) { |
|---|
| 39 | continue; |
|---|
| 40 | } |
|---|
| 41 | $f = $__resources['help'][$v]; |
|---|
| 42 | if (!file_exists($f) || !is_readable($f)) { |
|---|
| 43 | continue; |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | $fc = file_get_contents($f); |
|---|
| 47 | if (preg_match('|<body[^>]*?>(.*?)</body>|ms',$fc,$matches)) { |
|---|
| 48 | $content .= $matches[1]; |
|---|
| 49 | if (preg_match('|<title[^>]*?>(.*?)</title>|ms',$fc,$matches)) { |
|---|
| 50 | $title = $matches[1]; |
|---|
| 51 | } |
|---|
| 52 | } else { |
|---|
| 53 | $content .= $fc; |
|---|
| 54 | } |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | if (trim($content) == '') { |
|---|
| 58 | return ''; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | if ($title != '') { |
|---|
| 62 | $title = '<a href="help.php">'.__('Global help').'</a> › <span class="page-title">'.$title.'</span>'; |
|---|
| 63 | } else { |
|---|
| 64 | $title = '<span class="page-title">'.__('Global help').'</span>'; |
|---|
| 65 | } |
|---|
| 66 | return '<h2>'.$title.'</h2>'."\n".'<div id="mainhelp">'.$content.'</div>'; |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | $help_page = !empty($_GET['page']) ? html::escapeHTML($_GET['page']) : 'core_main'; |
|---|
| 70 | $content = helpPage($help_page); |
|---|
| 71 | |
|---|
| 72 | /* DISPLAY |
|---|
| 73 | -------------------------------------------------------- */ |
|---|
| 74 | dcPage::open(__('Global help'), |
|---|
| 75 | # --BEHAVIOR-- adminPostHeaders |
|---|
| 76 | $core->callBehavior('adminPostHeaders') |
|---|
| 77 | ); |
|---|
| 78 | |
|---|
| 79 | if (($content == '') || ($help_page == 'core_main')) { |
|---|
| 80 | $content = helpPage('core_main'); |
|---|
| 81 | } |
|---|
| 82 | echo $content; |
|---|
| 83 | |
|---|
| 84 | dcPage::close(); |
|---|
| 85 | ?> |
|---|