Dotclear

source: plugins/themeEditor/_admin.php @ 2815:58afbf9370e1

Revision 2815:58afbf9370e1, 2.0 KB checked in by franck <carnet.franck.paul@…>, 11 years ago (diff)

Using dcAdminURL, work in progress on plugins…

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 -----------------------------------------
12if (!defined('DC_CONTEXT_ADMIN')) { return; }
13
14// Register admin URL base of plugin
15$core->adminurl->registercopy('admin.plugin.theme.editor','admin.plugin',array('p' => 'themeEditor'));
16
17if (!isset($__resources['help']['themeEditor'])) {
18     $__resources['help']['themeEditor'] = dirname(__FILE__).'/help.html';
19}
20
21$core->addBehavior('adminCurrentThemeDetails', array('themeEditorBehaviors','theme_editor_details'));
22
23$core->addBehavior('adminBeforeUserOptionsUpdate',array('themeEditorBehaviors','adminBeforeUserUpdate'));
24$core->addBehavior('adminPreferencesForm',array('themeEditorBehaviors','adminPreferencesForm'));
25
26class themeEditorBehaviors
27{
28     public static function theme_editor_details($core,$id)
29     {
30          if ($id != 'default' && $core->auth->isSuperAdmin()) {
31               return '<p><a href="'.$core->adminurl->get('admin.plugin.theme.editor').'" class="button">'.__('Edit theme files').'</a></p>';
32          }
33     }
34
35     public static function adminBeforeUserUpdate($cur,$userID)
36     {
37          global $core;
38
39          // Get and store user's prefs for plugin options
40          $core->auth->user_prefs->addWorkspace('interface');
41          try {
42               $core->auth->user_prefs->interface->put('colorsyntax',!empty($_POST['colorsyntax']),'boolean');
43          }
44          catch (Exception $e)
45          {
46               $core->error->add($e->getMessage());
47          }
48     }
49
50     public static function adminPreferencesForm($core)
51     {
52          // Add fieldset for plugin options
53          $core->auth->user_prefs->addWorkspace('interface');
54
55          echo
56          '<p><label for="colorsyntax" class="classic">'.
57          form::checkbox('colorsyntax',1,$core->auth->user_prefs->interface->colorsyntax).'</label>'.
58          __('Syntax highlighting in theme editor').
59          '</p>';
60     }
61}
Note: See TracBrowser for help on using the repository browser.

Sites map