
Property changes on: E:\EclipseWorkWeb\WordPressDev
___________________________________________________________________
Name: svn:ignore
   + .project


Index: E:/EclipseWorkWeb/WordPressDev/wp-includes/category.php
===================================================================
--- E:/EclipseWorkWeb/WordPressDev/wp-includes/category.php	(revision 6635)
+++ E:/EclipseWorkWeb/WordPressDev/wp-includes/category.php	(working copy)
@@ -149,6 +149,18 @@
 	return get_term($tag, 'post_tag', $output, $filter);
 }
 
+// Retrieves tag data given a tag ID or tag object.
+// Converts to appropriate form for use in tag management pages
+function &get_tag_for_page($tag, $output = OBJECT, $filter = 'raw') {
+	$tag = get_term($tag, 'post_tag', $output, $filter);
+	if ( is_wp_error( $tag ) )
+		return $tag;
+
+	_make_tag_compat($tag);
+
+	return $tag;
+}
+
 //
 // Cache
 //
@@ -183,4 +195,17 @@
 	}
 }
 
+function _make_tag_compat( &$tag) {
+	if ( is_object($tag) ) {
+		$tag->tag_ID = &$tag->term_id;
+		$tag->tag_count = &$tag->count;
+		$tag->tag_name = &$tag->name;
+		$tag->tag_slug = &$tag->slug;
+	} else if ( is_array($tag) && isset($tag['term_id']) ) {
+		$tag['tag_ID'] = &$tag['term_id'];
+		$tag['tag_count'] = &$tag['count'];
+		$tag['tag_name'] = &$tag['name'];
+		$tag['tag_slug'] = &$tag['slug'];
+	}
+}
 ?>
Index: E:/EclipseWorkWeb/WordPressDev/wp-includes/taxonomy.php
===================================================================
--- E:/EclipseWorkWeb/WordPressDev/wp-includes/taxonomy.php	(revision 6635)
+++ E:/EclipseWorkWeb/WordPressDev/wp-includes/taxonomy.php	(working copy)
@@ -525,9 +525,10 @@
 		'hide_empty' => true, 'exclude' => '', 'include' => '',
 		'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '',
 		'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '',
-		'pad_counts' => false);
+		'pad_counts' => false, 'start' => '');
 	$args = wp_parse_args( $args, $defaults );
 	$args['number'] = absint( $args['number'] );
+	$args['start'] = absint( $args['start'] );
 	if ( !$single_taxonomy || !is_taxonomy_hierarchical($taxonomies[0]) ||
 		'' != $args['parent'] ) {
 		$args['child_of'] = 0;
@@ -625,9 +626,13 @@
 	if ( $hide_empty && !$hierarchical )
 		$where .= ' AND tt.count > 0';
 
-	if ( !empty($number) )
-		$number = 'LIMIT ' . $number;
-	else
+	if ( !empty($number) ) {
+		if( $start )
+			$number = 'LIMIT ' . $start . ',' . $number;
+		else 
+			$number = 'LIMIT ' . $number;
+		
+	} else
 		$number = '';
 
 	if ( 'all' == $fields )
Index: E:/EclipseWorkWeb/WordPressDev/wp-includes/script-loader.php
===================================================================
--- E:/EclipseWorkWeb/WordPressDev/wp-includes/script-loader.php	(revision 6635)
+++ E:/EclipseWorkWeb/WordPressDev/wp-includes/script-loader.php	(working copy)
@@ -94,6 +94,7 @@
 				'how' => __('Separate multiple categories with commas.')
 			) );
 			$this->add( 'admin-categories', '/wp-admin/js/categories.js', array('wp-lists'), '20071031' );
