3 // Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com
4 require_once('admin.php');
5 $title = __('Link Categories');
6 $this_file='link-categories.php';
7 $parent_file = 'link-manager.php';
10 $wpvarstoreset = array('action', 'cat', 'auto_toggle');
11 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
12 $wpvar = $wpvarstoreset[$i];
13 if (!isset($$wpvar)) {
14 if (empty($_POST["$wpvar"])) {
15 if (empty($_GET["$wpvar"])) {
18 $$wpvar = $_GET["$wpvar"];
21 $$wpvar = $_POST["$wpvar"];
29 check_admin_referer('add-link-category');
31 if ( !current_user_can('manage_links') )
32 die (__("Cheatin' uh ?"));
34 $cat_name = wp_specialchars($_POST['cat_name']);
35 $auto_toggle = $_POST['auto_toggle'];
36 if ($auto_toggle != 'Y') {
40 $show_images = $_POST['show_images'];
41 if ($show_images != 'Y') {
45 $show_description = $_POST['show_description'];
46 if ($show_description != 'Y') {
47 $show_description = 'N';
50 $show_rating = $_POST['show_rating'];
51 if ($show_rating != 'Y') {
55 $show_updated = $_POST['show_updated'];
56 if ($show_updated != 'Y') {
60 $sort_order = $_POST['sort_order'];
62 $sort_desc = $_POST['sort_desc'];
63 if ($sort_desc != 'Y') {
66 $text_before_link = $_POST['text_before_link'];
67 $text_after_link = $_POST['text_after_link'];
68 $text_after_all = $_POST['text_after_all'];
70 $list_limit = $_POST['list_limit'];
71 if ($list_limit == '')
74 $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name, auto_toggle, show_images, show_description, \n" .
75 " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, text_after_all, list_limit) \n" .
76 " VALUES ('0', '$cat_name', '$auto_toggle', '$show_images', '$show_description', \n" .
77 " '$show_rating', '$show_updated', '$sort_order', '$sort_desc', '$text_before_link', '$text_after_link', \n" .
78 " '$text_after_all', $list_limit)");
80 wp_redirect('link-categories.php');
85 $cat_id = (int) $_GET['cat_id'];
86 check_admin_referer('delete-link-category_' . $cat_id);
88 $cat_name=get_linkcatname($cat_id);
91 die(sprintf(__("Can't delete the <strong>%s</strong> link category: this is the default one"), $cat_name));
93 if ( !current_user_can('manage_links') )
94 die (__("Cheatin' uh ?"));
96 $wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$cat_id'");
97 $wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$cat_id'");
99 wp_redirect('link-categories.php');
104 include_once ('admin-header.php');
105 $cat_id = (int) $_GET['cat_id'];
106 $row = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
107 . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
108 . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$cat_id");
110 if ($row->list_limit == -1) {
111 $row->list_limit = '';
116 <h2><?php printf(__('Edit “%s” Category'), wp_specialchars($row->cat_name)); ?></h2>
118 <form name="editcat" method="post">
119 <?php wp_nonce_field('update-link-category_' . $row->cat_id) ?>
120 <input type="hidden" name="action" value="editedcat" />
121 <input type="hidden" name="cat_id" value="<?php echo $row->cat_id ?>" />
122 <fieldset class="options">
123 <legend><?php _e('Category Options') ?></legend>
124 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
126 <th width="33%" scope="row"><?php _e('Name:') ?></th>
127 <td width="67%"><input name="cat_name" type="text" value="<?php echo attribute_escape($row->cat_name)?>" size="30" /></td>
130 <th scope="row"><?php _e('Show:') ?></th>
133 <input type="checkbox" name="show_images" value="Y" <?php checked('Y', $row->show_images); ?> />
134 <?php _e('Image') ?></label> <br />
136 <input type="checkbox" name="show_description" value="Y" <?php checked('Y', $row->show_description); ?> />
137 <?php _e('Description') ?></label>
138 <?php _e('(shown in <code>title</code> regardless)') ?><br />
140 <input type="checkbox" name="show_rating" value="Y" <?php checked('Y', $row->show_rating); ?> />
141 <?php _e('Rating') ?></label> <br />
143 <input type="checkbox" name="show_updated" value="Y" <?php checked('Y', $row->show_updated); ?> />
144 <?php _e('Updated') ?></label>
145 <?php _e('(shown in <code>title</code> regardless)') ?></td>
148 <th scope="row"><?php _e('Sort order:') ?></th>
150 <select name="sort_order" size="1">
151 <option value="name" <?php echo ($row->sort_order == 'name') ? 'selected="selected"' : ''?>><?php _e('Name') ?></option>
152 <option value="id" <?php echo ($row->sort_order == 'id') ? 'selected' : ''?>><?php _e('Id') ?></option>
153 <option value="url" <?php echo ($row->sort_order == 'url') ? 'selected' : ''?>><?php _e('URL') ?></option>
154 <option value="rating" <?php echo ($row->sort_order == 'rating') ? 'selected' : ''?>><?php _e('Rating') ?></option>
155 <option value="updated" <?php echo ($row->sort_order == 'updated') ? 'selected' : ''?>><?php _e('Updated') ?></option>
156 <option value="rand" <?php echo ($row->sort_order == 'rand') ? 'selected' : ''?>><?php _e('Random') ?></option>
157 <option value="length" <?php echo ($row->sort_order == 'length') ? 'selected' : ''?>><?php _e('Name Length') ?></option>
160 <input type="checkbox" name="sort_desc" value="Y" <?php checked('Y', $row->sort_desc); ?> />
161 <?php _e('Descending') ?></label>
165 <th scope="row"><?php _e('Limit:') ?></th>
167 <input type="text" name="list_limit" size="5" value="<?php echo $row->list_limit ?>" />
168 <?php _e('(Leave empty for no limit to number of links shown)') ?>
172 <th scope="row"><?php _e('Toggle:') ?></th>
174 <input type="checkbox" name="auto_toggle" value="Y" <?php checked('Y', $row->auto_toggle); ?> />
175 <?php _e('When new link is added toggle all others to be invisible') ?></label></td>
180 <fieldset class="options">
181 <legend><?php _e('Formatting') ?></legend>
182 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
184 <th width="33%" scope="row"><?php _e('Before Link:') ?></th>
185 <td width="67%"><input type="text" name="text_before_link" size="45" value="<?php echo wp_specialchars($row->text_before_link,'double')?>" /></td>
188 <th scope="row"><?php _e('Between Link and Description:') ?></th>
189 <td><input type="text" name="text_after_link" size="45" value="<?php echo wp_specialchars($row->text_after_link,'double')?>" /></td>
192 <th scope="row"><?php _e('After Link:') ?></th>
193 <td><input type="text" name="text_after_all" size="45" value="<?php echo wp_specialchars($row->text_after_all,'double')?>"/></td>
197 <p class="submit"><input type="submit" name="submit" value="<?php _e('Save Category Settings »') ?>" /></p>
207 $cat_id = (int)$_POST["cat_id"];
208 check_admin_referer('update-link-category_' . $cat_id);
210 if ( !current_user_can('manage_links') )
211 die (__("Cheatin' uh ?"));
213 $submit=$_POST["submit"];
214 if (isset($submit)) {
216 $cat_name= wp_specialchars($_POST["cat_name"]);
217 $auto_toggle = $_POST["auto_toggle"];
218 if ($auto_toggle != 'Y') {
222 $show_images = $_POST["show_images"];
223 if ($show_images != 'Y') {
227 $show_description = $_POST["show_description"];
228 if ($show_description != 'Y') {
229 $show_description = 'N';
232 $show_rating = $_POST["show_rating"];
233 if ($show_rating != 'Y') {
237 $show_updated = $_POST["show_updated"];
238 if ($show_updated != 'Y') {
242 $sort_order = $_POST["sort_order"];
244 $sort_desc = $_POST["sort_desc"];
245 if ($sort_desc != 'Y') {
248 $text_before_link = $_POST["text_before_link"];
249 $text_after_link = $_POST["text_after_link"];
250 $text_after_all = $_POST["text_after_all"];
252 $list_limit = $_POST["list_limit"];
253 if ($list_limit == '')
256 $wpdb->query("UPDATE $wpdb->linkcategories set
257 cat_name='$cat_name',
258 auto_toggle='$auto_toggle',
259 show_images='$show_images',
260 show_description='$show_description',
261 show_rating='$show_rating',
262 show_updated='$show_updated',
263 sort_order='$sort_order',
264 sort_desc='$sort_desc',
265 text_before_link='$text_before_link',
266 text_after_link='$text_after_link',
267 text_after_all='$text_after_all',
268 list_limit=$list_limit
274 wp_redirect("link-categories.php");
279 include_once ("admin-header.php");
280 if ( !current_user_can('manage_links') )
281 die(__("You have do not have sufficient permissions to edit the link categories for this blog. :)"));
285 <h2><?php _e('Link Categories:') ?></h2>
286 <table id="the-list" width="100%" cellpadding="5" cellspacing="0" border="0">
288 <th rowspan="2" valign="bottom"><?php _e('Name') ?></th>
289 <th rowspan="2" valign="bottom"><?php _e('ID') ?></th>
290 <th rowspan="2" valign="bottom"><?php _e('Toggle?') ?></th>
291 <th colspan="4" valign="bottom" class="alternate"><?php _e('Show') ?></th>
292 <th rowspan="2" valign="bottom"><?php _e('Sort Order') ?></th>
293 <th rowspan="2" valign="bottom"><?php _e('Desc?') ?></th>
294 <th colspan="3" valign="bottom" class="alternate"><?php _e('Formatting') ?></th>
295 <th rowspan="2" valign="bottom"><?php _e('Limit') ?></th>
296 <th rowspan="2" colspan="2"> </th>
299 <th valign="top"><?php _e('Images') ?></th>
300 <th valign="top"><?php _e('Description') ?></th>
301 <th valign="top"><?php _e('Rating') ?></th>
302 <th valign="top"><?php _e('Updated') ?></th>
303 <th valign="top"><?php _e('Before') ?></th>
304 <th valign="top"><?php _e('Between') ?></th>
305 <th valign="top"><?php _e('After') ?></th>
308 $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
309 . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
310 . " text_after_all, list_limit FROM $wpdb->linkcategories ORDER BY cat_id");
312 foreach ( (array) $results as $row) {
313 if ($row->list_limit == -1) {
314 $row->list_limit = __('none');
316 $style = ($i % 2) ? ' class="alternate"' : '';
318 Manually internationalize every sort order option.
320 switch ($row->sort_order) {
322 $row->sort_order = __('name');
325 $row->sort_order = __('id');
328 $row->sort_order = __('url');
331 $row->sort_order = __('rating');
334 $row->sort_order = __('updated');
337 $row->sort_order = __('rand');
340 $row->sort_order = __('length');
344 <tr id="link-category-<?php echo $row->cat_id; ?>" valign="middle" align="center" <?php echo $style ?> style="border-bottom: 1px dotted #9C9A9C;">
345 <td><?php echo wp_specialchars($row->cat_name)?></td>
346 <td ><?php echo $row->cat_id?></td>
347 <td><?php echo $row->auto_toggle == 'Y' ? __('Yes') : __('No') ?></td>
348 <td><?php echo $row->show_images == 'Y' ? __('Yes') : __('No') ?></td>
349 <td><?php echo $row->show_description == 'Y' ? __('Yes') : __('No') ?></td>
350 <td><?php echo $row->show_rating == 'Y' ? __('Yes') : __('No') ?></td>
351 <td><?php echo $row->show_updated == 'Y' ? __('Yes') : __('No') ?></td>
352 <td><?php echo $row->sort_order ?></td>
353 <td><?php echo $row->sort_desc == 'Y' ? __('Yes') : __('No') ?></td>
354 <td nowrap="nowrap"><?php echo wp_specialchars($row->text_before_link)?> </td>
355 <td nowrap="nowrap"><?php echo wp_specialchars($row->text_after_link)?> </td>
356 <td nowrap="nowrap"><?php echo wp_specialchars($row->text_after_all)?></td>
357 <td><?php echo $row->list_limit ?></td>
358 <td><a href="link-categories.php?cat_id=<?php echo $row->cat_id?>&action=Edit" class="edit"><?php _e('Edit') ?></a></td>
360 <?php if (1 == $row->cat_id ) {
363 <a href="<?php echo wp_nonce_url("link-categories.php?cat_id=$row->cat_id?>&action=Delete", 'delete-link-category_' . $row->cat_id) ?>" onclick="return deleteSomething( 'link category', <?php echo $row->cat_id . ", '" . sprintf(__("You are about to delete the "%s" link category.\\n"Cancel" to stop, "OK" to delete."), js_escape($row->cat_name)); ?>' );" class="delete"><?php _e('Delete') ?></a>
372 <p><?php _e('These are the defaults for when you call a link category with no additional arguments. All of these settings may be overwritten.') ?></p>
374 <div id="ajax-response"></div>
379 <form name="addcat" method="post" action="">
380 <?php wp_nonce_field('add-link-category'); ?>
381 <input type="hidden" name="action" value="addcat" />
382 <h2><?php _e('Add a Link Category:') ?></h2>
383 <fieldset class="options">
384 <legend><?php _e('Category Options') ?></legend>
385 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
387 <th width="33%" scope="row"><?php _e('Name:') ?></th>
388 <td width="67%"><input type="text" name="cat_name" size="30" /></td>
391 <th scope="row"><?php _e('Show:') ?></th>
394 <input type="checkbox" name="show_images" value="Y" />
395 <?php _e('Image') ?></label> <br />
397 <input type="checkbox" name="show_description" value="Y" />
398 <?php _e('Description') ?></label>
399 <?php _e('(shown in <code>title</code> regardless)') ?><br />
401 <input type="checkbox" name="show_rating" value="Y" />
402 <?php _e('Rating') ?></label> <br />
404 <input type="checkbox" name="show_updated" value="Y" />
405 <?php _e('Updated') ?></label>
406 <?php _e('(shown in <code>title</code> regardless)') ?></td>
409 <th scope="row"><?php _e('Sort order:') ?></th>
411 <select name="sort_order" size="1">
412 <option value="name"><?php _e('Name') ?></option>
413 <option value="id"><?php _e('Id') ?></option>
414 <option value="url"><?php _e('URL') ?></option>
415 <option value="rating"><?php _e('Rating') ?></option>
416 <option value="updated"><?php _e('Updated') ?></option>
417 <option value="rand"><?php _e('Random') ?></option>
420 <input type="checkbox" name="sort_desc" value="Y" />
421 <?php _e('Descending') ?></label>
425 <th scope="row"><?php _e('Limit:') ?></th>
427 <input type="text" name="list_limit" size="5" value="" /> <?php _e('(Leave empty for no limit to number of links shown)') ?>
431 <th scope="row"><?php _e('Toggle:') ?></th>
433 <input type="checkbox" name="auto_toggle" value="Y" />
434 <?php _e('When new link is added toggle all others to be invisible') ?></label></td>
439 <fieldset class="options">
440 <legend><?php _e('Formatting') ?></legend>
441 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
443 <th width="33%" scope="row"><?php _e('Before Link:') ?></th>
444 <td width="67%"><input type="text" name="text_before_link" size="45" value="<li>" /></td>
447 <th scope="row"><?php _e('Between Link and Description:') ?></th>
448 <td><input type="text" name="text_after_link" size="45" value="<br />" /></td>
451 <th scope="row"><?php _e('After Link:') ?></th>
452 <td><input type="text" name="text_after_all" size="45" value="</li>"/></td>
456 <p class="submit"><input type="submit" name="submit" value="<?php _e('Add Category »') ?>" /></p>
460 <h3><?php _e('Note:') ?></h3>
461 <p><?php printf(__('Deleting a link category does not delete links from that category.<br />It will just set them back to the default category <strong>%s</strong>.'), get_linkcatname(1)) ?></p>
468 <?php include('admin-footer.php'); ?>