Changeset 2810 for trunk/bp-xprofile/bp-xprofile-templatetags.php
- Timestamp:
- 03/05/2010 04:01:27 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/bp-xprofile/bp-xprofile-templatetags.php (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/bp-xprofile-templatetags.php
r2798 r2810 21 21 function bp_xprofile_data_template( $user_id, $profile_group_id ) { 22 22 $this->groups = BP_XProfile_Group::get( array( 23 'profile_group_id' => $profile_group_id,24 'user_id' => $user_id,25 'hide_empty_groups' => true,26 'fetch_fields' => true,27 'fetch_field_data' => true23 'profile_group_id' => $profile_group_id, 24 'user_id' => $user_id, 25 'hide_empty_groups' => true, 26 'fetch_fields' => true, 27 'fetch_field_data' => true 28 28 ) ); 29 29 30 $this->group_count = count( $this->groups);30 $this->group_count = count( $this->groups ); 31 31 $this->user_id = $user_id; 32 32 } … … 51 51 function rewind_groups() { 52 52 $this->current_group = -1; 53 if ( $this->group_count > 0 ) { 53 54 if ( $this->group_count > 0 ) 54 55 $this->group = $this->groups[0]; 55 }56 56 } 57 57 … … 60 60 return true; 61 61 } elseif ( $this->current_group + 1 == $this->group_count ) { 62 do_action( 'xprofile_template_loop_end');62 do_action( 'xprofile_template_loop_end' ); 63 63 /* Do some cleaning up after the loop */ 64 64 $this->rewind_groups(); … … 76 76 77 77 if ( 0 == $this->current_group ) /* loop has just started */ 78 do_action( 'xprofile_template_loop_start');78 do_action( 'xprofile_template_loop_start' ); 79 79 } 80 80 … … 90 90 function rewind_fields() { 91 91 $this->current_field = -1; 92 if ( $this->field_count > 0 ) { 92 93 if ( $this->field_count > 0 ) 93 94 $this->field = $this->group->fields[0]; 94 }95 95 } 96 96 … … 101 101 $field = &$this->group->fields[$i]; 102 102 103 if ( $field->data->value != null ) {103 if ( $field->data->value != null ) 104 104 $has_data = true; 105 }106 105 } 107 106 … … 113 112 114 113 function profile_fields() { 115 if ( $this->current_field + 1 < $this->field_count ) {114 if ( $this->current_field + 1 < $this->field_count ) 116 115 return true; 117 } elseif ( $this->current_field + 1 == $this->field_count ) { 118 /* Do some cleaning up after the loop */ 116 117 /* Do some cleaning up after the loop */ 118 elseif ( $this->current_field + 1 == $this->field_count ) 119 119 $this->rewind_fields(); 120 }121 120 122 121 return false; … … 128 127 $field = $this->next_field(); 129 128 130 if ( !empty( $field->data->value ) ) {129 if ( !empty( $field->data->value ) ) 131 130 $this->field_has_data = true; 132 } 133 else { 131 else 134 132 $this->field_has_data = false; 135 }136 133 } 137 134 } … … 257 254 global $group; 258 255 259 foreach ( (array) $group->fields as $field ) 256 foreach ( (array) $group->fields as $field ) { 260 257 $field_ids .= $field->id . ','; 258 } 261 259 262 260 return substr( $field_ids, 0, -1 ); … … 372 370 $html .= '<option value="">--------</option>'; 373 371 374 for ( $k = 0; $k < count( $options); $k++ ) {375 $option_value = BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id);372 for ( $k = 0; $k < count( $options ); $k++ ) { 373 $option_value = BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id ); 376 374 377 375 /* Check for updated posted values, but errors preventing them from being saved first time */ … … 381 379 } 382 380 383 if ( $option_value == $options[$k]->name || $options[$k]->is_default_option ) {381 if ( $option_value == $options[$k]->name || $options[$k]->is_default_option ) 384 382 $selected = ' selected="selected"'; 385 } else {383 else 386 384 $selected = ''; 387 }388 385 389 386 $html .= apply_filters( 'bp_get_the_profile_field_options_select', '<option' . $selected . ' value="' . attribute_escape( $options[$k]->name ) . '">' . attribute_escape( $options[$k]->name ) . '</option>', $options[$k] ); … … 394 391 $html = '<div id="field_' . $field->id . '">'; 395 392 396 for ( $k = 0; $k < count( $options); $k++ ) {397 $option_value = BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id);393 for ( $k = 0; $k < count( $options ); $k++ ) { 394 $option_value = BP_XProfile_ProfileData::get_value_byid( $options[$k]->parent_id ); 398 395 399 396 /* Check for updated posted values, but errors preventing them from being saved first time */ … … 403 400 } 404 401 405 if ( $option_value == $options[$k]->name || $value == $options[$k]->name || $options[$k]->is_default_option ) {402 if ( $option_value == $options[$k]->name || $value == $options[$k]->name || $options[$k]->is_default_option ) 406 403 $selected = ' checked="checked"'; 407 } else {404 else 408 405 $selected = ''; 409 }410 406 411 407 $html .= apply_filters( 'bp_get_the_profile_field_options_radio', '<label><input' . $selected . ' type="radio" name="field_' . $field->id . '" id="option_' . $options[$k]->id . '" value="' . attribute_escape( $options[$k]->name ) . '"> ' . attribute_escape( $options[$k]->name ) . '</label>', $options[$k] ); … … 416 412 417 413 case 'checkbox': 418 $option_values = BP_XProfile_ProfileData::get_value_byid( $options[0]->parent_id);414 $option_values = BP_XProfile_ProfileData::get_value_byid( $options[0]->parent_id ); 419 415 420 416 /* Check for updated posted values, but errors preventing them from being saved first time */ … … 424 420 } 425 421 426 $option_values = maybe_unserialize( $option_values);427 428 for ( $k = 0; $k < count( $options); $k++ ) {429 for ( $j = 0; $j < count( $option_values); $j++ ) {422 $option_values = maybe_unserialize( $option_values ); 423 424 for ( $k = 0; $k < count( $options ); $k++ ) { 425 for ( $j = 0; $j < count( $option_values ); $j++ ) { 430 426 if ( $option_values[$j] == $options[$k]->name || @in_array( $options[$k]->name, $value ) || $options[$k]->is_default_option ) { 431 427 $selected = ' checked="checked"'; … … 442 438 443 439 if ( !empty( $field->data->value ) ) { 444 $day = date("j", $field->data->value);445 $month = date("F", $field->data->value);446 $year = date("Y", $field->data->value);447 $default_select = ' selected="selected"';440 $day = date("j", $field->data->value); 441 $month = date("F", $field->data->value); 442 $year = date("Y", $field->data->value); 443 $default_select = ' selected="selected"'; 448 444 } 449 445 … … 469 465 470 466 for ( $i = 1; $i < 32; $i++ ) { 471 if ( $day == $i ) {467 if ( $day == $i ) 472 468 $selected = ' selected = "selected"'; 473 } else {469 else 474 470 $selected = ''; 475 } 471 476 472 $html .= '<option value="' . $i .'"' . $selected . '>' . $i . '</option>'; 477 473 } … … 490 486 491 487 for ( $i = 0; $i < 12; $i++ ) { 492 if ( $month == $eng_months[$i] ) {488 if ( $month == $eng_months[$i] ) 493 489 $selected = ' selected = "selected"'; 494 } else {490 else 495 491 $selected = ''; 496 }497 492 498 493 $html .= '<option value="' . $eng_months[$i] . '"' . $selected . '>' . $months[$i] . '</option>'; … … 504 499 505 500 for ( $i = date( 'Y', time() ); $i > 1899; $i-- ) { 506 if ( $year == $i ) {501 if ( $year == $i ) 507 502 $selected = ' selected = "selected"'; 508 } else {503 else 509 504 $selected = ''; 510 }511 505 512 506 $html .= '<option value="' . $i .'"' . $selected . '>' . $i . '</option>'; … … 529 523 global $field; 530 524 531 return apply_filters( 'bp_get_the_profile_field_is_required', (int) $field->is_required );525 return apply_filters( 'bp_get_the_profile_field_is_required', (int) $field->is_required ); 532 526 } 533 527 534 528 function bp_unserialize_profile_field( $value ) { 535 if ( is_serialized( $value) ) {536 $field_value = maybe_unserialize( $value);529 if ( is_serialized( $value ) ) { 530 $field_value = maybe_unserialize( $value ); 537 531 $field_value = implode( ', ', $field_value ); 538 532 return $field_value; … … 547 541 function bp_get_profile_field_data( $args = '' ) { 548 542 $defaults = array( 549 'field' => false, /* Field name or ID. */550 'user_id' => $bp->displayed_user->id543 'field' => false, /* Field name or ID. */ 544 'user_id' => $bp->displayed_user->id 551 545 ); 552 546 … … 568 562 $group_name = bp_profile_group_name(false); 569 563 570 for ( $i = 0; $i < count( $groups); $i++ ) {571 if ( $group_name == $groups[$i]->name ) {564 for ( $i = 0; $i < count( $groups ); $i++ ) { 565 if ( $group_name == $groups[$i]->name ) 572 566 $selected = ' class="current"'; 573 } else {567 else 574 568 $selected = ''; 575 }576 569 577 570 if ( $groups[$i]->fields ) … … 591 584 592 585 if ( !$group = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) { 593 $group = new BP_XProfile_Group( $group_id);586 $group = new BP_XProfile_Group( $group_id ); 594 587 wp_cache_set( 'xprofile_group_' . $group_id, $group, 'bp' ); 595 588 } 596 589 597 if ( !$deprecated ) {590 if ( !$deprecated ) 598 591 return bp_get_profile_group_name(); 599 } else {592 else 600 593 echo bp_get_profile_group_name(); 601 }602 594 } 603 595 function bp_get_profile_group_name() { … … 610 602 611 603 if ( !$group = wp_cache_get( 'xprofile_group_' . $group_id, 'bp' ) ) { 612 $group = new BP_XProfile_Group( $group_id);604 $group = new BP_XProfile_Group( $group_id ); 613 605 wp_cache_set( 'xprofile_group_' . $group_id, $group, 'bp' ); 614 606 } … … 631 623 $last_updated = bp_get_profile_last_updated(); 632 624 633 if ( !$last_updated ) {625 if ( !$last_updated ) 634 626 _e( 'Profile not recently updated', 'buddypress' ) . '.'; 635 } else {627 else 636 628 echo $last_updated; 637 }638 629 } 639 630 function bp_get_profile_last_updated() { … … 680 671 global $bp; 681 672 682 ?> 673 ?> 674 683 675 <div class="generic-button"> 684 <a class="edit" title="<?php _e( 'Edit Profile', 'buddypress' ) ?>" href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/edit"><?php _e( 'Edit Profile', 'buddypress' )?></a>676 <a class="edit" title="<?php _e( 'Edit Profile', 'buddypress' ); ?>" href="<?php echo $bp->displayed_user->domain . $bp->profile->slug ?>/edit"><?php _e( 'Edit Profile', 'buddypress' ); ?></a> 685 677 </div> 686 <?php 687 } 688 678 <?php 679 } 689 680 690 681 ?>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)