+			$this->add( 'admin-tags', '/wp-admin/js/tags.js', array('wp-lists'), '20071031' );
 			$this->add( 'admin-custom-fields', '/wp-admin/js/custom-fields.js', array('wp-lists'), '20070823' );
 			$this->add( 'password-strength-meter', '/wp-admin/js/password-strength-meter.js', array('jquery'), '20070405' ); 
 			$this->localize( 'password-strength-meter', 'pwsL10n', array( 
Index: E:/EclipseWorkWeb/WordPressDev/wp-admin/tags.php
===================================================================
--- E:/EclipseWorkWeb/WordPressDev/wp-admin/tags.php	(revision 0)
+++ E:/EclipseWorkWeb/WordPressDev/wp-admin/tags.php	(revision 0)
@@ -0,0 +1,138 @@
+<?php
+require_once('admin.php');
+
+$title = __('Tags');
+$parent_file = 'edit.php';
+
+wp_reset_vars(array('action', 'tag'));
+
+switch($action) {
+
+case 'addtag':
+
+	check_admin_referer('add-tag');
+
+	if ( !current_user_can('manage_categories') )
+		wp_die(__('Cheatin&#8217; uh?'));
+
+	$ret = wp_insert_tag($_POST );
+	if( $ret && !is_wp_error( $ret ) ) {
+		wp_redirect('tags.php?message=1#addtag');
+	} else {
+		wp_redirect('tags.php?message=4#addtag');
+	}
+	exit;
+break;
+
+case 'delete':
+	$tag_ID = (int) $_GET['tag_ID'];
+	check_admin_referer('delete-tag_' .  $tag_ID);
+
+	if ( !current_user_can('manage_categories') )
+		wp_die(__('Cheatin&#8217; uh?'));
+
+	wp_delete_term( $tag_ID, 'post_tag');
+
+	wp_redirect('tags.php?message=2');
+	exit;
+
+break;
+
+case 'edit':
+
+	require_once ('admin-header.php');
+	$tag_ID = (int) $_GET['tag_ID'];
+	
+	$tag = get_tag_for_page($tag_ID, OBJECT, 'edit');
+	include('edit-tag-form.php');
+
+break;
+
+case 'editedtag':
+	$tag_ID = (int) $_POST['tag_ID'];
+	check_admin_referer('update-tag_' . $tag_ID);
+
+	if ( !current_user_can('manage_categories') )
+		wp_die(__('Cheatin&#8217; uh?'));
+
+	$ret = wp_insert_tag($_POST );
+	if( $ret && !is_wp_error( $ret ) ) {
+		wp_redirect('tags.php?message=3');
+	} else {
+		wp_redirect('tags.php?message=5');
+	}
+	exit;
+break;
+
+default:
+
+wp_enqueue_script( 'admin-tags' );
+require_once ('admin-header.php');
+
+$messages[1] = __('Tag added.');
+$messages[2] = __('Tag deleted.');
+$messages[3] = __('Tag updated.');
+$messages[4] = __('Tag not added.');
+$messages[5] = __('Tag not updated.');
+?>
+
+<?php if (isset($_GET['message'])) : ?>
+<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
+<?php endif; ?>
+
+<div class="wrap">
+<?php if ( current_user_can('manage_categories') ) : ?>
+	<h2><?php printf(__('Tags (<a href="%s">add new</a>)'), '#addtag') ?> </h2>
+<?php else : ?>
+	<h2><?php _e('Tags') ?> </h2>
+<?php endif; ?>
+<table class="widefat">
+	<thead>
+	<tr>
+		<th scope="col" style="text-align: center"><?php _e('ID') ?></th>
+        <th scope="col"><?php _e('Name') ?></th>
+        <th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th>
+        <th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
+	</tr>
+	</thead>
+	<tbody id="the-list" class="list:tag">
+<?php
+$pagenum = absint( $_GET['pagenum'] );
+$perpage = 10;
+$count = tag_rows( $pagenum, $perpage );
+?>
+	</tbody>
+</table>
+<?php
+
+$baseurl = get_bloginfo( 'home') . '/wp-admin/tags.php?pagenum=';
+if( $pagenum >= 1 ) {
+	echo '<a href="' . $baseurl . ($pagenum - 1 ) . '">&lt;&lt;' . __('Previous Tags') . '</a>';
+	if( $count == $perpage ) {
+		echo ' | ';
+	}
+}
+
+
+if( $count == $perpage ) {
+	echo '<a href="' . $baseurl . ($pagenum + 1 ) . '">' . __('Next Tags') . '&gt;&gt;</a>';
+}
+
+?>
+
+</div>
+
+<?php if ( current_user_can('manage_categories') ) : ?>
+
+<br />
+<?php include('edit-tag-form.php'); ?>
+
+<?php endif; ?>
+
+<?php
+break;
+}
+
+include('admin-footer.php');
+
+?>
Index: E:/EclipseWorkWeb/WordPressDev/wp-admin/admin-ajax.php
===================================================================
--- E:/EclipseWorkWeb/WordPressDev/wp-admin/admin-ajax.php	(revision 6635)
+++ E:/EclipseWorkWeb/WordPressDev/wp-admin/admin-ajax.php	(working copy)
@@ -62,6 +62,15 @@
 		die('1');
 	else	die('0');
 	break;
+case 'delete-tag' :
+	check_ajax_referer( "delete-tag_$id" );
+	if ( !current_user_can( 'manage_categories' ) )
+		die('-1');
+
+	if ( wp_delete_term($id, 'post_tag'))
+		die('1');
+	else	die('0');
+	break;
 case 'delete-link-cat' :
 	check_ajax_referer( "delete-link-category_$id" );
 	if ( !current_user_can( 'manage_categories' ) )
@@ -302,6 +311,44 @@
 	) );
 	$x->send();
 	break;
