diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-01-09 11:30:05 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-01-09 11:30:05 +0000 |
commit | 819f131230b6d2e4ff88a8773eef754228989ffc (patch) | |
tree | 547908e700cf516755e371de9a2149ff5a772832 /wp-includes | |
parent | 90888943466530c65823eac7e07e5a6f1c8ab5d5 (diff) | |
download | wordpress-mu-819f131230b6d2e4ff88a8773eef754228989ffc.tar.gz wordpress-mu-819f131230b6d2e4ff88a8773eef754228989ffc.tar.xz wordpress-mu-819f131230b6d2e4ff88a8773eef754228989ffc.zip |
WP Merge to rev 4709
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@835 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes')
-rw-r--r-- | wp-includes/category-template.php | 2 | ||||
-rw-r--r-- | wp-includes/category.php | 61 | ||||
-rw-r--r-- | wp-includes/comment.php | 7 | ||||
-rw-r--r-- | wp-includes/js/tinymce/themes/advanced/source_editor.htm | 6 |
4 files changed, 63 insertions, 13 deletions
diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 1ac742e..f1a8346 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -224,6 +224,8 @@ function wp_list_categories($args = '') { 'child_of' => 0, 'feed' => '', 'feed_image' => '', 'exclude' => '', 'hierarchical' => true, 'title_li' => __('Categories')); $r = array_merge($defaults, $r); + if ( !isset($r['pad_counts']) && $r['show_count'] && $r['hierarchical'] ) + $r['pad_counts'] = true; if ( isset($r['show_date']) ) $r['include_last_update_time'] = $r['show_date']; extract($r); diff --git a/wp-includes/category.php b/wp-includes/category.php index 56cdbb9..6025a67 100644 --- a/wp-includes/category.php +++ b/wp-includes/category.php @@ -21,7 +21,7 @@ function &get_categories($args = '') { $defaults = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1, 'exclude' => '', 'include' => '', - 'number' => ''); + 'number' => '', 'pad_counts' => false); $r = array_merge($defaults, $r); if ( 'count' == $r['orderby'] ) $r['orderby'] = 'category_count'; @@ -109,17 +109,21 @@ function &get_categories($args = '') { $categories = & _get_cat_children($child_of, $categories); // Update category counts to include children. - if ( $hierarchical ) { + if ( $pad_counts ) + _pad_category_counts($type, $categories); + + // Make sure we show empty categories that have children. + if ( $hierarchical && $hide_empty ) { foreach ( $categories as $k => $category ) { - $progeny = 'link' == $type ? $category->link_count : $category->category_count; - if ( $children = _get_cat_children($category->cat_ID, $categories) ) { + if ( ! $category->{'link' == $type ? 'link_count' : 'category_count'} ) { + $children = _get_cat_children($category->cat_ID, $categories); foreach ( $children as $child ) - $progeny += 'link' == $type ? $child->link_count : $child->category_count; - } - if ( !$progeny && $hide_empty ) + if ( $child->{'link' == $type ? 'link_count' : 'category_count'} ) + continue 2; + + // It really is empty unset($categories[$k]); - else - $categories[$k]->{'link' == $type ? 'link_count' : 'category_count'} = $progeny; + } } } reset ( $categories ); @@ -256,4 +260,43 @@ function &_get_cat_children($category_id, $categories) { return $category_list; } +// Recalculates link or post counts by including items from child categories +// Assumes all relevant children are already in the $categories argument +function _pad_category_counts($type, &$categories) { + global $wpdb; + + // Set up some useful arrays + foreach ( $categories as $key => $cat ) { + $cats[$cat->cat_ID] = & $categories[$key]; + $cat_IDs[] = $cat->cat_ID; + } + + // Get the relevant post2cat or link2cat records and stick them in a lookup table + if ( $type == 'post' ) { + $results = $wpdb->get_results("SELECT post_id, category_id FROM $wpdb->post2cat LEFT JOIN $wpdb->posts ON post_id = ID WHERE category_id IN (".join(',', $cat_IDs).") AND post_type = 'post' AND post_status = 'publish'"); + foreach ( $results as $row ) + ++$cat_items[$row->category_id][$row->post_id]; + } else { + $results = $wpdb->get_results("SELECT $wpdb->link2cat.link_id, category_id FROM $wpdb->link2cat LEFT JOIN $wpdb->links USING (link_id) WHERE category_id IN (".join(',', $cat_IDs).") AND link_visible = 'Y'"); + foreach ( $results as $row ) + ++$cat_items[$row->category_id][$row->link_id]; + } + + // Touch every ancestor's lookup row for each post in each category + foreach ( $cat_IDs as $cat_ID ) { + $child = $cat_ID; + while ( $parent = $cats[$child]->category_parent ) { + if ( !empty($cat_items[$cat_ID]) ) + foreach ( $cat_items[$cat_ID] as $item_id => $touches ) + ++$cat_items[$parent][$item_id]; + $child = $parent; + } + } + + // Transfer the touched cells + foreach ( $cat_items as $id => $items ) + if ( isset($cats[$id]) ) + $cats[$id]->{'link' == $type ? 'link_count' : 'category_count'} = count($items); +} + ?> diff --git a/wp-includes/comment.php b/wp-includes/comment.php index c9e47cb..19218a7 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -331,7 +331,7 @@ function wp_insert_comment($commentdata) { if ( ! isset($comment_date) ) $comment_date = current_time('mysql'); if ( ! isset($comment_date_gmt) ) - $comment_date_gmt = gmdate('Y-m-d H:i:s', strtotime($comment_date) ); + $comment_date_gmt = get_gmt_from_date($comment_date); if ( ! isset($comment_parent) ) $comment_parent = 0; if ( ! isset($comment_approved) ) @@ -460,6 +460,8 @@ function wp_update_comment($commentarr) { $comment_content = apply_filters('comment_save_pre', $comment_content); + $comment_date_gmt = get_gmt_from_date($comment_date); + $result = $wpdb->query( "UPDATE $wpdb->comments SET comment_content = '$comment_content', @@ -467,7 +469,8 @@ function wp_update_comment($commentarr) { comment_author_email = '$comment_author_email', comment_approved = '$comment_approved', comment_author_url = '$comment_author_url', - comment_date = '$comment_date' + comment_date = '$comment_date', + comment_date_gmt = '$comment_date_gmt' WHERE comment_ID = $comment_ID" ); $rval = $wpdb->rows_affected; diff --git a/wp-includes/js/tinymce/themes/advanced/source_editor.htm b/wp-includes/js/tinymce/themes/advanced/source_editor.htm index 630c721..a3b82c9 100644 --- a/wp-includes/js/tinymce/themes/advanced/source_editor.htm +++ b/wp-includes/js/tinymce/themes/advanced/source_editor.htm @@ -10,10 +10,12 @@ <form name="source" onsubmit="saveContent();" action="#"> <div style="float: left" class="title">{$lang_theme_code_title}</div> - <div style="float: right"> - <script language="javascript" type="text/javascript">renderWordWrap();</script> + <div id="wrapline" style="float: right"> + <input type="checkbox" name="wraped" id="wraped" onclick="toggleWordWrap(this);" class="wordWrapCode" /><label for="wraped">{$lang_theme_code_wordwrap}</label> </div> + <br style="clear: both" /> + <textarea name="htmlSource" id="htmlSource" rows="15" cols="100" style="width: 100%; height: 100%; font-family: 'Courier New',Courier,mono; font-size: 12px" dir="ltr" wrap="off"></textarea> <div class="mceActionPanel"> |