| | 155 | |
|---|
| | 156 | /** |
|---|
| | 157 | * Get an element from any form |
|---|
| | 158 | * |
|---|
| | 159 | * If more than one form contains an element of the specified name, |
|---|
| | 160 | * only the first will be returned. |
|---|
| | 161 | * |
|---|
| | 162 | * @param string |
|---|
| | 163 | * @return mixed |
|---|
| | 164 | */ |
|---|
| | 165 | function &getElementByName($name) |
|---|
| | 166 | { |
|---|
| | 167 | if ($name == '__form') { |
|---|
| | 168 | return $this; |
|---|
| | 169 | } |
|---|
| | 170 | foreach (array_keys($this->forms) as $formName) { |
|---|
| | 171 | patErrorManager::pushExpect(PATFORMS_ERROR_ELEMENT_NOT_FOUND); |
|---|
| | 172 | $element = $this->forms[$formName]->getElementByName($name); |
|---|
| | 173 | patErrorManager::popExpect(PATFORMS_ERROR_ELEMENT_NOT_FOUND); |
|---|
| | 174 | if (!patErrorManager::isError($element)) { |
|---|
| | 175 | return $element; |
|---|
| | 176 | } |
|---|
| | 177 | } |
|---|
| | 178 | |
|---|
| | 179 | $error = &patErrorManager::raiseError( |
|---|
| | 180 | PATFORMS_ERROR_ELEMENT_NOT_FOUND, |
|---|
| | 181 | 'Element '.$name.' could not be found.' |
|---|
| | 182 | ); |
|---|
| | 183 | return $error; |
|---|
| | 184 | } |
|---|
| | 185 | |
|---|
| | 186 | /** |
|---|
| | 187 | * Get an element from any form |
|---|
| | 188 | * |
|---|
| | 189 | * If more than one form contains an element with the specified id, |
|---|
| | 190 | * only the first will be returned. |
|---|
| | 191 | * |
|---|
| | 192 | * @param string |
|---|
| | 193 | * @return mixed |
|---|
| | 194 | */ |
|---|
| | 195 | function &getElementById($id) |
|---|
| | 196 | { |
|---|
| | 197 | foreach (array_keys($this->forms) as $formName) { |
|---|
| | 198 | patErrorManager::pushExpect(PATFORMS_ERROR_ELEMENT_NOT_FOUND); |
|---|
| | 199 | $element = $this->forms[$formName]->getElementById($id); |
|---|
| | 200 | patErrorManager::popExpect(PATFORMS_ERROR_ELEMENT_NOT_FOUND); |
|---|
| | 201 | if (!patErrorManager::isError($element)) { |
|---|
| | 202 | return $element; |
|---|
| | 203 | } |
|---|
| | 204 | } |
|---|
| | 205 | |
|---|
| | 206 | $error = &patErrorManager::raiseError( |
|---|
| | 207 | PATFORMS_ERROR_ELEMENT_NOT_FOUND, |
|---|
| | 208 | 'Element '.$name.' could not be found.' |
|---|
| | 209 | ); |
|---|
| | 210 | return $error; |
|---|
| | 211 | } |
|---|