+case 'add-tag' : // From Manage->Tags
+	check_ajax_referer( 'add-tag' );
+	if ( !current_user_can( 'manage_categories' ) )
+		die('-1');
+
+	if ( '' === trim($_POST['tag_name']) ) {
+		$x = new WP_Ajax_Response( array(
+			'what' => 'tag',
+			'id' => new WP_Error( 'tag_name', __('You did not enter a tag name.') )
+		) );
+		$x->send();
+	}
+
+	$tag = wp_insert_tag( $_POST, true );
+
+	if ( is_wp_error($tag) ) {
+		$x = new WP_Ajax_Response( array(
+			'what' => 'tag',
+			'id' => $tag
+		) );
+		$x->send();
+	}
+
+	if ( !$tag || (!$tag = get_tag_for_page( $tag )) )
+		die('0');
+
+	$tag_full_name = $tag->name;
+	$_tag = $tag;
+	$tag_full_name = attribute_escape($tag_full_name);
+
+	$x = new WP_Ajax_Response( array(
+		'what' => 'tag',
+		'id' => $tag->term_id,
+		'data' => _tag_row( $tag ),
+		'supplemental' => array('name' => $tag_full_name, 'show-link' => sprintf(__( 'Tag <a href="#%s">%s</a> added' ), "tag-$tag->term_id", $tag_full_name))
+	) );
+	$x->send();
+	break;
 case 'add-comment' :
 	check_ajax_referer( $action );
 	if ( !current_user_can( 'edit_post', $id ) )
Index: E:/EclipseWorkWeb/WordPressDev/wp-admin/includes/template.php
===================================================================
--- E:/EclipseWorkWeb/WordPressDev/wp-admin/includes/template.php	(revision 6635)
+++ E:/EclipseWorkWeb/WordPressDev/wp-admin/includes/template.php	(working copy)
@@ -232,6 +232,65 @@
 	}
 }
 
+// Tag stuff
+
+// Returns a single tag row (see tag_rows below)
+// Note: this is also used in admin-ajax.php!
+function _tag_row( $tag, $class = '' ) {
+		$count = number_format_i18n( $tag->count );
+		$count = ( $count > 0 ) ? "<a href='edit.php?tag_id=$tag->term_id'>$count</a>" : $count;
+		
+		$out = '';
+		$out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>';
+		$out .= '<th scope="row">' . $tag->term_id . '</th>';
+
+		$out .= '<td>' . apply_filters( 'term_name', $tag->name ) . '</td>';
+
+		$out .= "<td>$count</td>";		
+		$out .= '<td><a href="tags.php?action=edit&amp;tag_ID=' . $tag->term_id . '" class="edit">' .
+			__( 'Edit' ) . "</a></td>" .
+			'<td><a href="' . wp_nonce_url( "tags.php?action=delete&amp;tag_ID=$tag->term_id", 
+					'delete-tag_' . $tag->term_id ) . 
+				'" class="delete:the-list:tag-' . $tag->term_id . ' delete">' .
+				__( 'Delete' ) . "</a></td>";
+		$out .= '</tr>';
+		
+		return $out;
+}
+
+// Outputs appropriate rows for the Nth page of the Tag Management screen,
+// assuming M tags displayed at a time on the page 
+// Returns the number of tags displayed
+function tag_rows( $page = 0, $pagesize = 20 ) {
+	
+	// Get a page worth of tags
+	$start = $page * $pagesize;
+	$tags = get_terms( 'post_tag', "start=$start&number=$pagesize&hide_empty=0"  );
+	
+	// convert it to table rows
+	$out = '';
+	$class = '';
+	$i = 0;
+	$count = 0;
+	foreach( $tags as $tag ) {
+		if( $i ) {
+			$i = 0;
+			$class = ' class="alternate"';
+		} else {
+			$i = 1;
+			$class = '';
+		}
+
+		$out .= _tag_row( $tag, $class );
+		$count++;
+	}
+	
+	// filter and send to screen
+	$out = apply_filters('tag_rows', $out);
+	echo $out;
+	return $count;
+}
+
 // define the columns to display, the syntax is 'internal name' => 'display name'
 function wp_manage_posts_columns() {
 	$posts_columns = array();
Index: E:/EclipseWorkWeb/WordPressDev/wp-admin/includes/taxonomy.php
===================================================================
--- E:/EclipseWorkWeb/WordPressDev/wp-admin/includes/taxonomy.php	(revision 6635)
+++ E:/EclipseWorkWeb/WordPressDev/wp-admin/includes/taxonomy.php	(working copy)
@@ -141,4 +141,44 @@
 	return wp_insert_term($tag_name, 'post_tag');
 }
 
