- Timestamp:
- 10/01/2015 04:18:13 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type.php
r10142 r10163 1 1 <?php 2 2 /** 3 * BuddyPress XProfile Classes 3 * BuddyPress XProfile Classes. 4 4 * 5 5 * @package BuddyPress … … 7 7 */ 8 8 9 // Exit if accessed directly 9 // Exit if accessed directly. 10 10 defined( 'ABSPATH' ) || exit; 11 11 … … 18 18 19 19 /** 20 * @since 2.0.0 21 * @var array Field type validation regexes 20 * Validation regex rules for field type. 21 22 * @since 2.0.0 23 * @var array Field type validation regexes. 22 24 */ 23 25 protected $validation_regex = array(); 24 26 25 27 /** 26 * @since 2.0.0 27 * @var array Field type whitelisted values 28 * Whitelisted values for field type. 29 * 30 * @since 2.0.0 31 * @var array Field type whitelisted values. 28 32 */ 29 33 protected $validation_whitelist = array(); 30 34 31 35 /** 32 * @since 2.0.0 33 * @var string The name of this field type 36 * Name for field type. 37 * 38 * @since 2.0.0 39 * @var string The name of this field type. 34 40 */ 35 41 public $name = ''; … … 44 50 45 51 /** 52 * If allowed to store null/empty values. 53 * 46 54 * @since 2.0.0 47 55 * @var bool If this is set, allow BP to store null/empty values for this field type. … … 58 66 59 67 /** 68 * If allowed to support multiple options as default. 69 * 60 70 * @since 2.0.0 61 71 * @var bool Does this field type support multiple options being set as default values? e.g. multiselectbox, checkbox. … … 64 74 65 75 /** 66 * @since 2.0.0 67 * @var BP_XProfile_Field If this object is created by instantiating a {@link BP_XProfile_Field}, this is a reference back to that object. 76 * If object is created by an BP_XProfile_Field object. 77 * 78 * @since 2.0.0 79 * @var BP_XProfile_Field If this object is created by instantiating a {@link BP_XProfile_Field}, 80 * this is a reference back to that object. 68 81 */ 69 82 public $field_obj = null; 70 83 71 84 /** 72 * Constructor 85 * Constructor. 73 86 * 74 87 * @since 2.0.0 … … 93 106 * it's successful as long as the new value matches any one of the registered formats. 94 107 * 95 * @param string $format Regex string 96 * @param string $replace_format Optional; if 'replace', replaces the format instead of adding to it. Defaults to 'add'. 108 * @since 2.0.0 109 * 110 * @param string $format Regex string. 111 * @param string $replace_format Optional; if 'replace', replaces the format instead of adding to it. 112 * Defaults to 'add'. 113 * 97 114 * @return BP_XProfile_Field_Type 98 * @since 2.0.099 115 */ 100 116 public function set_format( $format, $replace_format = 'add' ) { … … 127 143 * it's successful as long as the new value matches any one of the registered formats. 128 144 * 129 * @param string|array $values 145 * @since 2.0.0 146 * 147 * @param string|array $values Whitelisted values. 148 * 130 149 * @return BP_XProfile_Field_Type 131 * @since 2.0.0132 150 */ 133 151 public function set_whitelist_values( $values ) { … … 154 172 * This method doesn't support chaining. 155 173 * 156 * @param string|array $values Value to check against the registered formats 174 * @since 2.0.0 175 * 176 * @param string|array $values Value to check against the registered formats. 177 * 157 178 * @return bool True if the value validates 158 * @since 2.0.0159 179 */ 160 180 public function is_valid( $values ) { 161 181 $validated = false; 162 182 163 // Some types of field (e.g. multi-selectbox) may have multiple values to check 183 // Some types of field (e.g. multi-selectbox) may have multiple values to check. 164 184 foreach ( (array) $values as $value ) { 165 185 … … 176 196 } 177 197 178 // Handle field types with accepts_null_value set if $values is an empty array 198 // Handle field types with accepts_null_value set if $values is an empty array. 179 199 if ( ( false === $validated ) && is_array( $values ) && empty( $values ) && $this->accepts_null_value ) { 180 200 $validated = true; … … 205 225 * Must be used inside the {@link bp_profile_fields()} template loop. 206 226 * 227 * @since 2.0.0 228 * 207 229 * @param array $raw_properties Optional key/value array of permitted attributes that you want to add. 208 * @since 2.0.0209 230 */ 210 231 abstract public function edit_field_html( array $raw_properties = array() ); 232 233 /** 234 * Output HTML for this field type on the wp-admin Profile Fields screen. 235 * 236 * Must be used inside the {@link bp_profile_fields()} template loop. 237 * 238 * @param array $raw_properties Optional key/value array of permitted attributes that you want to add. 239 * @since 2.0.0 240 */ 241 abstract public function admin_field_html( array $raw_properties = array() ); 211 242 212 243 /** … … 222 253 * Must be used inside the {@link bp_profile_fields()} template loop. 223 254 * 255 * @since 2.0.0 256 * 224 257 * @param array $args Optional. The arguments passed to {@link bp_the_profile_field_options()}. 225 * @since 2.0.0226 258 */ 227 259 public function edit_field_options_html( array $args = array() ) {} 228 229 /**230 * Output HTML for this field type on the wp-admin Profile Fields screen.231 *232 * Must be used inside the {@link bp_profile_fields()} template loop.233 *234 * @param array $raw_properties Optional key/value array of permitted attributes that you want to add.235 * @since 2.0.0236 */237 abstract public function admin_field_html( array $raw_properties = array() );238 260 239 261 /** … … 246 268 * Must be used inside the {@link bp_profile_fields()} template loop. 247 269 * 270 * @since 2.0.0 271 * 248 272 * @param BP_XProfile_Field $current_field The current profile field on the add/edit screen. 249 * @param string $control_type Optional. HTML input type used to render the current field's child options.250 * @since 2.0.0273 * @param string $control_type Optional. HTML input type used to render the current 274 * field's child options. 251 275 */ 252 276 public function admin_new_field_html( BP_XProfile_Field $current_field, $control_type = '' ) { … … 295 319 } 296 320 297 // Grab the values from $_POST to use as the form's options 321 // Grab the values from $_POST to use as the form's options. 298 322 $options[] = (object) array( 299 323 'id' => -1, … … 315 339 } 316 340 317 // Render the markup for the children options 341 // Render the markup for the children options. 318 342 if ( ! empty( $options ) ) { 319 343 $default_name = ''; … … 385 409 * @since 2.1.0 386 410 * 387 * @param mixed $submitted_value Submitted value. 411 * @param mixed $field_value Submitted field value. 412 * 388 413 * @return mixed 389 414 */ … … 402 427 * 403 428 * @param mixed $field_value Field value. 429 * 404 430 * @return mixed 405 431 */ … … 416 442 * This method was intended to be static but couldn't be because php.net/lsb/ requires PHP >= 5.3. 417 443 * 444 * @since 2.0.0 445 * 418 446 * @param array $properties Optional key/value array of attributes for this edit field. 447 * 419 448 * @return string 420 * @since 2.0.0421 449 */ 422 450 protected function get_edit_field_html_elements( array $properties = array() ) { … … 431 459 } 432 460 433 $html = '';434 435 461 /** 436 462 * Filters the edit html elements and attributes.
Note: See TracChangeset
for help on using the changeset viewer.