1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13:
14:
15: 16: 17: 18: 19: 20:
21: class NImageButton extends NSubmitButton
22: {
23:
24: 25: 26: 27:
28: public function __construct($src = NULL, $alt = NULL)
29: {
30: parent::__construct();
31: $this->control->type = 'image';
32: $this->control->src = $src;
33: $this->control->alt = $alt;
34: }
35:
36:
37:
38: 39: 40: 41:
42: public function getHtmlName()
43: {
44: $name = parent::getHtmlName();
45: return strpos($name, '[') === FALSE ? $name : $name . '[]';
46: }
47:
48:
49:
50: 51: 52: 53:
54: public function loadHttpData()
55: {
56: $path = $this->getHtmlName();
57: $path = explode('[', strtr(str_replace(']', '', strpos($path, '[') === FALSE ? $path . '.x' : substr($path, 0, -2)), '.', '_'));
58: $this->setValue(NArrayTools::get($this->getForm()->getHttpData(), $path) !== NULL);
59: }
60:
61: }
62: