Dotclear

source: admin/help.php @ 2720:bc400ebfc2e9

Revision 2720:bc400ebfc2e9, 2.1 KB checked in by Dsls, 11 years ago (diff)

One step further towards php hardcoded links annihilation in admin sources, more to come...

Line 
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
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14
15dcPage::check('usage');
16
17function 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);
72if (($content_array['content'] == '') || ($help_page == 'index')) {
73     $content_array = helpPage('index');
74}
75if ($content_array['title'] != '') {
76     $breadcrumb = dcPage::breadcrumb(
77          array(
78               __('Global help') => $core->adminurl->get("admin.help"),
79               $content_array['title'] => ''
80          ));
81} else {
82     $breadcrumb = dcPage::breadcrumb(
83          array(
84               __('Global help') => ''
85          ));
86}
87
88/* DISPLAY
89-------------------------------------------------------- */
90dcPage::open(__('Global help'),
91     dcPage::jsPageTabs('first-step'),
92     $breadcrumb
93);
94
95echo $content_array['content'];
96
97// Prevents global help link display
98$GLOBALS['__resources']['ctxhelp'] = true;
99
100dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map