diff options
Diffstat (limited to 'wp-inst/wp-admin')
-rw-r--r-- | wp-inst/wp-admin/admin-db.php | 237 | ||||
-rw-r--r-- | wp-inst/wp-admin/admin-functions.php | 252 | ||||
-rw-r--r-- | wp-inst/wp-admin/categories.js | 10 | ||||
-rw-r--r-- | wp-inst/wp-admin/categories.php | 62 | ||||
-rw-r--r-- | wp-inst/wp-admin/edit-link-form.php | 490 | ||||
-rw-r--r-- | wp-inst/wp-admin/import.php | 124 | ||||
-rw-r--r-- | wp-inst/wp-admin/link-add.php | 7 | ||||
-rw-r--r-- | wp-inst/wp-admin/link-import.php | 18 | ||||
-rw-r--r-- | wp-inst/wp-admin/link-manager.php | 559 | ||||
-rw-r--r-- | wp-inst/wp-admin/upgrade-functions.php | 5 | ||||
-rw-r--r-- | wp-inst/wp-admin/upgrade-schema.php | 47 | ||||
-rw-r--r-- | wp-inst/wp-admin/wp-admin.css | 84 | ||||
-rw-r--r-- | wp-inst/wp-admin/wpmu-upgrade.inc.php | 32 |
13 files changed, 1017 insertions, 910 deletions
diff --git a/wp-inst/wp-admin/admin-db.php b/wp-inst/wp-admin/admin-db.php index 32b79f4..84d73fc 100644 --- a/wp-inst/wp-admin/admin-db.php +++ b/wp-inst/wp-admin/admin-db.php @@ -94,6 +94,9 @@ function wp_insert_category($catarr) { $cat_name = wp_specialchars($cat_name); + if ( !$update && category_exists($cat_name) ) + return 0; + if (empty ($category_nicename)) $category_nicename = sanitize_title($cat_name); else @@ -105,12 +108,22 @@ function wp_insert_category($catarr) { if (empty ($category_parent)) $category_parent = 0; + if ( isset($posts_private) ) + $posts_private = (int) $posts_private; + else + $posts_private = 0; + + if ( isset($links_private) ) + $links_private = (int) $links_private; + else + $links_private = 0; + if (!$update) { $maxcat = $wpdb->get_var( "SELECT max(cat_ID) FROM {$wpdb->categories}" ); $cat_ID = mt_rand( $maxcat+100, $maxcat+4000 ); - $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('$cat_ID', '$cat_name', '$category_nicename', '$category_description', '$category_parent')"); + $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('$cat_ID', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')"); } else { - $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'"); + $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'"); } if ( $category_nicename == '' ) { @@ -129,8 +142,6 @@ function wp_insert_category($catarr) { } $cat_ID = apply_filters( "cat_id_filter", $cat_ID ); - update_option( 'categories_last_updated', time() ); - return $cat_ID; } @@ -157,7 +168,10 @@ function wp_delete_category($cat_ID) { $cat_ID = (int) $cat_ID; // Don't delete the default cat. - if (1 == $cat_ID) + if ( $cat_ID == get_option('default_category') ) + return 0; + + if ( $cat_ID == get_option('default_link_category') ) return 0; $category = get_category($cat_ID); @@ -165,17 +179,37 @@ function wp_delete_category($cat_ID) { $parent = $category->category_parent; // Delete the category. - $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'"); + if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") ) + return 0; // Update children to point to new parent. $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'"); - // TODO: Only set categories to general if they're not in another category already - $wpdb->query("UPDATE $wpdb->post2cat SET category_id='1' WHERE category_id='$cat_ID'"); + // Only set posts and links to the default category if they're not in another category already. + $default_cat = get_option('default_category'); + $posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'"); + if ( is_array($posts) ) foreach ($posts as $post_id) { + $cats = wp_get_post_cats('', $post_id); + if ( 1 == count($cats) ) + $cats = array($default_cat); + else + $cats = array_diff($cats, array($cat_ID)); + wp_set_post_cats('', $post_id, $cats); + } + $default_link_cat = get_option('default_link_category'); + $links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'"); + if ( is_array($links) ) foreach ($links as $link_id) { + $cats = wp_get_link_cats($link_id); + if ( 1 == count($cats) ) + $cats = array($default_link_cat); + else + $cats = array_diff($cats, array($cat_ID)); + wp_set_link_cats($link_id, $cats); + } + wp_cache_delete($cat_ID, 'category'); wp_cache_delete('all_category_ids', 'category'); - update_option( 'categories_last_updated', time() ); do_action('delete_category', $cat_ID); @@ -244,10 +278,18 @@ function wp_delete_user($id, $reassign = 'novalue') { return true; } +function wp_revoke_user($id) { + $id = (int) $id; + + $user = new WP_User($id); + $user->remove_all_caps(); +} + function get_link($link_id, $output = OBJECT) { global $wpdb; $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = '$link_id'"); + $link->link_category = wp_get_link_cats($link_id); if ( $output == OBJECT ) { return $link; @@ -284,19 +326,26 @@ function wp_insert_link($linkdata) { if ( empty($link_notes) ) $link_notes = ''; + // Make sure we set a valid category + if (0 == count($link_category) || !is_array($link_category)) { + $link_category = array(get_option('default_link_category')); + } + if ( $update ) { $wpdb->query("UPDATE $wpdb->links SET link_url='$link_url', link_name='$link_name', link_image='$link_image', - link_target='$link_target', link_category='$link_category', + link_target='$link_target', link_visible='$link_visible', link_description='$link_description', link_rating='$link_rating', link_rel='$link_rel', link_notes='$link_notes', link_rss = '$link_rss' WHERE link_id='$link_id'"); } else { - $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')"); + $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')"); $link_id = $wpdb->insert_id; } + wp_set_link_cats($link_id, $link_category); + if ( $update ) do_action('edit_link', $link_id); else @@ -315,8 +364,16 @@ function wp_update_link($linkdata) { // Escape data pulled from DB. $link = add_magic_quotes($link); + // Passed link category list overwrites existing category list if not empty. + if ( isset($linkdata['link_category']) && is_array($linkdata['link_category']) + && 0 != count($linkdata['link_category']) ) + $link_cats = $linkdata['link_category']; + else + $link_cats = $link['link_category']; + // Merge old and new fields with new fields overwriting old ones. $linkdata = array_merge($link, $linkdata); + $linkdata['link_category'] = $link_cats; return wp_insert_link($linkdata); } @@ -325,9 +382,88 @@ function wp_delete_link($link_id) { global $wpdb; do_action('delete_link', $link_id); + + $categories = wp_get_link_cats($link_id); + if( is_array( $categories ) ) { + foreach ( $categories as $category ) { + $wpdb->query("UPDATE $wpdb->categories SET link_count = link_count - 1 WHERE cat_ID = '$category'"); + wp_cache_delete($category, 'category'); + } + } + + $wpdb->query("DELETE FROM $wpdb->link2cat WHERE link_id = '$link_id'"); return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'"); } +function wp_get_link_cats($link_ID = 0) { + global $wpdb; + + $sql = "SELECT category_id + FROM $wpdb->link2cat + WHERE link_id = $link_ID + ORDER BY category_id"; + + $result = $wpdb->get_col($sql); + + if ( !$result ) + $result = array(); + + return array_unique($result); +} + +function wp_set_link_cats($link_ID = 0, $link_categories = array()) { + global $wpdb; + // If $link_categories isn't already an array, make it one: + if (!is_array($link_categories) || 0 == count($link_categories)) + $link_categories = array(get_option('default_link_category')); + + $link_categories = array_unique($link_categories); + + // First the old categories + $old_categories = $wpdb->get_col(" + SELECT category_id + FROM $wpdb->link2cat + WHERE link_id = $link_ID"); + + if (!$old_categories) { + $old_categories = array(); + } else { + $old_categories = array_unique($old_categories); + } + + // Delete any? + $delete_cats = array_diff($old_categories,$link_categories); + + if ($delete_cats) { + foreach ($delete_cats as $del) { + $wpdb->query(" + DELETE FROM $wpdb->link2cat + WHERE category_id = $del + AND link_id = $link_ID + "); + } + } + + // Add any? + $add_cats = array_diff($link_categories, $old_categories); + + if ($add_cats) { + foreach ($add_cats as $new_cat) { + $wpdb->query(" + INSERT INTO $wpdb->link2cat (link_id, category_id) + VALUES ($link_ID, $new_cat)"); + } + } + + // Update category counts. + $all_affected_cats = array_unique(array_merge($link_categories, $old_categories)); + foreach ( $all_affected_cats as $cat_id ) { + $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'"); + $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'"); + wp_cache_delete($cat_id, 'category'); + } +} // wp_set_link_cats() + function post_exists($title, $content = '', $post_date = '') { global $wpdb; @@ -350,4 +486,83 @@ function comment_exists($comment_author, $comment_date) { WHERE comment_author = '$comment_author' AND comment_date = '$comment_date'"); } +function wpmu_delete_blog($blog_id, $drop = false) { + global $wpdb, $wpmuBaseTablePrefix; + + if ( $blog_id != $wpdb->blogid ) { + $switch = true; + switch_to_blog($blog_id); + } + + do_action('delete_blog', $blog_id, $drop); + + $users = get_users_of_blog($blog_id); + + // Remove users from this blog. + if ( !empty($users) ) foreach ($users as $user) { + remove_user_from_blog($user->user_id, $blog_id); + } + + update_blog_status( $wpdb->blogid, 'deleted', 1 ); + + if ( $drop ) { + $drop_tables = array( $wpmuBaseTablePrefix . $blog_id . "_categories", + $wpmuBaseTablePrefix . $blog_id . "_comments", + $wpmuBaseTablePrefix . $blog_id . "_linkcategories", + $wpmuBaseTablePrefix . $blog_id . "_links", + $wpmuBaseTablePrefix . $blog_id . "_link2cat", + $wpmuBaseTablePrefix . $blog_id . "_options", + $wpmuBaseTablePrefix . $blog_id . "_post2cat", + $wpmuBaseTablePrefix . $blog_id . "_postmeta", + $wpmuBaseTablePrefix . $blog_id . "_posts", + $wpmuBaseTablePrefix . $blog_id . "_referer_visitLog", + $wpmuBaseTablePrefix . $blog_id . "_referer_blacklist" ); + reset( $drop_tables ); + + while( list( $key, $val ) = each( $drop_tables ) ) + $wpdb->query( "DROP TABLE IF EXISTS $val" ); + + $wpdb->query( "DELETE FROM $wpdb->blogs WHERE blog_id = '$blog_id'" ); + } + + if ( $switch ) + restore_current_blog(); +} + +function wpmu_delete_user($id) { + global $wpdb; + + $id = (int) $id; + $user = get_userdata($id); + + do_action('wpmu_delete_user', $id); + + $blogs = get_blogs_of_user($id); + + if ( ! empty($blogs) ) foreach ($blogs as $blog) { + switch_to_blog($blog->userblog_id); + remove_user_from_blog($id, $blog->userblog_id); + + $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_author = $id"); + + if ($post_ids) { + foreach ($post_ids as $post_id) + wp_delete_post($post_id); + } + + // Clean links + $wpdb->query("DELETE FROM $wpdb->links WHERE link_owner = $id"); + + restore_current_blog(); + } + + $wpdb->query("DELETE FROM $wpdb->users WHERE ID = $id"); + $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$id'"); + + wp_cache_delete($id, 'users'); + wp_cache_delete($user->user_login, 'userlogins'); + + return true; +} + ?> diff --git a/wp-inst/wp-admin/admin-functions.php b/wp-inst/wp-admin/admin-functions.php index b33f94e..527df20 100644 --- a/wp-inst/wp-admin/admin-functions.php +++ b/wp-inst/wp-admin/admin-functions.php @@ -75,8 +75,8 @@ function write_post() { $hh = ($hh > 23) ? $hh -24 : $hh; $mn = ($mn > 59) ? $mn -60 : $mn; $ss = ($ss > 59) ? $ss -60 : $ss; - $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; - $_POST['post_date_gmt'] = get_gmt_from_date("$aa-$mm-$jj $hh:$mn:$ss"); + $_POST['post_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss); + $_POST['post_date_gmt'] = get_gmt_from_date($_POST['post_date']); } // Create the post. @@ -361,15 +361,38 @@ function get_category_to_edit($id) { return $category; } +function wp_dropdown_roles( $default = false ) { + global $wp_roles; + $r = ''; + foreach($wp_roles->role_names as $role => $name) + if ( $default == $role ) // Make default first in list + $p = "\n\t<option selected='selected' value='$role'>$name</option>"; + else + $r .= "\n\t<option value='$role'>$name</option>"; + echo $p . $r; +} + + // Creates a new user from the "Users" form using $_POST information. function add_user() { - return edit_user(); + if ( func_num_args() ) { // The hackiest hack that ever did hack + global $current_user, $wp_roles; + $user_id = func_get_arg(0); + if (isset ($_POST['role'])) { + if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users')) { + $user = new WP_User($user_id); + $user->set_role($_POST['role']); + } + } + } else { + add_action('user_register', 'add_user'); // See above + return edit_user(); + } } function edit_user($user_id = 0) { global $current_user, $wp_roles, $wpdb; - if ($user_id != 0) { $update = true; $user->ID = $user_id; @@ -417,49 +440,49 @@ function edit_user($user_id = 0) { if (isset ($_POST['yim'])) $user->yim = wp_specialchars(trim($_POST['yim'])); - $errors = array (); + $errors = new WP_Error(); /* checking that username has been typed */ if ($user->user_login == '') - $errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.'); + $errors->add('user_login', __('<strong>ERROR</strong>: Please enter a username.')); /* checking the password has been typed twice */ do_action('check_passwords', array ($user->user_login, & $pass1, & $pass2)); if (!$update) { if ($pass1 == '' || $pass2 == '') - $errors['pass'] = __('<strong>ERROR</strong>: Please enter your password twice.'); + $errors->add('pass', __('<strong>ERROR</strong>: Please enter your password twice.')); } else { if ((empty ($pass1) && !empty ($pass2)) || (empty ($pass2) && !empty ($pass1))) - $errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once."); + $errors->add('pass', __("<strong>ERROR</strong>: you typed your new password only once.")); } /* Check for "\" in password */ if( strpos( " ".$pass1, "\\" ) ) - $errors['pass'] = __('<strong>ERROR</strong>: Passwords may not contain the character "\\".'); + $errors->add('pass', __('<strong>ERROR</strong>: Passwords may not contain the character "\\".')); /* checking the password has been typed twice the same */ if ($pass1 != $pass2) - $errors['pass'] = __('<strong>ERROR</strong>: Please type the same password in the two password fields.'); + $errors->add('pass', __('<strong>ERROR</strong>: Please type the same password in the two password fields.')); if (!empty ($pass1)) $user->user_pass = $pass1; if ( !validate_username($user->user_login) ) - $errors['user_login'] = __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.'); + $errors->add('user_login', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.')); if (!$update && username_exists($user->user_login)) - $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.'); + $errors->add('user_login', __('<strong>ERROR</strong>: This username is already registered, please choose another one.')); /* checking e-mail address */ if (empty ($user->user_email)) { - $errors['user_email'] = __("<strong>ERROR</strong>: please type an e-mail address"); + $errors->add('user_email', __("<strong>ERROR</strong>: please type an e-mail address")); } else if (!is_email($user->user_email)) { - $errors['user_email'] = __("<strong>ERROR</strong>: the email address isn't correct"); + $errors->add('user_email', __("<strong>ERROR</strong>: the email address isn't correct")); } - if (count($errors) != 0) + if ( $errors->get_error_codes() ) return $errors; if ($update) { @@ -468,8 +491,7 @@ function edit_user($user_id = 0) { $user_id = wp_insert_user(get_object_vars($user)); wp_new_user_notification($user_id); } - - return $errors; + return $user_id; } @@ -481,6 +503,7 @@ function get_link_to_edit($link_id) { $link->link_description = wp_specialchars($link->link_description); $link->link_notes = wp_specialchars($link->link_notes); $link->link_rss = wp_specialchars($link->link_rss); + $link->post_category = $link->link_category; return $link; } @@ -514,14 +537,7 @@ function edit_link($link_id = '') { $_POST['link_name'] = wp_specialchars($_POST['link_name']); $_POST['link_image'] = wp_specialchars($_POST['link_image']); $_POST['link_rss'] = wp_specialchars($_POST['link_rss']); - $auto_toggle = get_autotoggle($_POST['link_category']); - - // if we are in an auto toggle category and this one is visible then we - // need to make the others invisible before we add this new one. - // FIXME Add category toggle func. - //if (($auto_toggle == 'Y') && ($link_visible == 'Y')) { - // $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category"); - //} + $_POST['link_category'] = $_POST['post_category']; if ( !empty($link_id) ) { $_POST['link_id'] = $link_id; @@ -553,7 +569,7 @@ function checked($checked, $current) { function return_categories_list($parent = 0) { global $wpdb; - return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC LIMIT 100"); + return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC"); } function sort_cats($cat1, $cat2) { @@ -561,7 +577,7 @@ function sort_cats($cat1, $cat2) { } function get_nested_categories($default = 0, $parent = 0) { - global $post_ID, $mode, $wpdb; + global $post_ID, $link_id, $mode, $wpdb; if ($post_ID) { $checked_categories = $wpdb->get_col(" @@ -574,7 +590,17 @@ function get_nested_categories($default = 0, $parent = 0) { // No selected categories, strange $checked_categories[] = $default; } + } else if ($link_id) { + $checked_categories = $wpdb->get_col(" + SELECT category_id + FROM $wpdb->categories, $wpdb->link2cat + WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id' + "); + if (count($checked_categories) == 0) { + // No selected categories, strange + $checked_categories[] = $default; + } } else { $checked_categories[] = $default; } @@ -584,6 +610,10 @@ function get_nested_categories($default = 0, $parent = 0) { if (is_array($cats)) { foreach ($cats as $cat) { + if ( $cat == 0 ) { // HACK, added 2006-05-13 + $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = 0"); + continue; + } $result[$cat]['children'] = get_nested_categories($default, $cat); $result[$cat]['cat_ID'] = $cat; $result[$cat]['checked'] = in_array($cat, $checked_categories); @@ -598,12 +628,12 @@ function get_nested_categories($default = 0, $parent = 0) { function write_nested_categories($categories) { foreach ($categories as $category) { - echo '<label for="category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label>\n"; + echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label></li>\n"; - if (isset ($category['children'])) { - echo "\n<span class='cat-nest'>\n"; + if ( $category['children'] ) { + echo "<ul>\n"; write_nested_categories($category['children']); - echo "</span>\n"; + echo "</ul>\n"; } } } @@ -621,15 +651,20 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) { if ($categories) { foreach ($categories as $category) { + if ( $category->cat_ID == 0 ) { // HACK, added 2006-05-13 + $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = 0"); + continue; + } if ($category->category_parent == $parent) { - $category->cat_name = wp_specialchars($category->cat_name); + $category->cat_name = wp_specialchars($category->cat_name,'double'); $pad = str_repeat('— ', $level); if ( current_user_can('manage_categories') ) { $edit = "<a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>"; $default_cat_id = get_option('default_category'); + $default_link_cat_id = get_option('default_link_category'); - if ($category->cat_ID != $default_cat_id) - $edit .= "<td><a href='categories.php?action=delete&cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category "%s". All of its posts will go to the default category.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars($category->cat_name, 1))."' );\" class='delete'>".__('Delete')."</a>"; + if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) ) + $edit .= "<td><a href='categories.php?action=delete&cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category "%s".\\nAll of its posts will go into the default category of "%s"\\nAll of its bookmarks will go into the default category of "%s".\\n"OK" to delete, "Cancel" to stop."), addslashes($category->cat_name), addslashes(wp_specialchars(get_catname($default_cat_id),'double')), addslashes(wp_specialchars(get_catname($default_link_cat_id),'double')))."' );\" class='delete'>".__('Delete')."</a>"; else $edit .= "<td style='text-align:center'>".__("Default"); } @@ -637,9 +672,13 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) { $edit = ''; $class = ('alternate' == $class) ? '' : 'alternate'; + + $category->category_count = number_format( $category->category_count ); + $category->link_count = number_format( $category->link_count ); echo "<tr id='cat-$category->cat_ID' class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td> <td>$category->category_description</td> - <td>$category->category_count</td> + <td align='center'>$category->category_count</td> + <td align='center'>$category->link_count</td> <td>$edit</td> </tr>"; cat_rows($category->cat_ID, $level +1, $categories); @@ -678,7 +717,7 @@ function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) { <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td> <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td> <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=edit&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td> - <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td> + <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), addslashes(wp_specialchars(get_the_title(),'double')) ) . "' );\">" . __('Delete') . "</a>"; } ?></td> </tr> <?php @@ -686,6 +725,33 @@ function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) { } } +function user_row( $user_object, $style = '' ) { + if ( !(is_object($user_object) && is_a($user_object, 'WP_User')) ) + $user_object = new WP_User( (int) $user_object ); + $email = $user_object->user_email; + $url = $user_object->user_url; + $short_url = str_replace('http://', '', $url); + $short_url = str_replace('www.', '', $short_url); + if ('/' == substr($short_url, -1)) + $short_url = substr($short_url, 0, -1); + if (strlen($short_url) > 35) + $short_url = substr($short_url, 0, 32).'...'; + $numposts = get_usernumposts($user_object->ID); + if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_object->ID' title='" . __('View posts') . "'>$numposts</a>"; + $r = "<tr id='user-$user_object->ID'$style> + <td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td> + <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td> + <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td> + <td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td> + <td><a href='$url' title='website: $url'>$short_url</a></td>"; + $r .= "\n\t\t<td align='right'>$numposts</td>"; + $r .= "\n\t\t<td>"; + if (current_user_can('edit_users')) + $r .= "<a href='user-edit.php?user_id=$user_object->ID' class='edit'>".__('Edit')."</a>"; + $r .= "</td>\n\t</tr>"; + return $r; +} + function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) { global $wpdb, $bgcolor; if (!$categories) { @@ -694,7 +760,6 @@ function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $lev if ($categories) { foreach ($categories as $category) { if ($currentcat != $category->cat_ID && $parent == $category->category_parent) { - $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID"); $pad = str_repeat('– ', $level); $category->cat_name = wp_specialchars($category->cat_name); echo "\n\t<option value='$category->cat_ID'"; @@ -709,21 +774,9 @@ function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $lev } } -function link_category_dropdown($fieldname, $selected = 0) { +function return_link_categories_list($parent = 0) { global $wpdb; - - $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id"); - echo "\n<select name='$fieldname' size='1'>\n"; - foreach ($results as $row) { - echo "\n\t<option value='$row->cat_id'"; - if ($row->cat_id == $selected) - echo " selected='selected'"; - echo ">$row->cat_id : " . wp_specialchars($row->cat_name); - if ($row->auto_toggle == 'Y') - echo ' (auto toggle)'; - echo "</option>"; - } - echo "\n</select>\n"; + return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC"); } function wp_create_thumbnail($file, $max_side, $effect = '') { @@ -816,6 +869,7 @@ function wp_create_thumbnail($file, $max_side, $effect = '') { if (!empty ($error)) { return $error; } else { + apply_filters( 'wp_create_thumbnail', $thumbpath ); return $thumbpath; } } @@ -835,19 +889,21 @@ function has_meta($postid) { function list_meta($meta) { global $post_ID; // Exit if no meta - if (!$meta) + if (!$meta) { + echo '<tbody id="the-list"></tbody>'; //TBODY needed for list-manipulation JS return; + } $count = 0; ?> -<table id='meta-list' cellpadding="3"> + <thead> <tr> <th><?php _e('Key') ?></th> <th><?php _e('Value') ?></th> <th colspan='2'><?php _e('Action') ?></th> </tr> + </thead> <?php - - + $r ="\n\t<tbody id='the-list'>"; foreach ($meta as $entry) { ++ $count; if ($count % 2) @@ -856,18 +912,20 @@ function list_meta($meta) { $style = ''; if ('_' == $entry['meta_key'] { 0 }) $style .= ' hidden'; - echo " - <tr class='$style'> - <td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td> - <td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td> - <td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br /> - <input name='deletemeta[{$entry['meta_id']}]' type='submit' class='deletemeta' tabindex='6' value='".__('Delete')."' /></td> - </tr> - "; - } - echo " - </table> - "; + $key_js = addslashes(wp_specialchars( $entry['meta_key'], 'double' )); + $entry['meta_key'] = wp_specialchars( $entry['meta_key'], true ); + $entry['meta_value'] = wp_specialchars( $entry['meta_value'], true ); + $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>"; + $r .= "\n\t\t<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>"; + $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>"; + $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br />"; + $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '"; + $r .= sprintf(__("You are about to delete the "%s" custom field on this post.\\n"OK" to delete, "Cancel" to stop."), $key_js); + $r .= "' );\" class='deletemeta' tabindex='6' value='".__('Delete')."' /></td>"; + $r .= "\n\t</tr>"; + } + echo $r; + echo "\n\t</tbody>"; } // Get a list of previously defined keys @@ -893,7 +951,7 @@ function meta_form() { LIMIT 10"); ?> <h3><?php _e('Add a new custom field:') ?></h3> -<table cellspacing="3" cellpadding="3"> +<table id="newmeta" cellspacing="3" cellpadding="3"> <tr> <th colspan="2"><?php _e('Key') ?></th> <th><?php _e('Value') ?></th> @@ -917,13 +975,14 @@ function meta_form() { </tr> </table> -<p class="submit"><input type="submit" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field »') ?>" /></p> +<p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field »') ?>" /></p> <?php } function add_meta($post_ID) { global $wpdb; + $post_ID = (int) $post_ID; $metakeyselect = $wpdb->escape(stripslashes(trim($_POST['metakeyselect']))); $metakeyinput = $wpdb->escape(stripslashes(trim($_POST['metakeyinput']))); @@ -933,7 +992,7 @@ function add_meta($post_ID) { // We have a key/value pair. If both the select and the // input for the key have data, the input takes precedence: - if ('#NONE#' != $metakeyselect) + if ('#NONE#' != $metakeyselect) $metakey = $metakeyselect; if ($metakeyinput) @@ -944,23 +1003,34 @@ function add_meta($post_ID) { (post_id,meta_key,meta_value) VALUES ('$post_ID','$metakey','$metavalue') "); + return $wpdb->insert_id; } + return false; } // add_meta function delete_meta($mid) { global $wpdb; + $mid = (int) $mid; - $result = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'"); + return $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'"); } function update_meta($mid, $mkey, $mvalue) { global $wpdb; + $mid = (int) $mid; return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'"); } +function get_post_meta_by_id($mid) { + global $wpdb; + $mid = (int) $mid; + + return $wpdb->get_row("SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'"); +} + function touch_time($edit = 1, $for_post = 1) { - global $month, $post, $comment; + global $wp_locale, $post, $comment; if ( $for_post ) $edit = ( ('draft' == $post->post_status) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date) ) ? false : true; @@ -976,29 +1046,25 @@ function touch_time($edit = 1, $for_post = 1) { $mn = ($edit) ? mysql2date('i', $post_date) : gmdate('i', $time_adj); $ss = ($edit) ? mysql2date('s', $post_date) : gmdate('s', $time_adj); - echo "<select name=\"mm\">\n"; + echo "<select name=\"mm\" onchange=\"edit_date.checked=true\">\n"; for ($i = 1; $i < 13; $i = $i +1) { echo "\t\t\t<option value=\"$i\""; if ($i == $mm) - echo " selected='selected'"; - if ($i < 10) { - $ii = "0".$i; - } else { - $ii = "$i"; - } - echo ">".$month["$ii"]."</option>\n"; + echo ' selected="selected"'; + echo '>' . $wp_locale->get_month($i) . "</option>\n"; } ?> </select> -<input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" /> -<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" /> @ -<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" /> : -<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" /> -<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" /> +<input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" onchange="edit_date.checked=true"/> +<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" onchange="edit_date.checked=true" /> @ +<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> : +<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> +<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> <?php if ( $edit ) { _e('Existing timestamp'); - echo ": {$month[$mm]} $jj, $aa @ $hh:$mn"; + //echo ': ' . $wp_locale->get_month($mm) . "$jj, $aa @ $hh:$mn"; + echo sprintf(__(': %1$s %2$s, %3$s @ %4$s:%5$s'), $wp_locale->get_month($mm), $jj, $aa, $hh, $mn); } ?> </fieldset> @@ -1023,11 +1089,15 @@ function insert_with_markers($filename, $marker, $insertion) { $foundit = false; if ($markerdata) { $state = true; - foreach ($markerdata as $markerline) { + foreach ($markerdata as $n => $markerline) { if (strstr($markerline, "# BEGIN {$marker}")) $state = false; - if ($state) - fwrite($f, "{$markerline}\n"); + if ($state) { + if ( $n + 1 < count($markerdata) ) + fwrite($f, "{$markerline}\n"); + else + fwrite($f, "{$markerline}"); + } if (strstr($markerline, "# END {$marker}")) { fwrite($f, "# BEGIN {$marker}\n"); if (is_array($insertion)) @@ -1829,8 +1899,10 @@ function wp_handle_upload(&$file, $overrides = false) { // Compute the URL $url = $uploads['url'] . "/$filename"; + + $return = apply_filters( 'wp_handle_upload', array('file' => $new_file, 'url' => $url, 'type' => $type) ); - return array('file' => $new_file, 'url' => $url, 'type' => $type); + return $return; } function wp_shrink_dimensions($width, $height, $wmax = 128, $hmax = 96) { diff --git a/wp-inst/wp-admin/categories.js b/wp-inst/wp-admin/categories.js index 5be5a62..46ae62f 100644 --- a/wp-inst/wp-admin/categories.js +++ b/wp-inst/wp-admin/categories.js @@ -1,5 +1,5 @@ -addLoadEvent(newCategoryAddIn); -function newCategoryAddIn() { - if (!theList.theList) return false; - document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); }; -} +addLoadEvent(newCategoryAddIn);
+function newCategoryAddIn() {
+ if (!theList.theList) return false;
+ document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); };
+}
diff --git a/wp-inst/wp-admin/categories.php b/wp-inst/wp-admin/categories.php index 8a96872..28d6925 100644 --- a/wp-inst/wp-admin/categories.php +++ b/wp-inst/wp-admin/categories.php @@ -3,7 +3,6 @@ require_once('admin.php'); $title = __('Categories'); $parent_file = 'edit.php'; -$list_js = true; $wpvarstoreset = array('action','cat'); for ($i=0; $i<count($wpvarstoreset); $i += 1) { @@ -25,6 +24,8 @@ switch($action) { case 'addcat': + check_admin_referer(); + if ( !current_user_can('manage_categories') ) die (__('Cheatin’ uh?')); @@ -43,13 +44,12 @@ case 'delete': $cat_ID = (int) $_GET['cat_ID']; $cat_name = get_catname($cat_ID); - $default_category = get_option( "default_category" ); - if ( $default_category == $cat_ID ) + // Don't delete the default cats. + if ( $cat_ID == get_option('default_category') ) die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name)); - $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories"); - if( count( $categories ) == 1 ) - die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the only one"), $cat_name)); + if ( $cat_ID == get_option('default_link_category') ) + die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one for bookmarks"), $cat_name)); wp_delete_category($cat_ID); @@ -69,27 +69,23 @@ case 'edit': <form name="editcat" action="categories.php" method="post"> <table class="editform" width="100%" cellspacing="2" cellpadding="5"> <tr> - <th width="33%" scope="row"><?php _e('Category name:') ?></th> - <td width="67%"><input name="cat_name" type="text" id='cat_name' value="<?php echo wp_specialchars($category->cat_name ); ?>" size="40" /> <input type="hidden" name="action" value="editedcat" /> + <th width="33%" scope="row" valign="top"><label for="cat_name"><?php _e('Category name:') ?></label></th> + <td width="67%"><input name="cat_name" id="cat_name" type="text" value="<?php echo wp_specialchars($category->cat_name); ?>" size="40" /> <input type="hidden" name="action" value="editedcat" /> <div style='display:none; height: 100px; width: 200px; overflow: auto; border: 1px solid #ccc; background: #eee; margin: 5px; padding: 5px;' id="searchresults"><?php _e( 'Search Results' ) ?></div> <?php AJAX_search_box( "wpmu-edit.php?action=searchcategories&search=", "cat_name", "searchresults" ); ?> <input type="hidden" name="cat_ID" value="<?php echo $category->cat_ID ?>" /></td> </tr> <tr> - <th scope="row"><?php _e('Category slug:') ?></th> - <td><input name="category_nicename" type="text" value="<?php echo wp_specialchars($category->category_nicename); ?>" size="40" /></td> - </tr> - <tr> <th scope="row"><?php _e('Category parent:') ?></th> <td> - <select name='category_parent'> + <select name='category_parent' id='category_parent'> <option value='0' <?php if (!$category->category_parent) echo " selected='selected'"; ?>><?php _e('None') ?></option> <?php wp_dropdown_cats($category->cat_ID, $category->category_parent); ?> </select></td> </tr> <tr> - <th scope="row"><?php _e('Description:') ?></th> - <td><textarea name="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->category_description, 1); ?></textarea></td> + <th scope="row" valign="top"><label for="category_description"><?php _e('Description:') ?></label></th> + <td><textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->category_description, 1); ?></textarea></td> </tr> </table> <p class="submit"><input type="submit" name="submit" value="<?php _e('Edit category »') ?>" /></p> @@ -101,13 +97,11 @@ case 'edit': break; case 'editedcat': + check_admin_referer(); + if ( !current_user_can('manage_categories') ) die (__('Cheatin’ uh?')); - if( $_POST[ 'cat_ID' ] == get_option( 'default_category' ) ) { - header( "Location: categories.php" ); - } - wp_update_category($_POST); header('Location: categories.php?message=3'); @@ -115,6 +109,7 @@ break; default: +$list_js = true; require_once ('admin-header.php'); $messages[1] = __('Category added.'); @@ -132,43 +127,49 @@ $messages[3] = __('Category updated.'); <?php else : ?> <h2><?php _e('Categories') ?> </h2> <?php endif; ?> -<table id="the-list-x" width="100%" cellpadding="3" cellspacing="3"> +<table width="100%" cellpadding="3" cellspacing="3"> + <thead> <tr> <th scope="col"><?php _e('ID') ?></th> <th scope="col"><?php _e('Name') ?></th> <th scope="col"><?php _e('Description') ?></th> - <th scope="col"><?php _e('# Posts') ?></th> + <th scope="col" width="90"><?php _e('Posts') ?></th> + <th scope="col" width="90"><?php _e('Bookmarks') ?></th> <th colspan="2"><?php _e('Action') ?></th> </tr> + </thead> + <tbody id="the-list"> <?php cat_rows(); ?> + </tbody> </table> -<div id="ajax-response"></div> - </div> <?php if ( current_user_can('manage_categories') ) : ?> <div class="wrap"> -<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> +<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> +<p><?php _e('<strong>Also Note:</strong><br />Categories will appear on your blog once you have posted something in them. Empty categories remain invisible.'); ?></p> </div> <div class="wrap"> <h2><?php _e('Add New Category') ?></h2> <form name="addcat" id="addcat" action="categories.php" method="post"> - - <p><?php _e('Name:') ?><br /> - <input type="text" name="cat_name" id='cat_name' value="" /></p> + <div class="alignleft"><?php _e('Name:') ?><br /> + <input type="text" name="cat_name" id="cat_name" value="" /></p> <div style='display:none; height: 100px; width: 200px; overflow: auto; border: 1px solid #ccc; background: #eee; margin: 5px; padding: 5px;' id="searchresults"><?php _e( 'Search Results' ) ?></div> <?php AJAX_search_box( "wpmu-edit.php?action=searchcategories&search=", "cat_name", "searchresults" ); ?> <p><?php _e('Category parent:') ?><br /> - <select name='category_parent' class='postform'> + <select name='category_parent' id='category_parent' class='postform'> <option value='0'><?php _e('None') ?></option> <?php wp_dropdown_cats(0); ?> - </select></p> + </select> + </div> + <div id="ajax-response" class="alignleft"></div> + <br class="clear" /> <p><?php _e('Description: (optional)') ?> <br /> - <textarea name="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p> + <textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p> <p class="submit"><input type="hidden" name="action" value="addcat" /><input type="submit" name="submit" value="<?php _e('Add Category »') ?>" /></p> </form> </div> @@ -179,4 +180,5 @@ break; } include('admin-footer.php'); + ?> diff --git a/wp-inst/wp-admin/edit-link-form.php b/wp-inst/wp-admin/edit-link-form.php index 8a049b7..b2d60c8 100644 --- a/wp-inst/wp-admin/edit-link-form.php +++ b/wp-inst/wp-admin/edit-link-form.php @@ -1,236 +1,254 @@ -<?php -if ( ! empty($link_id) ) { - $editing = true; - $heading = __('Edit a link:'); - $submit_text = __('Save Changes »'); - $form = '<form action="" method="post" name="editlink" id="editlink">'; -} else { - $editing = false; - $heading = __('<strong>Add</strong> a link:'); - $submit_text = __('Add Link »'); - $form = '<form name="addlink" method="post" action="link-manager.php">'; -} - -function xfn_check($class, $value = '', $type = 'check') { - global $link; - - $link_rel = $link->link_rel; - $rels = preg_split('/\s+/', $link_rel); - - if ('' != $value && in_array($value, $rels) ) { - echo ' checked="checked"'; - } - - if ('' == $value) { - if ('family' == $class && !strstr($link_rel, 'child') && !strstr($link_rel, 'parent') && !strstr($link_rel, 'sibling') && !strstr($link_rel, 'spouse') && !strstr($link_rel, 'kin')) echo ' checked="checked"'; - if ('friendship' == $class && !strstr($link_rel, 'friend') && !strstr($link_rel, 'acquaintance') && !strstr($link_rel, 'contact') ) echo ' checked="checked"'; - if ('geographical' == $class && !strstr($link_rel, 'co-resident') && !strstr($link_rel, 'neighbor') ) echo ' checked="checked"'; - if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"'; - } -} - -?> - -<div class="wrap"> - <?php echo $form ?> - <h2><?php echo $heading ?></h2> -<fieldset class="options"> - <legend><?php _e('Basics') ?></legend> - <table class="editform" width="100%" cellspacing="2" cellpadding="5"> - <tr> - <th width="33%" scope="row"><?php _e('URI:') ?></th> - <td width="67%"><input type="text" name="link_url" value="<?php echo $link->link_url; ?>" style="width: 95%;" /></td> - </tr> - <tr> - <th scope="row"><?php _e('Link Name:') ?></th> - <td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td> - </tr> - <tr> - <th scope="row"><?php _e('Short description:') ?></th> - <td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td> - </tr> - <tr> - <th scope="row"><?php _e('Category:') ?></th> - <td><?php link_category_dropdown('link_category', $link->link_category); ?></td> - </tr> -</table> -</fieldset> - <p class="submit"> - <input type="submit" name="submit" value="<?php echo $submit_text ?>" /> - </p> - <fieldset class="options"> - <legend><?php _e('Link Relationship (XFN)') ?></legend> - <table class="editform" width="100%" cellspacing="2" cellpadding="5"> - <tr> - <th width="33%" scope="row"><?php _e('rel:') ?></th> - <td width="67%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td> - </tr> - <tr> - <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th> - <td> - <table cellpadding="3" cellspacing="5"> - <tr> - <th scope="row"> <?php _e('identity') ?> </th> - <td> - <label for="me"> - <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> /> - <?php _e('another web address of mine') ?></label> - </td> - </tr> - <tr> - <th scope="row"> <?php _e('friendship') ?> </th> - <td> - <label for="contact"> - <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label> - <label for="acquaintance"> - <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> /> <?php _e('acquaintance') ?></label> - <label id="friend"> - <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label> - <label for="friendship"> - <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label> - </td> - </tr> - <tr> - <th scope="row"> <?php _e('physical') ?> </th> - <td> - <label for="met"> - <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> /> - <?php _e('met') ?></label> - </td> - </tr> - <tr> - <th scope="row"> <?php _e('professional') ?> </th> - <td> - <label for="co-worker"> - <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> /> - <?php _e('co-worker') ?></label> - <label for="colleague"> - <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> /> - <?php _e('colleague') ?></label> - </td> - </tr> - <tr> - <th scope="row"> <?php _e('geographical') ?> </th> - <td> - <label for="co-resident"> - <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> /> - <?php _e('co-resident') ?></label> - <label for="neighbor"> - <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> /> - <?php _e('neighbor') ?></label> - <label for="geographical"> - <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> /> - <?php _e('none') ?></label> - </td> - </tr> - <tr> - <th scope="row"> <?php _e('family') ?> </th> - <td> - <label for="child"> - <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?> /> - <?php _e('child') ?></label> - <label for="kin"> - <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?> /> - <?php _e('kin') ?></label> - <label for="parent"> - <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> /> - <?php _e('parent') ?></label> - <label for="sibling"> - <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> /> - <?php _e('sibling') ?></label> - <label for="spouse"> - <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> /> - <?php _e('spouse') ?></label> - <label for="family"> - <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> /> - <?php _e('none') ?></label> - </td> - </tr> - <tr> - <th scope="row"> <?php _e('romantic') ?> </th> - <td> - <label for="muse"> - <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> /> - <?php _e('muse') ?></label> - <label for="crush"> - <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> /> - <?php _e('crush') ?></label> - <label for="date"> - <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> /> - <?php _e('date') ?></label> - <label for="romantic"> - <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> /> - <?php _e('sweetheart') ?></label> - </td> - </tr> - </table> - </td> - </tr> -</table> -</fieldset> - <p class="submit"> - <input type="submit" name="submit" value="<?php echo $submit_text ?>" /> - </p> -<fieldset class="options"> - <legend><?php _e('Advanced') ?></legend> - <table class="editform" width="100%" cellspacing="2" cellpadding="5"> - <tr> - <th width="33%" scope="row"><?php _e('Image URI:') ?></th> - <td width="67%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td> - </tr> -<tr> - <th scope="row"><?php _e('RSS URI:') ?> </th> - <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td> - </tr> - <tr> - <th scope="row"><?php _e('Notes:') ?></th> - <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td> - </tr> - <tr> - <th scope="row"><?php _e('Rating:') ?></th> - <td><select name="link_rating" size="1"> -<?php - for ($r = 0; $r < 10; $r++) { - echo(' <option value="'.$r.'" '); - if ($link->link_rating == $r) - echo 'selected="selected"'; - echo('>'.$r.'</option>'); - } -?> - </select> - <?php _e('(Leave at 0 for no rating.)') ?> </td> - </tr> - <tr> - <th scope="row"><?php _e('Target') ?></th> - <td><label> - <input type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> /> - <code>_blank</code></label><br /> -<label> -<input type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> /> -<code>_top</code></label><br /> -<label> -<input type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> /> -<?php _e('none') ?></label><br /> -<?php _e('(Note that the <code>target</code> attribute is illegal in XHTML 1.1 and 1.0 Strict.)') ?></td> - </tr> - <tr> - <th scope="row"><?php _e('Visible:') ?></th> - <td><label> - <input type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" /> -<?php _e('Yes') ?></label><br /><label> -<input type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" /> -<?php _e('No') ?></label></td> - </tr> -</table> -</fieldset> -<p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p> -<?php if ( $editing ) : ?> - <input type="hidden" name="action" value="editlink" /> - <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" /> - <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" /> - <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> -<?php else: ?> - <input type="hidden" name="action" value="Add" /> -<?php endif; ?> -</form> -</div> +<?php
+if ( ! empty($link_id) ) {
+ $heading = __('Edit Bookmark');
+ $submit_text = __('Save Changes »');
+ $form = '<form name="editlink" id="editlink" method="post" action="link.php">';
+} else {
+ $heading = __('Create Bookmark');
+ $submit_text = __('Add Bookmark »');
+ $form = '<form name="addlink" id="addlink" method="post" action="link.php">';
+}
+
+function xfn_check($class, $value = '', $type = 'check') {
+ global $link;
+
+ $link_rel = $link->link_rel;
+ $rels = preg_split('/\s+/', $link_rel);
+
+ if ('' != $value && in_array($value, $rels) ) {
+ echo ' checked="checked"';
+ }
+
+ if ('' == $value) {
+ if ('family' == $class && !strstr($link_rel, 'child') && !strstr($link_rel, 'parent') && !strstr($link_rel, 'sibling') && !strstr($link_rel, 'spouse') && !strstr($link_rel, 'kin')) echo ' checked="checked"';
+ if ('friendship' == $class && !strstr($link_rel, 'friend') && !strstr($link_rel, 'acquaintance') && !strstr($link_rel, 'contact') ) echo ' checked="checked"';
+ if ('geographical' == $class && !strstr($link_rel, 'co-resident') && !strstr($link_rel, 'neighbor') ) echo ' checked="checked"';
+ if ('identity' == $class && in_array('me', $rels) ) echo ' checked="checked"';
+ }
+}
+?>
+
+<div class="wrap">
+<h2><?php echo $heading ?></h2>
+<?php echo $form ?>
+
+<div id="poststuff">
+<div id="moremeta">
+<div id="grabit" class="dbx-group">
+
+<fieldset id="categorydiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
+<div class="dbx-content">
+<p id="jaxcat"></p>
+<ul id="categorychecklist"><?php dropdown_categories(get_settings('default_link_category')); ?></ul>
+</div>
+</fieldset>
+
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Target') ?></h3>
+<div class="dbx-content">
+<label for="link_target_blank" class="selectit">
+<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
+<code>_blank</code></label>
+<label for="link_target_top" class="selectit">
+<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
+<code>_top</code></label>
+<label for="link_target_none" class="selectit">
+<input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
+<?php _e('none') ?></label>
+</div>
+</fieldset>
+
+<fieldset class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Visible') ?></h3>
+<div class="dbx-content">
+<label for="link_visible_yes" class="selectit">
+<input id="link_visible_yes" type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
+<?php _e('Yes') ?></label>
+<label for="link_visible_no" class="selectit">
+<input id="link_visible_no" type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" />
+<?php _e('No') ?></label>
+</div>
+</fieldset>
+
+</div>
+</div>
+
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+<tr>
+<th width="20%" scope="row" valign="top"><label for="link_url"><?php _e('URI:') ?></label></th>
+<td width="80%"><input type="text" name="link_url" value="<?php echo $link->link_url; ?>" style="width: 95%" /></td>
+</tr>
+<tr>
+<th scope="row" valign="top"><label for="link_name"><?php _e('Name:') ?></label></th>
+<td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
+</tr>
+<tr>
+<th scope="row" valign="top"><label for="link_description"><?php _e('Description:') ?></label></th>
+<td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
+</tr>
+</table>
+
+<p class="submit">
+<input type="submit" name="submit" value="<?php echo $submit_text ?>" />
+</p>
+
+<div id="advancedstuff" class="dbx-group" >
+
+<fieldset id="xfn" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Link Relationship (XFN)') ?></h3>
+<div class="dbx-content">
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="20%" scope="row"><?php _e('rel:') ?></th>
+ <td width="80%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th>
+ <td>
+ <table cellpadding="3" cellspacing="5">
+ <tr>
+ <th scope="row"> <?php _e('identity') ?> </th>
+ <td>
+ <label for="me">
+ <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
+ <?php _e('another web address of mine') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('friendship') ?> </th>
+ <td>
+ <label for="contact">
+ <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
+ <label for="acquaintance">
+ <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> /> <?php _e('acquaintance') ?></label>
+ <label id="friend">
+ <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
+ <label for="friendship">
+ <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('physical') ?> </th>
+ <td>
+ <label for="met">
+ <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
+ <?php _e('met') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('professional') ?> </th>
+ <td>
+ <label for="co-worker">
+ <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
+ <?php _e('co-worker') ?></label>
+ <label for="colleague">
+ <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
+ <?php _e('colleague') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('geographical') ?> </th>
+ <td>
+ <label for="co-resident">
+ <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
+ <?php _e('co-resident') ?></label>
+ <label for="neighbor">
+ <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
+ <?php _e('neighbor') ?></label>
+ <label for="geographical">
+ <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
+ <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('family') ?> </th>
+ <td>
+ <label for="child">
+ <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?> />
+ <?php _e('child') ?></label>
+ <label for="kin">
+ <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?> />
+ <?php _e('kin') ?></label>
+ <label for="parent">
+ <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
+ <?php _e('parent') ?></label>
+ <label for="sibling">
+ <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
+ <?php _e('sibling') ?></label>
+ <label for="spouse">
+ <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
+ <?php _e('spouse') ?></label>
+ <label for="family">
+ <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
+ <?php _e('none') ?></label>
+ </td>
+ </tr>
+ <tr>
+ <th scope="row"> <?php _e('romantic') ?> </th>
+ <td>
+ <label for="muse">
+ <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
+ <?php _e('muse') ?></label>
+ <label for="crush">
+ <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
+ <?php _e('crush') ?></label>
+ <label for="date">
+ <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
+ <?php _e('date') ?></label>
+ <label for="romantic">
+ <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
+ <?php _e('sweetheart') ?></label>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+</div>
+</fieldset>
+
+<fieldset id="advanced" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Advanced') ?></h3>
+<div class="dbx-content">
+<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+ <tr>
+ <th width="20%" scope="row"><?php _e('Image URI:') ?></th>
+ <td width="80%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('RSS URI:') ?> </th>
+ <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Notes:') ?></th>
+ <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td>
+ </tr>
+ <tr>
+ <th scope="row"><?php _e('Rating:') ?></th>
+ <td><select name="link_rating" size="1">
+ <?php
+ for ($r = 0; $r < 10; $r++) {
+ echo(' <option value="'.$r.'" ');
+ if ($link->link_rating == $r)
+ echo 'selected="selected"';
+ echo('>'.$r.'</option>');
+ }
+ ?></select> <?php _e('(Leave at 0 for no rating.)') ?>
+ </td>
+ </tr>
+</table>
+</fieldset>
+</div>
+
+<?php if ( $link_id ) : ?>
+<input type="hidden" name="action" value="save" />
+<input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
+<input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
+<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
+<?php else: ?>
+<input type="hidden" name="action" value="add" />
+<?php endif; ?>
+</div>
+</form>
+</div>
diff --git a/wp-inst/wp-admin/import.php b/wp-inst/wp-admin/import.php index 2ed94ee..743da65 100644 --- a/wp-inst/wp-admin/import.php +++ b/wp-inst/wp-admin/import.php @@ -1,62 +1,62 @@ -<?php -require_once ('admin.php'); -$title = __('Import'); -$parent_file = 'import.php'; -require_once ('admin-header.php'); -?> - -<div class="wrap"> -<h2><?php _e('Import'); ?></h2> -<p><?php _e('If you have posts or comments in another system WordPress can import them into your current blog. To get started, choose a system to import from below:'); ?></p> - -<?php - -// Load all importers so that they can register. -$import_loc = 'wp-admin/import'; -$import_root = ABSPATH.$import_loc; -$imports_dir = @ dir($import_root); -if ($imports_dir) { - while (($file = $imports_dir->read()) !== false) { - if (preg_match('|^\.+$|', $file)) - continue; - if (preg_match('|\.php$|', $file)) - require_once("$import_root/$file"); - } -} - -$importers = get_importers(); - -if (empty ($importers)) { - echo '<p>'.__('No importers are available.').'</p>'; // TODO: make more helpful -} else { -?> -<table width="100%" cellpadding="3" cellspacing="3"> - -<?php - $style = ''; - foreach ($importers as $id => $data) { - $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate'; - $action = "<a href='admin.php?import=$id' title='{$data[1]}'>{$data[0]}</a>"; - - if ($style != '') - $style = 'class="'.$style.'"'; - echo " - <tr $style> - <td class=\"togl\">$action</td> - <td class=\"desc\">{$data[1]}</td> - </tr>"; - } -?> - -</table> -<?php -} -?> - -</div> - -<?php - -include ('admin-footer.php'); -?> - +<?php
+require_once ('admin.php');
+$title = __('Import');
+$parent_file = 'import.php';
+require_once ('admin-header.php');
+?>
+
+<div class="wrap">
+<h2><?php _e('Import'); ?></h2>
+<p><?php _e('If you have posts or comments in another system WordPress can import them into your current blog. To get started, choose a system to import from below:'); ?></p>
+
+<?php
+
+// Load all importers so that they can register.
+$import_loc = 'wp-admin/import';
+$import_root = ABSPATH.$import_loc;
+$imports_dir = @ dir($import_root);
+if ($imports_dir) {
+ while (($file = $imports_dir->read()) !== false) {
+ if (preg_match('|^\.+$|', $file))
+ continue;
+ if (preg_match('|\.php$|', $file))
+ require_once("$import_root/$file");
+ }
+}
+
+$importers = get_importers();
+
+if (empty ($importers)) {
+ echo '<p>'.__('No importers are available.').'</p>'; // TODO: make more helpful
+} else {
+?>
+<table width="100%" cellpadding="3" cellspacing="3">
+
+<?php
+ $style = '';
+ foreach ($importers as $id => $data) {
+ $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate';
+ $action = "<a href='admin.php?import=$id' title='{$data[1]}'>{$data[0]}</a>";
+
+ if ($style != '')
+ $style = 'class="'.$style.'"';
+ echo "
+ <tr $style>
+ <td class=\"togl\">$action</td>
+ <td class=\"desc\">{$data[1]}</td>
+ </tr>";
+ }
+?>
+
+</table>
+<?php
+}
+?>
+
+</div>
+
+<?php
+
+include ('admin-footer.php');
+?>
+
diff --git a/wp-inst/wp-admin/link-add.php b/wp-inst/wp-admin/link-add.php index 8a6553a..8f8f9f3 100644 --- a/wp-inst/wp-admin/link-add.php +++ b/wp-inst/wp-admin/link-add.php @@ -1,7 +1,7 @@ <?php require_once('admin.php'); -$title = __('Add Link'); +$title = __('Add Bookmark'); $this_file = 'link-manager.php'; $parent_file = 'link-manager.php'; @@ -26,11 +26,12 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) { } $xfn_js = true; +$editing = true; require('admin-header.php'); ?> <?php if ($_GET['added']) : ?> -<div id="message" class="updated fade"><p><?php _e('Link added.'); ?></p></div> +<div id="message" class="updated fade"><p><?php _e('Bookmark added.'); ?></p></div> <?php endif; ?> <?php @@ -39,7 +40,7 @@ require('admin-header.php'); ?> <div class="wrap"> -<?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’re on to your links! Right now this only works on Mozilla or Netscape, but we’re working on it.</p>'), "javascript:void(linkmanpopup=window.open('" . get_settings('siteurl') . "/wp-admin/link-add.php?action=popup&linkurl='+escape(location.href)+'&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();") ?> +<?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’re on to your bookmarks! Right now this only works on Mozilla or Netscape, but we’re working on it.</p>'), "javascript:void(linkmanpopup=window.open('" . get_settings('siteurl') . "/wp-admin/link-add.php?action=popup&linkurl='+escape(location.href)+'&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();") ?> </div> <?php diff --git a/wp-inst/wp-admin/link-import.php b/wp-inst/wp-admin/link-import.php index 58e58f8..73a7ae1 100644 --- a/wp-inst/wp-admin/link-import.php +++ b/wp-inst/wp-admin/link-import.php @@ -25,7 +25,7 @@ switch ($step) { <h2><?php _e('Import your blogroll from another system') ?> </h2> <form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll"> -<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.'); ?> +<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.'); ?> <div style="width: 70%; margin: auto; height: 8em;"> <input type="hidden" name="step" value="1" /> <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> @@ -42,13 +42,13 @@ switch ($step) { </div> -<p style="clear: both; margin-top: 1em;"><?php _e('Now select a category you want to put these links in.') ?><br /> +<p style="clear: both; margin-top: 1em;"><?php _e('Now select a category you want to put these bookmarks in.') ?><br /> <?php _e('Category:') ?> <select name="cat_id"> <?php -$categories = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id"); +$categories = get_categories('hide_empty=0'); foreach ($categories as $category) { ?> -<option value="<?php echo $category->cat_id; ?>"><?php echo $category->cat_id.': '.$category->cat_name; ?></option> +<option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars($category->cat_name); ?></option> <?php } // end foreach ?> @@ -63,6 +63,8 @@ foreach ($categories as $category) { } // end case 0 case 1: { + check_admin_referer(); + include_once('admin-header.php'); if ( !current_user_can('manage_links') ) die (__("Cheatin' uh ?")); @@ -103,14 +105,12 @@ foreach ($categories as $category) { $titles[$i] = ''; if ('http' == substr($titles[$i], 0, 4)) $titles[$i] = ''; - // FIXME: Use wp_insert_link(). - $query = "INSERT INTO $wpdb->links (link_url, link_name, link_target, link_category, link_description, link_owner, link_rss) - VALUES('{$urls[$i]}', '".$wpdb->escape($names[$i])."', '', $cat_id, '".$wpdb->escape($descriptions[$i])."', $user_ID, '{$feeds[$i]}')\n"; - $result = $wpdb->query($query); + $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]); + wp_insert_link($link); echo sprintf('<p>'.__('Inserted <strong>%s</strong>').'</p>', $names[$i]); } ?> - <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> + <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> <?php } // end if got url else diff --git a/wp-inst/wp-admin/link-manager.php b/wp-inst/wp-admin/link-manager.php index 9d86834..9ec047a 100644 --- a/wp-inst/wp-admin/link-manager.php +++ b/wp-inst/wp-admin/link-manager.php @@ -1,255 +1,65 @@ <?php + + // Links // Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com -require_once('admin.php'); +require_once ('admin.php'); -$title = __('Manage Links'); +$title = __('Manage Bookmarks'); $this_file = $parent_file = 'link-manager.php'; $list_js = true; -$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[]'); - -for ($i=0; $i<count($wpvarstoreset); $i += 1) { - $wpvar = $wpvarstoreset[$i]; - if (!isset($$wpvar)) { - if (empty($_POST["$wpvar"])) { - if (empty($_GET["$wpvar"])) { - $$wpvar = ''; - } else { - $$wpvar = $_GET["$wpvar"]; - } - } else { - $$wpvar = $_POST["$wpvar"]; - } - } -} - -$links_show_cat_id = $_COOKIE['links_show_cat_id_' . COOKIEHASH]; -$links_show_order = $_COOKIE['links_show_order_' . COOKIEHASH]; - -if ('' != $_POST['assign']) $action = 'assign'; -if ('' != $_POST['visibility']) $action = 'visibility'; -if ('' != $_POST['move']) $action = 'move'; -if ('' != $_POST['linkcheck']) $linkcheck = $_POST[ 'linkcheck' ]; - -update_option( 'links_last_updated', time() ); - -switch ($action) { - case 'assign': - { - check_admin_referer(); - - // check the current user's level first. - if ( !current_user_can('manage_links') ) - die (__("Cheatin' uh ?")); - - //for each link id (in $linkcheck[]): if the current user level >= the - //userlevel of the owner of the link then we can proceed. - - if (count($linkcheck) == 0) { - header('Location: ' . $this_file); - exit; - } - $all_links = join(',', $linkcheck); - $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)"); - foreach ($results as $row) { - $ids_to_change[] = $row->link_id; - } - - // should now have an array of links we can change - $all_links = join(',', $ids_to_change); - $q = $wpdb->query("update $wpdb->links SET link_owner='$newowner' WHERE link_id IN ($all_links)"); - - header('Location: ' . $this_file); - break; - } - case 'visibility': - { - check_admin_referer(); - - // check the current user's level first. - if ( !current_user_can('manage_links') ) - die (__("Cheatin' uh ?")); - - //for each link id (in $linkcheck[]): toggle the visibility - if (count($linkcheck) == 0) { - header('Location: ' . $this_file); - exit; - } - $all_links = join(',', $linkcheck); - $results = $wpdb->get_results("SELECT link_id, link_visible FROM $wpdb->links WHERE link_id in ($all_links)"); - foreach ($results as $row) { - if ($row->link_visible == 'Y') { // ok to proceed - $ids_to_turnoff[] = $row->link_id; - } else { - $ids_to_turnon[] = $row->link_id; - } - } - - // should now have two arrays of links to change - if (count($ids_to_turnoff)) { - $all_linksoff = join(',', $ids_to_turnoff); - $q = $wpdb->query("update $wpdb->links SET link_visible='N' WHERE link_id IN ($all_linksoff)"); - } - - if (count($ids_to_turnon)) { - $all_linkson = join(',', $ids_to_turnon); - $q = $wpdb->query("update $wpdb->links SET link_visible='Y' WHERE link_id IN ($all_linkson)"); - } - - header('Location: ' . $this_file); - break; - } - case 'move': - { - check_admin_referer(); - - // check the current user's level first. - if ( !current_user_can('manage_links') ) - die (__("Cheatin' uh ?")); - - //for each link id (in $linkcheck[]) change category to selected value - if (count($linkcheck) == 0) { - header('Location: ' . $this_file); - exit; - } - $all_links = join(',', $linkcheck); - // should now have an array of links we can change - $q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)"); - - header('Location: ' . $this_file); - break; - } - - case 'Add': - { - check_admin_referer(); - - add_link(); - - header('Location: ' . $_SERVER['HTTP_REFERER'] . '?added=true'); - break; - } // end Add - - case 'editlink': - { - - check_admin_referer(); - - if (isset($links_show_cat_id) && ($links_show_cat_id != '')) - $cat_id = $links_show_cat_id; - - if (!isset($cat_id) || ($cat_id == '')) { - if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) - $cat_id = 'All'; +$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[]'); + +for ($i = 0; $i < count($wpvarstoreset); $i += 1) { + $wpvar = $wpvarstoreset[$i]; + if (!isset ($$wpvar)) { + if (empty ($_POST["$wpvar"])) { + if (empty ($_GET["$wpvar"])) { + $$wpvar = ''; + } else { + $$wpvar = $_GET["$wpvar"]; + } + } else { + $$wpvar = $_POST["$wpvar"]; + } } - $links_show_cat_id = $cat_id; - - $link_id = (int) $_POST['link_id']; - edit_link($link_id); - - setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); - wp_redirect($this_file); - break; - } // end Save - - case 'Delete': - { - check_admin_referer(); - - if ( !current_user_can('manage_links') ) - die (__("Cheatin' uh ?")); - - $link_id = (int) $_GET['link_id']; - - wp_delete_link($link_id); - - if (isset($links_show_cat_id) && ($links_show_cat_id != '')) - $cat_id = $links_show_cat_id; - - if (!isset($cat_id) || ($cat_id == '')) { - if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) - $cat_id = 'All'; - } - $links_show_cat_id = $cat_id; - setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); - wp_redirect($this_file); - break; - } // end Delete - - case 'linkedit': { - $xfn_js = true; - include_once ('admin-header.php'); - if ( !current_user_can('manage_links') ) - die(__('You do not have sufficient permissions to edit the links for this blog.')); - - $link_id = (int) $_GET['link_id']; - - if ( !$link = get_link_to_edit($link_id) ) - die( __('Link not found.') ); - - include('edit-link-form.php'); - break; - } // end linkedit - case __("Show"): - { - if (!isset($cat_id) || ($cat_id == '')) { - if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) - $cat_id = 'All'; - } - $links_show_cat_id = $cat_id; - if (!isset($order_by) || ($order_by == '')) { - if (!isset($links_show_order) || ($links_show_order == '')) - $order_by = 'order_name'; - } - $links_show_order = $order_by; - //break; fall through - } // end Show - case "popup": - { - $link_url = stripslashes($_GET["linkurl"]); - $link_name = stripslashes($_GET["name"]); - //break; fall through - } - default: - { - if (isset($links_show_cat_id) && ($links_show_cat_id != '')) - $cat_id = $links_show_cat_id; - - if (!isset($cat_id) || ($cat_id == '')) { - if (!isset($links_show_cat_id) || ($links_show_cat_id == '')) - $cat_id = 'All'; - } - $links_show_cat_id = $cat_id; - if (isset($links_show_order) && ($links_show_order != '')) - $order_by = $links_show_order; - - if (!isset($order_by) || ($order_by == '')) - $order_by = 'order_name'; - $links_show_order = $order_by; - - setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600); - setcookie('links_show_order_' . COOKIEHASH, $links_show_order, time()+600); - include_once ("./admin-header.php"); - if ( !current_user_can('manage_links') ) - die(__("You do not have sufficient permissions to edit the links for this blog.")); - - switch ($order_by) - { - case 'order_id': $sqlorderby = 'id'; break; - case 'order_url': $sqlorderby = 'url'; break; - case 'order_desc': $sqlorderby = 'description'; break; - case 'order_owner': $sqlorderby = 'owner'; break; - case 'order_rating': $sqlorderby = 'rating'; break; - case 'order_name': - default: $sqlorderby = 'name'; break; - } +} - if ($action != "popup") { +if (empty ($cat_id)) + $cat_id = 'all'; + +if (empty ($order_by)) + $order_by = 'order_name'; + +$title = __('Manage Bookmarks'); +include_once ("./admin-header.php"); + +if (!current_user_can('manage_links')) + die(__("You do not have sufficient permissions to edit the bookmarks for this blog.")); + +switch ($order_by) { + case 'order_id' : + $sqlorderby = 'id'; + break; + case 'order_url' : + $sqlorderby = 'url'; + break; + case 'order_desc' : + $sqlorderby = 'description'; + break; + case 'order_owner' : + $sqlorderby = 'owner'; + break; + case 'order_rating' : + $sqlorderby = 'rating'; + break; + case 'order_name' : + default : + $sqlorderby = 'name'; + break; +} ?> <script type="text/javascript"> <!-- @@ -267,183 +77,134 @@ function checkAll(form) //--> </script> -<div class="wrap"> - <form name="cats" method="post" action=""> - <table width="75%" cellpadding="3" cellspacing="3"> - <tr> - <td> - <?php _e('<strong>Show</strong> links in category:'); ?><br /> - </td> - <td> - <?php _e('<strong>Order</strong> by:');?> - </td> - <td> </td> - </tr> - <tr> - <td> <?php - $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id"); - echo " <select name=\"cat_id\">\n"; - echo " <option value=\"All\""; - if ($cat_id == 'All') - echo " selected='selected'"; - echo "> " . __('All') . "</option>\n"; - foreach ($results as $row) { - echo " <option value=\"".$row->cat_id."\""; - if ($row->cat_id == $cat_id) - echo " selected='selected'"; - echo ">".$row->cat_id.": ".wp_specialchars($row->cat_name); - if ($row->auto_toggle == 'Y') - echo ' '.__('(auto toggle)'); - echo "</option>\n"; - } - echo " </select>\n"; +if ( isset($_GET['deleted']) ) { + echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>'; + $deleted = (int) $_GET['deleted']; + printf(__('%s bookmarks deleted.'), $deleted); + echo '</p></div>'; +} ?> - </td> - <td> - <select name="order_by"> - <option value="order_id" <?php if ($order_by == 'order_id') echo " selected='selected'";?>><?php _e('Link ID') ?></option> - <option value="order_name" <?php if ($order_by == 'order_name') echo " selected='selected'";?>><?php _e('Name') ?></option> - <option value="order_url" <?php if ($order_by == 'order_url') echo " selected='selected'";?>><?php _e('URI') ?></option> - <option value="order_desc" <?php if ($order_by == 'order_desc') echo " selected='selected'";?>><?php _e('Description') ?></option> - <option value="order_owner" <?php if ($order_by == 'order_owner') echo " selected='selected'";?>><?php _e('Owner') ?></option> - <option value="order_rating" <?php if ($order_by == 'order_rating') echo " selected='selected'";?>><?php _e('Rating') ?></option> - </select> - </td> - <td> - <input type="submit" name="action" value="<?php _e('Show') ?>" /> - </td> - </tr> - </table> - </form> - -</div> -<form name="links" id="links" method="post" action=""> <div class="wrap"> - <input type="hidden" name="link_id" value="" /> - <input type="hidden" name="action" value="" /> - <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" /> - <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> - <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3"> - <tr> - <th width="15%"><?php _e('Name') ?></th> - <th><?php _e('URI') ?></th> - <th><?php _e('Category') ?></th> - <th><?php _e('rel') ?></th> - <th><?php _e('Image') ?></th> - <th><?php _e('Visible') ?></th> - <th colspan="2"><?php _e('Action') ?></th> - <th> </th> - </tr> -<?php - // fix link owners! - $wpdb->query( "UPDATE $wpdb->links SET link_owner='" . $current_user->data->ID . "' WHERE link_owner='0'" ); - - $sql = "SELECT link_url, link_name, link_image, link_description, link_visible, - link_category AS cat_id, cat_name AS category, link_id, - link_rating, link_rel - FROM $wpdb->links - LEFT JOIN $wpdb->linkcategories ON $wpdb->links.link_category = $wpdb->linkcategories.cat_id - WHERE link_owner = '".$current_user->data->ID."'"; - if (isset($cat_id) && ($cat_id != 'All')) { - $sql .= " AND link_category = $cat_id "; - } - $sql .= ' ORDER BY link_' . $sqlorderby; - - // echo "$sql"; - $links = $wpdb->get_results($sql); - if ($links) { - foreach ($links as $link) { - $link->link_name = wp_specialchars($link->link_name); - $link->link_category = wp_specialchars($link->link_category); - $link->link_description = wp_specialchars($link->link_description); - $link->link_url = wp_specialchars($link->link_url); - $short_url = str_replace('http://', '', $link->link_url); - $short_url = str_replace('www.', '', $short_url); - if ('/' == substr($short_url, -1)) - $short_url = substr($short_url, 0, -1); - if (strlen($short_url) > 35) - $short_url = substr($short_url, 0, 32).'...'; +<h2><?php _e('Bookmark Management'); ?></h2> +<p><?php _e('Here you add links to sites that you visit often and share them on your blog. When you have a list of links in your sidebar to other blogs, it’s called a “blogroll.”'); ?></p> +<form id="cats" method="get" action=""> +<p>Currently showing +<?php $categories = get_categories("hide_empty=1&type=link"); ?> +<select name="cat_id"> +<option value="all" <?php echo ($cat_id == 'all') ? " selected='selected'" : ''; ?>><?php _e('All') ?></option> +<?php foreach ($categories as $cat): ?> +<option value="<?php echo $cat->cat_ID; ?>"<?php echo ($cat->cat_ID == $cat_id) ? " selected='selected'" : ''; ?>><?php echo wp_specialchars($cat->cat_name); ?> +</option> +<?php endforeach; ?> +</select> +bookmarks ordered by +<select name="order_by"> +<option value="order_id" <?php if ($order_by == 'order_id') echo " selected='selected'";?>><?php _e('Bookmark ID') ?></option> +<option value="order_name" <?php if ($order_by == 'order_name') echo " selected='selected'";?>><?php _e('Name') ?></option> +<option value="order_url" <?php if ($order_by == 'order_url') echo " selected='selected'";?>><?php _e('URI') ?></option> +</select> +<input type="submit" name="action" value="<?php _e('Update »') ?>" /> +</form> - $image = ($link->link_image != null) ? __('Yes') : __('No'); - $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No'); - ++$i; - $style = ($i % 2) ? '' : ' class="alternate"'; +<form id="links" method="post" action="link.php"> +<input type="hidden" name="link_id" value="" /> +<input type="hidden" name="action" value="" /> +<input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" /> +<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" /> +<table width="100%" cellpadding="3" cellspacing="3"> + <thead> + <tr> + <th width="15%"><?php _e('Name') ?></th> + <th><?php _e('URI') ?></th> + <th><?php _e('Categories') ?></th> + <th><?php _e('rel') ?></th> + <th><?php _e('Visible') ?></th> + <th colspan="2"><?php _e('Action') ?></th> + <th><input type="checkbox" onclick="checkAll(document.getElementById('links'));" /></th> + </tr> + </thead> + <tbody id="the-list"> +<?php +if ( 'all' == $cat_id ) + $cat_id = ''; +$links = get_bookmarks("category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0"); +if ($links) + foreach ($links as $link) { + $link->link_name = wp_specialchars($link->link_name); + $link->link_description = wp_specialchars($link->link_description); + $link->link_url = wp_specialchars($link->link_url); + $link->link_category = wp_get_link_cats($link->link_id); + $short_url = str_replace('http://', '', $link->link_url); + $short_url = str_replace('www.', '', $short_url); + if ('/' == substr($short_url, -1)) + $short_url = substr($short_url, 0, -1); + if (strlen($short_url) > 35) + $short_url = substr($short_url, 0, 32).'...'; + + $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No'); + ++ $i; + $style = ($i % 2) ? '' : ' class="alternate"'; ?> - <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>> + <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>> <td><strong><?php echo $link->link_name; ?></strong><br /> + <?php + + + echo $link->link_description . "</td>"; + echo "<td><a href=\"$link->link_url\" title=\"".sprintf(__('Visit %s'), $link->link_name)."\">$short_url</a></td>"; + ?> + <td> + <?php + + $cat_names = array(); + foreach ($link->link_category as $category) { + $cat_name = get_the_category_by_ID($category); + $cat_name = wp_specialchars($cat_name); + if ( $cat_id != $category ) + $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>"; + $cat_names[] = $cat_name; + } + echo implode(', ', $cat_names); + ?> + </td> + <td><?php echo $link->link_rel; ?></td> + <td align='center'><?php echo $visible; ?></td> <?php - echo sprintf(__('Description: %s'), $link->link_description) . "</td>"; - echo "<td><a href=\"$link->link_url\" title=\"" . sprintf(__('Visit %s'), $link->link_name) . "\">$short_url</a></td>"; - echo <<<LINKS - <td>$link->category</td> - <td>$link->link_rel</td> - <td align='center'>$image</td> - <td align='center'>$visible</td> -LINKS; - $show_buttons = 1; // default - if ($show_buttons) { - echo '<td><a href="link-manager.php?link_id=' . $link->link_id . '&action=linkedit" class="edit">' . __('Edit') . '</a></td>'; - echo '<td><a href="link-manager.php?link_id=' . $link->link_id . '&action=Delete"' . " onclick=\"return deleteSomething( 'link', $link->link_id , '" . sprintf(__("You are about to delete the "%s" link to %s.\\n"Cancel" to stop, "OK" to delete."), wp_specialchars($link->link_name,1), wp_specialchars($link->link_url)) . '\' );" class="delete">' . __('Delete') . '</a></td>'; - echo '<td><input type="checkbox" name="linkcheck[]" value="' . $link->link_id . '" /></td>'; - } else { - echo "<td> </td><td> </td><td> </td>\n"; - } + echo '<td><a href="link.php?link_id='.$link->link_id.'&action=edit" class="edit">'.__('Edit').'</a></td>'; + echo '<td><a href="link.php?link_id='.$link->link_id.'&action=delete"'." class='delete' onclick=\"return deleteSomething( 'link', $link->link_id , '".sprintf(__("You are about to delete the "%s" bookmark to %s.\\n"Cancel" to stop, "OK" to delete."), wp_specialchars($link->link_name, 1), wp_specialchars($link->link_url)).'\' );" class="delete">'.__('Delete').'</a></td>'; + echo '<td align="center"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></td>'; echo "\n </tr>\n"; - } - } + } ?> + </tbody> </table> <div id="ajax-response"></div> -</div> - -<div class="wrap"> - <table width="100%" cellpadding="3" cellspacing="3"> - <tr><th colspan="4"><?php _e('Manage Multiple Links:') ?></th></tr> - <tr><td colspan="4"><?php _e('Use the checkboxes on the right to select multiple links and choose an action below:') ?></td></tr> - <tr> - <td> - <?php _e('Assign ownership to:'); ?> -<?php - $results = get_users_of_blog( $wpdb->blogid ); - echo " <select name=\"newowner\" size=\"1\">\n"; - foreach ($results as $row) { - echo " <option value=\"".$row->ID."\""; - echo ">".$row->user_login; - echo "</option>\n"; - } - echo " </select>\n"; -?> - <input name="assign" type="submit" id="assign" value="<?php _e('Go') ?>" /> - </td> - <td> - <input name="visibility" type="submit" id="visibility" value="<?php _e('Toggle Visibility') ?>" /> - </td> - <td> - <?php _e('Move to category:'); link_category_dropdown('category'); ?> <input name="move" type="submit" id="move" value="<?php _e('Go') ?>" /> - </td> - <td align="right"> - <a href="#" onclick="checkAll(document.getElementById('links')); return false; "><?php _e('Toggle Checkboxes') ?></a> - </td> - </tr> -</table> - -<?php - } // end if !popup -?> +<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> </div> </form> - <?php - break; - } // end default -} // end case +if( wp_cache_get( "checked_bookmarks_table", "options" ) == false ) { + if( is_backup_queue_full() == false ) { + $results = $wpdb->get_results( "SELECT link_id, category_id, count( * ) AS c FROM {$wpdb->link2cat} GROUP BY link_id, category_id" ); + if( $results != null ) { + foreach( $results as $link ) { + if( $link->c > 1 ) { + $wpdb->query( "DELETE FROM {$wpdb->link2cat} WHERE link_id='{$link->link_id}' AND category_id='{$link->category_id}'" ); + $wpdb->query( "INSERT INTO {$wpdb->link2cat} VALUES ( 0, '{$link->link_id}', '{$link->category_id}' )" ); + } + } + } + wp_cache_set( "checked_bookmarks_table", "1", "options" ); + } +} + ?> <?php include('admin-footer.php'); ?> diff --git a/wp-inst/wp-admin/upgrade-functions.php b/wp-inst/wp-admin/upgrade-functions.php index 6850e3b..eb59d60 100644 --- a/wp-inst/wp-admin/upgrade-functions.php +++ b/wp-inst/wp-admin/upgrade-functions.php @@ -1,7 +1,7 @@ <?php -require_once(ABSPATH . '/wp-admin/admin-functions.php'); -require_once(ABSPATH . '/wp-admin/upgrade-schema.php'); +require_once(ABSPATH . 'wp-admin/admin-functions.php'); +require_once(ABSPATH . 'wp-admin/upgrade-schema.php'); define( "RESET_CAPS", true ); // Functions to be called in install and upgrade scripts function upgrade_all() { @@ -700,7 +700,6 @@ function dbDelta($queries, $execute = true) { function make_db_current() { global $wp_queries; - $alterations = dbDelta($wp_queries); echo "<ol>\n"; foreach($alterations as $alteration) echo "<li>$alteration</li>\n"; diff --git a/wp-inst/wp-admin/upgrade-schema.php b/wp-inst/wp-admin/upgrade-schema.php index 1e7c201..ad2b1ab 100644 --- a/wp-inst/wp-admin/upgrade-schema.php +++ b/wp-inst/wp-admin/upgrade-schema.php @@ -1,13 +1,18 @@ <?php // Here we keep the DB structure and option values -$wp_queries="CREATE TABLE $wpdb->categories ( +global $wp_queries; + +$wp_queries = "CREATE TABLE $wpdb->categories ( cat_ID bigint(20) NOT NULL auto_increment, cat_name varchar(55) NOT NULL default '', category_nicename varchar(200) NOT NULL default '', category_description longtext NOT NULL, category_parent bigint(20) NOT NULL default '0', category_count bigint(20) NOT NULL default '0', + link_count bigint(20) NOT NULL default '0', + posts_private tinyint(1) NOT NULL default '0', + links_private tinyint(1) NOT NULL default '0', PRIMARY KEY (cat_ID), KEY category_nicename (category_nicename) ); @@ -31,21 +36,12 @@ CREATE TABLE $wpdb->comments ( KEY comment_approved (comment_approved), KEY comment_post_ID (comment_post_ID) ); -CREATE TABLE $wpdb->linkcategories ( - cat_id bigint(20) NOT NULL auto_increment, - cat_name tinytext NOT NULL, - auto_toggle enum('Y','N') NOT NULL default 'N', - show_images enum('Y','N') NOT NULL default 'Y', - show_description enum('Y','N') NOT NULL default 'N', - show_rating enum('Y','N') NOT NULL default 'Y', - show_updated enum('Y','N') NOT NULL default 'Y', - sort_order varchar(64) NOT NULL default 'rand', - sort_desc enum('Y','N') NOT NULL default 'N', - text_before_link varchar(128) NOT NULL default '<li>', - text_after_link varchar(128) NOT NULL default '<br />', - text_after_all varchar(128) NOT NULL default '</li>', - list_limit int(11) NOT NULL default '-1', - PRIMARY KEY (cat_id) +CREATE TABLE $wpdb->link2cat ( + rel_id bigint(20) NOT NULL auto_increment, + link_id bigint(20) NOT NULL default '0', + category_id bigint(20) NOT NULL default '0', + PRIMARY KEY (rel_id), + KEY link_id (link_id,category_id) ); CREATE TABLE $wpdb->links ( link_id bigint(20) NOT NULL auto_increment, @@ -119,11 +115,12 @@ CREATE TABLE $wpdb->posts ( post_parent bigint(20) NOT NULL default '0', guid varchar(255) NOT NULL default '', menu_order int(11) NOT NULL default '0', - post_type varchar(100) NOT NULL default 'post', + post_type varchar(20) NOT NULL default 'post', post_mime_type varchar(100) NOT NULL default '', comment_count bigint(20) NOT NULL default '0', PRIMARY KEY (ID), - KEY post_name (post_name) + KEY post_name (post_name), + KEY type_status_date (post_type, post_status, post_date, ID) ); CREATE TABLE $wpdb->users ( ID bigint(20) unsigned NOT NULL auto_increment, @@ -189,6 +186,20 @@ CREATE TABLE $wpdb->sitecategories ( PRIMARY KEY (cat_ID), KEY category_nicename (category_nicename) ); +CREATE TABLE $wpdb->signups ( + domain varchar(200) NOT NULL default '', + path varchar(100) NOT NULL default '', + title longtext NOT NULL, + user_login varchar(60) NOT NULL default '', + user_email varchar(100) NOT NULL default '', + registered datetime NOT NULL default '0000-00-00 00:00:00', + activation_key longtext NOT NULL, + meta longtext, + active bigint(20), + activated datetime NOT NULL default '0000-00-00 00:00:00', + PRIMARY KEY (domain), + KEY user_login (user_login) +); "; function populate_options() { diff --git a/wp-inst/wp-admin/wp-admin.css b/wp-inst/wp-admin/wp-admin.css index 1b9ecc6..7b27c63 100644 --- a/wp-inst/wp-admin/wp-admin.css +++ b/wp-inst/wp-admin/wp-admin.css @@ -40,6 +40,28 @@ a.delete:hover { overflow: hidden; } +.widefat { + width: 100%; +} + +.widefat td, .widefat th { + padding: 5px 6px; +} + +.import-system { + font-size: 16px; +} + +thead { + background: #dfdfdf +} + +#import-upload-form { + width: 300px; + margin: auto; + text-align: center; +} + a.edit, a.delete, a.edit:hover, a.delete:hover { border-bottom: none; display: block; @@ -91,11 +113,6 @@ fieldset legend { padding: .1em .3em; } -fieldset span.cat-nest { - display: block; - margin-left: 10px; -} - fieldset.options { padding: 1em; } @@ -241,8 +258,14 @@ form#upload #post_content { } .commentlist li { - border-bottom: 1px solid #369; - padding: .3em 1em; + border-bottom: 1px solid #ccc; + padding: 1em 1em .2em; + margin: 0; +} + +.commentlist p { + padding: 0; + margin: 0 0 .8em; } .clear { @@ -326,6 +349,18 @@ form#upload #post_content { color: #009ef0; } +.approve { + display: none; +} + +.unapproved .approve { + display: inline; +} + +.unapproved .unapprove { + display: none; +} + .updated { background: #CFEBF7 url(images/notice.gif) no-repeat 1em ; border: 1px solid #2580B2; @@ -353,7 +388,7 @@ form#upload #post_content { clear: both; } -table .vers, table .name { +table .vers { text-align: center; } @@ -461,7 +496,12 @@ table .vers, table .name { width: 300px; } -#deletepost:hover { +#deletepost:hover, #deletecomment:hover { + background: #ce0000; + color: #fff; +} + +#deletebookmarks:hover { background: #ce0000; color: #fff; } @@ -615,7 +655,7 @@ table .vers, table .name { width: 170px; } -#templateside h3, #postcustom p { +#templateside h3, #postcustom p.submit { margin: 0; } @@ -713,6 +753,14 @@ table .vers, table .name { background: #8B8; } +#namediv, #emaildiv, #uridiv { + float: left; +} + +#ajax-response { + padding: .5em; +} + /* A handy div class for hiding controls. Some browsers will disable them when you set display:none; */ @@ -799,11 +847,20 @@ table .vers, table .name { margin-top: .5em; } -#categorydiv div div { +#categorydiv ul { + list-style: none; + padding: 0; + margin-left:10px; +} +#categorychecklist { height: 12em; overflow: auto; + margin-top: 8px; +} +#categorychecklist li { + margin: 0; + padding: 0; } - #ajaxcat input { border: 1px solid #ccc; } @@ -947,3 +1004,6 @@ input#catadd { background: #a4a4a4; margin: 0; padding: 0; } +#ajax-response.alignleft { + margin-left: 2em; +} diff --git a/wp-inst/wp-admin/wpmu-upgrade.inc.php b/wp-inst/wp-admin/wpmu-upgrade.inc.php deleted file mode 100644 index 4146eca..0000000 --- a/wp-inst/wp-admin/wpmu-upgrade.inc.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -$row = $wpdb->get_row( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = 'first_post'" ); -if( $row == false ) - $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, '$wpdb->siteid', 'first_post', 'Welcome to <a href=\"SITE_URL\">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!'" ); - -$row = $wpdb->get_row( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = 'welcome_email'" ); -if( $row == false ) - $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, '$wpdb->siteid', 'welcome_email', -'Dear User, - -Your new SITE_NAME blog has been successfully set up at: -BLOG_URL - -You can log in to the administrator account with the following information: -Username: USERNAME -Password: PASSWORD -Login Here: BLOG_URLwp-login.php - -We hope you enjoy your new weblog. -Thanks! - ---The WordPress Team -SITE_NAME' )" ); - -$row = $wpdb->get_row( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = 'site_name'" ); -if( $row == false ) - $wpdb->query( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, '$wpdb->siteid', 'site_name', '" . ucfirst( $current_site->domain ) . "')" ); - -unset( $row ); - -?> |