+// Inserts or updates a tag
+// $args is an array with elements:
+//    'tag_name' - name of the tag - required
+//    'tag_slug' - slug for the tag - not required
+//    'tag_ID' - ID number (if updating an existing tag; omit or set to 0 if not)
+// Return value: WP error object or 0 if it fails, ID if successful
+function wp_insert_tag( $args, $wp_error = false ) {
+	extract($args, EXTR_SKIP);
+
+	if ( trim( $tag_name ) == '' )
+		return 0;
+
+	$tag_ID = (int) $tag_ID;
+
+	// Are we updating or creating?
+	if ( !empty ($tag_ID) )
+		$update = true;
+	else
+		$update = false;
+
+	$name = $tag_name;
+	$slug = $tag_slug;
+	
+	$args = compact('name', 'slug');
+
+	if ( $update )
+		$tag_ID = wp_update_term($tag_ID, 'post_tag', $args);
+	else
+		$tag_ID = wp_insert_term($name, 'post_tag', $args);
+
+	if ( is_wp_error($tag_ID) ) {
+		if ( $wp_error )
+			return $tag_ID;
+		else
+			return 0;
+	}
+
+	return $tag_ID['term_id'];
+}
+
 ?>
Index: E:/EclipseWorkWeb/WordPressDev/wp-admin/js/tags.js
===================================================================
--- E:/EclipseWorkWeb/WordPressDev/wp-admin/js/tags.js	(revision 0)
+++ E:/EclipseWorkWeb/WordPressDev/wp-admin/js/tags.js	(revision 0)
@@ -0,0 +1,21 @@
+jQuery(function($) {
+	var options = false
+
+	var addAfter = function( r, settings ) {
+		var name = $("<span>" + $('name', r).text() + "</span>").html();
+		var id = $('tag', r).attr('id');
+		options[options.length] = new Option(name, id);
+	}
+
+	var delAfter = function( r, settings ) {
+		var id = $('tag', r).attr('id');
+		for ( var o = 0; o < options.length; o++ )
+			if ( id == options[o].value )
+				options[o] = null;
+	}
+
+	if ( options )
+		$('#the-list').wpList( { addAfter: addAfter, delAfter: delAfter } );
+	else
+		$('#the-list').wpList();
+});
Index: E:/EclipseWorkWeb/WordPressDev/wp-admin/edit-tag-form.php
===================================================================
--- E:/EclipseWorkWeb/WordPressDev/wp-admin/edit-tag-form.php	(revision 0)
+++ E:/EclipseWorkWeb/WordPressDev/wp-admin/edit-tag-form.php	(revision 0)
@@ -0,0 +1,39 @@
+<?php
+if ( ! empty($tag_ID) ) {
+	$heading = __('Edit Tag');
+	$submit_text = __('Edit Tag &raquo;');
+	$form = '<form name="edittag" id="edittag" method="post" action="tags.php">';
+	$action = 'editedtag';
+	$nonce_action = 'update-tag_' . $tag_ID;
+	do_action('edit_tag_form_pre', $tag);
+} else {
+	$heading = __('Add Tag');
+	$submit_text = __('Add Tag &raquo;');
+	$form = '<form name="addtag" id="addtag" method="post" action="tags.php" class="add:the-list:">';
+	$action = 'addtag';
+	$nonce_action = 'add-tag';
+	do_action('add_tag_form_pre', $tag);
+}
+?>
+
+<div class="wrap">
+<h2><?php echo $heading ?></h2>
+<div id="ajax-response"></div>
+<?php echo $form ?>
+<input type="hidden" name="action" value="<?php echo $action ?>" />
+<input type="hidden" name="tag_ID" value="<?php echo $tag->term_id ?>" />
+<?php wp_nonce_field($nonce_action); ?>
+	<table class="editform" width="100%" cellspacing="2" cellpadding="5">
+		<tr class="form-field form-required">
+			<th width="33%" scope="row" valign="top"><label for="tag_name"><?php _e('Tag name:') ?></label></th>
+			<td width="67%"><input name="tag_name" id="tag_name" type="text" value="<?php echo attribute_escape($tag->name); ?>" size="40" /></td>
+		</tr>
+		<tr class="form-field">
+			<th scope="row" valign="top"><label for="tag_slug"><?php _e('Tag slug:') ?></label></th>
+			<td><input name="tag_slug" id="tag_slug" type="text" value="<?php echo attribute_escape($tag->slug); ?>" size="40" /></td>
+		</tr>
+	</table>
+<p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p>
+<?php do_action('edit_tag_form', $tag); ?>
+</form>
+</div>
Index: E:/EclipseWorkWeb/WordPressDev/wp-admin/menu.php
===================================================================
--- E:/EclipseWorkWeb/WordPressDev/wp-admin/menu.php	(revision 6635)
+++ E:/EclipseWorkWeb/WordPressDev/wp-admin/menu.php	(working copy)
@@ -42,6 +42,7 @@
 $submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php');
 $submenu['edit.php'][15] = array(__('Links'), 'manage_links', 'link-manager.php');
 $submenu['edit.php'][20] = array(__('Categories'), 'manage_categories', 'categories.php');
