Changeset 2883
- Timestamp:
- 03/29/2010 12:08:14 PM (15 years ago)
- Location:
- trunk/bp-xprofile
- Files:
-
- 4 added
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/admin/css/admin.css
r2812 r2883 1 1 /* Profile field group main admin page */ 2 table.field-group { 3 margin-bottom: 20px; 4 background-color: #fafafa; 5 } 6 table.field-group.ui-sortable-placeholder { 7 border: 2px dashed #ddd; 2 #tabs { 3 position: relative; 4 } 5 p.nofields { 6 margin-top: 20px; 7 } 8 9 /* Field group tabs */ 10 ul#field-group-tabs { 11 float: left; 12 padding: 0 0 0 15px; 13 display: block; 14 } 15 ul#field-group-tabs li { 16 float: left; 17 margin-bottom: -1px; 18 background-color: #F7F6F1; 19 margin-right: 8px; 20 } 21 ul#field-group-tabs li.ui-state-hover { 22 background-color: #fafafa; 23 } 24 ul#field-group-tabs li.ui-state-hover a.ui-tab { 25 border-color: #bbb #bbb #ccc #bbb; 26 color: #888; 27 } 28 ul#field-group-tabs li.ui-state-acceptable a.ui-tab { 29 border-color: #5a5 #5a5 #ccc #5a5; 30 color: #8a8; 31 background-image: url(../images/plus.gif); 32 background-color: #efe; 33 } 34 ul#field-group-tabs li.ui-tabs-selected.ui-state-acceptable a.ui-tab { 35 background-color: #fff; 36 background-image: url(../images/cross.gif); 37 } 38 ul#field-group-tabs li.drop-candidate a.ui-tab { 39 background-color: #ffc; 40 border-color: #aa5 #aa5 #ccc #aa5; 41 color: #aa8; 42 } 43 ul#field-group-tabs li a.ui-tab { 44 display: block; 45 margin-top: 3px; 46 padding: 8px 10px 8px 28px; 47 border: 1px solid #ccc; 48 border-bottom: none; 49 -moz-border-radius: 5px 5px 0 0; 50 -khtml-border-radius: 5px 5px 0 0; 51 -webkit-border-radius: 5px 5px 0 0; 52 border-radius: 5px 5px 0 0; 53 text-decoration: none; 54 background: url(../images/move-x.gif) 7px 55% no-repeat; 55 color: #888; 56 } 57 58 /* Selected tab */ 59 ul#field-group-tabs li.ui-tabs-selected { 60 background-color: #fff; 61 } 62 ul#field-group-tabs li.ui-tabs-selected a.ui-tab { 63 margin-top: -1px; 64 padding: 10px 10px 10px 28px; 65 border: 1px solid #bbb; 66 border-bottom: 1px solid transparent; 67 color: #000; 68 font-weight: bold; 69 } 70 71 /* Toolbar */ 72 .tab-toolbar { 73 margin-top: 1px; 74 clear: left; 75 background-color: #fff; 76 padding: 10px; 77 border: 1px solid #bbb; 78 } 79 80 div.tab-wrapper { 81 clear: left; 82 } 83 84 .tab-wrapper fieldset { 85 border: 1px solid #ddd; 86 -moz-border-radius: 5px; 87 -khtml-border-radius: 5px; 88 -webkit-border-radius: 5px; 89 border-radius: 5px; 90 padding: 0 10px 10px; 91 margin: 10px 0 0 0; 92 position: relative; 93 background-color: #fff; 94 } 95 .tab-wrapper fieldset fieldset { 96 cursor: move; 97 padding: 10px 10px 20px 10px; 98 background-color: #fcfcfc; 99 } 100 .field-group fieldset:hover { 101 background-color: #fafafa; 102 border-color: #ccc; 103 } 104 fieldset div.field-wrapper { 105 padding-left: 30px; 106 background: url(../images/move.gif) 0px 3px no-repeat transparent; 107 } 108 fieldset.radio div div, 109 fieldset.checkbox div div { 110 float: left; 111 } 112 fieldset.radio div div label, 113 fieldset.checkbox div div label { 114 margin-right: 20px; 115 } 116 117 fieldset.clear-value { 118 margin-left: 10px; 119 } 120 .field-group div.actions { 121 display: none; 122 position: absolute; 123 right: 20px; 124 top: 0; 125 } 126 .field-group fieldset:hover div.actions { 127 display: block; 128 } 129 .field-group fieldset.ui-sortable-placeholder { 130 border: 1px dashed #999; 131 background-color: #eee; 8 132 visibility: visible !important; 9 background-color: transparent; 10 width: 100%; 11 margin-bottom: 20px; 12 } 13 table.field-group thead tr.grabber, 14 table.field-group tbody { 15 cursor: move; 16 } 17 table.field-group tbody tr.nodrag { 18 cursor: default !important; 19 } 20 table.field-group tbody tr.ui-sortable-placeholder { 21 visibility: visible !important; 22 display: block !important; 23 background-color: #fafafa; 24 } 25 table.field-group td { 26 background-color: #fff; 27 } 28 table.field-group tbody tr:hover td { 29 background-color: #fffee9; 30 } 31 table.field-group tbody tr.nodrag:hover td { 32 background-color: #fff; 33 } 34 35 tr.header td { 36 border-bottom: 1px solid #eee; 37 background-color: #fafafa; 38 font-weight: bold; 39 padding: 5px 6px; 40 } 41 42 tr.core td { 43 color: #999; 44 } 45 tr td.center, tr th.center { 46 text-align: center; 47 } 48 49 thead tr th { 50 font-size: 16px; 51 } 133 } 52 134 53 135 ul.forTab { -
trunk/bp-xprofile/admin/js/admin.js
r2812 r2883 98 98 }); 99 99 100 var fixHelper = function(e, ui) { 101 ui.children().each(function() { 102 jQuery(this).width( jQuery(this).width() ); 103 }); 104 return ui; 105 }; 100 /* Main XProfile behavior layer */ 101 jQuery(document).ready( function() { 106 102 107 jQuery(document).ready( function() { 108 jQuery( "form#profile-field-form div#field-groups").sortable( {103 /* Allow reordering of field group tabs */ 104 jQuery( "ul#field-group-tabs" ).sortable( { 109 105 cursor: 'move', 110 axis: 'y', 111 helper: fixHelper, 106 axis: 'x', 112 107 opacity: 0.6, 113 items: 'table', 114 cancel: 'tbody,tfoot', 108 items: 'li', 115 109 tolerance: 'pointer', 110 116 111 update: function() { 117 112 jQuery.post( ajaxurl, { 118 113 action: 'xprofile_reorder_groups', 119 114 'cookie': encodeURIComponent(document.cookie), 120 '_wpnonce_reorder_groups': jQuery( "input#_wpnonce_reorder_groups").val(),121 'group_order': jQuery(this).sortable( 'serialize')115 '_wpnonce_reorder_groups': jQuery( "input#_wpnonce_reorder_groups" ).val(), 116 'group_order': jQuery(this).sortable( 'serialize' ) 122 117 }, 123 118 function(response){}); … … 125 120 }).disableSelection(); 126 121 127 jQuery("table.field-group tbody").sortable( { 122 /* Allow reordering of fields within groups */ 123 jQuery( "fieldset.field-group" ).sortable({ 128 124 cursor: 'move', 129 axis: 'y', 130 helper: fixHelper, 131 opacity: 0.6, 132 items: 'tr', 133 cancel: 'tr.nodrag,tr.core', 134 connectWith: 'table.field-group tbody', 125 opacity: 0.3, 126 items: 'fieldset', 135 127 tolerance: 'pointer', 136 update: function() { 128 129 update: function() { 137 130 jQuery.post( ajaxurl, { 138 131 action: 'xprofile_reorder_fields', 139 132 'cookie': encodeURIComponent(document.cookie), 140 '_wpnonce_reorder_fields': jQuery( "input#_wpnonce_reorder_fields").val(),141 'field_order': jQuery(this).sortable( 'serialize'),142 'field_group_id': jQuery(this).attr( 'id')133 '_wpnonce_reorder_fields': jQuery( "input#_wpnonce_reorder_fields" ).val(), 134 'field_order': jQuery(this).sortable( 'serialize' ), 135 'field_group_id': jQuery(this).attr( 'id' ) 143 136 }, 144 137 function(response){}); … … 146 139 }).disableSelection(); 147 140 141 var $tab_items; 142 143 /* tabs init with a custom tab template and an "add" callback filling in the content */ 144 var $tabs = jQuery( "#tabs" ).tabs(); 145 set_tab_items( $tabs ); 146 147 function set_tab_items( $tabs ) { 148 $tab_items = jQuery( "ul:first li", $tabs ).droppable({ 149 accept: ".connectedSortable fieldset", 150 hoverClass: "ui-state-hover", 151 activeClass: "ui-state-acceptable", 152 touch: "pointer", 153 tolerance: "pointer", 154 155 /* When field is dropped on tab */ 156 drop: function( ev, ui ) { 157 /* The tab */ 158 var $item = jQuery(this); 159 160 /* The tab body */ 161 var $list = jQuery( $item.find( 'a' ).attr( 'href' ) ).find( '.connectedSortable' ); 162 163 /* Remove helper class */ 164 jQuery($item).removeClass( 'drop-candidate' ); 165 166 /* Hide field, change selected tab, and show new placement */ 167 ui.draggable.hide( 'slow', function() { 168 169 /* Select new tab as current */ 170 $tabs.tabs( 'select', $tab_items.index( $item ) ); 171 172 /* Show new placement */ 173 jQuery(this).appendTo($list).show( 'slow' ).animate( {opacity: "1"}, 500 ); 174 175 /* Refresh $list variable */ 176 $list = jQuery( $item.find( 'a' ).attr( 'href' ) ).find( '.connectedSortable' ); 177 jQuery($list).find( 'p.nofields' ).hide( 'slow' ); 178 }); 179 180 jQuery.post( ajaxurl, { 181 action: 'xprofile_reorder_fields', 182 'cookie': encodeURIComponent(document.cookie), 183 '_wpnonce_reorder_fields': jQuery( "input#_wpnonce_reorder_fields" ).val(), 184 'field_order': jQuery( $list ).sortable( 'serialize' ), 185 'field_group_id': jQuery( $list ).attr( 'id' ) 186 }, 187 function(response){}); 188 }, 189 over: function( event, ui ) { 190 jQuery(this).addClass( 'drop-candidate' ); 191 }, 192 out: function( event, ui ) { 193 jQuery(this).removeClass( 'drop-candidate' ); 194 } 195 }); 196 } 148 197 }); -
trunk/bp-xprofile/bp-xprofile-admin.php
r2813 r2883 40 40 else { 41 41 ?> 42 42 43 <div class="wrap"> 43 <h2><?php _e( 'Profile Field Setup', 'buddypress'); ?></h2> 44 <div class="icon32" id="icon-tools"><br></div> 45 <h2> 46 <?php _e( 'Profile Field Setup', 'buddypress'); ?> 47 <a id="add_group" class="button add-new-h2" href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e( 'Add New Group', 'buddypress' ); ?></a> 48 </h2> 44 49 <p><?php _e( 'Your users will distinguish themselves through their profile page. You must give them profile fields that allow them to describe themselves in a way that is relevant to the theme of your social network.', 'buddypress'); ?></p> 45 <p><?php _e('NOTE: Any fields in the first group will appear on the signup page.', 'buddypress'); ?></p>50 <p><?php echo sprintf( __( 'NOTE: Any fields in the "%s" group will appear on the signup page.', 'buddypress' ), get_site_option( 'bp-xprofile-base-group-name' ) ); ?></p> 46 51 47 52 <form action="" id="profile-field-form" method="post"> … … 51 56 52 57 if ( $message != '' ) : 53 $type = ( $type == 'error' ) ? 'error' : 'updated'; 54 ?> 58 $type = ( $type == 'error' ) ? 'error' : 'updated'; ?> 55 59 56 60 <div id="message" class="<?php echo $type; ?> fade"> … … 59 63 <?php endif; ?> 60 64 61 <div id="field-groups"> 65 <div id="tabs"> 66 <ul id="field-group-tabs"> 62 67 <?php 63 68 if ( $groups ) : 64 69 foreach ( $groups as $group ) { ?> 65 66 <table id="group_<?php echo $group->id; ?>" class="widefat field-group sortable"> 67 <thead> 68 <tr class="grabber"> 69 <th scope="col" width="10"><img src="<?php echo BP_PLUGIN_URL; ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ); ?>" /></th> 70 <th scope="col" colspan="3"><?php echo attribute_escape( $group->name ); ?></th> 71 <?php 72 if ( $group->can_delete ) : 73 ?> 74 <th scope="col" class="center"><a class="edit" href="admin.php?page=bp-profile-setup&mode=edit_group&group_id=<?php echo attribute_escape( $group->id ); ?>"><?php _e( 'Edit', 'buddypress' ); ?></a></th> 75 <th scope="col" class="center"><a class="delete" href="admin.php?page=bp-profile-setup&mode=delete_group&group_id=<?php echo attribute_escape( $group->id ); ?>"><?php _e( 'Delete', 'buddypress' ); ?></a></th> 76 <?php 77 else : 78 ?> 79 <th scope="col" class="center"><a class="edit" href="admin.php?page=bp-general-settings"><?php _e( 'Edit', 'buddypress' ); ?></a></th> 80 <th scope="col" class="center"> </th> 81 <?php 82 endif; 83 ?> 84 85 </tr> 86 <tr class="header"> 87 <td> </td> 88 <td><?php _e( 'Field Name', 'buddypress' ); ?></td> 89 <td width="14%"><?php _e( 'Field Type', 'buddypress' ); ?></td> 90 <td width="6%" class="center"><?php _e( 'Required?', 'buddypress' ); ?></td> 91 <td colspan="2" width="10%" class="center"><?php _e( 'Actions', 'buddypress' ); ?></td> 92 </tr> 93 </thead> 94 95 <tfoot> 96 <tr class="nodrag"> 97 <td colspan="6"><a href="admin.php?page=bp-profile-setup&group_id=<?php echo attribute_escape( $group->id ); ?>&mode=add_field"><?php _e( 'Add New Field', 'buddypress' ); ?></a></td> 98 </tr> 99 </tfoot> 100 101 <tbody id="<?php echo $group->id ?>"> 102 <?php 103 if ( $group->fields ) : 104 foreach ( $group->fields as $field ) { 105 if ( 0 == $j % 2 ) 106 $class = ''; 107 else 108 $class = 'alternate'; 109 110 $field = new BP_XProfile_Field( $field->id ); 111 if ( !$field->can_delete ) 112 $class .= ' core nodrag'; 113 ?> 114 115 <tr id="field_<?php echo attribute_escape( $field->id ); ?>" class="sortable<?php if ( $class ) echo ' ' . $class; ?>"> 116 <td width="10"><?php if ( $field->can_delete ) : ?><img src="<?php echo BP_PLUGIN_URL; ?>/bp-xprofile/admin/images/move.gif" alt="<?php _e( 'Drag', 'buddypress' ); ?>" /><?php endif; ?></td> 117 <td><span title="<?php echo $field->description; ?>"><?php echo attribute_escape( $field->name ); ?> <?php if(!$field->can_delete) : ?> <?php _e( '(Core Field)', 'buddypress' ); endif; ?></span></td> 118 <td><?php echo attribute_escape( $field->type ); ?></td> 119 <td class="center"><?php if ( $field->is_required ) : echo '<img src="' . BP_PLUGIN_URL . '/bp-xprofile/admin/images/tick.gif" alt="' . __( 'Yes', 'buddypress' ) . '" />'; else : ?>-<?php endif; ?></td> 120 <td class="center"><a class="edit" href="<?php if ( !$field->can_delete ) { ?>admin.php?page=bp-general-settings<?php } else { ?>admin.php?page=bp-profile-setup&group_id=<?php echo attribute_escape( $group->id ); ?>&field_id=<?php echo attribute_escape( $field->id ); ?>&mode=edit_field<?php } ?>"><?php _e( 'Edit', 'buddypress' ); ?></a></td> 121 <td class="center"><?php if ( !$field->can_delete ) : ?> <?php else : ?><a class="delete" href="admin.php?page=bp-profile-setup&field_id=<?php echo attribute_escape( $field->id ); ?>&mode=delete_field"><?php _e( 'Delete', 'buddypress' ); ?></a><?php endif; ?></td> 122 </tr> 123 <?php 124 } /* end for */ 125 126 else : /* !$group->fields */ 127 ?> 128 129 <tr class="nodrag"> 130 <td colspan="6"><?php _e( 'There are no fields in this group.', 'buddypress' ); ?></td> 131 </tr> 70 <li id="group_<?php echo $group->id; ?>"><a href="#tabs-<?php echo $group->id; ?>" class="ui-tab"><?php echo attribute_escape( $group->name ); ?><?php if ( !$group->can_delete ) : ?> <?php _e( '(Core)', 'buddypress'); endif; ?></a></li> 71 <?php } 72 endif; ?> 73 </ul> 74 75 <?php if ( $groups ) : 76 foreach ( $groups as $group ) { ?> 77 78 <div id="tabs-<?php echo $group->id; ?>" class="tab-wrapper"> 79 <div class="tab-toolbar"> 80 <div class="tab-toolbar-left"> 81 <a class="button" href="admin.php?page=bp-profile-setup&group_id=<?php echo attribute_escape( $group->id ); ?>&mode=add_field"><?php _e( 'Add New Field', 'buddypress' ); ?></a> 82 <a class="button edit" href="admin.php?page=bp-profile-setup&mode=edit_group&group_id=<?php echo attribute_escape( $group->id ); ?>"><?php _e( 'Edit Group', 'buddypress' ); ?></a> 83 <?php if ( $group->can_delete ) : ?> 84 <a class="button delete" href="admin.php?page=bp-profile-setup&mode=delete_group&group_id=<?php echo attribute_escape( $group->id ); ?>"><?php _e( 'Delete Group', 'buddypress' ); ?></a> 85 <?php endif; ?> 86 </div> 87 </div> 88 89 <fieldset id="<?php echo $group->id; ?>" class="connectedSortable field-group"> 90 <?php if( $group->description ) : ?> 91 <legend><?php echo attribute_escape( $group->description ) ?></legend> 92 <?php endif; 93 94 if ( $group->fields ) : 95 foreach ( $group->fields as $field ) { 96 97 /* Load the field */ 98 $field = new BP_XProfile_Field( $field->id ); 99 if ( !$field->can_delete ) 100 $class .= ' core nodrag'; 101 102 /* This function handles the WYSIWYG profile field 103 * display for the xprofile admin setup screen 104 */ 105 xprofile_admin_field( $field, $group ); 106 107 } /* end for */ 108 109 else : /* !$group->fields */ 110 ?> 111 112 <p class="nodrag nofields"><?php _e( 'There are no fields in this group.', 'buddypress' ); ?></p> 132 113 <?php 133 114 endif; /* end $group->fields */ 134 115 ?> 135 136 </tbody> 137 </table> 138 <?php 139 } /* End For */ ?> 116 </fieldset> 140 117 </div> 141 <p> 142 <a class="button" href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e( 'Add New Field Group', 'buddypress' ); ?></a>143 </p>118 <?php 119 } /* End For */ ?> 120 </div> 144 121 <?php 145 122 else : 146 123 ?> 147 148 <div id="message" class="error"><p><?php _e('You have no groups.', 'buddypress' ); ?></p></div> 124 <div id="message" class="error"><p><?php _e( 'You have no groups.', 'buddypress' ); ?></p></div> 149 125 <p><a href="admin.php?page=bp-profile-setup&mode=add_group"><?php _e( 'Add New Group', 'buddypress' ); ?></a></p> 150 126 <?php 151 127 endif; 152 128 ?> 153 154 </form> 155 </div> 129 </form> 130 </div> 156 131 <?php 157 132 } … … 169 144 $group = new BP_XProfile_Group( $group_id ); 170 145 171 if ( isset( $_POST['save Group'] ) ) {146 if ( isset( $_POST['save_group'] ) ) { 172 147 if ( BP_XProfile_Group::admin_validate( $_POST ) ) { 173 $group->name 174 $group->description = wp_filter_kses( $_POST['group_desc'] );148 $group->name = wp_filter_kses( $_POST['group_name'] ); 149 $group->description = wp_filter_kses( $_POST['group_description'] ); 175 150 176 151 if ( !$group->save() ) { … … 216 191 } 217 192 218 unset( $_GET['mode'] ); /* TODO: wtf? */193 unset( $_GET['mode'] ); 219 194 xprofile_admin( $message, $type ); 220 195 } … … 242 217 243 218 $field->field_order = $wpdb->get_var( $wpdb->prepare( "SELECT field_order FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id ) ); 244 245 219 if ( !$field->field_order ) { 246 220 $field->field_order = (int) $wpdb->get_var( $wpdb->prepare( "SELECT max(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id ) ); … … 278 252 Handles the deletion of a profile field [or option]. 279 253 **************************************************************************/ 280 281 254 function xprofile_admin_delete_field( $field_id, $type = 'field' ) { 282 255 global $message, $type; … … 303 276 } 304 277 278 /************************************************************************** 279 xprofile_ajax_reorder_fields() 280 281 Handles the ajax reordering of fields within a group 282 **************************************************************************/ 305 283 function xprofile_ajax_reorder_fields() { 306 284 global $bp; … … 321 299 add_action( 'wp_ajax_xprofile_reorder_fields', 'xprofile_ajax_reorder_fields' ); 322 300 301 /************************************************************************** 302 xprofile_ajax_reorder_field_groups() 303 304 Handles the reordering of field groups 305 **************************************************************************/ 323 306 function xprofile_ajax_reorder_field_groups() { 324 307 global $bp; … … 337 320 } 338 321 add_action( 'wp_ajax_xprofile_reorder_groups', 'xprofile_ajax_reorder_field_groups' ); 322 323 /************************************************************************** 324 xprofile_admin_field() 325 326 Handles the WYSIWYG display of each profile field on the edit screen 327 **************************************************************************/ 328 function xprofile_admin_field( $admin_field, $admin_group ) { 329 global $field; 330 331 $field = $admin_field; 332 ?> 333 <fieldset id="field_<?php echo attribute_escape( $field->id ); ?>" class="sortable<?php echo ' ' . $field->type; if ( $class ) echo ' ' . $class; ?>"> 334 <legend><?php bp_the_profile_field_name(); ?> <?php if( !$field->can_delete ) : ?> <?php _e( '(Core)', 'buddypress' ); endif; ?> <?php if ( bp_get_the_profile_field_is_required() ) : ?><?php _e( '(required)', 'buddypress' ) ?><?php endif; ?></legend> 335 <div class="field-wrapper"> 336 <?php 337 switch ( $field->type ) { 338 case 'textbox' : ?> 339 340 <input type="text" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" value="" /> 341 <?php break; case 'textarea' : ?> 342 343 <textarea rows="5" cols="40" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>"></textarea> 344 <?php break; case 'selectbox' : ?> 345 346 <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>"> 347 <?php bp_the_profile_field_options() ?> 348 349 </select> 350 351 <?php break; case 'multiselectbox' : ?> 352 353 <select name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" multiple="multiple"> 354 <?php bp_the_profile_field_options() ?> 355 356 </select> 357 358 <?php break; case 'radio' : ?> 359 360 <?php bp_the_profile_field_options() ?> 361 362 <?php if ( !bp_get_the_profile_field_is_required() ) : ?> 363 364 <a class="clear-value" href="javascript:clear( '<?php bp_the_profile_field_input_name() ?>' );"><?php _e( 'Clear', 'buddypress' ) ?></a> 365 <?php endif; ?> 366 367 <?php break; case 'checkbox' : ?> 368 369 <?php bp_the_profile_field_options(); ?> 370 371 <?php break; case 'datebox' : ?> 372 373 <select name="<?php bp_the_profile_field_input_name(); ?>_day" id="<?php bp_the_profile_field_input_name(); ?>_day"> 374 <?php bp_the_profile_field_options( 'type=day' ); ?> 375 376 </select> 377 378 <select name="<?php bp_the_profile_field_input_name(); ?>_month" id="<?php bp_the_profile_field_input_name(); ?>_month"> 379 <?php bp_the_profile_field_options( 'type=month' ); ?> 380 381 </select> 382 383 <select name="<?php bp_the_profile_field_input_name(); ?>_year" id="<?php bp_the_profile_field_input_name(); ?>_year"> 384 <?php bp_the_profile_field_options( 'type=year' ); ?> 385 386 </select> 387 388 <?php break; default : ?> 389 390 <?php do_action( 'xprofile_admin_field', $field, 1 ); ?> 391 392 <?php } ?> 393 <div class="actions"> 394 <a class="button edit" href="admin.php?page=bp-profile-setup&group_id=<?php echo attribute_escape( $admin_group->id ); ?>&field_id=<?php echo attribute_escape( $field->id ); ?>&mode=edit_field"><?php _e( 'Edit', 'buddypress' ); ?></a> 395 <?php if ( !$field->can_delete ) : ?> <?php else : ?><a class="button delete" href="admin.php?page=bp-profile-setup&field_id=<?php echo attribute_escape( $field->id ); ?>&mode=delete_field"><?php _e( 'Delete', 'buddypress' ); ?></a><?php endif; ?> 396 397 </div> 398 <?php if ( $field->description ) : ?> 399 <p class="description"><?php echo attribute_escape( $field->description ); ?></p> 400 <?php endif; ?> 401 </div> 402 </fieldset> 403 <?php 404 } -
trunk/bp-xprofile/bp-xprofile-classes.php
r2810 r2883 6 6 var $description; 7 7 var $can_delete; 8 var $group_order; 8 9 var $fields; 9 10 … … 11 12 global $bp, $wpdb; 12 13 13 if ( $id ) {14 if ( $id ) 14 15 $this->populate( $id ); 15 } 16 16 17 } 17 18 … … 24 25 return false; 25 26 26 $this->id = $group->id; 27 $this->name = $group->name; 28 $this->description = $group->description; 29 $this->can_delete = $group->can_delete; 27 $this->id = $group->id; 28 $this->name = $group->name; 29 $this->description = $group->description; 30 $this->can_delete = $group->can_delete; 31 $this->group_order = $group->group_order; 30 32 } 31 33 … … 33 35 global $wpdb, $bp; 34 36 35 $this->name 36 $this->description 37 $this->name = apply_filters( 'xprofile_group_name_before_save', $this->name, $this->id ); 38 $this->description = apply_filters( 'xprofile_group_description_before_save', $this->description, $this->id ); 37 39 38 40 do_action( 'xprofile_group_before_save', $this ); … … 43 45 $sql = $wpdb->prepare( "INSERT INTO {$bp->profile->table_name_groups} (name, description, can_delete) VALUES (%s, %s, 1)", $this->name, $this->description ); 44 46 45 if ( !$wpdb->query( $sql) )47 if ( !$wpdb->query( $sql ) ) 46 48 return false; 47 49 … … 121 123 if ( $fetch_field_data ) { 122 124 /* Fetch the field data for the user. */ 123 foreach( (array)$fields as $field ) {125 foreach( (array)$fields as $field ) 124 126 $field_ids[] = $field->id; 125 }126 127 127 128 $field_ids = implode( ',', (array) $field_ids ); … … 172 173 } 173 174 174 /* ADMIN AREA HTML. TODO: Get this out of here. */ 175 /* ADMIN AREA HTML. 176 * TODO: Get this out of here and replace with standard loops 177 */ 175 178 176 179 function render_admin_form() { … … 178 181 179 182 if ( !$this->id ) { 180 $title = __('Add New Field Group', 'buddypress'); 181 $action = "admin.php?page=bp-profile-setup&mode=add_group"; 183 $title = __( 'Add New Field Group', 'buddypress' ); 184 $action = "admin.php?page=bp-profile-setup&mode=add_group"; 185 $button = __( 'Create Field Group', 'buddypress' ); 182 186 } else { 183 $title = __( 'Edit Field Group', 'buddypress');187 $title = __( 'Edit Field Group', 'buddypress' ); 184 188 $action = "admin.php?page=bp-profile-setup&mode=edit_group&group_id=" . $this->id; 189 $button = __( 'Save Changes', 'buddypress' ); 185 190 } 186 191 ?> 187 192 <div class="wrap"> 188 193 <div class="icon32" id="icon-tools"><br></div> 189 194 <h2><?php echo $title; ?></h2> 190 <?php 191 if ( $message != '' ) { 192 $type = ( 'error' == $type ) ? 'error' : 'updated'; 193 ?> 194 195 <p><?php _e( 'Fields marked * are required', 'buddypress' ) ?></p> 196 197 <?php if ( $message != '' ) : 198 $type = ( 'error' == $type ) ? 'error' : 'updated'; ?> 195 199 <div id="message" class="<?php echo $type; ?> fade"> 196 200 <p><?php echo $message; ?></p> 197 201 </div> 198 <?php } ?> 199 200 <form action="<?php echo attribute_escape( $action ); ?>" method="post"> 201 <div id="titlediv"> 202 <label for="group_name"><?php _e( "Field Group Name", 'buddypress') ?></label> 203 <div> 204 <input type="text" name="group_name" id="group_name" value="<?php echo attribute_escape( $this->name ); ?>" style="width:50%" /> 202 <?php endif; ?> 203 <div id="poststuff"> 204 <form action="<?php echo attribute_escape( $action ); ?>" method="post"> 205 <div id="titlediv"> 206 <h3><label for="group_name"><?php _e( "Field Group Title", 'buddypress') ?> *</label></h3> 207 <div id="titlewrap"> 208 <input type="text" name="group_name" id="title" value="<?php echo attribute_escape( $this->name ); ?>" style="width:50%" /> 209 </div> 205 210 </div> 206 </div> 207 208 <p class="submit" style="text-align: left"> 209 <input type="submit" name="saveGroup" value="<?php echo attribute_escape( $title ); ?> →" /> 210 </p> 211 </form> 211 212 <?php if ( '0' != $this->can_delete ) : ?> 213 <div id="titlediv"> 214 <h3><label for="description"><?php _e( "Group Description", 'buddypress' ); ?></label></h3> 215 <div id="titlewrap"> 216 <textarea name="group_description" id="group_description" rows="8" cols="60"><?php echo htmlspecialchars( $this->description ); ?></textarea> 217 </div> 218 </div> 219 <?php endif; ?> 220 221 <p class="submit"> 222 <input type="hidden" name="group_order" id="group_order" value="<?php echo attribute_escape( $this->group_order ); ?>" /> 223 <input type="submit" name="save_group" value="<?php echo attribute_escape( $button ); ?>" class="button-primary"/> 224 <?php _e( 'or', 'buddypress' ); ?> <a href="admin.php?page=bp-profile-setup" class="deletion"><?php _e( 'Cancel', 'buddypress' ); ?></a> 225 </p> 226 </form> 227 </div> 212 228 </div> 213 229 <?php … … 248 264 249 265 if ( $field = $wpdb->get_row( $sql ) ) { 250 $this->id 251 $this->group_id 252 $this->parent_id 253 $this->type 254 $this->name 255 $this->description 256 $this->is_required 257 $this->can_delete 258 $this->field_order 259 $this->option_order 260 $this->order_by 261 $this->is_default_option 266 $this->id = $field->id; 267 $this->group_id = $field->group_id; 268 $this->parent_id = $field->parent_id; 269 $this->type = $field->type; 270 $this->name = stripslashes($field->name); 271 $this->description = stripslashes($field->description); 272 $this->is_required = $field->is_required; 273 $this->can_delete = $field->can_delete; 274 $this->field_order = $field->field_order; 275 $this->option_order = $field->option_order; 276 $this->order_by = $field->order_by; 277 $this->is_default_option = $field->is_default_option; 262 278 263 279 if ( $get_data ) 264 $this->data 280 $this->data = $this->get_field_data( $user_id ); 265 281 266 282 } … … 291 307 $error = false; 292 308 293 $this->group_id 294 $this->parent_id 295 $this->type 296 $this->name 297 $this->description 298 $this->is_required 299 $this->order_by 300 $this->field_order 309 $this->group_id = apply_filters( 'xprofile_field_group_id_before_save', $this->group_id, $this->id ); 310 $this->parent_id = apply_filters( 'xprofile_field_parent_id_before_save', $this->parent_id, $this->id ); 311 $this->type = apply_filters( 'xprofile_field_type_before_save', $this->type, $this->id ); 312 $this->name = apply_filters( 'xprofile_field_name_before_save', $this->name, $this->id ); 313 $this->description = apply_filters( 'xprofile_field_description_before_save', $this->description, $this->id ); 314 $this->is_required = apply_filters( 'xprofile_field_is_required_before_save', $this->is_required, $this->id ); 315 $this->order_by = apply_filters( 'xprofile_field_order_by_before_save', $this->order_by, $this->id ); 316 $this->field_order = apply_filters( 'xprofile_field_field_order_before_save', $this->field_order, $this->id ); 301 317 302 318 do_action( 'xprofile_field_before_save', $this ); … … 312 328 */ 313 329 if ( $wpdb->query( $sql ) !== null ) { 314 315 330 if ( $this->id ) 316 331 $field_id = $this->id; … … 340 355 341 356 if ( 'radio' == $this->type ) { 342 $options 343 $defaults 357 $options = $_POST['radio_option']; 358 $defaults = $_POST['isDefault_radio_option']; 344 359 345 360 } else if ( 'selectbox' == $this->type ) { 346 $options 347 $defaults 361 $options = $_POST['selectbox_option']; 362 $defaults = $_POST['isDefault_selectbox_option']; 348 363 349 364 } else if ( 'multiselectbox' == $this->type ) { 350 $options 351 $defaults 365 $options = $_POST['multiselectbox_option']; 366 $defaults = $_POST['isDefault_multiselectbox_option']; 352 367 353 368 } else if ( 'checkbox' == $this->type ) { 354 $options = $_POST['checkbox_option']; 355 $defaults = $_POST['isDefault_checkbox_option']; 356 369 $options = $_POST['checkbox_option']; 370 $defaults = $_POST['isDefault_checkbox_option']; 357 371 } 358 372 … … 379 393 } 380 394 } 381 } else { 382 $error = true; 383 } 384 385 if ( !$error ) { 395 386 396 do_action( 'xprofile_field_after_save', $this ); 397 387 398 return $field_id; 388 399 } else { … … 486 497 } 487 498 488 /* ADMIN AREA HTML. TODO: Get this out of here. */ 499 /* ADMIN AREA HTML. 500 * TODO: Get this out of here and replace with standard template loops 501 */ 489 502 490 503 /* This function populates the items for radio buttons checkboxes and drop down boxes */ … … 501 514 ?> 502 515 <div id="<?php echo $type; ?>" class="options-box" style="<?php if ( $this->type != $type ) { ?>display: none;<?php } ?> margin-left: 15px;"> 503 <h4><?php _e( 'Please enter options for this Field:', 'buddypress'); ?></h4>516 <h4><?php _e( 'Please enter options for this Field:', 'buddypress' ); ?></h4> 504 517 <p><?php _e( 'Order By:', 'buddypress' ); ?> 505 518 <select name="sort_order_<?php echo $type; ?>" id="sort_order_<?php echo $type; ?>" > … … 536 549 <input type="text" name="<?php echo $type; ?>_option[<?php echo $j; ?>]" id="<?php echo $type; ?>_option<?php echo $j; ?>" value="<?php echo attribute_escape( $options[$i]->name ); ?>" /> 537 550 <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' ); ?> 538 <?php if ( $j != 1 && 539 $options[$i]->id != -1 ) : ?><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><?php endif; ?></p> 551 <?php 552 if ( $j != 1 && $options[$i]->id != -1 ) : ?> 553 <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> 554 <?php endif; ?> 540 555 </p> 541 556 <?php } /* end for */ ?> … … 564 579 if ( !$this->id ) { 565 580 $title = __( 'Add Field', 'buddypress' ); 566 $action = "admin.php?page=bp-profile-setup&group_id=" . $this->group_id . "&mode=add_field ";581 $action = "admin.php?page=bp-profile-setup&group_id=" . $this->group_id . "&mode=add_field#tabs-" . $this->group_id; 567 582 568 583 $this->name = $_POST['title']; … … 571 586 $this->type = $_POST['fieldtype']; 572 587 $this->order_by = $_POST["sort_order_{$this->type}"]; 588 $this->field_order = $_POST['field_order']; 573 589 } else { 574 590 $title = __( 'Edit Field', 'buddypress' ); 575 $action = "admin.php?page=bp-profile-setup&mode=edit_field&group_id=" . $this->group_id . "&field_id=" . $this->id; 576 } 577 ?> 578 591 $action = "admin.php?page=bp-profile-setup&mode=edit_field&group_id=" . $this->group_id . "&field_id=" . $this->id . "#tabs-" . $this->group_id; 592 } 593 ?> 579 594 <div class="wrap"> 595 <div id="icon-users" class="icon32"><br /></div> 580 596 <h2><?php echo $title; ?></h2> 597 <p><?php _e( 'Fields marked * are required', 'buddypress' ) ?></p> 598 581 599 <?php 582 600 if ( $message != '' ) { 583 601 ?> 584 585 602 <div id="message" class="error fade"> 586 603 <p><?php echo $message; ?></p> 587 604 </div> 588 <?php 605 <?php } ?> 589 606 590 607 <form action="<?php echo $action; ?>" method="post"> … … 596 613 </div> 597 614 </div> 598 599 <div id="titlediv" class="inside"> 615 <?php 616 if ( '0' != $this->can_delete ) { 617 ?> 618 <div id="titlediv"> 600 619 <h3><label for="description"><?php _e("Field Description", 'buddypress'); ?></label></h3> 601 620 <div id="titlewrap"> … … 626 645 627 646 <?php $this->render_admin_form_children(); ?> 628 647 <?php } else { ?> 648 <input type="hidden" name="required" id="required" value="1" /> 649 <input type="hidden" name="fieldtype" id="fieldtype" value="textbox" /> 650 <?php } ?> 629 651 <p class="submit"> 630 <input type="submit" value="<?php _e( 'Save', 'buddypress' ); ?> →" name="saveField" id="saveField" style="font-weight: bold" /> 631 <?php _e( 'or', 'buddypress' ); ?> <a href="admin.php?page=bp-profile-setup" style="color: red"><?php _e( 'Cancel', 'buddypress' ); ?></a> 652 <input type="hidden" name="field_order" id="field_order" value="<?php echo attribute_escape( $this->field_order ); ?>" /> 653 <input type="submit" value="<?php _e( 'Save', 'buddypress' ); ?>" name="saveField" id="saveField" style="font-weight: bold" class="button-primary" /> 654 <?php _e( 'or', 'buddypress' ); ?> <a href="admin.php?page=bp-profile-setup" class="deletion"><?php _e( 'Cancel', 'buddypress' ); ?></a> 632 655 </p> 633 656 634 657 </div> 635 636 <div class="clear"></div>637 658 638 659 <?php if ( function_exists( 'wp_nonce_field' ) ) wp_nonce_field( 'xprofile_delete_option' ); ?> -
trunk/bp-xprofile/bp-xprofile-cssjs.php
r2798 r2883 8 8 function xprofile_add_admin_js() { 9 9 if ( strpos( $_GET['page'], 'bp-profile-setup' ) !== false ) { 10 wp_enqueue_script( 'jquery-ui-core' ); 11 wp_enqueue_script( 'jquery-ui-tabs' ); 12 wp_enqueue_script( 'jquery-ui-mouse' ); 13 wp_enqueue_script( 'jquery-ui-draggable' ); 14 wp_enqueue_script( 'jquery-ui-droppable' ); 10 15 wp_enqueue_script( 'jquery-ui-sortable' ); 11 16 wp_enqueue_script( 'xprofile-admin-js', BP_PLUGIN_URL . '/bp-xprofile/admin/js/admin.js', array( 'jquery', 'jquery-ui-sortable' ) ); 17 //wp_enqueue_script( 'xprofile-button-js', BP_PLUGIN_URL . '/bp-xprofile/admin/js/button.js', array( 'xprofile-admin-js' ) ); 12 18 } 13 19 }
Note: See TracChangeset
for help on using the changeset viewer.