1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2010 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 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
---|
13 | |
---|
14 | $id = $_REQUEST['id']; |
---|
15 | |
---|
16 | try { |
---|
17 | $rs = $blogroll->getLink($id); |
---|
18 | } catch (Exception $e) { |
---|
19 | $core->error->add($e->getMessage()); |
---|
20 | } |
---|
21 | |
---|
22 | if (!$core->error->flag() && $rs->isEmpty()) { |
---|
23 | $core->error->add(__('No such link or title')); |
---|
24 | } else { |
---|
25 | $link_title = $rs->link_title; |
---|
26 | $link_href = $rs->link_href; |
---|
27 | $link_desc = $rs->link_desc; |
---|
28 | $link_lang = $rs->link_lang; |
---|
29 | $link_xfn = $rs->link_xfn; |
---|
30 | } |
---|
31 | |
---|
32 | # Update a link |
---|
33 | if (isset($rs) && !$rs->is_cat && !empty($_POST['edit_link'])) |
---|
34 | { |
---|
35 | $link_title = $_POST['link_title']; |
---|
36 | $link_href = $_POST['link_href']; |
---|
37 | $link_desc = $_POST['link_desc']; |
---|
38 | $link_lang = $_POST['link_lang']; |
---|
39 | |
---|
40 | $link_xfn = ''; |
---|
41 | |
---|
42 | if (!empty($_POST['identity'])) |
---|
43 | { |
---|
44 | $link_xfn .= $_POST['identity']; |
---|
45 | } |
---|
46 | else |
---|
47 | { |
---|
48 | if(!empty($_POST['friendship'])) { |
---|
49 | $link_xfn .= ' '.$_POST['friendship']; |
---|
50 | } |
---|
51 | if(!empty($_POST['physical'])) { |
---|
52 | $link_xfn .= ' met'; |
---|
53 | } |
---|
54 | if(!empty($_POST['professional'])) { |
---|
55 | $link_xfn .= ' '.implode(' ',$_POST['professional']); |
---|
56 | } |
---|
57 | if(!empty($_POST['geographical'])) { |
---|
58 | $link_xfn .= ' '.$_POST['geographical']; |
---|
59 | } |
---|
60 | if(!empty($_POST['family'])) { |
---|
61 | $link_xfn .= ' '.$_POST['family']; |
---|
62 | } |
---|
63 | if(!empty($_POST['romantic'])) { |
---|
64 | $link_xfn .= ' '.implode(' ',$_POST['romantic']); |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
68 | try { |
---|
69 | $blogroll->updateLink($id,$link_title,$link_href,$link_desc,$link_lang,trim($link_xfn)); |
---|
70 | http::redirect($p_url.'&edit=1&id='.$id.'&upd=1'); |
---|
71 | } catch (Exception $e) { |
---|
72 | $core->error->add($e->getMessage()); |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | |
---|
77 | # Update a category |
---|
78 | if (isset($rs) && $rs->is_cat && !empty($_POST['edit_cat'])) |
---|
79 | { |
---|
80 | $link_desc = $_POST['link_desc']; |
---|
81 | |
---|
82 | try { |
---|
83 | $blogroll->updateCategory($id,$link_desc); |
---|
84 | http::redirect($p_url.'&edit=1&id='.$id.'&upd=1'); |
---|
85 | } catch (Exception $e) { |
---|
86 | $core->error->add($e->getMessage()); |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | ?> |
---|
91 | <html> |
---|
92 | <head> |
---|
93 | <title>Blogroll</title> |
---|
94 | </head> |
---|
95 | |
---|
96 | <body> |
---|
97 | <?php echo '<p><a href="'.$p_url.'">'.__('Return to blogroll').'</a></p>'; ?> |
---|
98 | |
---|
99 | <?php |
---|
100 | if (isset($rs) && $rs->is_cat) |
---|
101 | { |
---|
102 | if (!empty($_GET['upd'])) { |
---|
103 | echo '<p class="message">'.__('Category has been successfully updated').'</p>'; |
---|
104 | } |
---|
105 | |
---|
106 | echo |
---|
107 | '<form action="'.$p_url.'" method="post">'. |
---|
108 | '<fieldset><legend>'.__('Edit category').'</legend>'. |
---|
109 | |
---|
110 | '<p><label class="required classic" title="'.__('Required field').'">'.__('Title:').' '. |
---|
111 | form::field('link_desc',30,255,html::escapeHTML($link_desc)).'</label> '. |
---|
112 | |
---|
113 | form::hidden('edit',1). |
---|
114 | form::hidden('id',$id). |
---|
115 | $core->formNonce(). |
---|
116 | '<input type="submit" name="edit_cat" class="submit" value="'.__('save').'"/></p>'. |
---|
117 | '</fieldset>'. |
---|
118 | '</form>'; |
---|
119 | } |
---|
120 | if (isset($rs) && !$rs->is_cat) |
---|
121 | { |
---|
122 | if (!empty($_GET['upd'])) { |
---|
123 | echo '<p class="message">'.__('Link has been successfully updated').'</p>'; |
---|
124 | } |
---|
125 | |
---|
126 | echo |
---|
127 | '<form action="plugin.php" method="post">'. |
---|
128 | '<fieldset class="two-cols"><legend>'.__('Edit link').'</legend>'. |
---|
129 | |
---|
130 | '<p class="col"><label class="required" title="'.__('Required field').'">'.__('Title:').' '. |
---|
131 | form::field('link_title',30,255,html::escapeHTML($link_title)).'</label></p>'. |
---|
132 | |
---|
133 | '<p class="col"><label class="required" title="'.__('Required field').'">'.__('URL:').' '. |
---|
134 | form::field('link_href',30,255,html::escapeHTML($link_href)).'</label></p>'. |
---|
135 | |
---|
136 | '<p class="col"><label>'.__('Description:').' '. |
---|
137 | form::field('link_desc',30,255,html::escapeHTML($link_desc)).'</label></p>'. |
---|
138 | |
---|
139 | '<p class="col"><label>'.__('Language:').' '. |
---|
140 | form::field('link_lang',5,5,html::escapeHTML($link_lang)).'</label></p>'. |
---|
141 | |
---|
142 | '<p>'.form::hidden('p','blogroll'). |
---|
143 | form::hidden('edit',1). |
---|
144 | form::hidden('id',$id). |
---|
145 | $core->formNonce(). |
---|
146 | '<input type="submit" name="edit_link" class="submit" value="'.__('save').'"/></p>'. |
---|
147 | '</fieldset>'. |
---|
148 | |
---|
149 | |
---|
150 | # XFN nightmare |
---|
151 | '<fieldset><legend>'.__('XFN').'</legend>'. |
---|
152 | '<table class="noborder">'. |
---|
153 | |
---|
154 | '<tr>'. |
---|
155 | '<th>'.__('_xfn_Me').'</th>'. |
---|
156 | '<td><p>'.'<label class="classic">'. |
---|
157 | form::checkbox(array('identity'), 'me', ($link_xfn == 'me')).' '. |
---|
158 | __('_xfn_Another link for myself').'</label></p></td>'. |
---|
159 | '</tr>'. |
---|
160 | |
---|
161 | '<tr>'. |
---|
162 | '<th>'.__('_xfn_Friendship').'</th>'. |
---|
163 | '<td><p>'. |
---|
164 | '<label class="classic">'.form::radio(array('friendship'),'contact', |
---|
165 | strpos($link_xfn,'contact') !== false).__('_xfn_Contact').'</label> '. |
---|
166 | '<label class="classic">'.form::radio(array('friendship'),'acquaintance', |
---|
167 | strpos($link_xfn,'acquaintance') !== false).__('_xfn_Acquaintance').'</label> '. |
---|
168 | '<label class="classic">'.form::radio(array('friendship'),'friend', |
---|
169 | strpos($link_xfn,'friend') !== false).__('_xfn_Friend').'</label> '. |
---|
170 | '<label class="classic">'.form::radio(array('friendship'),'').__('None').'</label>'. |
---|
171 | '</p></td>'. |
---|
172 | '</tr>'. |
---|
173 | |
---|
174 | '<tr>'. |
---|
175 | '<th>'.__('_xfn_Physical').'</th>'. |
---|
176 | '<td><p>'. |
---|
177 | '<label class="classic">'.form::checkbox(array('physical'),'met', |
---|
178 | strpos($link_xfn,'met') !== false).__('_xfn_Met').'</label>'. |
---|
179 | '</p></td>'. |
---|
180 | '</tr>'. |
---|
181 | |
---|
182 | '<tr>'. |
---|
183 | '<th>'.__('_xfn_Professional').'</th>'. |
---|
184 | '<td><p>'. |
---|
185 | '<label class="classic">'.form::checkbox(array('professional[]'),'co-worker', |
---|
186 | strpos($link_xfn,'co-worker') !== false).__('_xfn_Co-worker').'</label> '. |
---|
187 | '<label class="classic">'.form::checkbox(array('professional[]'),'colleague', |
---|
188 | strpos($link_xfn,'colleague') !== false).__('_xfn_Colleague').'</label>'. |
---|
189 | '</p></td>'. |
---|
190 | '</tr>'. |
---|
191 | |
---|
192 | '<tr>'. |
---|
193 | '<th>'.__('_xfn_Geographical').'</th>'. |
---|
194 | '<td><p>'. |
---|
195 | '<label class="classic">'.form::radio(array('geographical'),'co-resident', |
---|
196 | strpos($link_xfn,'co-resident') !== false).__('_xfn_Co-resident').'</label> '. |
---|
197 | '<label class="classic">'.form::radio(array('geographical'),'neighbor', |
---|
198 | strpos($link_xfn,'neighbor') !== false).__('_xfn_Neighbor').'</label> '. |
---|
199 | '<label class="classic">'.form::radio(array('geographical'),'').__('None').'</label>'. |
---|
200 | '</p></td>'. |
---|
201 | '</tr>'. |
---|
202 | |
---|
203 | '<tr>'. |
---|
204 | '<th>'.__('_xfn_Family').'</th>'. |
---|
205 | '<td><p>'. |
---|
206 | '<label class="classic">'.form::radio(array('family'),'child', |
---|
207 | strpos($link_xfn,'child') !== false).__('_xfn_Child').'</label> '. |
---|
208 | '<label class="classic">'.form::radio(array('family'),'parent', |
---|
209 | strpos($link_xfn,'parent') !== false).__('_xfn_Parent').'</label> '. |
---|
210 | '<label class="classic">'.form::radio(array('family'),'sibling', |
---|
211 | strpos($link_xfn, 'sibling') !== false).__('_xfn_Sibling').'</label> '. |
---|
212 | '<label class="classic">'.form::radio(array('family'),'spouse', |
---|
213 | strpos($link_xfn, 'spouse') !== false).__('_xfn_Spouse').'</label> '. |
---|
214 | '<label class="classic">'.form::radio(array('family'),'kin', |
---|
215 | strpos($link_xfn, 'kin') !== false).__('_xfn_Kin').'</label> '. |
---|
216 | '<label class="classic">'.form::radio(array('family'),'').__('None').'</label>'. |
---|
217 | '</p></td>'. |
---|
218 | '</tr>'. |
---|
219 | |
---|
220 | '<tr>'. |
---|
221 | '<th>'.__('_xfn_Romantic').'</th>'. |
---|
222 | '<td><p>'. |
---|
223 | '<label class="classic">'.form::checkbox(array('romantic[]'),'muse', |
---|
224 | strpos($link_xfn,'muse') !== false).__('_xfn_Muse').'</label> '. |
---|
225 | '<label class="classic">'.form::checkbox(array('romantic[]'),'crush', |
---|
226 | strpos($link_xfn,'crush') !== false).__('_xfn_Crush').'</label> '. |
---|
227 | '<label class="classic">'.form::checkbox(array('romantic[]'),'date', |
---|
228 | strpos($link_xfn,'date') !== false).__('_xfn_Date').'</label> '. |
---|
229 | '<label class="classic">'.form::checkbox(array('romantic[]'),'sweetheart', |
---|
230 | strpos($link_xfn,'sweetheart') !== false).__('_xfn_Sweetheart').'</label> '. |
---|
231 | '</p></td>'. |
---|
232 | '</tr>'. |
---|
233 | '</table>'. |
---|
234 | |
---|
235 | '</fieldset>'. |
---|
236 | |
---|
237 | '</form>'; |
---|
238 | } |
---|
239 | ?> |
---|
240 | </body> |
---|
241 | </html> |
---|