More link manager fixes.

git-svn-id: http://svn.automattic.com/wordpress/trunk@656 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2003-12-28 08:38:31 +00:00
parent 9a5a4a52de
commit 4d44f4d8e7
1 changed files with 136 additions and 132 deletions

View File

@ -8,20 +8,20 @@ $title = 'Manage Links';
$this_file = 'link-manager.php'; $this_file = 'link-manager.php';
function category_dropdown($fieldname, $selected = 0) { function category_dropdown($fieldname, $selected = 0) {
global $wpdb, $tablelinkcategories; global $wpdb, $tablelinkcategories;
$results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id"); $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $tablelinkcategories ORDER BY cat_id");
echo ' <select name="'.$fieldname.'" size="1">'."\n"; echo "\n<select name='$fieldname' size='1'>";
foreach ($results as $row) { foreach ($results as $row) {
echo " <option value=\"".$row->cat_id."\""; echo "\n\t<option value='$row->cat_id'";
if ($row->cat_id == $selected) if ($row->cat_id == $selected)
echo " selected"; echo " selected='selected'";
echo ">".$row->cat_id.": ".$row->cat_name; echo ">$row->cat_id: $row->cat_name";
if ($row->auto_toggle == 'Y') if ('Y' == $row->auto_toggle)
echo ' (auto toggle)'; echo ' (auto toggle)';
echo "</option>\n"; echo "</option>\n";
} }
echo " </select>\n"; echo "\n</select>\n";
} }
function add_magic_quotes($array) { function add_magic_quotes($array) {
@ -44,6 +44,7 @@ $wpvarstoreset = array('action','standalone','cat_id', 'linkurl', 'name', 'image
'description', 'visible', 'target', 'category', 'link_id', 'description', 'visible', 'target', 'category', 'link_id',
'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
'notes', 'linkcheck[]'); 'notes', 'linkcheck[]');
for ($i=0; $i<count($wpvarstoreset); $i += 1) { for ($i=0; $i<count($wpvarstoreset); $i += 1) {
$wpvar = $wpvarstoreset[$i]; $wpvar = $wpvarstoreset[$i];
if (!isset($$wpvar)) { if (!isset($$wpvar)) {
@ -59,11 +60,12 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
} }
} }
$links_show_cat_id = $HTTP_COOKIE_VARS["links_show_cat_id_".$cookiehash]; $links_show_cat_id = $HTTP_COOKIE_VARS['links_show_cat_id_' . $cookiehash];
$links_show_order = $HTTP_COOKIE_VARS["links_show_order_".$cookiehash]; $links_show_order = $HTTP_COOKIE_VARS['links_show_order_' . $cookiehash];
if (!empty($action2)) if (!empty($action2)) {
$action = $action2; $action = $action2;
}
switch ($action) { switch ($action) {
case 'Assign': case 'Assign':
@ -79,7 +81,7 @@ switch ($action) {
//userlevel of the owner of the link then we can proceed. //userlevel of the owner of the link then we can proceed.
if (count($linkcheck) == 0) { if (count($linkcheck) == 0) {
header('Location: '.$this_file); header('Location: ' . $this_file);
exit; exit;
} }
$all_links = join(',', $linkcheck); $all_links = join(',', $linkcheck);
@ -94,7 +96,7 @@ switch ($action) {
$all_links = join(',', $ids_to_change); $all_links = join(',', $ids_to_change);
$q = $wpdb->query("update $tablelinks SET link_owner='$newowner' WHERE link_id IN ($all_links)"); $q = $wpdb->query("update $tablelinks SET link_owner='$newowner' WHERE link_id IN ($all_links)");
header('Location: '.$this_file); header('Location: ' . $this_file);
break; break;
} }
case 'Visibility': case 'Visibility':
@ -108,7 +110,7 @@ switch ($action) {
//for each link id (in $linkcheck[]): toggle the visibility //for each link id (in $linkcheck[]): toggle the visibility
if (count($linkcheck) == 0) { if (count($linkcheck) == 0) {
header('Location: '.$this_file); header('Location: ' . $this_file);
exit; exit;
} }
$all_links = join(',', $linkcheck); $all_links = join(',', $linkcheck);
@ -132,7 +134,7 @@ switch ($action) {
$q = $wpdb->query("update $tablelinks SET link_visible='Y' WHERE link_id IN ($all_linkson)"); $q = $wpdb->query("update $tablelinks SET link_visible='Y' WHERE link_id IN ($all_linkson)");
} }
header('Location: '.$this_file); header('Location: ' . $this_file);
break; break;
} }
case 'Move': case 'Move':
@ -145,14 +147,14 @@ switch ($action) {
//for each link id (in $linkcheck[]) change category to selected value //for each link id (in $linkcheck[]) change category to selected value
if (count($linkcheck) == 0) { if (count($linkcheck) == 0) {
header('Location: '.$this_file); header('Location: ' . $this_file);
exit; exit;
} }
$all_links = join(',', $linkcheck); $all_links = join(',', $linkcheck);
// should now have an array of links we can change // should now have an array of links we can change
$q = $wpdb->query("update $tablelinks SET link_category='$category' WHERE link_id IN ($all_links)"); $q = $wpdb->query("update $tablelinks SET link_category='$category' WHERE link_id IN ($all_links)");
header('Location: '.$this_file); header('Location: ' . $this_file);
break; break;
} }
@ -161,16 +163,16 @@ switch ($action) {
$standalone = 1; $standalone = 1;
include_once('admin-header.php'); include_once('admin-header.php');
$link_url = $HTTP_POST_VARS["linkurl"]; $link_url = $HTTP_POST_VARS['linkurl'];
$link_name = $HTTP_POST_VARS["name"]; $link_name = $HTTP_POST_VARS['name'];
$link_image = $HTTP_POST_VARS["image"]; $link_image = $HTTP_POST_VARS['image'];
$link_target = $HTTP_POST_VARS["target"]; $link_target = $HTTP_POST_VARS['target'];
$link_category = $HTTP_POST_VARS["category"]; $link_category = $HTTP_POST_VARS['category'];
$link_description = $HTTP_POST_VARS["description"]; $link_description = $HTTP_POST_VARS['description'];
$link_visible = $HTTP_POST_VARS["visible"]; $link_visible = $HTTP_POST_VARS['visible'];
$link_rating = $HTTP_POST_VARS["rating"]; $link_rating = $HTTP_POST_VARS['rating'];
$link_rel = $HTTP_POST_VARS["rel"]; $link_rel = $HTTP_POST_VARS['rel'];
$link_notes = $HTTP_POST_VARS["notes"]; $link_notes = $HTTP_POST_VARS['notes'];
$auto_toggle = get_autotoggle($link_category); $auto_toggle = get_autotoggle($link_category);
if ($user_level < get_settings('links_minadminlevel')) if ($user_level < get_settings('links_minadminlevel'))
@ -193,7 +195,7 @@ switch ($action) {
case 'editlink': case 'editlink':
{ {
if (isset($submit) && ($submit == "Save")) { if (isset($submit)) {
if (isset($links_show_cat_id) && ($links_show_cat_id != '')) if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
$cat_id = $links_show_cat_id; $cat_id = $links_show_cat_id;
@ -207,17 +209,17 @@ switch ($action) {
$standalone = 1; $standalone = 1;
include_once('admin-header.php'); include_once('admin-header.php');
$link_id = $HTTP_POST_VARS["link_id"]; $link_id = $HTTP_POST_VARS['link_id'];
$link_url = $HTTP_POST_VARS["linkurl"]; $link_url = $HTTP_POST_VARS['linkurl'];
$link_name = $HTTP_POST_VARS["name"]; $link_name = $HTTP_POST_VARS['name'];
$link_image = $HTTP_POST_VARS["image"]; $link_image = $HTTP_POST_VARS['image'];
$link_target = $HTTP_POST_VARS["target"]; $link_target = $HTTP_POST_VARS['target'];
$link_category = $HTTP_POST_VARS["category"]; $link_category = $HTTP_POST_VARS['category'];
$link_description = $HTTP_POST_VARS["description"]; $link_description = $HTTP_POST_VARS['description'];
$link_visible = $HTTP_POST_VARS["visible"]; $link_visible = $HTTP_POST_VARS['visible'];
$link_rating = $HTTP_POST_VARS["rating"]; $link_rating = $HTTP_POST_VARS['rating'];
$link_rel = $HTTP_POST_VARS["rel"]; $link_rel = $HTTP_POST_VARS['rel'];
$link_notes = $HTTP_POST_VARS["notes"]; $link_notes = $HTTP_POST_VARS['notes'];
$auto_toggle = get_autotoggle($link_category); $auto_toggle = get_autotoggle($link_category);
if ($user_level < get_settings('links_minadminlevel')) if ($user_level < get_settings('links_minadminlevel'))
@ -238,8 +240,8 @@ switch ($action) {
" link_notes='" . addslashes($link_notes) . "'\n" . " link_notes='" . addslashes($link_notes) . "'\n" .
" WHERE link_id=$link_id"); " WHERE link_id=$link_id");
} // end if save } // end if save
setcookie('links_show_cat_id_'.$cookiehash, $links_show_cat_id, time()+600); setcookie('links_show_cat_id_' . $cookiehash, $links_show_cat_id, time()+600);
header('Location: '.$this_file); header('Location: ' . $this_file);
break; break;
} // end Save } // end Save
@ -248,12 +250,12 @@ switch ($action) {
$standalone = 1; $standalone = 1;
include_once('admin-header.php'); include_once('admin-header.php');
$link_id = $HTTP_POST_VARS["link_id"]; $link_id = $HTTP_GET_VARS["link_id"];
if ($user_level < get_settings('links_minadminlevel')) if ($user_level < get_settings('links_minadminlevel'))
die ("Cheatin' uh ?"); die ("Cheatin' uh ?");
$wpdb->query("DELETE FROM $tablelinks WHERE link_id = '$link_id'"); $wpdb->query("DELETE FROM $tablelinks WHERE link_id = $link_id");
if (isset($links_show_cat_id) && ($links_show_cat_id != '')) if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
$cat_id = $links_show_cat_id; $cat_id = $links_show_cat_id;
@ -273,12 +275,12 @@ switch ($action) {
$standalone=0; $standalone=0;
include_once ('admin-header.php'); include_once ('admin-header.php');
if ($user_level < get_settings('links_minadminlevel')) { if ($user_level < get_settings('links_minadminlevel')) {
die("You have no right to edit the links for this blog.<br />Ask for a promotion to your <a href=\"mailto:$admin_email\">blog admin</a>. :)"); die("You have no right to edit the links for this blog.<br />Ask for a promotion to your <a href='mailto:$admin_email'>blog admin</a>. :)");
} }
$row = $wpdb->get_row("SELECT link_url, link_name, link_image, link_target, link_description, link_visible, link_category AS cat_id, link_rating, link_rel, link_notes " . $row = $wpdb->get_row("SELECT link_url, link_name, link_image, link_target, link_description, link_visible, link_category AS cat_id, link_rating, link_rel, link_notes
" FROM $tablelinks " . FROM $tablelinks
" WHERE link_id = $link_id"); WHERE link_id = $link_id");
if ($row) { if ($row) {
$link_url = stripslashes($row->link_url); $link_url = stripslashes($row->link_url);
@ -294,52 +296,47 @@ switch ($action) {
} }
?> ?>
<ul id="adminmenu2"> <ul id="adminmenu2">
<li><a href="link-manager.php" class="current">Manage Links</a></li> <li><a href="link-manager.php" class="current">Manage Links</a></li>
<li><a href="link-add.php">Add Link</a></li> <li><a href="link-add.php">Add Link</a></li>
<li><a href="link-categories.php">Link Categories</a></li> <li><a href="link-categories.php">Link Categories</a></li>
<li class="last"><a href="link-import.php">Import Blogroll</a></li> <li class="last"><a href="link-import.php">Import Blogroll</a></li>
</ul> </ul>
<div class="wrap"> <style media="screen" type="text/css">
th { text-align: right; }
<table width="100%" cellpadding="3" cellspacing="3"> </style>
<form name="editlink" method="post"> <div class="wrap">
<input type="hidden" name="action" value="editlink" /> <form action="" method="post" name="editlink" id="editlink">
<input type="hidden" name="link_id" value="<?php echo $link_id; ?>" /> <h3>Edit a link:</h3>
<input type="hidden" name="order_by" value="<?php echo $order_by ?>" /> <table width="100%" border="0" cellspacing="5" cellpadding="3">
<input type="hidden" name="cat_id" value="<?php echo $cat_id ?>" /> <tr>
<tr> <th scope="row">URI:</th>
<td colspan="2"><strong>Edit</strong> a link:</td> <td><input type="text" name="linkurl" size="80" value="<?php echo $link_url; ?>" /></td>
</tr> </tr>
<tr> <tr>
<td align="right">URL:</td> <th scope="row">Link Name: </th>
<td><input type="text" name="linkurl" size="80" value="<?php echo $link_url; ?>"></td> <td><input type="text" name="name" size="80" value="<?php echo $link_name; ?>" /></td>
</tr> </tr>
<tr> <tr>
<td align="right">Display Name/Alt text:</td> <th scope="row">Image:</th>
<td><input type="text" name="name" size="80" value="<?php echo $link_name; ?>"></td> <td><input type="text" name="image" size="80" value="<?php echo $link_image; ?>" /></td>
</tr> </tr>
<tr> <tr>
<td align="right">Image:</td> <th scope="row">Description:</th>
<td><input type="text" name="image" size="80" value="<?php echo $link_image; ?>"></td> <td><input type="text" name="description" size="80" value="<?php echo $link_description; ?>" /></td>
</tr> </tr>
<tr> <tr>
<td align="right">Description:</td> <th scope="row">rel:</th>
<td><input type="text" name="description" size="80" value="<?php echo $link_description; ?>"></td> <td><input type="text" name="rel" size="80" value="<?php echo $link_rel; ?>" /></td>
</tr> </tr>
<tr> <tr>
<td align="right">Rel:</td> <th scope="row">Notes:</th>
<td><input type="text" name="rel" size="80" value="<?php echo $link_rel; ?>"></td> <td><textarea name="notes" cols="80" rows="10"><?php echo $link_notes; ?></textarea></td>
</tr> </tr>
<tr> <tr>
<td valign="top" align="right">Notes:</td> <th scope="row">Rating:</th>
<td><textarea name="notes" cols="80" rows="10"><?php echo $link_notes; ?></textarea></td> <td><select name="rating" size="1">
</tr> <?php
<tr>
<td align="right">Rating:</td>
<td>
<select name="rating" size="1">
<?php
for ($r = 0; $r < 10; $r++) { for ($r = 0; $r < 10; $r++) {
echo(' <option value="'.$r.'" '); echo(' <option value="'.$r.'" ');
if ($link_rating == $r) if ($link_rating == $r)
@ -347,39 +344,46 @@ switch ($action) {
echo('>'.$r.'</option>'); echo('>'.$r.'</option>');
} }
?> ?>
</select>&nbsp;(Leave at 0 for no rating.) </select> (Leave at 0 for no rating.) </td>
</td> </tr>
</tr> <tr>
<tr> <th scope="row">Target:</th>
<td align="right">Target:</td> <td><label>
<td><label><input type="radio" name="target" value="_blank" <?php echo(($link_target == '_blank') ? 'checked="checked"' : ''); ?>> _blank</label> <input type="radio" name="target" value="_blank" <?php echo(($link_target == '_blank') ? 'checked="checked"' : ''); ?> />
&nbsp;<label><input type="radio" name="target" value="_top" <?php echo(($link_target == '_top') ? 'checked="checked"' : ''); ?>> _top</label> <code>_blank</code></label>
&nbsp;<label><input type="radio" name="target" value="" <?php echo(($link_target == '') ? 'checked="checked"' : ''); ?>> none</label> &nbsp;<label>
</td> <input type="radio" name="target" value="_top" <?php echo(($link_target == '_top') ? 'checked="checked"' : ''); ?> />
</tr> <code>_top</code></label>
<tr> &nbsp;
<td align="right">Visible:</td> <label>
<td><label> <input type="radio" name="target" value="" <?php echo(($link_target == '') ? 'checked="checked"' : ''); ?> />
<input type="radio" name="visible" <?php if ($link_visible == 'Y') echo "checked"; ?> value="Y"> none (Note that the <code>target</code> attribute is illegal in XHTML 1.1 and 1.0 Strict.)</label></td>
Yes</label> </tr>
&nbsp;<label> <tr>
<input type="radio" name="visible" <?php if ($link_visible == 'N') echo "checked"; ?> value="N"> <th scope="row">Visible:</th>
No</label> <td><label>
</td> <input type="radio" name="visible" <?php if ($link_visible == 'Y') echo "checked"; ?> value="Y" />
</tr> Yes</label>
<tr> &nbsp;
<td align="right"><label for="category">Category</label>:</td> <label>
<td> <input type="radio" name="visible" <?php if ($link_visible == 'N') echo "checked"; ?> value="N" />
<?php category_dropdown('category', $link_category); ?> No</label></td>
</td> </tr>
</tr> <tr>
<tr> <th scope="row">Category:</th>
<td colspan="2" align="center"> <td><?php category_dropdown('category', $link_category); ?></td>
<input type="submit" name="submit" value="Save" class="search">&nbsp; </tr>
<input type="submit" name="submit" value="Cancel" class="search"> <tr>
</td> <td colspan="2" align="center"><input type="submit" name="submit" value="Save Changes" class="search" />
</tr> &nbsp;
</table> <input type="submit" name="submit" value="Cancel" class="search" />
<input type="hidden" name="action" value="editlink" />
<input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
<input type="hidden" name="order_by" value="<?php echo $order_by ?>" />
<input type="hidden" name="cat_id" value="<?php echo $cat_id ?>" /></td>
</tr>
</table>
</form>
</div> </div>
<?php <?php
break; break;