Dotclear

source: admin/plugin.php @ 3333:11107ba2fc59

Revision 3333:11107ba2fc59, 2.4 KB checked in by franck <carnet.franck.paul@…>, 9 years ago (diff)

Cope with settings URLs for modules (defined in _define.php).
The settings URLs are displayed on the plugins maganement page, and at the bottom of each plugin main page if any (index.php).

The URLs are set in _define.php, as a new property using this schema:

'settings' => array( <list of URLs> )

With:

<list of URLs> = '<type>' => '<location>', …
<type> = 'self' (own plugin page), 'blog' (in blog parameters page) or 'pref' (in user preferences page)
<location> = (empty) or #<tab>[.<id>] with <tab> = id of the corresponding tab, and <id> = id of fieldset, h4, h5, field, … of first corresponding field

The list of URLs are displayed in the order defined in the array above.

Examples:

Antispam plugin:

'settings' => array(

'self' => ,
'blog' => '#params.antispam_params'

)

self → for main settings of the plugin on its own page (index.php)
blog → for secondary settings in the blog parameters

Tags plugin:

'settings' => array(

'pref' => '#user-options.tags_prefs'

)

pref → for tags list format in user preferences

Maintenance plugin:

'settings' => array(

'self' => '#settings'

)

self → "settings" tab of its own page (index.php)

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 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,contentadmin');
16
17$p_file = '';
18$p = !empty($_REQUEST['p']) ? $_REQUEST['p'] : null;
19$popup = (integer) !empty($_REQUEST['popup']);
20
21if ($popup) {
22     $open_f = array('dcPage','openPopup');
23     $close_f = array('dcPage','closePopup');
24} else {
25     $open_f = array('dcPage','open');
26     $close_f = array('dcPage','close');
27}
28
29if ($core->plugins->moduleExists($p)) {
30     $p_file = $core->plugins->moduleRoot($p).'/index.php';
31}
32
33if (file_exists($p_file))
34{
35     # Loading plugin
36     $p_info = $core->plugins->getModules($p);
37
38     $p_name = $p;
39     $p_url = 'plugin.php?p='.$p;
40
41     $p_title = 'no content - plugin';
42     $p_head = '';
43     $p_content = '<p>'.__('No content found on this plugin.').'</p>';
44
45     ob_start();
46     include $p_file;
47     $res = ob_get_contents();
48     ob_end_clean();
49
50     if (preg_match('|<head>(.*?)</head|ms',$res,$m)) {
51          if (preg_match('|<title>(.*?)</title>|ms',$m[1],$mt)) {
52               $p_title = $mt[1];
53          }
54
55          if (preg_match_all('|(<script.*?>.*?</script>)|ms',$m[1],$ms)) {
56               foreach ($ms[1] as $v) {
57                    $p_head .= $v."\n";
58               }
59          }
60
61          if (preg_match_all('|(<style.*?>.*?</style>)|ms',$m[1],$ms)) {
62               foreach ($ms[1] as $v) {
63                    $p_head .= $v."\n";
64               }
65          }
66
67          if (preg_match_all('|(<link.*?/>)|ms',$m[1],$ms)) {
68               foreach ($ms[1] as $v) {
69                    $p_head .= $v."\n";
70               }
71          }
72     }
73
74     if (preg_match('|<body.*?>(.+)</body>|ms',$res,$m)) {
75          $p_content = $m[1];
76     }
77
78     call_user_func($open_f,$p_title,$p_head);
79     echo $p_content;
80     if (!$popup) {
81          // Add direct links to plugin settings if any
82          $settings = adminModulesList::getSettingsUrls($core,$p,true,false);
83          if (!empty($settings)) {
84               echo '<hr class="clear"/><p class="right modules">'.implode(' - ',$settings).'</p>';
85          }
86     }
87     call_user_func($close_f);
88}
89else
90{
91     call_user_func($open_f,__('Plugin not found'),'',
92          dcPage::breadcrumb(
93               array(
94                    __('System') => '',
95                    __('Plugin not found') => ''
96               ))
97     );
98
99     echo '<p>'.__('The plugin you reached does not exist or does not have an admin page.').'</p>';
100
101     call_user_func($close_f);
102}
Note: See TracBrowser for help on using the repository browser.

Sites map