Source for file ImageButton.php

Documentation is available at ImageButton.php

  1. 1: <?php
  2. 2:  
  3. 3: /**
  4. 4:  * Nette Framework
  5. 5:  *
  6. 6:  * @copyright  Copyright (c) 2004, 2010 David Grudl
  7. 7:  * @license    http://nettephp.com/license  Nette license
  8. 8:  * @link       http://nettephp.com
  9. 9:  * @category   Nette
  10. 10:  * @package    Nette\Forms
  11. 11:  */
  12. 12:  
  13. 13:  
  14. 14:  
  15. 15: /**
  16. 16:  * Submittable image button form control.
  17. 17:  *
  18. 18:  * @copyright  Copyright (c) 2004, 2010 David Grudl
  19. 19:  * @package    Nette\Forms
  20. 20:  */
  21. 21: class ImageButton extends SubmitButton
  22. 22: {
  23. 23:  
  24. 24:     /**
  25. 25:      * @param  string  URI of the image
  26. 26:      * @param  string  alternate text for the image
  27. 27:      */
  28. 28:     public function __construct($src NULL$alt NULL)
  29. 29:     {
  30. 30:         parent::__construct();
  31. 31:         $this->control->type 'image';
  32. 32:         $this->control->src $src;
  33. 33:         $this->control->alt $alt;
  34. 34:     }
  35. 35:  
  36. 36:  
  37. 37:  
  38. 38:     /**
  39. 39:      * Returns name of control within a Form & INamingContainer scope.
  40. 40:      * @return string 
  41. 41:      */
  42. 42:     public function getHtmlName()
  43. 43:     {
  44. 44:         $name parent::getHtmlName();
  45. 45:         return strpos($name'['=== FALSE $name $name '[]';
  46. 46:     }
  47. 47:  
  48. 48:  
  49. 49:  
  50. 50:     /**
  51. 51:      * Loads HTTP data.
  52. 52:      * @return void 
  53. 53:      */
  54. 54:     public function loadHttpData()
  55. 55:     {
  56. 56:         $path $this->getHtmlName()// img_x or img['x']
  57. 57:         $path explode('['strtr(str_replace(']'''strpos($path'['=== FALSE $path '.x' substr($path0-2))'.''_'));
  58. 58:         $this->setValue(ArrayTools::get($this->getForm()->getHttpData()$path!== NULL);
  59. 59:     }
  60. 60:  
  61. 61: }