Dotclear

source: plugins/typo/index.php @ 655

Revision 655, 4.2 KB checked in by franck, 15 years ago (diff)

Hyphenation feature removed
Draft code for action on selected entries in admin

Line 
1<?php
2# ***** BEGIN LICENSE BLOCK *****
3# This file is part of CommentsWikibar, a plugin for DotClear2.
4# Copyright (c) 2006-2008 Pep and contributors. All rights
5# reserved.
6#
7# This plugin is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This plugin is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this plugin; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20#
21# ***** END LICENSE BLOCK *****
22if (!defined('DC_CONTEXT_ADMIN')) { exit; }
23
24// Setting default parameters if missing configuration
25if (is_null($core->blog->settings->typo_active)) {
26     try {
27          $core->blog->settings->setNameSpace('typo');
28
29          // Default state is active for entries content and inactive for comments
30          $core->blog->settings->put('typo_active',true,'boolean');
31          $core->blog->settings->put('typo_entries',true,'boolean');
32          $core->blog->settings->put('typo_comments',false,'boolean');
33          $core->blog->triggerBlog();
34          http::redirect(http::getSelfURI());
35     }
36     catch (Exception $e) {
37          $core->error->add($e->getMessage());
38     }
39} else {
40     // Setting new 1.3 parameter if missing in configuration
41     if (is_null($core->blog->settings->typo_entries)) {
42          try {
43               // Default state is active for entries content
44               $core->blog->settings->setNameSpace('typo');
45               $core->blog->settings->put('typo_entries',true,'boolean');
46               $core->blog->triggerBlog();
47               http::redirect(http::getSelfURI());
48          }
49          catch (Exception $e) {
50               $core->error->add($e->getMessage());
51          }
52     }
53}
54
55// Getting current parameters
56$typo_active = (boolean)$core->blog->settings->typo_active;
57$typo_entries = (boolean)$core->blog->settings->typo_entries;
58$typo_comments = (boolean)$core->blog->settings->typo_comments;
59
60// Saving new configuration
61if (!empty($_POST['saveconfig'])) {
62     try
63     {
64          $core->blog->settings->setNameSpace('typo');
65
66          $typo_active = (empty($_POST['active']))?false:true;
67          $typo_entries = (empty($_POST['entries']))?false:true;
68          $typo_comments = (empty($_POST['comments']))?false:true;
69          $core->blog->settings->put('typo_active',$typo_active,'boolean');
70          $core->blog->settings->put('typo_entries',$typo_entries,'boolean');
71          $core->blog->settings->put('typo_comments',$typo_comments,'boolean');
72          $core->blog->triggerBlog();
73          $msg = __('Configuration successfully updated.');
74     }
75     catch (Exception $e)
76     {
77          $core->error->add($e->getMessage());
78     }
79}
80?>
81<html>
82<head>
83     <title><?php echo __('Typo'); ?></title>
84</head>
85
86<body>
87<h2><?php echo html::escapeHTML($core->blog->name); ?> &gt; <?php echo __('Typo'); ?></h2>
88
89<?php if (!empty($msg)) echo '<p class="message">'.$msg.'</p>'; ?>
90
91<div id="typo_options">
92     <form method="post" action="plugin.php">
93     <fieldset>
94          <legend><?php echo __('Plugin activation'); ?></legend>
95          <p class="field">
96               <?php echo form::checkbox('active', 1, $typo_active); ?>
97               <label class="classic" for="active"><?php echo __('Enable Typo for this blog'); ?></label>
98          </p>
99     </fieldset>
100
101     <fieldset>
102          <legend><?php echo __('Options'); ?></legend>
103          <p class="field">
104               <?php echo form::checkbox('entries', 1, $typo_entries); ?>
105               <label class="classic" for="entries"><?php echo __('Enable Typo for entries'); ?></label>
106          </p>
107          <p class="form-note"><?php echo __('Activating this option enforces typographic replacements in blog entries'); ?></p>
108          <p class="field">
109               <?php echo form::checkbox('comments', 1, $typo_comments); ?>
110               <label class="classic" for="comments"><?php echo __('Enable Typo for comments'); ?></label>
111          </p>
112          <p class="form-note"><?php echo __('Activating this option enforces typographic replacements in blog comments (excluding trackbacks)'); ?></p>
113     </fieldset>
114
115     <p><input type="hidden" name="p" value="typo" />
116     <?php echo $core->formNonce(); ?>
117     <input type="submit" name="saveconfig" value="<?php echo __('Save configuration'); ?>" />
118     </p>
119     </form>
120</div>
121
122</body>
123</html>
Note: See TracBrowser for help on using the repository browser.

Sites map