1 | <?php /* -*- tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */ |
---|
2 | /***************************************************************\ |
---|
3 | * This is 'Carnaval', a plugin for Dotclear 2 * |
---|
4 | * * |
---|
5 | * Copyright (c) 2007-2008 * |
---|
6 | * Osku and contributors. * |
---|
7 | * * |
---|
8 | * This is an open source software, distributed under the GNU * |
---|
9 | * General Public License (version 2) terms and conditions. * |
---|
10 | * * |
---|
11 | * You should have received a copy of the GNU General Public * |
---|
12 | * License along with 'Carnaval' (see COPYING.txt); * |
---|
13 | * if not, write to the Free Software Foundation, Inc., * |
---|
14 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
---|
15 | \***************************************************************/ |
---|
16 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
---|
17 | |
---|
18 | if (!empty($_REQUEST['edit']) && !empty($_REQUEST['id'])) { |
---|
19 | include dirname(__FILE__).'/edit.php'; |
---|
20 | return; |
---|
21 | } |
---|
22 | |
---|
23 | if (!empty($_REQUEST['add'])) { |
---|
24 | include dirname(__FILE__).'/add.php'; |
---|
25 | return; |
---|
26 | } |
---|
27 | |
---|
28 | // Setting default parameters if missing configuration |
---|
29 | if (is_null($core->blog->settings->carnaval_active)) { |
---|
30 | try { |
---|
31 | $core->blog->settings->setNameSpace('carnaval'); |
---|
32 | |
---|
33 | // Carnaval is not active by default |
---|
34 | $core->blog->settings->put('carnaval_active',false,'boolean'); |
---|
35 | $core->blog->triggerBlog(); |
---|
36 | http::redirect(http::getSelfURI()); |
---|
37 | } |
---|
38 | catch (Exception $e) { |
---|
39 | $core->error->add($e->getMessage()); |
---|
40 | } |
---|
41 | } |
---|
42 | |
---|
43 | // Getting current parameters |
---|
44 | $active = (boolean)$core->blog->settings->carnaval_active; |
---|
45 | |
---|
46 | # Delete CSS Class |
---|
47 | if (!empty($_POST['removeaction']) && !empty($_POST['remove'])) { |
---|
48 | foreach ($_POST['remove'] as $k => $v) |
---|
49 | { |
---|
50 | try { |
---|
51 | dcCarnaval::delClass($v); |
---|
52 | } catch (Exception $e) { |
---|
53 | $core->error->add($e->getMessage()); |
---|
54 | break; |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | if (!$core->error->flag()) { |
---|
59 | http::redirect($p_url.'&removed=1'); |
---|
60 | } |
---|
61 | } |
---|
62 | |
---|
63 | // Saving new configuration |
---|
64 | if (!empty($_POST['saveconfig'])) { |
---|
65 | try |
---|
66 | { |
---|
67 | $core->blog->settings->setNameSpace('carnaval'); |
---|
68 | |
---|
69 | $active = (empty($_POST['active']))?false:true; |
---|
70 | $core->blog->settings->put('carnaval_active',$active,'boolean'); |
---|
71 | |
---|
72 | $core->blog->triggerBlog(); |
---|
73 | |
---|
74 | $msg = __('Configuration successfully updated.'); |
---|
75 | } |
---|
76 | catch (Exception $e) |
---|
77 | { |
---|
78 | $core->error->add($e->getMessage()); |
---|
79 | } |
---|
80 | } |
---|
81 | |
---|
82 | # Get CSS Classes |
---|
83 | try { |
---|
84 | $rs = dcCarnaval::getClasses(); |
---|
85 | } catch (Exception $e) { |
---|
86 | $core->error->add($e->getMessage()); |
---|
87 | } |
---|
88 | ?> |
---|
89 | <html> |
---|
90 | <head> |
---|
91 | <title>Carnaval</title> |
---|
92 | </head> |
---|
93 | |
---|
94 | <body> |
---|
95 | <h2 style="padding:8px 0 8px 34px;background:url(index.php?pf=carnaval/icon_32.png) no-repeat;"> |
---|
96 | <?php echo html::escapeHTML($core->blog->name); ?> › Carnaval - |
---|
97 | <a class="button" href="<?php echo $p_url.'&add=1'; ?>"><?php echo html::escapeJS( |
---|
98 | __('New CSS Class')); ?></a> |
---|
99 | </h2> |
---|
100 | |
---|
101 | <?php |
---|
102 | |
---|
103 | if (!empty($_GET['removed'])) { |
---|
104 | echo '<p class="message">'.__('Classes have been successfully removed.').'</p>'; |
---|
105 | } |
---|
106 | |
---|
107 | if (!empty($_GET['addclass'])) { |
---|
108 | echo '<p class="message">'.__('Class has been successfully created.').'</p>'; |
---|
109 | } |
---|
110 | |
---|
111 | if (!empty($msg)) { |
---|
112 | echo '<p class="message">'.$msg.'</p>'; |
---|
113 | } |
---|
114 | |
---|
115 | ?> |
---|
116 | <?php |
---|
117 | echo '<form action="'.$p_url.'" method="post" id="config-form">'; |
---|
118 | echo '<fieldset><legend>'.__('Plugin activation').'</legend>'; |
---|
119 | echo |
---|
120 | '<p class="field">'. |
---|
121 | form::checkbox('active', 1, $active). |
---|
122 | '<label class=" classic" for="active">'.__('Enable Carnaval').'</label></p></fieldset>'; |
---|
123 | echo |
---|
124 | '<p>'.form::hidden(array('p'),'carnaval'). |
---|
125 | $core->formNonce(). |
---|
126 | '<input type="submit" name="saveconfig" accesskey="s" value="'.__('Save configuration').' (s)"/>'; |
---|
127 | echo '</p></form>'; |
---|
128 | ?> |
---|
129 | <fieldset class="two-cols"><legend><?php echo __('My CSS Classes'); ?></legend> |
---|
130 | <form action="plugin.php" method="post" id="classes-form"> |
---|
131 | <table class="maximal"> |
---|
132 | <thead> |
---|
133 | <tr> |
---|
134 | <th colspan="2"><?php echo __('Name'); ?></th> |
---|
135 | <th><strong><?php echo __('CSS Class'); ?></strong></th> |
---|
136 | <th><?php echo __('Mail'); ?></th> |
---|
137 | <th><?php echo __('URL'); ?></th> |
---|
138 | <th><?php if ($core->blog->settings->theme == 'default') {echo __('Text color');} ?></th> |
---|
139 | <th><?php if ($core->blog->settings->theme == 'default') { echo __('Background color');} ?></th> |
---|
140 | </tr> |
---|
141 | </thead> |
---|
142 | <tbody id="classes-list"> |
---|
143 | <?php |
---|
144 | while ($rs->fetch()) |
---|
145 | { |
---|
146 | echo |
---|
147 | '<tr class="line" id="l_'.$rs->class_id.'">'. |
---|
148 | '<td class="minimal">'.form::checkbox(array('remove[]'),$rs->class_id).'</td>'. |
---|
149 | '<td>'.html::escapeHTML($rs->comment_author).'</a></td>'. |
---|
150 | '<td><a href="'.$p_url.'&edit=1&id='.$rs->class_id.'">'. |
---|
151 | html::escapeHTML($rs->comment_class).'</a></td>'. |
---|
152 | '<td>'.html::escapeHTML($rs->comment_author_mail).'</td>'. |
---|
153 | '<td>'.html::escapeHTML($rs->comment_author_site).'</td>'; |
---|
154 | if ($core->blog->settings->theme == 'default') { |
---|
155 | echo '<td>'.html::escapeHTML($rs->comment_text_color).'</td>'. |
---|
156 | '<td>'.html::escapeHTML($rs->comment_background_color).'</td>'; |
---|
157 | } |
---|
158 | echo '</tr>'; |
---|
159 | } |
---|
160 | ?> |
---|
161 | </tbody> |
---|
162 | </table> |
---|
163 | |
---|
164 | <div class="two-cols"> |
---|
165 | <p class="col"> |
---|
166 | <?php echo form::hidden(array('p'),'carnaval'); |
---|
167 | echo $core->formNonce(); ?> |
---|
168 | <input type="submit" name="removeaction" accesskey="d" |
---|
169 | value="<?php echo __('Delete selected CSS Classes'); ?>" |
---|
170 | onclick="return window.confirm('<?php echo html::escapeJS( |
---|
171 | __('Are you sure you you want to delete selected CSS Classes ?')); ?>');" /></p> |
---|
172 | </div> |
---|
173 | |
---|
174 | </fieldset> |
---|
175 | |
---|
176 | <?php dcPage::helpBlock('carnaval');?> |
---|
177 | </body></html> |
---|