| | 318 | |
|---|
| | 319 | // }}} |
|---|
| | 320 | // {{{ setDisabled() |
|---|
| | 321 | /** |
|---|
| | 322 | * Sets whether an input is disabled |
|---|
| | 323 | * |
|---|
| | 324 | * @param bool $disabled Whether the field is disabled or not |
|---|
| | 325 | * @since 1.0 |
|---|
| | 326 | * @access public |
|---|
| | 327 | * @return void |
|---|
| | 328 | */ |
|---|
| | 329 | function setDisabled($disabled) |
|---|
| | 330 | { |
|---|
| | 331 | if (!$disabled) { |
|---|
| | 332 | $this->removeAttribute('disabled'); |
|---|
| | 333 | } else { |
|---|
| | 334 | $this->updateAttributes(array('disabled'=>'disabled')); |
|---|
| | 335 | } |
|---|
| | 336 | } //end func setDisabled |
|---|
| | 337 | |
|---|
| | 338 | // }}} |
|---|
| | 339 | // {{{ getDisabled() |
|---|
| | 340 | /** |
|---|
| | 341 | * Gets whether an input is disabled |
|---|
| | 342 | * |
|---|
| | 343 | * @param bool $disabled Whether the field is disabled or not |
|---|
| | 344 | * @since 1.0 |
|---|
| | 345 | * @access public |
|---|
| | 346 | * @return void |
|---|
| | 347 | */ |
|---|
| | 348 | function getDisabled($disabled) |
|---|
| | 349 | { |
|---|
| | 350 | return $this->getAttribute('disabled'); |
|---|
| | 351 | } //end func getDisabled |
|---|
| | 352 | |
|---|
| | 353 | // }}} |
|---|
| | 354 | // {{{ setClass() |
|---|
| | 355 | /** |
|---|
| | 356 | * Sets the class |
|---|
| | 357 | * |
|---|
| | 358 | * @param mixed $class A string or array indicating the class(es) to set |
|---|
| | 359 | * @since 1.0 |
|---|
| | 360 | * @access public |
|---|
| | 361 | * @return void |
|---|
| | 362 | */ |
|---|
| | 363 | function setClass($class) |
|---|
| | 364 | { |
|---|
| | 365 | if (is_array($class)) { |
|---|
| | 366 | $class = implode(' ',$class); |
|---|
| | 367 | } |
|---|
| | 368 | $this->updateAttributes(array('class'=>$class)); |
|---|
| | 369 | } //end func setClass |
|---|
| | 370 | |
|---|
| | 371 | // }}} |
|---|
| | 372 | // {{{ addClass() |
|---|
| | 373 | /** |
|---|
| | 374 | * Sets whether a checkbox is disabled |
|---|
| | 375 | * |
|---|
| | 376 | * @param bool $disabled Whether the field is disabled or not |
|---|
| | 377 | * @since 1.0 |
|---|
| | 378 | * @access public |
|---|
| | 379 | * @return void |
|---|
| | 380 | */ |
|---|
| | 381 | function addClass($class) |
|---|
| | 382 | { |
|---|
| | 383 | if (!is_array($class)) { |
|---|
| | 384 | $class = array($class); |
|---|
| | 385 | } |
|---|
| | 386 | |
|---|
| | 387 | $curclass = $this->getClass(); |
|---|
| | 388 | foreach ($class as $c) { |
|---|
| | 389 | if (!in_array($c, $curclass)) { |
|---|
| | 390 | $curclass[] = $c; |
|---|
| | 391 | } |
|---|
| | 392 | } |
|---|
| | 393 | $this->setClass($class); |
|---|
| | 394 | } //end func addClass |
|---|
| | 395 | |
|---|
| | 396 | // }}} |
|---|
| | 397 | // {{{ removeClass() |
|---|
| | 398 | /** |
|---|
| | 399 | * Sets whether a checkbox is disabled |
|---|
| | 400 | * |
|---|
| | 401 | * @param bool $disabled Whether the field is disabled or not |
|---|
| | 402 | * @since 1.0 |
|---|
| | 403 | * @access public |
|---|
| | 404 | * @return void |
|---|
| | 405 | */ |
|---|
| | 406 | function removeClass($class) |
|---|
| | 407 | { |
|---|
| | 408 | if (!is_array($class)) { |
|---|
| | 409 | $class = array($class); |
|---|
| | 410 | } |
|---|
| | 411 | |
|---|
| | 412 | $curclass = $this->getClass(); |
|---|
| | 413 | foreach ($class as $c) { |
|---|
| | 414 | if (in_array($c, $curclass)) { |
|---|
| | 415 | $idx = array_search($c, $curclass); |
|---|
| | 416 | unset($curclass[$idx]); |
|---|
| | 417 | } |
|---|
| | 418 | } |
|---|
| | 419 | $this->setClass($class); |
|---|
| | 420 | } //end func removeClass |
|---|
| | 421 | |
|---|
| | 422 | // }}} |
|---|
| | 423 | |
|---|
| | 424 | // {{{ getClass() |
|---|
| | 425 | /** |
|---|
| | 426 | * Sets whether a checkbox is disabled |
|---|
| | 427 | * |
|---|
| | 428 | * @since 1.0 |
|---|
| | 429 | * @access public |
|---|
| | 430 | * @return array |
|---|
| | 431 | */ |
|---|
| | 432 | function getClass() |
|---|
| | 433 | { |
|---|
| | 434 | return explode(' ',$this->getAttribute('class')); |
|---|
| | 435 | } //end func getClass |
|---|