Changeset 396 for trunk/patForms/Element
- Timestamp:
- 09/27/07 20:01:56 (1 year ago)
- Files:
-
- trunk/patForms/Element/String.php (modified) (6 diffs)
- trunk/patForms/Element/Text.php (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/patForms/Element/String.php
r361 r396 337 337 if( $this->attributes["type"] == "password" ) 338 338 { 339 $display = str_repeat( "*", strlen( $value ) );339 $display = str_repeat( "*", $this->strlen( $value ) ); 340 340 } 341 341 … … 359 359 $required = true; 360 360 361 if( strlen( $value ) == 0 )361 if( $this->strlen( $value ) == 0 ) 362 362 $empty = true; 363 363 … … 379 379 380 380 // check for tags 381 if( strlen( $this->attributes["allowedtags"] ) )381 if( $this->strlen( $this->attributes["allowedtags"] ) ) 382 382 { 383 383 $allowed = explode( ',', $this->attributes["allowedtags"] ); … … 388 388 $allowed = implode( '', $allowed ); 389 389 $newValue = strip_tags( $value, $allowed ); 390 if( strlen( $newValue ) !=strlen( $value ) )390 if( $this->strlen( $newValue ) != $this->strlen( $value ) ) 391 391 { 392 392 $this->addValidationError( 6, array( 'allowedtags' => htmlspecialchars( $allowed ) ) ); … … 397 397 { 398 398 $newValue = strip_tags( $value ); 399 if( strlen( $newValue ) !=strlen( $value ) )399 if( $this->strlen( $newValue ) != $this->strlen( $value ) ) 400 400 { 401 401 $this->addValidationError( 7 ); … … 412 412 413 413 // maxlength 414 if( isset( $this->attributes["maxlength"] ) && strlen( $value ) > $this->attributes["maxlength"] )414 if( isset( $this->attributes["maxlength"] ) && $this->strlen( $value ) > $this->attributes["maxlength"] ) 415 415 { 416 416 $this->addValidationError( 4, array( "maxlength" => $this->attributes["maxlength"] ) ); trunk/patForms/Element/Text.php
r336 r396 2 2 /** 3 3 * simple textfield patForms element that builds and validates text input fields. 4 * 4 * 5 5 * @access protected 6 6 * @package patForms … … 11 11 /** 12 12 * simple textfield patForms element that builds and validates text input fields. 13 * 13 * 14 14 * @access protected 15 15 * @package patForms … … 29 29 /** 30 30 * the type of the element - set this to the type of element you are creating 31 * if you want to use the {@link patForms_Element::element2html()} method to 31 * if you want to use the {@link patForms_Element::element2html()} method to 32 32 * create the final HTML tag for your element. 33 33 * … … 35 35 * @see patForms_Element::element2html() 36 36 */ 37 var $elementType = array( 37 var $elementType = array( 38 38 'html' => 'input', 39 39 ); 40 40 41 41 /** 42 42 * set here which attributes you want to include in the element if you want to use … … 47 47 * @see patForms_Element::convertDefinition2Attribute() 48 48 */ 49 var $attributeDefinition = array( 50 51 'id' => array( 52 'required' => false, 53 'format' => 'string', 54 'outputFormats' => array( 'html' ), 55 ), 56 'name' => array( 49 var $attributeDefinition = array( 50 51 'id' => array( 52 'required' => false, 53 'format' => 'string', 54 'outputFormats' => array( 'html' ), 55 ), 56 'name' => array( 57 57 'required' => true, 58 58 'format' => 'string', … … 60 60 'modifiers' => array( 'insertSpecials' => array() ), 61 61 ), 62 'title' => array( 63 'required' => false, 64 'format' => 'string', 65 'outputFormats' => array( 'html' ), 66 'modifiers' => array( 'insertSpecials' => array() ), 67 ), 68 'description' => array( 69 'required' => false, 70 'format' => 'string', 71 'outputFormats' => array(), 72 'modifiers' => array( 'insertSpecials' => array() ), 73 ), 74 'default' => array( 75 'required' => false, 76 'format' => 'string', 77 'outputFormats' => array(), 78 ), 79 'label' => array( 80 'required' => false, 81 'format' => 'string', 82 'outputFormats' => array(), 83 ), 84 'edit' => array( 62 'title' => array( 63 'required' => false, 64 'format' => 'string', 65 'outputFormats' => array( 'html' ), 66 'modifiers' => array( 'insertSpecials' => array() ), 67 ), 68 'description' => array( 69 'required' => false, 70 'format' => 'string', 71 'outputFormats' => array(), 72 'modifiers' => array( 'insertSpecials' => array() ), 73 ), 74 'default' => array( 75 'required' => false, 76 'format' => 'string', 77 'outputFormats' => array(), 78 ), 79 'label' => array( 80 'required' => false, 81 'format' => 'string', 82 'outputFormats' => array(), 83 ), 84 'edit' => array( 85 85 'required' => false, 86 86 'format' => 'string', … … 88 88 'outputFormats' => array(), 89 89 ), 90 'display' => array( 90 'display' => array( 91 91 'required' => false, 92 92 'format' => 'string', … … 94 94 'outputFormats' => array(), 95 95 ), 96 'required' => array( 96 'required' => array( 97 97 'required' => false, 98 98 'format' => 'string', … … 100 100 'outputFormats' => array(), 101 101 ), 102 'value' => array( 103 'required' => false, 104 'format' => 'string', 105 'outputFormats' => array( 'html' ), 106 ), 107 'style' => array( 108 'required' => false, 109 'outputFormats' => array( 'html' ), 110 'format' => 'string', 111 ), 112 'class' => array( 113 'required' => false, 114 'outputFormats' => array( 'html' ), 115 'format' => 'string', 116 ), 117 'onchange' => array( 118 'required' => false, 119 'format' => 'string', 120 'outputFormats' => array( 'html' ), 121 'modifiers' => array( 'insertSpecials' => array() ), 122 ), 123 'onclick' => array( 124 'required' => false, 125 'format' => 'string', 126 'outputFormats' => array( 'html' ), 127 'modifiers' => array( 'insertSpecials' => array() ), 128 ), 129 'onfocus' => array( 130 'required' => false, 131 'format' => 'string', 132 'outputFormats' => array( 'html' ), 133 'modifiers' => array( 'insertSpecials' => array() ), 134 ), 135 'onmouseover' => array( 136 'required' => false, 137 'format' => 'string', 138 'outputFormats' => array( 'html' ), 139 'modifiers' => array( 'insertSpecials' => array() ), 140 ), 141 'onmouseout' => array( 142 'required' => false, 143 'format' => 'string', 144 'outputFormats' => array( 'html' ), 145 'modifiers' => array( 'insertSpecials' => array() ), 146 ), 147 'onblur' => array( 148 'required' => false, 149 'format' => 'string', 150 'outputFormats' => array( 'html' ), 151 'modifiers' => array( 'insertSpecials' => array() ), 152 ), 153 'accesskey' => array( 154 'required' => false, 155 'format' => 'string', 156 'outputFormats' => array( 'html' ), 157 ), 158 'position' => array( 159 'required' => false, 160 'format' => 'int', 161 'outputFormats' => array(), 162 ), 163 'tabindex' => array( 102 'value' => array( 103 'required' => false, 104 'format' => 'string', 105 'outputFormats' => array( 'html' ), 106 ), 107 'style' => array( 108 'required' => false, 109 'outputFormats' => array( 'html' ), 110 'format' => 'string', 111 ), 112 'class' => array( 113 'required' => false, 114 'outputFormats' => array( 'html' ), 115 'format' => 'string', 116 ), 117 'onchange' => array( 118 'required' => false, 119 'format' => 'string', 120 'outputFormats' => array( 'html' ), 121 'modifiers' => array( 'insertSpecials' => array() ), 122 ), 123 'onclick' => array( 124 'required' => false, 125 'format' => 'string', 126 'outputFormats' => array( 'html' ), 127 'modifiers' => array( 'insertSpecials' => array() ), 128 ), 129 'onfocus' => array( 130 'required' => false, 131 'format' => 'string', 132 'outputFormats' => array( 'html' ), 133 'modifiers' => array( 'insertSpecials' => array() ), 134 ), 135 'onmouseover' => array( 136 'required' => false, 137 'format' => 'string', 138 'outputFormats' => array( 'html' ), 139 'modifiers' => array( 'insertSpecials' => array() ), 140 ), 141 'onmouseout' => array( 142 'required' => false, 143 'format' => 'string', 144 'outputFormats' => array( 'html' ), 145 'modifiers' => array( 'insertSpecials' => array() ), 146 ), 147 'onblur' => array( 148 'required' => false, 149 'format' => 'string', 150 'outputFormats' => array( 'html' ), 151 'modifiers' => array( 'insertSpecials' => array() ), 152 ), 153 'accesskey' => array( 154 'required' => false, 155 'format' => 'string', 156 'outputFormats' => array( 'html' ), 157 ), 158 'position' => array( 159 'required' => false, 160 'format' => 'int', 161 'outputFormats' => array(), 162 ), 163 'tabindex' => array( 164 164 'required' => false, 165 165 'format' => 'int', … … 205 205 ), 206 206 ); 207 207 208 208 /** 209 209 * define error codes and messages for each form element … … 242 242 ); 243 243 244 244 245 245 /** 246 246 * element creation method for the 'HTML' format in the 'default' form mode. … … 255 255 return $this->createDisplaylessTag( $value ); 256 256 } 257 257 258 258 if( $this->attributes['edit'] == 'no' ) { 259 259 $this->attributes['disabled'] = 'yes'; 260 260 } 261 261 262 262 return $this->createTag( 'textarea', 'full', $this->getAttributesFor( $this->getFormat() ), $value ); 263 263 } 264 264 265 265 /** 266 266 * element creation method for the 'HTML' format in the 'readonly' form mode. … … 274 274 { 275 275 $tag = $this->createDisplaylessTag( $value ); 276 276 277 277 if( $this->attributes['display'] == 'no' ) { 278 278 return $tag; 279 279 } 280 280 281 return $value.$tag; 281 return $value.$tag; 282 282 } 283 283 284 284 /** 285 285 * validates the element. … … 293 293 $required = false; 294 294 $empty = false; 295 295 296 296 // store the required flag for easy access 297 297 if( isset( $this->attributes['required'] ) && $this->attributes['required'] == 'yes' ) { 298 298 $required = true; 299 299 } 300 301 if( strlen( $value ) == 0 ) {300 301 if( $this->strlen( $value ) == 0 ) { 302 302 $empty = true; 303 303 } 304 304 305 305 if( $empty && $required ) { 306 306 $this->addValidationError( 1 ); 307 307 return false; 308 308 } 309 309 310 310 if( $empty && !$required ) { 311 311 return true; 312 312 } 313 313 314 314 // is it a string? 315 315 if( !is_string( $value ) ) { … … 317 317 return false; 318 318 } 319 319 320 320 // check for allowed tags 321 321 if( $this->attributes['allowedtags'] && $this->attributes['allowedtags'] != '*' ) { … … 326 326 $allowed = implode( '', $allowed ); 327 327 $newValue = strip_tags( $value, $allowed ); 328 if( strlen( $newValue ) !=strlen( $value ) ) {328 if( $this->strlen( $newValue ) != $this->strlen( $value ) ) { 329 329 $this->addValidationError( 6, array( 'allowedtags' => $this->attributes['allowedtags'] ) ); 330 330 return false; … … 334 334 // check for denied tags 335 335 if( $this->attributes['deniedtags'] ) { 336 336 337 337 // must prohibit any tag 338 338 if( $this->attributes['deniedtags'] == '*' ) { 339 339 $newValue = strip_tags( $value ); 340 if( strlen( $newValue ) !=strlen( $value ) ) {340 if( $this->strlen( $newValue ) != $this->strlen( $value ) ) { 341 341 $this->addValidationError( 5 ); 342 342 return false; … … 351 351 } 352 352 } 353 353 354 354 } 355 356 355 356 357 357 // minlength 358 if( isset( $this->attributes['minlength'] ) && strlen( $value ) < $this->attributes['minlength'] ) {358 if( isset( $this->attributes['minlength'] ) && $this->strlen( $value ) < $this->attributes['minlength'] ) { 359 359 $this->addValidationError( 3, array( 'minlength' => $this->attributes['minlength'] ) ); 360 360 return false; 361 361 } 362 362 363 363 // maxlength 364 if( isset( $this->attributes['maxlength'] ) && strlen( $value ) > $this->attributes['maxlength'] ) {364 if( isset( $this->attributes['maxlength'] ) && $this->strlen( $value ) > $this->attributes['maxlength'] ) { 365 365 $this->addValidationError( 4, array( 'maxlength' => $this->attributes['maxlength'] ) ); 366 366 return false;
