Make WordPress Core


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

Bookmark/link rework. #2499

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.