Changeset 6294
- Timestamp:
- 09/03/2012 02:28:05 AM (13 years ago)
- Location:
- trunk/bp-xprofile
- Files:
-
- 3 edited
-
admin/css/admin.css (modified) (3 diffs)
-
admin/js/admin.js (modified) (7 diffs)
-
bp-xprofile-classes.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/admin/css/admin.css
r6264 r6294 27 27 margin-right: 8px; 28 28 } 29 ul#field-group-tabs li.ui-state-hover {29 ul#field-group-tabs li.ui-state-hover a { 30 30 background-color: #fafafa; 31 31 } … … 39 39 background-color: #efe; 40 40 } 41 ul#field-group-tabs li.ui- tabs-selected.ui-state-acceptable a.ui-tab {41 ul#field-group-tabs li.ui-state-active.ui-state-acceptable a.ui-tab { 42 42 background-color: #f9f9f9; 43 43 } … … 61 61 62 62 /* Selected tab */ 63 ul#field-group-tabs li.ui- tabs-selecteda.ui-tab {63 ul#field-group-tabs li.ui-state-active a.ui-tab { 64 64 background-color: #f9f9f9; 65 65 margin-top: -1px; -
trunk/bp-xprofile/admin/js/admin.js
r6264 r6294 4 4 var newDiv = document.createElement('p'); 5 5 var newOption = document.createElement('input'); 6 var label = document.createElement( 'label' );7 var txt = document.createTextNode( " Option " + theId + ":" );6 var span = document.createElement( 'span' ); 7 var txt = document.createTextNode( "\u00A0\u039E\u00A0" ); 8 8 var isDefault = document.createElement( 'input' ); 9 var label1 = document.createElement( 'label' );9 var span1 = document.createElement( 'span' ); 10 10 var txt1 = document.createTextNode( " Default Value " ); 11 11 12 12 newDiv.setAttribute('id', forWhat + '_div' + theId); 13 newDiv.setAttribute('class', 'sortable'); 13 14 14 15 newOption.setAttribute( 'type', 'text' ); … … 16 17 newOption.setAttribute( 'id', forWhat + '_option' + theId ); 17 18 18 label.setAttribute( 'for', forWhat + '_option' + theId ); 19 label.appendChild( txt ); 19 span.appendChild( txt ); 20 20 21 21 if ( forWhat == 'checkbox' || forWhat == 'multiselectbox' ) { … … 29 29 isDefault.setAttribute( 'value', theId ); 30 30 31 label1.appendChild( txt1 ); 32 label1.setAttribute( 'for', 'isDefault_' + forWhat + '_option[]' ); 31 span1.appendChild( txt1 ); 33 32 34 33 var toDelete = document.createElement( 'a' ); … … 39 38 toDelete.appendChild( toDeleteText ); 40 39 41 newDiv.appendChild( label);40 newDiv.appendChild( span ); 42 41 newDiv.appendChild( newOption ); 43 42 newDiv.appendChild( document.createTextNode( " " ) ); 44 43 newDiv.appendChild( isDefault ); 45 newDiv.appendChild( label1 );44 newDiv.appendChild( span1 ); 46 45 newDiv.appendChild( toDelete ); 47 46 holder.appendChild( newDiv ); 48 47 48 // re-initialize the sorable ui 49 enableSortableFieldOptions( forWhat ); 49 50 50 51 theId++; … … 86 87 }; 87 88 88 // Set up deleting options ajax 89 function enableSortableFieldOptions( forWhat ) { 90 if ( jQuery( '#' + forWhat + ' p.sortable' ).length > 1 ) { 91 jQuery( '.options-box' ).sortable( { 92 items: 'p.sortable', 93 tolerance: 'pointer', 94 axis: 'y', 95 handle: 'span' 96 }); 97 98 jQuery( '.sortable span' ).css( 'cursor', 'move' ); 99 } 100 } 101 102 function destroySortableFieldOptions() { 103 jQuery( '.options-box' ).sortable( 'destroy' ); 104 jQuery( '.sortable span' ).css( 'cursor', 'default' ); 105 } 106 89 107 jQuery( document ).ready( function() { 90 108 109 // Set up deleting options ajax 91 110 jQuery( 'a.ajax-option-delete' ).click( 92 111 function() { … … 103 122 } 104 123 ); 124 125 // 126 jQuery( '[id^="sort_order_"]' ).change(function() { 127 if ( jQuery( this ).val() != 'custom' ) { 128 destroySortableFieldOptions(); 129 } else { 130 enableSortableFieldOptions( jQuery('#fieldtype :selected').val() ); 131 } 132 }); 105 133 106 134 // Show object if JS is enabled … … 150 178 // Change cursor to move if JS is enabled 151 179 .css( 'cursor', 'move' ); 180 181 // Allow reordering of field options 182 enableSortableFieldOptions( jQuery('#fieldtype :selected').val() ); 152 183 153 184 // tabs init with a custom tab template and an "add" callback filling in the content -
trunk/bp-xprofile/bp-xprofile-classes.php
r6259 r6294 381 381 382 382 <div id="poststuff"> 383 <form action="<?php echo esc_ attr( $action ); ?>" method="post">383 <form action="<?php echo esc_erl( $action ); ?>" method="post"> 384 384 <div id="titlediv"> 385 385 <h3><label for="group_name"><?php _e( "Field Group Title", 'buddypress') ?> *</label></h3> … … 737 737 ?> 738 738 739 <div id="<?php echo $type; ?>" class="options-box" style="<?php echo $class; ?> margin-left: 15px;">739 <div id="<?php echo esc_attr( $type ); ?>" class="options-box" style="<?php echo esc_attr( $class ); ?> margin-left: 15px;"> 740 740 <h4><?php _e( 'Please enter options for this Field:', 'buddypress' ); ?></h4> 741 <p><label for="sort_order_<?php echo $type; ?>"><?php _e( 'Order By:', 'buddypress' ); ?></label> 742 <select name="sort_order_<?php echo $type; ?>" id="sort_order_<?php echo $type; ?>" > 743 <option value="default" <?php if ( 'default' == $this->order_by ) {?> selected="selected"<?php } ?> ><?php _e( 'Order Entered', 'buddypress' ); ?></option> 744 <option value="asc" <?php if ( 'asc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Name - Ascending', 'buddypress' ); ?></option> 745 <option value="desc" <?php if ( 'desc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Name - Descending', 'buddypress' ); ?></option> 741 <p> 742 <label for="sort_order_<?php echo esc_attr( $type ); ?>"><?php _e( 'Sort Order:', 'buddypress' ); ?></label> 743 <select name="sort_order_<?php echo esc_attr( $type ); ?>" id="sort_order_<?php echo esc_attr( $type ); ?>" > 744 <option value="custom" <?php selected( 'custom', $this->order_by ); ?>><?php _e( 'Custom', 'buddypress' ); ?></option> 745 <option value="asc" <?php selected( 'asc', $this->order_by ); ?>><?php _e( 'Ascending', 'buddypress' ); ?></option> 746 <option value="desc" <?php selected( 'desc', $this->order_by ); ?>><?php _e( 'Descending', 'buddypress' ); ?></option> 746 747 </select> 747 748 … … 767 768 $default_name = '[' . $j . ']'; ?> 768 769 769 <p><?php _e( 'Option', 'buddypress' ); ?> <?php echo $j; ?>: 770 <input type="text" name="<?php echo $type; ?>_option[<?php echo $j; ?>]" id="<?php echo $type; ?>_option<?php echo $j; ?>" value="<?php echo stripslashes( esc_attr( $options[$i]->name ) ); ?>" /> 771 <input type="<?php echo $default_input; ?>" name="isDefault_<?php echo $type; ?>_option<?php echo $default_name; ?>" <?php if ( (int) $options[$i]->is_default_option ) {?> checked="checked"<?php } ?> " value="<?php echo $j; ?>" /> <?php _e( 'Default Value', 'buddypress' ); ?> 772 773 <?php if ( $j != 1 && $options[$i]->id != -1 ) : ?> 774 775 <a href="admin.php?page=bp-profile-setup&mode=delete_option&option_id=<?php echo $options[$i]->id ?>" class="ajax-option-delete" id="delete-<?php echo $options[$i]->id; ?>">[x]</a> 776 777 <?php endif; ?> 778 770 <p class="sortable"> 771 <span> Ξ </span> 772 <input type="text" name="<?php echo esc_attr( $type ); ?>_option[<?php echo esc_attr( $j ); ?>]" id="<?php echo esc_attr( $type ); ?>_option<?php echo esc_attr( $j ); ?>" value="<?php echo stripslashes( esc_attr( $options[$i]->name ) ); ?>" /> 773 <input type="<?php echo $default_input; ?>" name="isDefault_<?php echo esc_attr( $type ); ?>_option<?php echo esc_attr( $default_name ); ?>" <?php checked( (int) $options[$i]->is_default_option, true ); ?> value="<?php echo esc_attr( $j ); ?>" /> 774 <span><?php _e( 'Default Value', 'buddypress' ); ?></span> 775 <a href="<?php echo esc_url( 'admin.php?page=bp-profile-setup&mode=delete_option&option_id=' . $options[$i]->id ); ?>" class="ajax-option-delete" id="delete-<?php echo esc_attr( $options[$i]->id ); ?>">[x]</a> 779 776 </p> 780 777 781 778 <?php } /* end for */ ?> 782 779 783 <input type="hidden" name="<?php echo $type; ?>_option_number" id="<?php echo $type; ?>_option_number" value="<?php echo $j + 1; ?>" />780 <input type="hidden" name="<?php echo esc_attr( $type ); ?>_option_number" id="<?php echo esc_attr( $type ); ?>_option_number" value="<?php echo esc_attr( (int) $j + 1 ); ?>" /> 784 781 785 782 <?php } else { … … 788 785 $default_name = '[1]'; ?> 789 786 790 <p><?php _e( 'Option', 'buddypress' ); ?> 1: <input type="text" name="<?php echo $type; ?>_option[1]" id="<?php echo $type; ?>_option1" /> 791 <input type="<?php echo $default_input; ?>" name="isDefault_<?php echo $type; ?>_option<?php echo $default_name; ?>" id="isDefault_<?php echo $type; ?>_option" value="1" /> <?php _e( 'Default Value', 'buddypress' ); ?> 792 <input type="hidden" name="<?php echo $type; ?>_option_number" id="<?php echo $type; ?>_option_number" value="2" /> 787 <p class="sortable"> 788 <span> Ξ </span> 789 <input type="text" name="<?php echo esc_attr( $type ); ?>_option[1]" id="<?php echo esc_attr( $type ); ?>_option1" /> 790 <input type="<?php echo esc_attr( $default_input ); ?>" name="isDefault_<?php echo esc_attr( $type ); ?>_option<?php echo esc_attr( $default_name ); ?>" id="isDefault_<?php echo esc_attr( $type ); ?>_option" value="1" /> 791 <span><?php _e( 'Default Value', 'buddypress' ); ?></span> 792 <input type="hidden" name="<?php echo esc_attr( $type ); ?>_option_number" id="<?php echo esc_attr( $type ); ?>_option_number" value="2" /> 793 </p> 793 794 794 795 <?php } /* end if */ ?> 795 796 796 <div id="<?php echo $type; ?>_more"></div>797 <p><a href="javascript:add_option('<?php echo $type; ?>')"><?php _e('Add Another Option', 'buddypress'); ?></a></p>797 <div id="<?php echo esc_attr( $type ); ?>_more"></div> 798 <p><a href="javascript:add_option('<?php echo esc_attr( $type ); ?>')"><?php _e( 'Add Another Option', 'buddypress' ); ?></a></p> 798 799 </div> 799 800 … … 803 804 function render_admin_form( $message = '' ) { 804 805 if ( empty( $this->id ) ) { 805 $title = __( 'Add Field', 'buddypress' );806 $action = "admin.php?page=bp-profile-setup&group_id=" . $this->group_id . "&mode=add_field#tabs-" . $this->group_id;806 $title = __( 'Add Field', 'buddypress' ); 807 $action = "admin.php?page=bp-profile-setup&group_id=" . $this->group_id . "&mode=add_field#tabs-" . $this->group_id; 807 808 808 809 if ( !empty( $_POST['saveField'] ) ) { 809 $this->name = $_POST['title'];810 $this->name = $_POST['title']; 810 811 $this->description = $_POST['description']; 811 812 $this->is_required = $_POST['required']; … … 821 822 <div class="wrap"> 822 823 <div id="icon-users" class="icon32"><br /></div> 823 <h2><?php echo $title; ?></h2>824 <h2><?php echo esc_html( $title ); ?></h2> 824 825 <p><?php _e( 'Fields marked * are required', 'buddypress' ) ?></p> 825 826 … … 827 828 828 829 <div id="message" class="error fade"> 829 <p><?php echo $message; ?></p>830 <p><?php echo esc_html( $message ); ?></p> 830 831 </div> 831 832 832 833 <?php endif; ?> 833 834 834 <form action="<?php echo $action; ?>" method="post">835 <form action="<?php echo esc_url( $action ); ?>" method="post"> 835 836 <div id="poststuff"> 836 837 <div id="titlediv"> … … 844 845 <h3><label for="description"><?php _e("Field Description", 'buddypress'); ?></label></h3> 845 846 <div id="titlewrap"> 846 <textarea name="description" id="description" rows="8" cols="60"><?php echo htmlspecialchars( $this->description ); ?></textarea>847 <textarea name="description" id="description" rows="8" cols="60"><?php echo esc_textarea( $this->description ); ?></textarea> 847 848 </div> 848 849 </div> 849 850 850 <?php if ( '0' != $this->can_delete ) {?>851 <?php if ( '0' != $this->can_delete ) : ?> 851 852 852 853 <div id="titlediv"> 853 854 <h3><label for="required"><?php _e( "Is This Field Required?", 'buddypress' ); ?> *</label></h3> 854 855 <select name="required" id="required" style="width: 30%"> 855 <option value="0"<?php if ( $this->is_required == '0' ) { ?> selected="selected"<?php }?>><?php _e( 'Not Required', 'buddypress' ); ?></option>856 <option value="1"<?php if ( $this->is_required == '1' ) { ?> selected="selected"<?php } ?>><?php _e( 'Required','buddypress' ); ?></option>856 <option value="0"<?php selected( $this->is_required, '0' ); ?>><?php _e( 'Not Required', 'buddypress' ); ?></option> 857 <option value="1"<?php selected( $this->is_required, '1' ); ?>><?php _e( 'Required', 'buddypress' ); ?></option> 857 858 </select> 858 859 </div> 859 860 860 861 <div id="titlediv"> 861 <h3><label for="fieldtype"><?php _e( "Field Type", 'buddypress'); ?> *</label></h3>862 <h3><label for="fieldtype"><?php _e( 'Field Type', 'buddypress'); ?> *</label></h3> 862 863 <select name="fieldtype" id="fieldtype" onchange="show_options(this.value)" style="width: 30%"> 863 <option value="textbox" <?php if ( $this->type == 'textbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Text Box','buddypress' ); ?></option>864 <option value="textarea" <?php if ( $this->type == 'textarea' ) {?> selected="selected"<?php } ?>><?php _e( 'Multi-line Text Box','buddypress' ); ?></option>865 <option value="datebox" <?php if ( $this->type == 'datebox' ) {?> selected="selected"<?php } ?>><?php _e( 'Date Selector','buddypress' ); ?></option>866 <option value="radio" <?php if ( $this->type == 'radio' ) {?> selected="selected"<?php } ?>><?php _e( 'Radio Buttons','buddypress' ); ?></option>867 <option value="selectbox" <?php if ( $this->type == 'selectbox' ) {?> selected="selected"<?php }?>><?php _e( 'Drop Down Select Box', 'buddypress' ); ?></option>868 <option value="multiselectbox" <?php if ( $this->type == 'multiselectbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Multi Select Box','buddypress' ); ?></option>869 <option value="checkbox" <?php if ( $this->type == 'checkbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Checkboxes','buddypress' ); ?></option>864 <option value="textbox" <?php selected( $this->type, 'textbox' ); ?>><?php _e( 'Text Box', 'buddypress' ); ?></option> 865 <option value="textarea" <?php selected( $this->type, 'textarea' ); ?>><?php _e( 'Multi-line Text Box', 'buddypress' ); ?></option> 866 <option value="datebox" <?php selected( $this->type, 'datebox' ); ?>><?php _e( 'Date Selector', 'buddypress' ); ?></option> 867 <option value="radio" <?php selected( $this->type, 'radio' ); ?>><?php _e( 'Radio Buttons', 'buddypress' ); ?></option> 868 <option value="selectbox" <?php selected( $this->type, 'selectbox' ); ?>><?php _e( 'Drop Down Select Box', 'buddypress' ); ?></option> 869 <option value="multiselectbox" <?php selected( $this->type, 'multiselectbox' ); ?>><?php _e( 'Multi Select Box', 'buddypress' ); ?></option> 870 <option value="checkbox" <?php selected( $this->type, 'checkbox' ); ?>><?php _e( 'Checkboxes', 'buddypress' ); ?></option> 870 871 </select> 871 872 </div> … … 875 876 <?php $this->render_admin_form_children(); ?> 876 877 877 <?php } else {?>878 879 <input type="hidden" name="required" id="required" value="1"/>878 <?php else : ?> 879 880 <input type="hidden" name="required" id="required" value="1" /> 880 881 <input type="hidden" name="fieldtype" id="fieldtype" value="textbox" /> 881 882 882 <?php } ?>883 884 <?php /* The fullname field cannot be hidden */ ?>885 <?phpif ( 1 != $this->id ) : ?>883 <?php endif; 884 885 /* The fullname field cannot be hidden */ 886 if ( 1 != $this->id ) : ?> 886 887 887 888 <div id="titlediv"> 888 889 889 <div id="titlewrap"> 890 <h3><label for="default-visibility"><?php _e( "Default Visibility", 'buddypress' ); ?></label></h3>890 <h3><label for="default-visibility"><?php _e( 'Default Visibility', 'buddypress' ); ?></label></h3> 891 891 <ul> 892 <?php foreach( bp_xprofile_get_visibility_levels() as $level ) : ?> 893 <li><input type="radio" name="default-visibility" value="<?php echo esc_attr( $level['id'] ) ?>" <?php checked( $this->default_visibility, $level['id'] ) ?>> <?php echo esc_html( $level['label'] ) ?></li> 894 <?php endforeach ?> 892 893 <?php foreach( bp_xprofile_get_visibility_levels() as $level ) : ?> 894 895 <li><input type="radio" name="default-visibility" value="<?php echo esc_attr( $level['id'] ) ?>" <?php checked( $this->default_visibility, $level['id'] ); ?>> <?php echo esc_html( $level['label'] ) ?></li> 896 897 <?php endforeach ?> 898 895 899 </ul> 896 900 </div> 897 901 898 902 <div id="titlewrap"> 899 <h3><label for="allow-custom-visibility"><?php _e( "Per-Member Visibility", 'buddypress' ); ?></label></h3>903 <h3><label for="allow-custom-visibility"><?php _e( 'Per-Member Visibility', 'buddypress' ); ?></label></h3> 900 904 <ul> 901 <li><input type="radio" name="allow-custom-visibility" value="allowed" <?php checked( $this->allow_custom_visibility, 'allowed' ) ?>> <?php _e( "Let members change the this field's visibility", 'buddypress' ) ?></li> 902 903 <li><input type="radio" name="allow-custom-visibility" value="disabled" <?php checked( $this->allow_custom_visibility, 'disabled' ) ?>> <?php _e( 'Enforce the default visibility for all members', 'buddypress' ) ?></li> 905 <li><input type="radio" name="allow-custom-visibility" value="allowed" <?php checked( $this->allow_custom_visibility, 'allowed' ); ?>> <?php _e( "Let members change the this field's visibility", 'buddypress' ); ?></li> 906 <li><input type="radio" name="allow-custom-visibility" value="disabled" <?php checked( $this->allow_custom_visibility, 'disabled' ); ?>> <?php _e( 'Enforce the default visibility for all members', 'buddypress' ); ?></li> 904 907 </ul> 905 908 </div> … … 958 961 959 962 function __construct( $field_id = null, $user_id = null ) { 960 if ( !empty( $field_id ) ) 963 if ( !empty( $field_id ) ) { 961 964 $this->populate( $field_id, $user_id ); 965 } 962 966 } 963 967 … … 1071 1075 1072 1076 if ( !empty( $results ) ) { 1073 $profile_data['user_login'] = $results[0]->user_login;1074 $profile_data['user_nicename'] = $results[0]->user_nicename;1075 $profile_data['user_email'] = $results[0]->user_email;1077 $profile_data['user_login'] = $results[0]->user_login; 1078 $profile_data['user_nicename'] = $results[0]->user_nicename; 1079 $profile_data['user_email'] = $results[0]->user_email; 1076 1080 1077 1081 foreach( (array) $results as $field ) { … … 1137 1141 if ( is_array( $fields ) ) { 1138 1142 for ( $i = 0, $count = count( $fields ); $i < $count; ++$i ) { 1139 if ( $i == 0 ) 1143 if ( $i == 0 ) { 1140 1144 $field_sql .= $wpdb->prepare( "AND ( f.name = %s ", $fields[$i] ); 1141 else1145 } else { 1142 1146 $field_sql .= $wpdb->prepare( "OR f.name = %s ", $fields[$i] ); 1147 } 1143 1148 } 1144 1149 … … 1158 1163 for ( $i = 0, $count = count( $values ); $i < $count; ++$i ) { 1159 1164 for ( $j = 0; $j < count( $fields ); $j++ ) { 1160 if ( $values[$i]->name == $fields[$j] ) 1165 if ( $values[$i]->name == $fields[$j] ) { 1161 1166 $new_values[$fields[$j]] = $values[$i]->value; 1162 else if ( !array_key_exists( $fields[$j], $new_values ) )1167 } else if ( !array_key_exists( $fields[$j], $new_values ) ) { 1163 1168 $new_values[$fields[$j]] = NULL; 1169 } 1164 1170 } 1165 1171 } … … 1209 1215 1210 1216 $field_name = bp_xprofile_fullname_field_name(); 1211 1212 $data = xprofile_get_field_data( $field_name, $user_id ); 1217 $data = xprofile_get_field_data( $field_name, $user_id ); 1213 1218 1214 1219 return $data[$field_name]; 1215 1220 } 1216 1221 } 1217 1218 ?>
Note: See TracChangeset
for help on using the changeset viewer.