Dotclear

source: plugins/blogroll/edit.php @ 3874:ab8368569446

Revision 3874:ab8368569446, 9.1 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

short notation for array (array() → [])

Line 
1<?php
2/**
3 * @brief blogroll, a plugin for Dotclear 2
4 *
5 * @package Dotclear
6 * @subpackage Plugins
7 *
8 * @copyright Olivier Meunier & Association Dotclear
9 * @copyright GPL-2.0-only
10 */
11
12if (!defined('DC_CONTEXT_ADMIN')) {return;}
13
14$id = html::escapeHTML($_REQUEST['id']);
15
16try {
17    $rs = $blogroll->getLink($id);
18} catch (Exception $e) {
19    $core->error->add($e->getMessage());
20}
21
22if (!$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
33if (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']);
38
39    $link_xfn = '';
40
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    }
63
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    }
71}
72
73# Update a category
74if (isset($rs) && $rs->is_cat && !empty($_POST['edit_cat'])) {
75    $link_desc = html::escapeHTML($_POST['link_desc']);
76
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    }
84}
85
86# Languages combo
87$links      = $blogroll->getLangs(['order' => 'asc']);
88$lang_combo = dcAdminCombos::getLangsCombo($links, true);
89
90?>
91<html>
92<head>
93  <title>Blogroll</title>
94</head>
95
96<body>
97<?php
98echo dcPage::breadcrumb(
99    [
100        html::escapeHTML($core->blog->name) => '',
101        __('Blogroll')                      => $p_url
102    ]) .
103dcPage::notices();
104?>
105
106<?php echo '<p><a class="back" href="' . $p_url . '">' . __('Return to blogroll') . '</a></p>'; ?>
107
108<?php
109if (isset($rs) && $rs->is_cat) {
110    echo
111    '<form action="' . $p_url . '" method="post">' .
112    '<h3>' . __('Edit category') . '</h3>' .
113
114    '<p><label for="link_desc" class="required classic"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Title:') . '</label> ' .
115    form::field('link_desc', 30, 255, [
116        'default'    => html::escapeHTML($link_desc),
117        'extra_html' => 'required placeholder="' . __('Title') . '"'
118    ]) .
119
120    form::hidden('edit', 1) .
121    form::hidden('id', $id) .
122    $core->formNonce() .
123    '<input type="submit" name="edit_cat" value="' . __('Save') . '"/></p>' .
124        '</form>';
125}
126if (isset($rs) && !$rs->is_cat) {
127
128    echo
129    '<form action="' . $core->adminurl->get('admin.plugin') . '" method="post" class="two-cols fieldset">' .
130
131    '<div class="col30 first-col">' .
132    '<h3>' . __('Edit link') . '</h3>' .
133
134    '<p><label for="link_title" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Title:') . '</label> ' .
135    form::field('link_title', 30, 255, [
136        'default'    => html::escapeHTML($link_title),
137        'extra_html' => 'required placeholder="' . __('Title') . '"'
138    ]) .
139    '</p>' .
140
141    '<p><label for="link_href" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('URL:') . '</label> ' .
142    form::url('link_href', [
143        'size'       => 30,
144        'default'    => html::escapeHTML($link_href),
145        'extra_html' => 'required placeholder="' . __('URL') . '"'
146    ]) .
147    '</p>' .
148
149    '<p><label for="link_desc">' . __('Description:') . '</label> ' .
150    form::field('link_desc', 30, 255, html::escapeHTML($link_desc)) . '</p>' .
151
152    '<p><label for="link_lang">' . __('Language:') . '</label> ' .
153    form::combo('link_lang', $lang_combo, $link_lang) .
154    '</p>' .
155
156    '</div>' .
157
158    # XFN nightmare
159    '<div class="col70 last-col">' .
160    '<h3>' . __('XFN information') . '</h3>' .
161    '<p class="clear form-note">' . __('More information on <a href="https://en.wikipedia.org/wiki/XHTML_Friends_Network">Wikipedia</a> website') . '</p>' .
162
163    '<div class="table-outer">' .
164    '<table class="noborder">' .
165
166    '<tr class="line">' .
167    '<th>' . __('_xfn_Me') . '</th>' .
168    '<td><p>' . '<label class="classic">' .
169    form::checkbox(['identity'], 'me', ($link_xfn == 'me')) . ' ' .
170    __('_xfn_Another link for myself') . '</label></p></td>' .
171    '</tr>' .
172
173    '<tr class="line">' .
174    '<th>' . __('_xfn_Friendship') . '</th>' .
175    '<td><p>' .
176    '<label class="classic">' . form::radio(['friendship'], 'contact',
177        strpos($link_xfn, 'contact') !== false) . __('_xfn_Contact') . '</label> ' .
178    '<label class="classic">' . form::radio(['friendship'], 'acquaintance',
179        strpos($link_xfn, 'acquaintance') !== false) . __('_xfn_Acquaintance') . '</label> ' .
180    '<label class="classic">' . form::radio(['friendship'], 'friend',
181        strpos($link_xfn, 'friend') !== false) . __('_xfn_Friend') . '</label> ' .
182    '<label class="classic">' . form::radio(['friendship'], '') . __('None') . '</label>' .
183    '</p></td>' .
184    '</tr>' .
185
186    '<tr class="line">' .
187    '<th>' . __('_xfn_Physical') . '</th>' .
188    '<td><p>' .
189    '<label class="classic">' . form::checkbox(['physical'], 'met',
190        strpos($link_xfn, 'met') !== false) . __('_xfn_Met') . '</label>' .
191    '</p></td>' .
192    '</tr>' .
193
194    '<tr class="line">' .
195    '<th>' . __('_xfn_Professional') . '</th>' .
196    '<td><p>' .
197    '<label class="classic">' . form::checkbox(['professional[]'], 'co-worker',
198        strpos($link_xfn, 'co-worker') !== false) . __('_xfn_Co-worker') . '</label> ' .
199    '<label class="classic">' . form::checkbox(['professional[]'], 'colleague',
200        strpos($link_xfn, 'colleague') !== false) . __('_xfn_Colleague') . '</label>' .
201    '</p></td>' .
202    '</tr>' .
203
204    '<tr class="line">' .
205    '<th>' . __('_xfn_Geographical') . '</th>' .
206    '<td><p>' .
207    '<label class="classic">' . form::radio(['geographical'], 'co-resident',
208        strpos($link_xfn, 'co-resident') !== false) . __('_xfn_Co-resident') . '</label> ' .
209    '<label class="classic">' . form::radio(['geographical'], 'neighbor',
210        strpos($link_xfn, 'neighbor') !== false) . __('_xfn_Neighbor') . '</label> ' .
211    '<label class="classic">' . form::radio(['geographical'], '') . __('None') . '</label>' .
212    '</p></td>' .
213    '</tr>' .
214
215    '<tr class="line">' .
216    '<th>' . __('_xfn_Family') . '</th>' .
217    '<td><p>' .
218    '<label class="classic">' . form::radio(['family'], 'child',
219        strpos($link_xfn, 'child') !== false) . __('_xfn_Child') . '</label> ' .
220    '<label class="classic">' . form::radio(['family'], 'parent',
221        strpos($link_xfn, 'parent') !== false) . __('_xfn_Parent') . '</label> ' .
222    '<label class="classic">' . form::radio(['family'], 'sibling',
223        strpos($link_xfn, 'sibling') !== false) . __('_xfn_Sibling') . '</label> ' .
224    '<label class="classic">' . form::radio(['family'], 'spouse',
225        strpos($link_xfn, 'spouse') !== false) . __('_xfn_Spouse') . '</label> ' .
226    '<label class="classic">' . form::radio(['family'], 'kin',
227        strpos($link_xfn, 'kin') !== false) . __('_xfn_Kin') . '</label> ' .
228    '<label class="classic">' . form::radio(['family'], '') . __('None') . '</label>' .
229    '</p></td>' .
230    '</tr>' .
231
232    '<tr class="line">' .
233    '<th>' . __('_xfn_Romantic') . '</th>' .
234    '<td><p>' .
235    '<label class="classic">' . form::checkbox(['romantic[]'], 'muse',
236        strpos($link_xfn, 'muse') !== false) . __('_xfn_Muse') . '</label> ' .
237    '<label class="classic">' . form::checkbox(['romantic[]'], 'crush',
238        strpos($link_xfn, 'crush') !== false) . __('_xfn_Crush') . '</label> ' .
239    '<label class="classic">' . form::checkbox(['romantic[]'], 'date',
240        strpos($link_xfn, 'date') !== false) . __('_xfn_Date') . '</label> ' .
241    '<label class="classic">' . form::checkbox(['romantic[]'], 'sweetheart',
242        strpos($link_xfn, 'sweetheart') !== false) . __('_xfn_Sweetheart') . '</label> ' .
243    '</p></td>' .
244    '</tr>' .
245    '</table></div>' .
246
247    '</div>' .
248    '<p class="clear">' . form::hidden('p', 'blogroll') .
249    form::hidden('edit', 1) .
250    form::hidden('id', $id) .
251    $core->formNonce() .
252    '<input type="submit" name="edit_link" value="' . __('Save') . '"/></p>' .
253
254        '</form>';
255}
256?>
257</body>
258</html>
Note: See TracBrowser for help on using the repository browser.

Sites map