+$submenu['edit.php'][21] = array(__('Tags'), 'manage_categories', 'tags.php');
 $submenu['edit.php'][25] = array(__('Media Library'), 'upload_files', 'upload.php');
 $submenu['edit.php'][30] = array(__('Import'), 'import', 'import.php');
 $submenu['edit.php'][35] = array(__('Export'), 'import', 'export.php');
Index: E:/EclipseWorkWeb/WordPressDev/wp-admin/edit.php
===================================================================
--- E:/EclipseWorkWeb/WordPressDev/wp-admin/edit.php	(revision 6635)
+++ E:/EclipseWorkWeb/WordPressDev/wp-admin/edit.php	(working copy)
@@ -48,8 +48,9 @@
 	}
 	$h2_search = isset($_GET['s'])   && $_GET['s']   ? ' ' . sprintf(__('matching &#8220;%s&#8221;'), wp_specialchars( get_search_query() ) ) : '';
 	$h2_cat    = isset($_GET['cat']) && $_GET['cat'] ? ' ' . sprintf( __('in &#8220;%s&#8221;'), single_cat_title('', false) ) : '';
+	$h2_tag    = isset($_GET['tag_id']) && $_GET['tag_id'] ? ' ' . sprintf( __('tagged with &#8220;%s&#8221;'), single_tag_title('', false) ) : '';
 	$h2_month  = isset($_GET['m'])   && $_GET['m']   ? ' ' . sprintf( __('during %s'), single_month_title(' ', false) ) : '';
-	printf( _c( '%1$s%2$s%3$s%4$s%5$s|You can reorder these: 1: Posts, 2: by {s}, 3: matching {s}, 4: in {s}, 5: during {s}' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_month );
+	printf( _c( '%1$s%2$s%3$s%4$s%5$s%6$s|You can reorder these: 1: Posts, 2: by {s}, 3: matching {s}, 4: in {s}, 5: tagged with {s}, 6: during {s}' ), $h2_noun, $h2_author, $h2_search, $h2_cat, $h2_tag, $h2_month );
 }
 ?></h2>
 

