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