Make WordPress Core

Changeset 3570


Ignore:
Timestamp:
02/27/2006 04:57:30 AM (19 years ago)
Author:
ryan
Message:

Bookmark/link rework. #2499

Location:
trunk
Files:
1 added
1 deleted
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-db.php

    r3528 r3570  
    106106        $category_parent = 0;
    107107
     108    if ( isset($posts_private) )
     109        $posts_private = (int) $posts_private;
     110    else
     111        $posts_private = 0;
     112
     113    if ( isset($links_private) )
     114        $links_private = (int) $links_private;
     115    else
     116        $links_private = 0;
     117
    108118    if (!$update) {
    109         $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent')");
     119        $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')");
    110120        $cat_ID = $wpdb->insert_id;
    111121    } else {
    112         $wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent' WHERE cat_ID = '$cat_ID'");
     122        $wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private' WHERE cat_ID = '$cat_ID'");
    113123    }
    114124
     
    154164
    155165    // Don't delete the default cat.
    156     if (1 == $cat_ID)
     166    if ( $cat_ID == get_option('default_category') )
     167        return 0;
     168
     169    if ( $cat_ID == get_option('default_link_category') )
    157170        return 0;
    158171
     
    167180    $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'");
    168181
    169     // TODO: Only set categories to general if they're not in another category already
    170     $wpdb->query("UPDATE $wpdb->post2cat SET category_id='1' WHERE category_id='$cat_ID'");
    171 
     182    // Only set posts and links to the default category if they're not in another category already.
     183    $default_cat = get_option('default_category');
     184    $posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'");
     185    if ( is_array($posts) ) foreach ($posts as $post_id) {
     186        $cats = wp_get_post_cats('', $post_id);
     187        if ( 1 == count($cats) )
     188            $cats = array($default_cat);
     189        else
     190            $cats = array_diff($cats, array($cat_ID));
     191        wp_set_post_cats('', $post_id, $cats);
     192    }
     193
     194    $default_link_cat = get_option('default_link_category');
     195    $links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'");
     196    if ( is_array($links) ) foreach ($links as $link_id) {
     197        $cats = wp_get_link_cats($link_id);
     198        if ( 1 == count($cats) )
     199            $cats = array($default_link_cat);
     200        else
     201            $cats = array_diff($cats, array($cat_ID));
     202        wp_set_link_cats($link_id, $cats);
     203    }
     204   
    172205    wp_cache_delete($cat_ID, 'category');
    173206    wp_cache_delete('all_category_ids', 'category');
     
    245278
    246279    $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = '$link_id'");
     280    $link->link_category = wp_get_link_cats($link_id);
    247281
    248282    if ( $output == OBJECT ) {
     
    281315        $link_notes = '';
    282316
     317    // Make sure we set a valid category
     318    if (0 == count($link_category) || !is_array($link_category)) {
     319        $link_category = array(get_option('default_category'));
     320    }
     321
    283322    if ( $update ) {
    284323        $wpdb->query("UPDATE $wpdb->links SET link_url='$link_url',
    285324            link_name='$link_name', link_image='$link_image',
    286             link_target='$link_target', link_category='$link_category',
     325            link_target='$link_target',
    287326            link_visible='$link_visible', link_description='$link_description',
    288327            link_rating='$link_rating', link_rel='$link_rel',
     
    290329            WHERE link_id='$link_id'");
    291330    } else {
    292         $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_category', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
     331        $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
    293332        $link_id = $wpdb->insert_id;
    294333    }
     334
     335    wp_set_link_cats($link_id, $link_category);
    295336
    296337    if ( $update )
     
    312353    $link = add_magic_quotes($link);
    313354
     355    // Passed link category list overwrites existing category list if not empty.
     356    if ( isset($linkdata['link_category']) && is_array($linkdata['link_category'])
     357             && 0 != count($linkdata['link_category']) )
     358        $link_cats = $linkdata['link_category'];
     359    else
     360        $link_cats = $link['link_category'];
     361
    314362    // Merge old and new fields with new fields overwriting old ones.
    315363    $linkdata = array_merge($link, $linkdata);
     364    $linkdata['link_category'] = $link_cats;
    316365
    317366    return wp_insert_link($linkdata);
     
    322371
    323372    do_action('delete_link', $link_id);
     373   
     374    $categories = wp_get_link_cats($link_id);
     375    if( is_array( $categories ) ) {
     376        foreach ( $categories as $category ) {
     377            $wpdb->query("UPDATE $wpdb->categories SET link_count = link_count - 1 WHERE cat_ID = '$category'");
     378            wp_cache_delete($category, 'category');
     379        }
     380    }
     381
     382    $wpdb->query("DELETE FROM $wpdb->link2cat WHERE link_id = '$link_id'");
    324383    return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'");
    325384}
     385
     386function wp_get_link_cats($link_ID = 0) {
     387    global $wpdb;
     388
     389    $sql = "SELECT category_id
     390        FROM $wpdb->link2cat
     391        WHERE link_id = $link_ID
     392        ORDER BY category_id";
     393
     394    $result = $wpdb->get_col($sql);
     395
     396    if ( !$result )
     397        $result = array();
     398
     399    return array_unique($result);
     400}
     401
     402function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
     403    global $wpdb;
     404    // If $link_categories isn't already an array, make it one:
     405    if (!is_array($link_categories) || 0 == count($link_categories))
     406        $link_categories = array(get_option('default_category'));
     407
     408    $link_categories = array_unique($link_categories);
     409
     410    // First the old categories
     411    $old_categories = $wpdb->get_col("
     412        SELECT category_id
     413        FROM $wpdb->link2cat
     414        WHERE link_id = $link_ID");
     415
     416    if (!$old_categories) {
     417        $old_categories = array();
     418    } else {
     419        $old_categories = array_unique($old_categories);
     420    }
     421
     422    // Delete any?
     423    $delete_cats = array_diff($old_categories,$link_categories);
     424
     425    if ($delete_cats) {
     426        foreach ($delete_cats as $del) {
     427            $wpdb->query("
     428                DELETE FROM $wpdb->link2cat
     429                WHERE category_id = $del
     430                    AND link_id = $link_ID
     431                ");
     432        }
     433    }
     434
     435    // Add any?
     436    $add_cats = array_diff($link_categories, $old_categories);
     437
     438    if ($add_cats) {
     439        foreach ($add_cats as $new_cat) {
     440            $wpdb->query("
     441                INSERT INTO $wpdb->link2cat (link_id, category_id)
     442                VALUES ($link_ID, $new_cat)");
     443        }
     444    }
     445   
     446    // Update category counts.
     447    $all_affected_cats = array_unique(array_merge($link_categories, $old_categories));
     448    foreach ( $all_affected_cats as $cat_id ) {
     449        $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
     450        $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
     451        wp_cache_delete($cat_id, 'category');
     452    }
     453}   // wp_set_link_cats()
    326454
    327455function post_exists($title, $content = '', $post_date = '') {
  • trunk/wp-admin/admin-functions.php

    r3564 r3570  
    477477    $link->link_notes = wp_specialchars($link->link_notes);
    478478    $link->link_rss = wp_specialchars($link->link_rss);
     479    $link->post_category = $link->link_category;
    479480
    480481    return $link;
     
    492493        $link->link_name = '';
    493494
     495    $link->link_visible = 'Y';
     496
    494497    return $link;
    495498}
     
    508511    $_POST['link_image'] = wp_specialchars($_POST['link_image']);
    509512    $_POST['link_rss'] = wp_specialchars($_POST['link_rss']);
    510     $auto_toggle = get_autotoggle($_POST['link_category']);
    511 
    512     // if we are in an auto toggle category and this one is visible then we
    513     // need to make the others invisible before we add this new one.
    514     // FIXME Add category toggle func.
    515     //if (($auto_toggle == 'Y') && ($link_visible == 'Y')) {
    516     //  $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category");
    517     //}
     513    $_POST['link_category'] = $_POST['post_category'];
    518514
    519515    if ( !empty($link_id) ) {
     
    555551
    556552function get_nested_categories($default = 0, $parent = 0) {
    557     global $post_ID, $mode, $wpdb;
     553    global $post_ID, $link_id, $mode, $wpdb;
    558554
    559555    if ($post_ID) {
     
    568564            $checked_categories[] = $default;
    569565        }
    570 
     566    } else if ($link_id) {
     567        $checked_categories = $wpdb->get_col("
     568             SELECT category_id
     569             FROM $wpdb->categories, $wpdb->link2cat
     570             WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'
     571             ");
     572
     573        if (count($checked_categories) == 0) {
     574            // No selected categories, strange
     575            $checked_categories[] = $default;
     576        }   
    571577    } else {
    572578        $checked_categories[] = $default;
     
    621627                    $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>";
    622628                    $default_cat_id = get_option('default_category');
    623 
    624                     if ($category->cat_ID != $default_cat_id)
    625                         $edit .= "<td><a href='categories.php?action=delete&amp;cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category &quot;%s&quot;.  All of its posts will go to the default category.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars($category->cat_name, 1))."' );\" class='delete'>".__('Delete')."</a>";
     629                    $default_link_cat_id = get_option('default_link_category');
     630
     631                    if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) )
     632                        $edit .= "<td><a href='categories.php?action=delete&amp;cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category &quot;%s&quot;.  All of its posts and bookmarks will go to the default categories.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars($category->cat_name, 1))."' );\" class='delete'>".__('Delete')."</a>";
    626633                    else
    627634                        $edit .= "<td style='text-align:center'>".__("Default");
     
    634641                                <td>$category->category_description</td>
    635642                                <td>$category->category_count</td>
     643                                <td>$category->link_count</td>
    636644                                <td>$edit</td>
    637645                                </tr>";
     
    688696        foreach ($categories as $category) {
    689697            if ($currentcat != $category->cat_ID && $parent == $category->category_parent) {
    690                 $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
    691698                $pad = str_repeat('&#8211; ', $level);
    692699                $category->cat_name = wp_specialchars($category->cat_name);
     
    703710}
    704711
    705 function link_category_dropdown($fieldname, $selected = 0) {
     712function return_link_categories_list($parent = 0) {
    706713    global $wpdb;
    707 
    708     $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
    709     echo "\n<select name='$fieldname' size='1'>\n";
    710     foreach ($results as $row) {
    711         echo "\n\t<option value='$row->cat_id'";
    712         if ($row->cat_id == $selected)
    713             echo " selected='selected'";
    714         echo ">$row->cat_id : " . wp_specialchars($row->cat_name);
    715         if ($row->auto_toggle == 'Y')
    716             echo ' (auto toggle)';
    717         echo "</option>";
    718     }
    719     echo "\n</select>\n";
     714    return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC LIMIT 100");
    720715}
    721716
  • trunk/wp-admin/admin-header.php

    r3563 r3570  
    4141<?php break; case 'page.php' : case 'page-new.php' : ?>
    4242var manager = new dbxManager('pagemeta');
     43<?php break; case 'link.php' : case 'link-add.php' : ?>
     44var manager = new dbxManager('linkmeta');
    4345<?php break; endswitch; ?>
    4446});
  • trunk/wp-admin/categories.php

    r3541 r3570  
    128128        <th scope="col"><?php _e('Description') ?></th>
    129129        <th scope="col"><?php _e('# Posts') ?></th>
     130        <th scope="col"><?php _e('# Links') ?></th>
    130131        <th colspan="2"><?php _e('Action') ?></th>
    131132    </tr>
     
    141142<?php if ( current_user_can('manage_categories') ) : ?>
    142143<div class="wrap">
    143 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete posts from that category, it will just set them back to the default category <strong>%s</strong>.'), get_catname(get_option('default_category'))) ?></p>
     144<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and bookmarks in that category.  Instead, posts in the deleted category are set to the category <strong>%s</strong> and bookmarks are set to <strong>%s</strong>.'), get_catname(get_option('default_category')), get_catname(get_option('default_link_category'))) ?></p>
    144145</div>
    145146
  • trunk/wp-admin/edit-link-form.php

    r3257 r3570  
    11<?php
    22if ( ! empty($link_id) ) {
    3     $editing = true;
    4     $heading = __('Edit a link:');
     3    $heading = __('Edit Bookmark');
    54    $submit_text = __('Save Changes &raquo;');
    6     $form = '<form action="" method="post" name="editlink" id="editlink">';
     5    $form = '<form name="editlink" id="editlink" method="post" action="link.php">';
    76} else {
    8     $editing = false;
    9     $heading = __('<strong>Add</strong> a link:');
    10     $submit_text = __('Add Link &raquo;');
    11     $form = '<form name="addlink" method="post" action="link-manager.php">';
     7    $heading = __('Create Bookmark');
     8    $submit_text = __('Add Bookmark &raquo;');
     9    $form = '<form name="addlink" id="addlink" method="post" action="link.php">';
    1210}
    1311
     
    2927    }
    3028}
    31 
    3229?>
    3330
    3431<div class="wrap">
    35   <?php echo $form ?>
    36   <h2><?php echo $heading ?></h2>
    37 <fieldset class="options">
    38     <legend><?php _e('Basics') ?></legend>
    39         <table class="editform" width="100%" cellspacing="2" cellpadding="5">
    40          <tr>
    41            <th width="33%" scope="row"><?php _e('URI:') ?></th>
    42            <td width="67%"><input type="text" name="link_url" value="<?php echo $link->link_url; ?>" style="width: 95%;" /></td>
    43          </tr>
    44          <tr>
    45            <th scope="row"><?php _e('Link Name:') ?></th>
    46            <td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
    47          </tr>
    48          <tr>
    49             <th scope="row"><?php _e('Short description:') ?></th>
    50             <td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
    51             </tr>
    52         <tr>
    53            <th scope="row"><?php _e('Category:') ?></th>
    54            <td><?php link_category_dropdown('link_category', $link->link_category); ?></td>
    55          </tr>
     32<h2><?php echo $heading ?></h2>
     33<?php echo $form ?>
     34 
     35<div id="poststuff">
     36<div id="moremeta">
     37<div id="grabit" class="dbx-group">
     38
     39<fieldset id="categorydiv" class="dbx-box">
     40<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
     41<div class="dbx-content">
     42<p id="jaxcat"></p>
     43<div id="categorychecklist"><?php dropdown_categories(get_settings('default_link_category')); ?></div></div>
     44</fieldset>
     45
     46<fieldset class="dbx-box">
     47<h3 class="dbx-handle"><?php _e('Target') ?></h3>
     48<div class="dbx-content">
     49<label for="link_target_blank" class="selectit">
     50<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
     51<code>_blank</code></label>
     52<label for="link_target_top" class="selectit">
     53<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
     54<code>_top</code></label>
     55<label for="link_target_none" class="selectit">
     56<input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
     57<?php _e('none') ?></label>
     58</div>
     59</fieldset>
     60
     61<fieldset class="dbx-box">
     62<h3 class="dbx-handle"><?php _e('Visible') ?></h3>
     63<div class="dbx-content">
     64<label for="link_visible_yes" class="selectit">
     65<input id="link_visible_yes" type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
     66<?php _e('Yes') ?></label>
     67<label for="link_visible_no" class="selectit">
     68<input id="link_visible_no" type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" />
     69<?php _e('No') ?></label>
     70</div>
     71</fieldset>
     72
     73</div>
     74</div>
     75
     76<fieldset id="uridiv">
     77<legend><?php _e('URI:') ?></legend>
     78<div><input type="text" name="link_url" value="<?php echo $link->link_url; ?>" style="width: 95%" /></div>
     79</fieldset>
     80
     81<fieldset id="namediv">
     82<legend><?php _e('Name:') ?></legend>
     83<div><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></div>
     84</fieldset>
     85
     86<fieldset id="descdiv">
     87<legend><?php _e('Description:') ?></legend>
     88<div><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></div>
     89</fieldset>
     90
     91<p class="submit">
     92<input type="submit" name="submit" value="<?php echo $submit_text ?>" />
     93</p>
     94
     95<div id="advancedstuff" class="dbx-group" >
     96
     97<fieldset id="xfn" class="dbx-box">
     98<h3 class="dbx-handle"><?php _e('Link Relationship (XFN)') ?></h3>
     99<div class="dbx-content">
     100<table class="editform" width="100%" cellspacing="2" cellpadding="5">
     101    <tr>
     102        <th width="33%" scope="row"><?php _e('rel:') ?></th>
     103        <td width="67%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td>
     104    </tr>
     105    <tr>
     106        <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th>
     107        <td>
     108            <table cellpadding="3" cellspacing="5">
     109                <tr>
     110                    <th scope="row"> <?php _e('identity') ?> </th>
     111                    <td>
     112                        <label for="me">
     113                        <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
     114                        <?php _e('another web address of mine') ?></label>
     115                    </td>
     116                </tr>
     117                <tr>
     118                    <th scope="row"> <?php _e('friendship') ?> </th>
     119                    <td>
     120                        <label for="contact">
     121                        <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
     122                        <label for="acquaintance">
     123                        <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> />  <?php _e('acquaintance') ?></label>
     124                        <label id="friend">
     125                        <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
     126                        <label for="friendship">
     127                        <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label>
     128                    </td>
     129                </tr>
     130                <tr>
     131                    <th scope="row"> <?php _e('physical') ?> </th>
     132                    <td>
     133                        <label for="met">
     134                        <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
     135                        <?php _e('met') ?></label>
     136                    </td>
     137                </tr>
     138                <tr>
     139                    <th scope="row"> <?php _e('professional') ?> </th>
     140                    <td>
     141                        <label for="co-worker">
     142                        <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
     143                        <?php _e('co-worker') ?></label>
     144                        <label for="colleague">
     145                        <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
     146                        <?php _e('colleague') ?></label>
     147                    </td>
     148                </tr>
     149                <tr>
     150                    <th scope="row"> <?php _e('geographical') ?> </th>
     151                    <td>
     152                        <label for="co-resident">
     153                        <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
     154                        <?php _e('co-resident') ?></label>
     155                        <label for="neighbor">
     156                        <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
     157                        <?php _e('neighbor') ?></label>
     158                        <label for="geographical">
     159                        <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
     160                        <?php _e('none') ?></label>
     161                    </td>
     162                </tr>
     163                <tr>
     164                    <th scope="row"> <?php _e('family') ?> </th>
     165                    <td>
     166                        <label for="child">
     167                        <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?>  />
     168                        <?php _e('child') ?></label>
     169                        <label for="kin">
     170                        <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?>  />
     171                        <?php _e('kin') ?></label>
     172                        <label for="parent">
     173                        <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
     174                        <?php _e('parent') ?></label>
     175                        <label for="sibling">
     176                        <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
     177                        <?php _e('sibling') ?></label>
     178                        <label for="spouse">
     179                        <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
     180                        <?php _e('spouse') ?></label>
     181                        <label for="family">
     182                        <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
     183                        <?php _e('none') ?></label>
     184                    </td>
     185                </tr>
     186                <tr>
     187                    <th scope="row"> <?php _e('romantic') ?> </th>
     188                    <td>
     189                        <label for="muse">
     190                        <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
     191                        <?php _e('muse') ?></label>
     192                        <label for="crush">
     193                        <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
     194                        <?php _e('crush') ?></label>
     195                        <label for="date">
     196                        <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
     197                        <?php _e('date') ?></label>
     198                        <label for="romantic">
     199                        <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
     200                        <?php _e('sweetheart') ?></label>
     201                    </td>
     202                </tr>
     203            </table>
     204        </td>
     205    </tr>
    56206</table>
    57 </fieldset>
    58        <p class="submit">
    59        <input type="submit" name="submit" value="<?php echo $submit_text ?>" />
    60        </p>
    61     <fieldset class="options">
    62         <legend><?php _e('Link Relationship (XFN)') ?></legend>
    63         <table class="editform" width="100%" cellspacing="2" cellpadding="5">
    64             <tr>
    65                 <th width="33%" scope="row"><?php _e('rel:') ?></th>
    66                 <td width="67%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td>
    67             </tr>
    68             <tr>
    69                 <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th>
    70                 <td>
    71                     <table cellpadding="3" cellspacing="5">
    72               <tr>
    73               <th scope="row"> <?php _e('identity') ?> </th>
    74               <td>
    75                 <label for="me">
    76                 <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
    77           <?php _e('another web address of mine') ?></label>
    78               </td>
    79             </tr>
    80             <tr>
    81               <th scope="row"> <?php _e('friendship') ?> </th>
    82               <td>
    83                 <label for="contact">
    84                 <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
    85                 <label for="acquaintance">
    86                 <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> />  <?php _e('acquaintance') ?></label>
    87                 <label id="friend">
    88                 <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
    89                 <label for="friendship">
    90                 <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label>
    91               </td>
    92             </tr>
    93             <tr>
    94               <th scope="row"> <?php _e('physical') ?> </th>
    95               <td>
    96                 <label for="met">
    97                 <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
    98           <?php _e('met') ?></label>
    99               </td>
    100             </tr>
    101             <tr>
    102               <th scope="row"> <?php _e('professional') ?> </th>
    103               <td>
    104                 <label for="co-worker">
    105                 <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
    106           <?php _e('co-worker') ?></label>
    107                 <label for="colleague">
    108                 <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
    109           <?php _e('colleague') ?></label>
    110               </td>
    111             </tr>
    112             <tr>
    113               <th scope="row"> <?php _e('geographical') ?> </th>
    114               <td>
    115                 <label for="co-resident">
    116                 <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
    117           <?php _e('co-resident') ?></label>
    118                 <label for="neighbor">
    119                 <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
    120           <?php _e('neighbor') ?></label>
    121                 <label for="geographical">
    122                 <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
    123           <?php _e('none') ?></label>
    124               </td>
    125             </tr>
    126             <tr>
    127               <th scope="row"> <?php _e('family') ?> </th>
    128               <td>
    129                 <label for="child">
    130                 <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?>  />
    131           <?php _e('child') ?></label>
    132                 <label for="kin">
    133                 <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?>  />
    134           <?php _e('kin') ?></label>
    135                 <label for="parent">
    136                 <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
    137           <?php _e('parent') ?></label>
    138                 <label for="sibling">
    139                 <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
    140           <?php _e('sibling') ?></label>
    141                 <label for="spouse">
    142                 <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
    143           <?php _e('spouse') ?></label>
    144                 <label for="family">
    145                 <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
    146           <?php _e('none') ?></label>
    147               </td>
    148             </tr>
    149             <tr>
    150               <th scope="row"> <?php _e('romantic') ?> </th>
    151               <td>
    152                 <label for="muse">
    153                 <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
    154          <?php _e('muse') ?></label>
    155                 <label for="crush">
    156                 <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
    157          <?php _e('crush') ?></label>
    158                 <label for="date">
    159                 <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
    160          <?php _e('date') ?></label>
    161                 <label for="romantic">
    162                 <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
    163          <?php _e('sweetheart') ?></label>
    164               </td>
    165             </tr>
    166         </table>
    167           </td>
    168             </tr>
     207</div>
     208</fieldset>
     209
     210<fieldset id="advanced" class="dbx-box">
     211<h3 class="dbx-handle"><?php _e('Advanced') ?></h3>
     212<div class="dbx-content">
     213<table class="editform" width="100%" cellspacing="2" cellpadding="5">
     214    <tr>
     215        <th width="33%" scope="row"><?php _e('Image URI:') ?></th>
     216        <td width="67%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
     217    </tr>
     218    <tr>
     219        <th scope="row"><?php _e('RSS URI:') ?> </th>
     220        <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
     221    </tr>
     222    <tr>
     223        <th scope="row"><?php _e('Notes:') ?></th>
     224        <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td>
     225    </tr>
     226    <tr>
     227        <th scope="row"><?php _e('Rating:') ?></th>
     228        <td><select name="link_rating" size="1">
     229        <?php
     230            for ($r = 0; $r < 10; $r++) {
     231                echo('            <option value="'.$r.'" ');
     232                if ($link->link_rating == $r)
     233                    echo 'selected="selected"';
     234                echo('>'.$r.'</option>');
     235            }
     236        ?></select>&nbsp;<?php _e('(Leave at 0 for no rating.)') ?>
     237        </td>
     238    </tr>
    169239</table>
    170240</fieldset>
    171        <p class="submit">
    172        <input type="submit" name="submit" value="<?php echo $submit_text ?>" />
    173        </p>
    174 <fieldset class="options">
    175         <legend><?php _e('Advanced') ?></legend>
    176         <table class="editform" width="100%" cellspacing="2" cellpadding="5">
    177          <tr>
    178            <th width="33%" scope="row"><?php _e('Image URI:') ?></th>
    179            <td width="67%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
    180          </tr>
    181 <tr>
    182            <th scope="row"><?php _e('RSS URI:') ?> </th>
    183            <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
    184          </tr>
    185          <tr>
    186            <th scope="row"><?php _e('Notes:') ?></th>
    187            <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td>
    188          </tr>
    189          <tr>
    190            <th scope="row"><?php _e('Rating:') ?></th>
    191            <td><select name="link_rating" size="1">
    192 <?php
    193     for ($r = 0; $r < 10; $r++) {
    194       echo('            <option value="'.$r.'" ');
    195       if ($link->link_rating == $r)
    196         echo 'selected="selected"';
    197       echo('>'.$r.'</option>');
    198     }
    199 ?>
    200            </select>
    201          &nbsp;<?php _e('(Leave at 0 for no rating.)') ?> </td>
    202          </tr>
    203          <tr>
    204            <th scope="row"><?php _e('Target') ?></th>
    205            <td><label>
    206           <input type="radio" name="link_target" value="_blank"   <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
    207           <code>_blank</code></label><br />
    208 <label>
    209 <input type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
    210 <code>_top</code></label><br />
    211 <label>
    212 <input type="radio" name="link_target" value=""     <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
    213 <?php _e('none') ?></label><br />
    214 <?php _e('(Note that the <code>target</code> attribute is illegal in XHTML 1.1 and 1.0 Strict.)') ?></td>
    215          </tr>
    216          <tr>
    217            <th scope="row"><?php _e('Visible:') ?></th>
    218            <td><label>
    219              <input type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
    220 <?php _e('Yes') ?></label><br /><label>
    221 <input type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" />
    222 <?php _e('No') ?></label></td>
    223          </tr>
    224 </table>
    225 </fieldset>
    226 <p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p>
    227 <?php if ( $editing ) : ?>
    228           <input type="hidden" name="action" value="editlink" />
    229           <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
    230           <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
    231           <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
     241</div>
     242
     243<?php if ( $link_id ) : ?>
     244<input type="hidden" name="action" value="save" />
     245<input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
     246<input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
     247<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
    232248<?php else: ?>
    233         <input type="hidden" name="action" value="Add" />
     249<input type="hidden" name="action" value="add" />
    234250<?php endif; ?>
    235 </form>
    236 </div>
     251</div>
     252</form>
     253</div>
  • trunk/wp-admin/index.php

    r3568 r3570  
    121121<li><a href="post-new.php"><?php _e('Write a post'); ?></a></li>
    122122<li><a href="profile.php"><?php _e('Update your profile or change your password'); ?></a></li>
    123 <li><a href="link-add.php"><?php _e('Add a link to your blogroll'); ?></a></li>
     123<li><a href="link-add.php"><?php _e('Add a bookmark to your blogroll'); ?></a></li>
    124124<li><a href="themes.php"><?php _e('Change your site&#8217;s look or theme'); ?></a></li>
    125125</ul>
  • trunk/wp-admin/install.php

    r3548 r3570  
    155155    update_option('default_pingback_flag', 0);
    156156
    157 // Now drop in some default links
    158 $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".$wpdb->escape(__('Blogroll'))."')");
    159 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 1, 'http://blogs.linux.ie/xeer/feed/', '');");
    160 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 1, 'http://zengun.org/weblog/feed/', '');");
    161 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/', '');");
    162 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/', '');");
    163 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 1, 'http://zed1.com/journalized/feed/', '');");
    164 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 1, 'http://www.alexking.org/blog/wp-rss2.php', '');");
    165 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 1, 'http://dougal.gunters.org/feed/', '');");
    166 
    167157// Default category
    168158$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')");
     159
     160// Default link category
     161$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, link_count, category_description) VALUES ('0', '".$wpdb->escape(__('Blogroll'))."', '".sanitize_title(__('Blogroll'))."', '7', '')");
     162
     163// Now drop in some default links
     164$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 0, 'http://blogs.linux.ie/xeer/feed/', '');");
     165$wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (1, 2)" );
     166
     167$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 0, 'http://zengun.org/weblog/feed/', '');");
     168$wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (2, 2)" );
     169
     170$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 0, 'http://boren.nu/feed/', '');");
     171$wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (3, 2)" );
     172
     173$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 0, 'http://xml.photomatt.net/feed/', '');");
     174$wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (4, 2)" );
     175
     176$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 0, 'http://zed1.com/journalized/feed/', '');");
     177$wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (5, 2)" );
     178
     179$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 0, 'http://www.alexking.org/blog/wp-rss2.php', '');");
     180$wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (6, 2)" );
     181
     182$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 0, 'http://dougal.gunters.org/feed/', '');");
     183$wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (7, 2)" );
    169184
    170185// First post
  • trunk/wp-admin/link-add.php

    r3422 r3570  
    22require_once('admin.php');
    33
    4 $title = __('Add Link');
     4$title = __('Add Bookmark');
    55$this_file = 'link-manager.php';
    66$parent_file = 'link-manager.php';
     
    2727
    2828$xfn_js = true;
     29$editing = true;
    2930require('admin-header.php');
    3031?>
    3132
    3233<?php if ($_GET['added']) : ?>
    33 <div id="message" class="updated fade"><p><?php _e('Link added.'); ?></p></div>
     34<div id="message" class="updated fade"><p><?php _e('Bookmark added.'); ?></p></div>
    3435<?php endif; ?>
    3536
     
    4041
    4142<div class="wrap">
    42 <?php printf(__('<p>You can drag <a href="%s" title="Link add bookmarklet">Link This</a> to your toolbar and when you click it a window will pop up that will allow you to add whatever site you&#8217;re on to your links! Right now this only works on Mozilla or Netscape, but we&#8217;re working on it.</p>'), "javascript:void(linkmanpopup=window.open('" . get_settings('siteurl') . "/wp-admin/link-add.php?action=popup&amp;linkurl='+escape(location.href)+'&amp;name='+escape(document.title),'LinkManager','scrollbars=yes,width=750,height=550,left=15,top=15,status=yes,resizable=yes'));linkmanpopup.focus();window.focus();linkmanpopup.focus();") ?>
     43<?php printf(__('<p>You can drag <a href="%s" title="Bookmark add bookmarklet">Link This</a> to your toolbar and when you click it a window will pop up that will allow you to add whatever site you&#8217;re on to your bookmarks! Right now this only works on Mozilla or Netscape, but we&#8217;re working on it.</p>'), "javascript:void(linkmanpopup=window.open('" . get_settings('siteurl') . "/wp-admin/link-add.php?action=popup&amp;linkurl='+escape(location.href)+'&amp;name='+escape(document.title),'LinkManager','scrollbars=yes,width=750,height=550,left=15,top=15,status=yes,resizable=yes'));linkmanpopup.focus();window.focus();linkmanpopup.focus();") ?>
    4344</div>
    4445
  • trunk/wp-admin/link-import.php

    r3541 r3570  
    2626<form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll">
    2727
    28 <p><?php _e('If a program or website you use allows you to export your links or subscriptions as OPML you may import them here.'); ?>
     28<p><?php _e('If a program or website you use allows you to export your bookmarks or subscriptions as OPML you may import them here.'); ?>
    2929<div style="width: 70%; margin: auto; height: 8em;">
    3030<input type="hidden" name="step" value="1" />
     
    4343</div>
    4444
    45 <p style="clear: both; margin-top: 1em;"><?php _e('Now select a category you want to put these links in.') ?><br />
     45<p style="clear: both; margin-top: 1em;"><?php _e('Now select a category you want to put these bookmarks in.') ?><br />
    4646<?php _e('Category:') ?> <select name="cat_id">
    4747<?php
    48 $categories = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
     48$categories = get_categories('hide_empty=0');
    4949foreach ($categories as $category) {
    5050?>
    51 <option value="<?php echo $category->cat_id; ?>"><?php echo $category->cat_id.': '.$category->cat_name; ?></option>
     51<option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars($category->cat_name); ?></option>
    5252<?php
    5353} // end foreach
     
    104104                        if ('http' == substr($titles[$i], 0, 4))
    105105                            $titles[$i] = '';
    106                         // FIXME:  Use wp_insert_link().
    107                         $query = "INSERT INTO $wpdb->links (link_url, link_name, link_target, link_category, link_description, link_owner, link_rss)
    108                                 VALUES('{$urls[$i]}', '".$wpdb->escape($names[$i])."', '', $cat_id, '".$wpdb->escape($descriptions[$i])."', $user_ID, '{$feeds[$i]}')\n";
    109                         $result = $wpdb->query($query);
     106                        $link = array( 'link_url' => $urls[$i], 'link_name' => $wpdb->escape($names[$i]), 'link_category' => array($cat_id), 'link_description' => $wpdb->escape($descriptions[$i]), 'link_owner' => $user_ID, 'link_rss' => $feeds[$i]);                       
     107                        wp_insert_link($link);
    110108                        echo sprintf('<p>'.__('Inserted <strong>%s</strong>').'</p>', $names[$i]);
    111109                    }
    112110?>
    113      <p><?php printf(__('Inserted %1$d links into category %2$s. All done! Go <a href="%3$s">manage those links</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p>
     111     <p><?php printf(__('Inserted %1$d bookmarks into category %2$s. All done! Go <a href="%3$s">manage those bookmarks</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p>
    114112<?php
    115113                } // end if got url
  • trunk/wp-admin/link-manager.php

    r3517 r3570  
    11<?php
     2
     3
    24// Links
    35// Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com
    46
    5 require_once('admin.php');
    6 
    7 $title = __('Manage Links');
     7require_once ('admin.php');
     8
     9$title = __('Manage Bookmarks');
    810$this_file = $parent_file = 'link-manager.php';
    911$list_js = true;
    1012
    11 $wpvarstoreset = array('action','cat_id', 'linkurl', 'name', 'image',
    12                        'description', 'visible', 'target', 'category', 'link_id',
    13                        'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
    14                        'notes', 'linkcheck[]');
    15 
    16 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    17     $wpvar = $wpvarstoreset[$i];
    18     if (!isset($$wpvar)) {
    19         if (empty($_POST["$wpvar"])) {
    20             if (empty($_GET["$wpvar"])) {
    21                 $$wpvar = '';
    22             } else {
    23                 $$wpvar = $_GET["$wpvar"];
    24             }
    25         } else {
    26             $$wpvar = $_POST["$wpvar"];
    27         }
    28     }
    29 }
    30 
    31 $links_show_cat_id = $_COOKIE['links_show_cat_id_' . COOKIEHASH];
    32 $links_show_order = $_COOKIE['links_show_order_' . COOKIEHASH];
    33 
    34 if ('' != $_POST['assign']) $action = 'assign';
    35 if ('' != $_POST['visibility']) $action = 'visibility';
    36 if ('' != $_POST['move']) $action = 'move';
    37 if ('' != $_POST['linkcheck']) $linkcheck = $_POST[linkcheck];
    38 
    39 switch ($action) {
    40   case 'assign':
    41   {
    42     check_admin_referer();
    43 
    44     // check the current user's level first.
    45     if ( !current_user_can('manage_links') )
    46       die (__("Cheatin' uh ?"));
    47 
    48     //for each link id (in $linkcheck[]): if the current user level >= the
    49     //userlevel of the owner of the link then we can proceed.
    50 
    51     if (count($linkcheck) == 0) {
    52         header('Location: ' . $this_file);
    53         exit;
    54     }
    55     $all_links = join(',', $linkcheck);
    56     $results = $wpdb->get_results("SELECT link_id, link_owner FROM $wpdb->links LEFT JOIN $wpdb->users ON link_owner = ID WHERE link_id in ($all_links)");
    57     foreach ($results as $row) {
    58        $ids_to_change[] = $row->link_id;
    59     }
    60 
    61     // should now have an array of links we can change
    62     $all_links = join(',', $ids_to_change);
    63     $q = $wpdb->query("update $wpdb->links SET link_owner='$newowner' WHERE link_id IN ($all_links)");
    64 
    65     header('Location: ' . $this_file);
    66     break;
    67   }
    68   case 'visibility':
    69   {
    70     check_admin_referer();
    71 
    72     // check the current user's level first.
    73     if ( !current_user_can('manage_links') )
    74       die (__("Cheatin' uh ?"));
    75 
    76     //for each link id (in $linkcheck[]): toggle the visibility
    77     if (count($linkcheck) == 0) {
    78         header('Location: ' . $this_file);
    79         exit;
    80     }
    81     $all_links = join(',', $linkcheck);
    82     $results = $wpdb->get_results("SELECT link_id, link_visible FROM $wpdb->links WHERE link_id in ($all_links)");
    83     foreach ($results as $row) {
    84         if ($row->link_visible == 'Y') { // ok to proceed
    85             $ids_to_turnoff[] = $row->link_id;
    86         } else {
    87             $ids_to_turnon[] = $row->link_id;
    88         }
    89     }
    90 
    91     // should now have two arrays of links to change
    92     if (count($ids_to_turnoff)) {
    93         $all_linksoff = join(',', $ids_to_turnoff);
    94         $q = $wpdb->query("update $wpdb->links SET link_visible='N' WHERE link_id IN ($all_linksoff)");
    95     }
    96 
    97     if (count($ids_to_turnon)) {
    98         $all_linkson = join(',', $ids_to_turnon);
    99         $q = $wpdb->query("update $wpdb->links SET link_visible='Y' WHERE link_id IN ($all_linkson)");
    100     }
    101 
    102     header('Location: ' . $this_file);
    103     break;
    104   }
    105   case 'move':
    106   {
    107     check_admin_referer();
    108 
    109     // check the current user's level first.
    110     if ( !current_user_can('manage_links') )
    111       die (__("Cheatin' uh ?"));
    112 
    113     //for each link id (in $linkcheck[]) change category to selected value
    114     if (count($linkcheck) == 0) {
    115         header('Location: ' . $this_file);
    116         exit;
    117     }
    118     $all_links = join(',', $linkcheck);
    119     // should now have an array of links we can change
    120     $q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
    121 
    122     header('Location: ' . $this_file);
    123     break;
    124   }
    125 
    126   case 'Add':
    127   {
    128     check_admin_referer();
    129 
    130     add_link();
    131 
    132     header('Location: ' . $_SERVER['HTTP_REFERER'] . '?added=true');
    133     break;
    134   } // end Add
    135 
    136   case 'editlink':
    137   {
    138  
    139     check_admin_referer();
    140  
    141     if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
    142         $cat_id = $links_show_cat_id;
    143 
    144     if (!isset($cat_id) || ($cat_id == '')) {
    145         if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
    146             $cat_id = 'All';
     13$wpvarstoreset = array ('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]');
     14
     15for ($i = 0; $i < count($wpvarstoreset); $i += 1) {
     16    $wpvar = $wpvarstoreset[$i];
     17    if (!isset ($$wpvar)) {
     18        if (empty ($_POST["$wpvar"])) {
     19            if (empty ($_GET["$wpvar"])) {
     20                $$wpvar = '';
     21            } else {
     22                $$wpvar = $_GET["$wpvar"];
     23            }
     24        } else {
     25            $$wpvar = $_POST["$wpvar"];
     26        }
    14727    }
    148     $links_show_cat_id = $cat_id;
    149 
    150     $link_id = (int) $_POST['link_id'];
    151     edit_link($link_id);
    152 
    153     setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
    154     wp_redirect($this_file);
    155     break;
    156   } // end Save
    157 
    158   case 'Delete':
    159   {
    160     check_admin_referer();
    161 
    162     if ( !current_user_can('manage_links') )
    163       die (__("Cheatin' uh ?"));
    164 
    165     $link_id = (int) $_GET['link_id'];
    166 
    167     wp_delete_link($link_id);
    168 
    169     if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
    170         $cat_id = $links_show_cat_id;
    171 
    172     if (!isset($cat_id) || ($cat_id == '')) {
    173         if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
    174         $cat_id = 'All';
    175     }
    176     $links_show_cat_id = $cat_id;
    177     setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
    178     wp_redirect($this_file);
    179     break;
    180   } // end Delete
    181 
    182   case 'linkedit': {
    183     $xfn_js = true;
    184     include_once ('admin-header.php');
    185     if ( !current_user_can('manage_links') )
    186         die(__('You do not have sufficient permissions to edit the links for this blog.'));
    187 
    188     $link_id = (int) $_GET['link_id'];
    189 
    190     if ( !$link = get_link_to_edit($link_id) )
    191         die( __('Link not found.') );
    192 
    193     include('edit-link-form.php');
    194     break;
    195   } // end linkedit
    196   case __("Show"):
    197   {
    198     if (!isset($cat_id) || ($cat_id == '')) {
    199         if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
    200         $cat_id = 'All';
    201     }
    202     $links_show_cat_id = $cat_id;
    203     if (!isset($order_by) || ($order_by == '')) {
    204         if (!isset($links_show_order) || ($links_show_order == ''))
    205         $order_by = 'order_name';
    206     }
    207     $links_show_order = $order_by;
    208     //break; fall through
    209   } // end Show
    210   case "popup":
    211   {
    212     $link_url = stripslashes($_GET["linkurl"]);
    213     $link_name = stripslashes($_GET["name"]);
    214     //break; fall through
    215   }
    216   default:
    217   {
    218     if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
    219         $cat_id = $links_show_cat_id;
    220 
    221     if (!isset($cat_id) || ($cat_id == '')) {
    222         if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
    223         $cat_id = 'All';
    224     }
    225     $links_show_cat_id = $cat_id;
    226     if (isset($links_show_order) && ($links_show_order != ''))
    227         $order_by = $links_show_order;
    228 
    229     if (!isset($order_by) || ($order_by == ''))
    230         $order_by = 'order_name';
    231     $links_show_order = $order_by;
    232 
    233     setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
    234     setcookie('links_show_order_' . COOKIEHASH, $links_show_order, time()+600);
    235     include_once ("./admin-header.php");
    236     if ( !current_user_can('manage_links') )
    237       die(__("You do not have sufficient permissions to edit the links for this blog."));
    238 
    239     switch ($order_by)
    240     {
    241         case 'order_id':     $sqlorderby = 'id';          break;
    242         case 'order_url':    $sqlorderby = 'url';         break;
    243         case 'order_desc':   $sqlorderby = 'description'; break;
    244         case 'order_owner':  $sqlorderby = 'owner';       break;
    245         case 'order_rating': $sqlorderby = 'rating';      break;
    246         case 'order_name':
    247         default:             $sqlorderby = 'name';        break;
    248     }
    249 
    250   if ($action != "popup") {
     28}
     29
     30if (empty ($cat_id))
     31    $cat_id = 'all';
     32
     33if (empty ($order_by))
     34    $order_by = 'order_name';
     35
     36$title = __('Manage Bookmarks');
     37include_once ("./admin-header.php");
     38
     39if (!current_user_can('manage_links'))
     40    die(__("You do not have sufficient permissions to edit the bookmarks for this blog."));
     41
     42switch ($order_by) {
     43    case 'order_id' :
     44        $sqlorderby = 'id';
     45        break;
     46    case 'order_url' :
     47        $sqlorderby = 'url';
     48        break;
     49    case 'order_desc' :
     50        $sqlorderby = 'description';
     51        break;
     52    case 'order_owner' :
     53        $sqlorderby = 'owner';
     54        break;
     55    case 'order_rating' :
     56        $sqlorderby = 'rating';
     57        break;
     58    case 'order_name' :
     59    default :
     60        $sqlorderby = 'name';
     61        break;
     62}
    25163?>
    25264<script type="text/javascript">
     
    26678</script>
    26779
     80<?php
     81if ( isset($_GET['deleted']) ) {
     82    echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
     83    $deleted = (int) $_GET['deleted'];
     84    printf(__('%s bookmarks deleted.'), $deleted);
     85    echo '</p></div>';
     86}
     87?>
     88
    26889<div class="wrap">
    269     <form name="cats" method="post" action="">
    270     <table width="75%" cellpadding="3" cellspacing="3">
    271       <tr>
    272         <td>
    273         <?php _e('<strong>Show</strong> links in category:'); ?><br />
    274         </td>
    275         <td>
    276           <?php _e('<strong>Order</strong> by:');?>
    277         </td>
     90<h2><?php _e('Bookmark Management'); ?></h2>
     91<form name="cats" method="post" action="">
     92<table width="75%" cellpadding="3" cellspacing="3">
     93    <tr>
     94        <td>
     95            <?php _e('<strong>Show</strong> bookmarks in category:'); ?><br />
     96        </td>
     97        <td>
     98            <?php _e('<strong>Order</strong> by:');?>
     99        </td>
    278100        <td>&nbsp;</td>
    279101      </tr>
    280102      <tr>
    281103        <td>
    282 <?php
    283     $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
    284     echo "        <select name=\"cat_id\">\n";
    285     echo "          <option value=\"All\"";
    286     if ($cat_id == 'All')
    287       echo " selected='selected'";
    288     echo "> " . __('All') . "</option>\n";
    289     foreach ($results as $row) {
    290       echo "          <option value=\"".$row->cat_id."\"";
    291       if ($row->cat_id == $cat_id)
    292         echo " selected='selected'";
    293         echo ">".$row->cat_id.": ".wp_specialchars($row->cat_name);
    294         if ($row->auto_toggle == 'Y')
    295             echo ' '.__('(auto toggle)');
    296         echo "</option>\n";
    297     }
    298     echo "        </select>\n";
    299 ?>
    300         </td>
     104        <?php $categories = get_categories("hide_empty=1&type=link"); ?>
     105        <select name="cat_id">
     106            <option value="all" <?php echo ($cat_id == 'all') ? " selected='selected'" : ''; ?>><?php _e('All') ?></option>
     107            <?php foreach ($categories as $cat): ?>
     108            <option value="<?php echo $cat->cat_ID; ?>"<?php echo ($cat->cat_ID == $cat_id) ? " selected='selected'" : ''; ?>><?php echo wp_specialchars($cat->cat_name); ?>
     109            </option>
     110            <?php endforeach; ?>
     111            </select>
     112        </td>
     113        <td>
     114            <select name="order_by">
     115                <option value="order_id"     <?php if ($order_by == 'order_id')     echo " selected='selected'";?>><?php _e('Bookmark ID') ?></option>
     116                <option value="order_name"   <?php if ($order_by == 'order_name')   echo " selected='selected'";?>><?php _e('Name') ?></option>
     117                <option value="order_url"    <?php if ($order_by == 'order_url')    echo " selected='selected'";?>><?php _e('URI') ?></option>
     118                <option value="order_desc"   <?php if ($order_by == 'order_desc')   echo " selected='selected'";?>><?php _e('Description') ?></option>
     119            </select>
     120        </td>
     121        <td>
     122            <input type="submit" name="action" value="<?php _e('Show') ?>" />
     123        </td>
     124    </tr>
     125</table>
     126</form>
     127
     128<form name="links" id="links" method="post" action="link.php">
     129<input type="hidden" name="link_id" value="" />
     130<input type="hidden" name="action" value="" />
     131<input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
     132<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
     133<table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
     134    <tr>
     135        <th width="15%"><?php _e('Name') ?></th>
     136        <th><?php _e('URI') ?></th>
     137        <th><?php _e('Categories') ?></th>
     138        <th><?php _e('rel') ?></th>
     139        <th><?php _e('Visible') ?></th>
     140        <th colspan="2"><?php _e('Action') ?></th>
     141        <th>&nbsp;</th>
     142    </tr>
     143<?php
     144if ( 'all' == $cat_id )
     145    $cat_id = '';
     146$links = get_linkz("category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0");
     147if ($links)
     148    foreach ($links as $link) {
     149        $link->link_name = wp_specialchars($link->link_name);
     150        $link->link_description = wp_specialchars($link->link_description);
     151        $link->link_url = wp_specialchars($link->link_url);
     152        $link->link_category = wp_get_link_cats($link->link_id);
     153        $short_url = str_replace('http://', '', $link->link_url);
     154        $short_url = str_replace('www.', '', $short_url);
     155        if ('/' == substr($short_url, -1))
     156            $short_url = substr($short_url, 0, -1);
     157        if (strlen($short_url) > 35)
     158            $short_url = substr($short_url, 0, 32).'...';
     159
     160        $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
     161        ++ $i;
     162        $style = ($i % 2) ? '' : ' class="alternate"';
     163?>
     164    <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>>
     165        <td><strong><?php echo $link->link_name; ?></strong><br />
     166        <?php
     167
     168
     169        echo $link->link_description . "</td>";
     170        echo "<td><a href=\"$link->link_url\" title=\"".sprintf(__('Visit %s'), $link->link_name)."\">$short_url</a></td>";
     171        ?>
    301172        <td>
    302           <select name="order_by">
    303             <option value="order_id"     <?php if ($order_by == 'order_id')     echo " selected='selected'";?>><?php _e('Link ID') ?></option>
    304             <option value="order_name"   <?php if ($order_by == 'order_name')   echo " selected='selected'";?>><?php _e('Name') ?></option>
    305             <option value="order_url"    <?php if ($order_by == 'order_url')    echo " selected='selected'";?>><?php _e('URI') ?></option>
    306             <option value="order_desc"   <?php if ($order_by == 'order_desc')   echo " selected='selected'";?>><?php _e('Description') ?></option>
    307             <option value="order_owner"  <?php if ($order_by == 'order_owner')  echo " selected='selected'";?>><?php _e('Owner') ?></option>
    308             <option value="order_rating" <?php if ($order_by == 'order_rating') echo " selected='selected'";?>><?php _e('Rating') ?></option>
    309           </select>
    310         </td>
    311         <td>
    312           <input type="submit" name="action" value="<?php _e('Show') ?>" />
    313         </td>
    314       </tr>
    315     </table>
    316     </form>
    317 
    318 </div>
    319 
    320 <form name="links" id="links" method="post" action="">
    321 <div class="wrap">
    322 
    323     <input type="hidden" name="link_id" value="" />
    324     <input type="hidden" name="action" value="" />
    325     <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
    326     <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
    327   <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
    328     <tr>
    329       <th width="15%"><?php _e('Name') ?></th>
    330       <th><?php _e('URI') ?></th>
    331       <th><?php _e('Category') ?></th>
    332       <th><?php _e('rel') ?></th>
    333       <th><?php _e('Image') ?></th>
    334       <th><?php _e('Visible') ?></th>
    335       <th colspan="2"><?php _e('Action') ?></th>
    336       <th>&nbsp;</th>
    337   </tr>
    338 <?php
    339     $sql = "SELECT link_url, link_name, link_image, link_description, link_visible,
    340             link_category AS cat_id, cat_name AS category, $wpdb->users.user_login, link_id,
    341             link_rating, link_rel
    342             FROM $wpdb->links
    343             LEFT JOIN $wpdb->linkcategories ON $wpdb->links.link_category = $wpdb->linkcategories.cat_id
    344             LEFT JOIN $wpdb->users ON $wpdb->users.ID = $wpdb->links.link_owner ";
    345 
    346     if (isset($cat_id) && ($cat_id != 'All')) {
    347       $sql .= " WHERE link_category = $cat_id ";
    348     }
    349     $sql .= ' ORDER BY link_' . $sqlorderby;
    350 
    351     // echo "$sql";
    352     $links = $wpdb->get_results($sql);
    353     if ($links) {
    354         foreach ($links as $link) {
    355             $link->link_name = wp_specialchars($link->link_name);
    356             $link->link_category = wp_specialchars($link->link_category);
    357             $link->link_description = wp_specialchars($link->link_description);
    358             $link->link_url = wp_specialchars($link->link_url);
    359             $short_url = str_replace('http://', '', $link->link_url);
    360             $short_url = str_replace('www.', '', $short_url);
    361             if ('/' == substr($short_url, -1))
    362                 $short_url = substr($short_url, 0, -1);
    363             if (strlen($short_url) > 35)
    364                 $short_url =  substr($short_url, 0, 32).'...';
    365 
    366             $image = ($link->link_image != null) ? __('Yes') : __('No');
    367             $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
    368             ++$i;
    369             $style = ($i % 2) ? '' : ' class="alternate"';
    370 ?>
    371     <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>>
    372         <td><strong><?php echo $link->link_name; ?></strong><br />
    373 <?php
    374         echo sprintf(__('Description: %s'), $link->link_description) . "</td>";
    375         echo "<td><a href=\"$link->link_url\" title=\"" . sprintf(__('Visit %s'), $link->link_name) . "\">$short_url</a></td>";
    376         echo <<<LINKS
    377         <td>$link->category</td>
    378         <td>$link->link_rel</td>
    379         <td align='center'>$image</td>
    380         <td align='center'>$visible</td>
    381 LINKS;
    382             $show_buttons = 1; // default
    383 
    384             if ($show_buttons) {
    385         echo '<td><a href="link-manager.php?link_id=' . $link->link_id . '&amp;action=linkedit" class="edit">' . __('Edit') . '</a></td>';
    386         echo '<td><a href="link-manager.php?link_id=' . $link->link_id . '&amp;action=Delete"' .  " onclick=\"return deleteSomething( 'link', $link->link_id , '" . sprintf(__("You are about to delete the &quot;%s&quot; link to %s.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($link->link_name,1), wp_specialchars($link->link_url)) . '\' );" class="delete">' . __('Delete') . '</a></td>';
    387         echo '<td><input type="checkbox" name="linkcheck[]" value="' . $link->link_id . '" /></td>';
    388             } else {
    389               echo "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>\n";
    390             }
     173        <?php
     174
     175        $cat_names = array();
     176        foreach ($link->link_category as $category) {
     177            $cat_name = get_the_category_by_ID($category);
     178            $cat_names[] = wp_specialchars($cat_name);
     179        }
     180        echo implode(', ', $cat_names);
     181        ?>
     182        </td>
     183        <td><?php echo $link->link_rel; ?></td>
     184        <td align='center'><?php echo $visible; ?></td>
     185<?php
     186
     187        echo '<td><a href="link.php?link_id='.$link->link_id.'&amp;action=edit" class="edit">'.__('Edit').'</a></td>';
     188        echo '<td><a href="link.php?link_id='.$link->link_id.'&amp;action=delete"'." class='delete' onclick=\"return deleteSomething( 'link', $link->link_id , '".sprintf(__("You are about to delete the &quot;%s&quot; bookmark to %s.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($link->link_name, 1), wp_specialchars($link->link_url)).'\' );" class="delete">'.__('Delete').'</a></td>';
     189        echo '<td><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></td>';
    391190        echo "\n    </tr>\n";
    392         }
    393     }
     191    }
    394192?>
    395193</table>
     
    397195<div id="ajax-response"></div>
    398196
    399 </div>
    400 
    401 <div class="wrap">
    402   <table width="100%" cellpadding="3" cellspacing="3">
    403     <tr><th colspan="4"><?php _e('Manage Multiple Links:') ?></th></tr>
    404     <tr><td colspan="4"><?php _e('Use the checkboxes on the right to select multiple links and choose an action below:') ?></td></tr>
    405     <tr>
    406         <td>
    407           <?php _e('Assign ownership to:'); ?>
    408 <?php
    409     $results = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY ID");
    410     echo "          <select name=\"newowner\" size=\"1\">\n";
    411     foreach ($results as $row) {
    412       echo "            <option value=\"".$row->ID."\"";
    413       echo ">".$row->user_login;
    414       echo "</option>\n";
    415     }
    416     echo "          </select>\n";
    417 ?>
    418         <input name="assign" type="submit" id="assign" value="<?php _e('Go') ?>" />
    419         </td>
    420         <td>
    421           <input name="visibility" type="submit" id="visibility" value="<?php _e('Toggle Visibility') ?>" />
    422         </td>
    423         <td>
    424           <?php _e('Move to category:'); link_category_dropdown('category'); ?> <input name="move" type="submit" id="move" value="<?php _e('Go') ?>" />
    425         </td>
    426         <td align="right">
    427           <a href="#" onclick="checkAll(document.getElementById('links')); return false; "><?php _e('Toggle Checkboxes') ?></a>
    428         </td>
    429     </tr>
     197<table width="100%" cellpadding="3" cellspacing="3">
     198    <tr>
     199        <td>
     200            <p class="submit"><input type="submit" class="button" name="deletebookmarks" id="deletebookmarks" value="<?php _e('Delete Checked Bookmarks') ?>" onclick="return confirm('<?php _e("You are about to delete these bookmarks permanently \\n  \'Cancel\' to stop, \'OK\' to delete.") ?>')" /></p>
     201        </td>
     202        <td align="right">
     203            <a href="#" onclick="checkAll(document.getElementById('links')); return false; "><?php _e('Toggle Checkboxes') ?></a>
     204        </td>
     205    </tr>
    430206</table>
    431 
    432 <?php
    433   } // end if !popup
    434 ?>
    435207</div>
    436208</form>
    437209
    438 
    439 <?php
    440     break;
    441   } // end default
    442 } // end case
    443 ?>
    444 
    445210<?php include('admin-footer.php'); ?>
  • trunk/wp-admin/list-manipulation.php

    r3566 r3570  
    2323        die ('-1');
    2424
    25     if ( $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$id'") )
     25    if ( wp_delete_link($id) )
    2626        die('1');
    2727    else    die('0');
     
    8181    if ( 1 == $id )
    8282        die('0');
    83     if ( !current_user_can('manage_links') )
     83    if ( !current_user_can('manage_categories') )
    8484        die('-1');
    8585
    86     if ( $wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$id'") ) {
    87         $wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$id'");
     86    if ( wp_delete_category($id) ) {
    8887        die('1');
    8988    } else {
  • trunk/wp-admin/menu.php

    r3563 r3570  
    88$menu[5] = array(__('Write'), 'edit_posts', 'post-new.php');
    99$menu[10] = array(__('Manage'), 'edit_posts', 'edit.php');
    10 $menu[20] = array(__('Links'), 'manage_links', 'link-manager.php');
     10$menu[20] = array(__('Bookmarks'), 'manage_links', 'link-manager.php');
    1111$menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php');
    1212$menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
     
    2929$submenu['edit.php'][30] = array(__('Files'), 'edit_files', 'templates.php');
    3030
    31 $submenu['link-manager.php'][5] = array(__('Manage Links'), 'manage_links', 'link-manager.php');
    32 $submenu['link-manager.php'][10] = array(__('Add Link'), 'manage_links', 'link-add.php');
    33 $submenu['link-manager.php'][15] = array(__('Link Categories'), 'manage_links', 'link-categories.php');
    34 $submenu['link-manager.php'][20] = array(__('Import Links'), 'manage_links', 'link-import.php');
     31$submenu['link-manager.php'][5] = array(__('Manage Bookmarks'), 'manage_links', 'link-manager.php');
     32$submenu['link-manager.php'][10] = array(__('Add Bookmark'), 'manage_links', 'link-add.php');
     33$submenu['link-manager.php'][20] = array(__('Import Bookmarks'), 'manage_links', 'link-import.php');
    3534
    3635$submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
  • trunk/wp-admin/options-misc.php

    r3541 r3570  
    3636
    3737<p><input name="use_linksupdate" type="checkbox" id="use_linksupdate" value="1" <?php checked('1', get_settings('use_linksupdate')); ?> />
    38 <label for="use_linksupdate"><?php _e('Track Links&#8217; Update Times') ?></label></p>
     38<label for="use_linksupdate"><?php _e('Track Bookmarks&#8217; Update Times') ?></label></p>
    3939<p>
    4040<label><input type="checkbox" name="hack_file" value="1" <?php checked('1', get_settings('hack_file')); ?> /> <?php _e('Use legacy <code>my-hacks.php</code> file support') ?></label>
  • trunk/wp-admin/options-writing.php

    r3541 r3570  
    3636foreach ($categories as $category) :
    3737if ($category->cat_ID == get_settings('default_category')) $selected = " selected='selected'";
     38else $selected = '';
     39echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
     40endforeach;
     41?>
     42</select></td>
     43</tr>
     44<tr valign="top">
     45<th scope="row"><?php _e('Default bookmark category:') ?></th>
     46<td><select name="default_link_category" id="default_link_category">
     47<?php
     48foreach ($categories as $category) :
     49if ($category->cat_ID == get_settings('default_link_category')) $selected = " selected='selected'";
    3850else $selected = '';
    3951echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
     
    91103<p class="submit">
    92104<input type="hidden" name="action" value="update" />
    93 <input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,rich_editing,ping_sites,mailserver_url,mailserver_port,mailserver_login,mailserver_pass,default_category,default_email_category,use_balanceTags" />
     105<input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,rich_editing,ping_sites,mailserver_url,mailserver_port,mailserver_login,mailserver_pass,default_category,default_email_category,use_balanceTags,default_link_category" />
    94106<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
    95107</p>
  • trunk/wp-admin/upgrade-functions.php

    r3548 r3570  
    22
    33require_once(ABSPATH . '/wp-admin/admin-functions.php');
     4require_once(ABSPATH . '/wp-admin/admin-db.php');
    45require_once(ABSPATH . '/wp-admin/upgrade-schema.php');
    56// Functions to be called in install and upgrade scripts
     
    3435        upgrade_160();
    3536
    36     if ( $wp_current_db_version < 3548 )
     37    if ( $wp_current_db_version < 3570 )
    3738        upgrade_210();
    3839
     
    366367            foreach ( $posts as $post )
    367368                wp_schedule_event(mysql2date('U', $post->post_date), 'once', 'publish_future_post', $post->ID);
     369    }
     370    if ( $wp_current_db_version < 3570 ) {
     371        // Create categories for link categories if a category with the same
     372        // name doesn't exist.  Create a map of link cat IDs to cat IDs.
     373        $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories"); 
     374        foreach ( $link_cats as $link_cat) {
     375            if ( $cat_id = category_exists($link_cat->cat_name) ) {
     376                $link_cat_id_map[$link_cat->cat_id] = $cat_id;
     377                $default_link_cat = $cat_id;
     378            } else {
     379                $link_cat_id_map[$link_cat->cat_id] = wp_create_category($link_cat->cat_name);
     380                $default_link_cat = $link_cat_id_map[$link_cat->cat_id];
     381            }
     382        }
     383
     384        // Associate links to cats.
     385        $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
     386        foreach ( $links as $link ) {
     387            $link_cat = $link_cat_id_map[$link->link_category];
     388            $cat = $wpdb->get_row("SELECT * FROM $wpdb->link2cat WHERE link_id = '$link->link_id' AND category_id = '$link_cat'");
     389            if (!$cat && 0 != $link->link_category) {
     390                $wpdb->query("INSERT INTO $wpdb->link2cat (link_id, category_id)
     391                    VALUES ('$link->link_id', '$link_cat')");
     392            }           
     393        }
     394       
     395        // Set default to the last category we grabbed during the upgrade loop.
     396        update_option('default_link_category', $default_link_cat);
     397
     398        // Count links per category.
     399        if ( 0 == $wpdb->get_var("SELECT SUM(link_count) FROM $wpdb->categories") ) {
     400            $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
     401            foreach ( $categories as $cat_id ) {
     402                $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
     403                $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
     404            }
     405        }
    368406    }
    369407}
  • trunk/wp-admin/upgrade-schema.php

    r3548 r3570  
    99  category_parent bigint(20) NOT NULL default '0',
    1010  category_count bigint(20) NOT NULL default '0',
     11  link_count bigint(20) NOT NULL default '0',
     12  posts_private tinyint(1) NOT NULL default '0',
     13  links_private tinyint(1) NOT NULL default '0',
    1114  PRIMARY KEY  (cat_ID),
    1215  KEY category_nicename (category_nicename)
     
    3134  KEY comment_approved (comment_approved),
    3235  KEY comment_post_ID (comment_post_ID)
     36);
     37CREATE TABLE $wpdb->link2cat (
     38  rel_id bigint(20) NOT NULL auto_increment,
     39  link_id bigint(20) NOT NULL default '0',
     40  category_id bigint(20) NOT NULL default '0',
     41  PRIMARY KEY  (rel_id),
     42  KEY link_id (link_id,category_id)
    3343);
    3444CREATE TABLE $wpdb->linkcategories (
     
    232242    // 2.1
    233243    add_option('blog_public', 1);
     244    add_option('default_link_category', 2);
    234245
    235246    // Delete unused options
  • trunk/wp-admin/wp-admin.css

    r3517 r3570  
    463463
    464464#deletepost:hover {
     465    background: #ce0000;
     466    color: #fff;
     467}
     468
     469#deletebookmarks:hover {
    465470    background: #ce0000;
    466471    color: #fff;
  • trunk/wp-includes/functions.php

    r3566 r3570  
    24102410        return '';
    24112411}
     2412
     2413function bool_from_yn($yn) {
     2414    if ($yn == 'Y') return 1;
     2415    return 0;
     2416}
    24122417?>
  • trunk/wp-includes/links.php

    r2795 r3570  
    2929    global $wpdb;
    3030    $cat_id = -1;
    31     $results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
     31    $results = $wpdb->get_results("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'");
    3232    if ($results) {
    3333        foreach ($results as $result) {
    34             $cat_id = $result->cat_id;
     34            $cat_id = $result->cat_ID;
    3535        }
    3636    }
     
    3939}
    4040
    41 function bool_from_yn($yn) {
    42     if ($yn == 'Y') return 1;
    43     return 0;
    44 }
    45 
    4641/** function wp_get_linksbyname()
    4742 ** Gets the links associated with the named category.
     
    5247    global $wpdb;
    5348
    54     $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
    55                                                 . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
    56                                                 . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_name='$category'");
    57 
    58     if (! $cat) {
     49    $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category' LIMIT 1");
     50
     51    if (! $cat_id)
    5952        return;
    60     }
    61 
    62     if (empty($args)) {
    63         if ($cat->sort_desc == 'Y') {
    64             $cat->sort_order = '_'.$cat->sort_order;
    65         }
    66         get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all,
    67                             $cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order,
    68                             bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating),
    69                             $cat->list_limit, bool_from_yn($cat->show_updated));
    70     } else {
    71         $args = add_query_arg('category', $cat->cat_id, $args);
    72         wp_get_links($args);
    73     }
     53
     54    $args = add_query_arg('category', $cat_id, $args);
     55    wp_get_links($args);
    7456} // end wp_get_linksbyname
    7557
     
    8466    global $wpdb;
    8567
    86     if (!empty($args) && false === strpos($args, '=')) {
    87         // If args is not a query string, it's a category id.
    88         $category = $args;
    89         $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
    90                                                     . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
    91                                                     . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$category");
    92         if ($cat) {
    93             if ($cat->sort_desc == 'Y') {
    94                 $cat->sort_order = '_'.$cat->sort_order;
    95             }
    96             get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all,
    97                                 $cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order,
    98                                 bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating),
    99                                 $cat->list_limit, bool_from_yn($cat->show_updated));
    100         }
    101     } else {
    102         parse_str($args);
    103 
    104         if (! isset($category)) $category = -1;
    105         if (! isset($before)) $before = '';
    106         if (! isset($after)) $after = '<br />';
    107         if (! isset($between))  $between = ' ';
    108         if (! isset($show_images)) $show_images = true;
    109         if (! isset($orderby)) $orderby = 'name';
    110         if (! isset($show_description)) $show_description = true;
    111         if (! isset($show_rating)) $show_rating = false;
    112         if (! isset($limit)) $limit = -1;
    113         if (! isset($show_updated)) $show_updated = 1;
    114         if (! isset($echo)) $echo = true;
    115 
    116         return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo);
    117     }
     68    if ( empty($args) )
     69        return;
     70
     71    if ( false === strpos($args, '=') ) {
     72        $cat_id = $args;
     73        $args = add_query_arg('category', $cat_id, $args);
     74    }
     75
     76    parse_str($args);
     77
     78    if (! isset($category)) $category = -1;
     79    if (! isset($before)) $before = '';
     80    if (! isset($after)) $after = '<br />';
     81    if (! isset($between))  $between = ' ';
     82    if (! isset($show_images)) $show_images = true;
     83    if (! isset($orderby)) $orderby = 'name';
     84    if (! isset($show_description)) $show_description = true;
     85    if (! isset($show_rating)) $show_rating = false;
     86    if (! isset($limit)) $limit = -1;
     87    if (! isset($show_updated)) $show_updated = 1;
     88    if (! isset($echo)) $echo = true;
     89
     90    return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo);
    11891} // end wp_get_links
    11992
     
    155128    global $wpdb;
    156129
    157     $direction = ' ASC';
    158     $category_query = '';
    159     if ($category != -1) {
    160         $category_query = " AND link_category = $category ";
    161     }
    162     if (get_settings('links_recently_updated_time')) {
    163         $recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL " . get_settings('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated ";
    164     } else {
    165         $recently_updated_test = '';
    166     }
    167     if ($show_updated) {
    168         $get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f ";
    169     }
    170 
    171     $orderby = strtolower($orderby);
    172     if ($orderby == '')
    173         $orderby = 'id';
    174     if (substr($orderby, 0, 1) == '_') {
    175         $direction = ' DESC';
    176         $orderby = substr($orderby, 1);
    177     }
    178 
    179     switch($orderby) {
    180         case 'length':
    181         $length = ", CHAR_LENGTH(link_name) AS length";
    182         break;
    183         case 'rand':
    184             $orderby = 'rand()';
    185             break;
    186         default:
    187             $orderby = " link_" . $orderby;
    188     }
    189 
    190     if (!isset($length)) {
    191         $length = '';
    192     }
    193 
    194     $sql = "SELECT link_url, link_name, link_image, link_target, link_description, link_rating, link_rel $length $recently_updated_test $get_updated FROM $wpdb->links WHERE link_visible = 'Y' " . $category_query;
    195     $sql .= ' ORDER BY ' . $orderby . $direction;
    196     /* The next 2 lines implement LIMIT TO processing */
    197     if ($limit != -1)
    198         $sql .= " LIMIT $limit";
    199     $results = $wpdb->get_results($sql);
     130    $results = get_linkz("category=$category&orderby=$orderby&show_updated=$show_updated&limit=$limit");
     131
    200132    if (!$results) {
    201133        return;
    202134    }
     135
    203136
    204137    $output = '';
     
    291224 ** }
    292225 **/
     226// Deprecate in favor of get_linkz().
    293227function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
    294228    global $wpdb;
    295229    $cat_id = -1;
    296     $results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
     230    //$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
     231    // TODO: Fix me.
    297232    if ($results) {
    298233        foreach ($results as $result) {
     
    338273 ** link_notes
    339274 **/
     275// Deprecate in favor of get_linkz().
    340276function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
    341277    global $wpdb;
     
    446382 */
    447383function get_linkcatname($id = 0) {
    448     global $wpdb;
    449     $cat_name = '';
    450     if ('' != $id) {
    451         $cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->linkcategories WHERE cat_id=$id");
    452     }
    453     return $cat_name;
     384    if ( empty($id) )
     385        return '';
     386 
     387    $cats = wp_get_link_cats($id);
     388
     389    if ( empty($cats) || ! is_array($cats) )
     390        return '';
     391
     392    $cat_id = $cats[0]; // Take the first cat.
     393
     394    $cat = get_category($cat_id);
     395    return $cat->cat_name;
    454396}
    455397
     
    460402 */
    461403function get_autotoggle($id = 0) {
    462     global $wpdb;
    463     $auto_toggle = $wpdb->get_var("SELECT auto_toggle FROM $wpdb->linkcategories WHERE cat_id=$id");
    464     if ('' == $auto_toggle)
    465         $auto_toggle = 'N';
    466     return $auto_toggle;
     404    return 0; 
    467405}
    468406
     
    512450 */
    513451function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
    514     global $wpdb;
    515 
    516452    $order = strtolower($order);
    517453
    518454    // Handle link category sorting
     455    $direction = 'ASC';
    519456    if (substr($order,0,1) == '_') {
    520         $direction = ' DESC';
     457        $direction = 'DESC';
    521458        $order = substr($order,1);
    522459    }
    523460
    524     // if 'name' wasn't specified, assume 'id':
    525     $cat_order = ('name' == $order) ? 'cat_name' : 'cat_id';
    526 
    527461    if (!isset($direction)) $direction = '';
    528     // Fetch the link category data as an array of hashesa
    529     $cats = $wpdb->get_results("
    530         SELECT DISTINCT link_category, cat_name, show_images,
    531             show_description, show_rating, show_updated, sort_order,
    532             sort_desc, list_limit
    533         FROM `$wpdb->links`
    534         LEFT JOIN `$wpdb->linkcategories` ON (link_category = cat_id)
    535         WHERE link_visible =  'Y'
    536             AND list_limit <> 0
    537         ORDER BY $cat_order $direction ", ARRAY_A);
     462
     463    $cats = get_categories("type=link&orderby=$order&order=$direction");
    538464
    539465    // Display each category
     
    541467        foreach ($cats as $cat) {
    542468            // Handle each category.
    543             // First, fix the sort_order info
    544             $orderby = $cat['sort_order'];
    545             $orderby = (bool_from_yn($cat['sort_desc'])?'_':'') . $orderby;
    546469
    547470            // Display the category name
    548             echo '  <li id="linkcat-' . $cat['link_category'] . '"><h2>' . $cat['cat_name'] . "</h2>\n\t<ul>\n";
     471            echo '  <li id="linkcat-' . $cat->cat_ID . '"><h2>' . $cat->cat_name . "</h2>\n\t<ul>\n";
    549472            // Call get_links() with all the appropriate params
    550             get_links($cat['link_category'],
    551                 '<li>',"</li>","\n",
    552                 bool_from_yn($cat['show_images']),
    553                 $orderby,
    554                 bool_from_yn($cat['show_description']),
    555                 bool_from_yn($cat['show_rating']),
    556                 $cat['list_limit'],
    557                 bool_from_yn($cat['show_updated']));
     473            get_links($cat->cat_ID,
     474                '<li>',"</li>","\n");
    558475
    559476            // Close the last category
     
    563480}
    564481
     482function get_linkz($args = '') {
     483    global $wpdb;
     484
     485    parse_str($args, $r);
     486
     487    if ( !isset($r['orderby']) )
     488        $r['orderby'] = 'name';
     489    if ( !isset($r['order']) )
     490        $r['order'] = 'ASC';
     491    if ( !isset($r['limit']) )
     492        $r['limit'] = -1;
     493    if ( !isset($r['category']) )
     494        $r['category'] = -1;
     495    if ( !isset($r['category_name']) )
     496        $r['category_name'] = '';
     497    if ( !isset($r['hide_invisible']) )
     498        $r['hide_invisible'] = 1;
     499    if ( !isset($r['show_updated']) )
     500        $r['show_updated'] = 0;
     501
     502    $exclusions = '';
     503    if ( !empty($r['exclude']) ) {
     504        $exlinks = preg_split('/[\s,]+/',$r['exclude']);
     505        if ( count($exlinks) ) {
     506            foreach ( $exlinks as $exlink ) {
     507                $exclusions .= ' AND link_id <> ' . intval($exlink) . ' ';
     508            }
     509        }
     510    }
     511
     512    extract($r);
     513
     514    if ( ! empty($category_name) ) {
     515        if ( $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category_name' LIMIT 1") )
     516            $category = $cat_id;
     517    }
     518
     519    $category_query = '';
     520    $join = '';
     521    if ( $category != -1 && !empty($category) ) {
     522        $join = " LEFT JOIN $wpdb->link2cat ON ($wpdb->links.link_id = $wpdb->link2cat.link_id) ";
     523
     524        $category_query = " AND category_id = $category ";
     525    }
     526
     527    if (get_settings('links_recently_updated_time')) {
     528        $recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL " . get_settings('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated ";
     529    } else {
     530        $recently_updated_test = '';
     531    }
     532
     533    if ($show_updated) {
     534        $get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f ";
     535    }
     536
     537    $orderby = strtolower($r['orderby']);
     538    $length = '';
     539    switch ($orderby) {
     540        case 'length':
     541            $length = ", CHAR_LENGTH(link_name) AS length";
     542            break;
     543        case 'rand':
     544            $orderby = 'rand()';
     545            break;
     546        default:
     547            $orderby = "link_" . $orderby;
     548    }
     549
     550    if ( 'link_id' == $orderby )
     551        $orderby = "$wpdb->links.link_id";
     552
     553    $visible = '';
     554    if ( $hide_invisible )
     555        $visible = "AND link_visible = 'Y'";
     556
     557    $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query";
     558    $query .= " ORDER BY $orderby $order";
     559    if ($limit != -1)
     560        $query .= " LIMIT $limit";
     561
     562    return $wpdb->get_results($query);
     563}
    565564?>
  • trunk/wp-includes/template-functions-category.php

    r3540 r3570  
    411411}
    412412
     413function &get_categories($args = '') {
     414    global $wpdb, $category_links;
     415
     416    parse_str($args, $r);
     417
     418    if ( !isset($r['type']) )  // 'post' or 'link'
     419        $r['type'] = 'post';
     420    if ( !isset($r['child_of']) )
     421        $r['child_of'] = 0;
     422    if ( !isset($r['orderby']) )
     423        $r['orderby'] = 'name';
     424    if ( !isset($r['order']) )
     425        $r['order'] = 'ASC';
     426    if ( !isset($r['hide_empty']) )
     427        $r['hide_empty'] = true;
     428
     429    $r['orderby'] = "cat_" . $r['orderby'];
     430
     431    $exclusions = '';
     432    if ( !empty($r['exclude']) ) {
     433        $excategories = preg_split('/[\s,]+/',$r['exclude']);
     434        if ( count($excategories) ) {
     435            foreach ( $excategories as $excat ) {
     436                $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
     437            }
     438        }
     439    }
     440
     441    $categories = $wpdb->get_results("SELECT * " .
     442        "FROM $wpdb->categories " .
     443        "$exclusions " .
     444        "ORDER BY " . $r['orderby'] . " " . $r['order']);
     445
     446    if ( empty($categories) )
     447        return array();
     448
     449    if ( $r['hide_empty'] ) {
     450        foreach ( $categories as $category ) {
     451            $count = 0;
     452            if ( 'link' == $r['type'] ) {
     453                $count = $category->link_count;
     454            } else {
     455                $count = $category->category_count;
     456            }
     457            if ( $count )
     458                $the_categories[] = $category;
     459        }
     460        $categories = $the_categories;
     461    }
     462
     463    /* if ( $r['child_of'] )
     464        $categories = & get_category_children($r['child_of'], $categories); */
     465
     466    return $categories;
     467}
     468
    413469?>
  • trunk/wp-includes/version.php

    r3548 r3570  
    44
    55$wp_version = '2.1-alpha1';
    6 $wp_db_version = 3548;
     6$wp_db_version = 3570;
    77
    88?>
  • trunk/wp-settings.php

    r3561 r3570  
    7979$wpdb->post2cat         = $table_prefix . 'post2cat';
    8080$wpdb->comments         = $table_prefix . 'comments';
     81$wpdb->link2cat         = $table_prefix . 'link2cat';
    8182$wpdb->links            = $table_prefix . 'links';
    8283$wpdb->linkcategories   = $table_prefix . 'linkcategories';
     
    99100$tablepost2cat = $wpdb->post2cat;
    100101$tablecomments = $wpdb->comments;
     102$tablelink2cat = $wpdb->link2cat;
    101103$tablelinks = $wpdb->links;
    102104$tablelinkcategories = $wpdb->linkcategories;
Note: See TracChangeset for help on using the changeset viewer.