1: <?php
2: 3: 4: 5: 6:
7:
8: 9: 10: 11:
12: class QImageFileAsset extends QFileAsset {
13:
14: protected $intMinWidth;
15:
16: protected $intMaxWidth;
17:
18: protected $intMinHeight;
19:
20: protected $intMaxHeight;
21:
22: 23: 24: 25: 26: 27:
28: public function __construct($objParentObject, $strControlId = null) {
29: parent::__construct($objParentObject, $strControlId);
30: $this->SetFileAssetType(QFileAssetType::Image);
31: }
32:
33: 34: 35: 36: 37:
38: public function Validate() {
39: $blnToReturn = parent::Validate();
40:
41: if ($blnToReturn) {
42: if ($this->blnRequired) {
43: list($width, $height) = getimagesize($this->File);
44:
45: if (isset($this->intMinWidth) AND $this->intMinWidth > $width) {
46: $blnToReturn = false;
47: $this->ValidationError = $this->strName . QApplication::Translate(' is too short the min width is ') . $this->intMinWidth;
48: }
49:
50: if (isset($this->intMaxWidth) AND $this->intMaxWidth < $width) {
51: $blnToReturn = false;
52: $this->ValidationError = $this->strName . QApplication::Translate(' is too big the max width is ') . $this->intMaxWidth;
53: }
54:
55: if (isset($this->intMinHeight) AND $this->intMinHeight > $height) {
56: $blnToReturn = false;
57: $this->ValidationError = $this->strName . QApplication::Translate(' is too short the min height is ') . $this->intMinHeight;
58: }
59:
60: if (isset($this->intMaxHeight) AND $this->intMaxHeight < $height) {
61: $blnToReturn = false;
62: $this->ValidationError = $this->strName . QApplication::Translate(' is too big the max height is ') . $this->intMaxHeight;
63: }
64: }
65: }
66:
67: return $blnToReturn;
68: }
69:
70: 71: 72: 73: 74: 75: 76: 77: 78:
79: public function __set($strName, $mixValue) {
80: $this->blnModified = true;
81:
82: switch ($strName) {
83:
84: case 'MinWidth':
85: try {
86: return ($this->intMinWidth = QType::Cast($mixValue, QType::Integer));
87: } catch (QCallerException $objExc) {
88: $objExc->IncrementOffset();
89: throw $objExc;
90: }
91:
92: case 'MaxWidth':
93: try {
94: return ($this->intMaxWidth = QType::Cast($mixValue, QType::Integer));
95: } catch (QCallerException $objExc) {
96: $objExc->IncrementOffset();
97: throw $objExc;
98: }
99:
100: case 'MinHeight':
101: try {
102: return ($this->intMinHeight = QType::Cast($mixValue, QType::Integer));
103: } catch (QCallerException $objExc) {
104: $objExc->IncrementOffset();
105: throw $objExc;
106: }
107:
108: case 'MaxHeight':
109: try {
110: return ($this->intMaxHeight = QType::Cast($mixValue, QType::Integer));
111: } catch (QCallerException $objExc) {
112: $objExc->IncrementOffset();
113: throw $objExc;
114: }
115:
116: default:
117: try {
118: return parent::__set($strName, $mixValue);
119: } catch (QCallerException $objExc) {
120: $objExc->IncrementOffset();
121: throw $objExc;
122: }
123: }
124: }
125: }