X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/76aea3697c6043c1613370f172395b4f65ee71f0..refs/tags/wordpress-2.7.1:/wp-admin/includes/template.php diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index e132733e..2566a616 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1,15 +1,43 @@ 0); @@ -39,7 +67,6 @@ function _cat_rows( $categories, &$count, $parent = 0, $level = 0, $page = 1, $p // If the page starts in a subtree, print the parents. if ( $count == $start && $category->parent > 0 ) { $my_parents = array(); - $my_parent = $category->parent; while ( $my_parent) { $my_parent = get_category($my_parent); $my_parents[] = $my_parent; @@ -57,7 +84,7 @@ function _cat_rows( $categories, &$count, $parent = 0, $level = 0, $page = 1, $p if ( $count >= $start ) echo "\t" . _cat_row( $category, $level ); - unset($categories[$i]); // Prune the working set + unset($categories[$i]); // Prune the working set $count++; if ( isset($children[$category->term_id]) ) @@ -68,83 +95,284 @@ function _cat_rows( $categories, &$count, $parent = 0, $level = 0, $page = 1, $p $output = ob_get_contents(); ob_end_clean(); - $output = apply_filters('cat_rows', $output); - echo $output; } +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $category + * @param unknown_type $level + * @param unknown_type $name_override + * @return unknown + */ function _cat_row( $category, $level, $name_override = false ) { - global $class; + static $row_class = ''; - $category = get_category( $category ); + $category = get_category( $category, OBJECT, 'display' ); + $default_cat_id = (int) get_option( 'default_category' ); $pad = str_repeat( '— ', $level ); $name = ( $name_override ? $name_override : $pad . ' ' . $category->name ); + $edit_link = "categories.php?action=edit&cat_ID=$category->term_id"; if ( current_user_can( 'manage_categories' ) ) { - $edit = "name)) . "'>$name"; + $edit = "name)) . "'>" . attribute_escape( $name ) . '
'; + $actions = array(); + $actions['edit'] = '' . __('Edit') . ''; + $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; + if ( $default_cat_id != $category->term_id ) + $actions['delete'] = "term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . ""; + $action_count = count($actions); + $i = 0; + $edit .= '
'; + foreach ( $actions as $action => $link ) { + ++$i; + ( $i == $action_count ) ? $sep = '' : $sep = ' | '; + $edit .= "$link$sep"; + } + $edit .= '
'; } else { $edit = $name; } - $class = " class='alternate'" == $class ? '' : " class='alternate'"; + $row_class = 'alternate' == $row_class ? '' : 'alternate'; + $qe_data = get_category_to_edit($category->term_id); $category->count = number_format_i18n( $category->count ); $posts_count = ( $category->count > 0 ) ? "$category->count" : $category->count; - $output = " - "; - if ( absint(get_option( 'default_category' ) ) != $category->term_id ) { - $output .= ""; - } else { - $output .= " "; + $output = ""; + + $columns = get_column_headers('categories'); + $hidden = get_hidden_columns('categories'); + foreach ( $columns as $column_name => $column_display_name ) { + $class = "class=\"$column_name column-$column_name\""; + + $style = ''; + if ( in_array($column_name, $hidden) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + switch ($column_name) { + case 'cb': + $output .= ""; + if ( $default_cat_id != $category->term_id ) { + $output .= ""; + } else { + $output .= " "; + } + $output .= ''; + break; + case 'name': + $output .= "$edit"; + $output .= ''; + break; + case 'description': + $output .= "$category->description"; + break; + case 'slug': + $output .= "$category->slug"; + break; + case 'posts': + $attributes = 'class="posts column-posts num"' . $style; + $output .= "$posts_count\n"; + } + } + $output .= ''; + + return $output; +} + +/** + * {@internal Missing Short Description}} + * + * @since 2.7 + * + * Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit. + * + * @param string $type "tag", "category" or "link-category" + * @return + */ +function inline_edit_term_row($type) { + + if ( ! current_user_can( 'manage_categories' ) ) + return; + + $is_tag = $type == 'edit-tags'; + $columns = get_column_headers($type); + $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) ); + $col_count = count($columns) - count($hidden); + ?> + +
+ - - \n\t\n"; - return apply_filters('cat_row', $output); +?> + +

+ + + + + + +
+

+ +
+name ); + $edit_link = "link-category.php?action=edit&cat_ID=$category->term_id"; if ( current_user_can( 'manage_categories' ) ) { - $edit = "name)) . "' class='edit'>$name"; - $default_cat_id = (int) get_option( 'default_link_category' ); + $edit = "name)) . "'>$name
"; + $actions = array(); + $actions['edit'] = '' . __('Edit') . ''; + $actions['inline hide-if-no-js'] = '' . __('Quick Edit') . ''; + if ( $default_cat_id != $category->term_id ) + $actions['delete'] = "term_id) . "' onclick=\"if ( confirm('" . js_escape(sprintf(__("You are about to delete this category '%s'\n 'Cancel' to stop, 'OK' to delete."), $name )) . "') ) { return true;}return false;\">" . __('Delete') . ""; + $action_count = count($actions); + $i = 0; + $edit .= '
'; + foreach ( $actions as $action => $link ) { + ++$i; + ( $i == $action_count ) ? $sep = '' : $sep = ' | '; + $edit .= "$link$sep"; + } + $edit .= '
'; } else { $edit = $name; } - $class = " class='alternate'" == $class ? '' : " class='alternate'"; + $row_class = 'alternate' == $row_class ? '' : 'alternate'; + $qe_data = get_term_to_edit($category->term_id, 'link_category'); $category->count = number_format_i18n( $category->count ); $count = ( $category->count > 0 ) ? "$category->count" : $category->count; - $output = " - "; - if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) { - $output .= ""; - } else { - $output .= " "; + $output = ""; + $columns = get_column_headers('edit-link-categories'); + $hidden = get_hidden_columns('edit-link-categories'); + foreach ( $columns as $column_name => $column_display_name ) { + $class = "class=\"$column_name column-$column_name\""; + + $style = ''; + if ( in_array($column_name, $hidden) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + switch ($column_name) { + case 'cb': + $output .= ""; + if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) { + $output .= ""; + } else { + $output .= " "; + } + $output .= ""; + break; + case 'name': + $output .= "$edit"; + $output .= ''; + break; + case 'description': + $output .= "$category->description"; + break; + case 'slug': + $output .= "$category->slug"; + break; + case 'links': + $attributes = 'class="links column-links num"' . $style; + $output .= "$count"; + } } - $output .= " - $edit - $category->description - $count"; + $output .= ''; - return apply_filters( 'link_cat_row', $output ); + return $output; } +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $checked + * @param unknown_type $current + */ function checked( $checked, $current) { if ( $checked == $current) echo ' checked="checked"'; } +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $selected + * @param unknown_type $current + */ function selected( $selected, $current) { if ( $selected == $current) echo ' selected="selected"'; @@ -154,12 +382,27 @@ function selected( $selected, $current) { // Category Checklists // -// Deprecated. Use wp_link_category_checklist +/** + * {@internal Missing Short Description}} + * + * @since unknown + * @deprecated Use {@link wp_link_category_checklist()} + * @see wp_link_category_checklist() + * + * @param unknown_type $default + * @param unknown_type $parent + * @param unknown_type $popular_ids + */ function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) { global $post_ID; wp_category_checklist($post_ID); } +/** + * {@internal Missing Short Description}} + * + * @since unknown + */ class Walker_Category_Checklist extends Walker { var $tree_type = 'category'; var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this @@ -178,7 +421,7 @@ class Walker_Category_Checklist extends Walker { extract($args); $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; - $output .= "\n
  • " . ''; + $output .= "\n
  • " . ''; } function end_el(&$output, $category, $depth, $args) { @@ -186,12 +429,24 @@ class Walker_Category_Checklist extends Walker { } } -function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false ) { - $walker = new Walker_Category_Checklist; +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $post_id + * @param unknown_type $descendants_and_self + * @param unknown_type $selected_cats + * @param unknown_type $popular_cats + */ +function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null ) { + if ( empty($walker) || !is_a($walker, 'Walker') ) + $walker = new Walker_Category_Checklist; + $descendants_and_self = (int) $descendants_and_self; $args = array(); - + if ( is_array( $selected_cats ) ) $args['selected_cats'] = $selected_cats; elseif ( $post_id ) @@ -227,6 +482,17 @@ function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $select echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args)); } +/** + * {@internal Missing Short Description}} + * + * @since unknown + * + * @param unknown_type $taxonomy + * @param unknown_type $default + * @param unknown_type $number + * @param unknown_type $echo + * @return unknown + */ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { global $post_ID; if ( $post_ID ) @@ -244,7 +510,7 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ech ?>