Changeset 4495 for trunk/wp-includes/classes.php
- Timestamp:
- 11/19/2006 07:56:05 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/classes.php (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/classes.php
r4483 r4495 13 13 var $matched_query; 14 14 var $did_permalink = false; 15 15 16 16 function add_query_var($qv) { 17 17 $this->public_query_vars[] = $qv; … … 97 97 // Got a match. 98 98 $this->matched_rule = $match; 99 99 100 100 // Trim the query of everything up to the '?'. 101 101 $query = preg_replace("!^.+\?!", '', $query); … … 191 191 ) 192 192 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT'; 193 else 193 else 194 194 $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT'; 195 195 $wp_etag = '"' . md5($wp_last_modified) . '"'; … … 198 198 199 199 // Support for Conditional GET 200 if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) 200 if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) 201 201 $client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])); 202 202 else $client_etag = false; … … 322 322 return ''; 323 323 324 return $codes[0]; 324 return $codes[0]; 325 325 } 326 326 … … 338 338 return $this->errors[$code]; 339 339 else 340 return array(); 340 return array(); 341 341 } 342 342 … … 382 382 // A class for displaying various tree-like structures. Extend the Walker class to use it, see examples at the bottom 383 383 384 class Walker { 384 class Walker { 385 385 var $tree_type; 386 386 var $db_fields; 387 387 388 388 //abstract callbacks 389 389 function start_lvl($output) { return $output; } … … 391 391 function start_el($output) { return $output; } 392 392 function end_el($output) { return $output; } 393 393 394 394 function walk($elements, $to_depth) { 395 395 $args = array_slice(func_get_args(), 2); $parents = array(); $depth = 1; $previous_element = ''; $output = ''; 396 396 397 397 //padding at the end 398 398 $last_element->post_parent = 0; 399 399 $last_element->post_id = 0; 400 400 $elements[] = $last_element; 401 401 402 402 $id_field = $this->db_fields['id']; 403 403 $parent_field = $this->db_fields['parent']; 404 404 405 405 $flat = ($to_depth == -1) ? true : false; 406 406 407 407 foreach ( $elements as $element ) { 408 408 // If flat, start and end the element and skip the level checks. … … 444 444 $output = call_user_func_array(array(&$this, 'end_el'), $cb_args); 445 445 } 446 446 447 447 while ( $parent = array_shift($parents) ) { 448 448 $depth--; … … 464 464 } 465 465 } 466 466 467 467 // Start the element. 468 468 if ( !$to_depth || ($depth <= $to_depth) ) { … … 472 472 } 473 473 } 474 474 475 475 $previous_element = $element; 476 476 } 477 477 478 478 return $output; 479 479 } … … 483 483 var $tree_type = 'page'; 484 484 var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this 485 485 486 486 function start_lvl($output, $depth) { 487 487 $indent = str_repeat("\t", $depth); … … 489 489 return $output; 490 490 } 491 491 492 492 function end_lvl($output, $depth) { 493 493 $indent = str_repeat("\t", $depth); … … 495 495 return $output; 496 496 } 497 497 498 498 function start_el($output, $page, $depth, $current_page, $show_date, $date_format) { 499 499 if ( $depth ) … … 531 531 532 532 function start_el($output, $page, $depth, $args) { 533 $pad = str_repeat(' ', $depth * 3);534 535 $output .= "\t<option value=\"$page->ID\"";536 if ( $page->ID == $args['selected'] )537 $output .= ' selected="selected"';538 $output .= '>';539 $title = wp_specialchars($page->post_title);540 $output .= "$pad$title";541 $output .= "</option>\n";542 543 return $output;533 $pad = str_repeat(' ', $depth * 3); 534 535 $output .= "\t<option value=\"$page->ID\""; 536 if ( $page->ID == $args['selected'] ) 537 $output .= ' selected="selected"'; 538 $output .= '>'; 539 $title = wp_specialchars($page->post_title); 540 $output .= "$pad$title"; 541 $output .= "</option>\n"; 542 543 return $output; 544 544 } 545 545 } … … 548 548 var $tree_type = 'category'; 549 549 var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this 550 550 551 551 function start_lvl($output, $depth, $args) { 552 552 if ( 'list' != $args['style'] ) 553 553 return $output; 554 554 555 555 $indent = str_repeat("\t", $depth); 556 556 $output .= "$indent<ul class='children'>\n"; 557 557 return $output; 558 558 } 559 559 560 560 function end_lvl($output, $depth, $args) { 561 561 if ( 'list' != $args['style'] ) 562 562 return $output; 563 563 564 564 $indent = str_repeat("\t", $depth); 565 565 $output .= "$indent</ul>\n"; 566 566 return $output; 567 567 } 568 568 569 569 function start_el($output, $category, $depth, $args) { 570 570 extract($args); 571 571 572 572 $link = '<a href="' . get_category_link($category->cat_ID) . '" '; 573 573 if ( $use_desc_for_title == 0 || empty($category->category_description) ) … … 577 577 $link .= '>'; 578 578 $link .= apply_filters('list_cats', $category->cat_name, $category).'</a>'; 579 579 580 580 if ( (! empty($feed_image)) || (! empty($feed)) ) { 581 581 $link .= ' '; 582 582 583 583 if ( empty($feed_image) ) 584 584 $link .= '('; 585 585 586 586 $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"'; 587 587 588 588 if ( !empty($feed) ) { 589 589 $title = ' title="' . $feed . '"'; … … 592 592 $link .= $title; 593 593 } 594 594 595 595 $link .= '>'; 596 596 597 597 if ( !empty($feed_image) ) 598 598 $link .= "<img src='$feed_image' $alt$title" . ' />'; … … 619 619 $output .= "\t$link<br />\n"; 620 620 } 621 622 return $output; 623 } 624 621 622 return $output; 623 } 624 625 625 function end_el($output, $page, $depth, $args) { 626 626 if ( 'list' != $args['style'] ) 627 627 return $output; 628 628 629 629 $output .= "</li>\n"; 630 630 return $output; … … 636 636 var $tree_type = 'category'; 637 637 var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this 638 639 function start_el($output, $category, $depth, $args) { 638 639 function start_el($output, $category, $depth, $args) { 640 640 $pad = str_repeat(' ', $depth * 3); 641 641 642 642 $cat_name = apply_filters('list_cats', $category->cat_name, $category); 643 643 $output .= "\t<option value=\"".$category->cat_ID."\""; … … 653 653 } 654 654 $output .= "</option>\n"; 655 655 656 656 return $output; 657 657 }
Note: See TracChangeset
for help on using the changeset viewer.