1 | <?php |
||
17 | class AdminPageFramework_Form_Model extends AdminPageFramework_Form_Base { |
||
1 ignored issue
–
show
|
|||
18 | |||
19 | /** |
||
20 | * Sets up hooks. |
||
21 | * @since DEVVER |
||
22 | */ |
||
23 | public function __construct() { |
||
40 | |||
41 | /** |
||
42 | * Retrieves the submitted form data from $_POST. |
||
43 | * @since DEVVER |
||
44 | * @return array |
||
45 | */ |
||
46 | public function getSubmittedData( array $aDataToParse, $bExtractFromFieldStructure=true, $bStripSlashes=true ) { |
||
64 | |||
65 | /** |
||
66 | * Sorts dynamic elements. |
||
67 | * |
||
68 | * The main routine which instantiates the this form calass object will call this method when they retrieve |
||
69 | * the submitted form data. |
||
70 | * |
||
71 | * @since 3.6.0 |
||
72 | * @since DEVVER Moved from `AdminPageFramework_Factory_Model`. |
||
73 | * Renamed from `_getSortedInputs()`. |
||
74 | * @return array The sorted input array. |
||
75 | */ |
||
76 | public function getSortedInputs( array $aFormInputs ) { |
||
104 | |||
105 | /** |
||
106 | * Returns a fields model array that represents the structure of the array of saving data from the given fields definition array. |
||
107 | * |
||
108 | * The passed fields array should be structured like the following. This is used for page meta boxes. |
||
109 | * <code> |
||
110 | * array( |
||
111 | * '_default' => array( // _default is reserved for the system. |
||
112 | * 'my_field_id' => array( .... ), |
||
113 | * 'my_field_id2' => array( .... ), |
||
114 | * ), |
||
115 | * 'my_secion_id' => array( |
||
116 | * 'my_field_id' => array( ... ), |
||
117 | * 'my_field_id2' => array( ... ), |
||
118 | * 'my_field_id3' => array( ... ), |
||
119 | * |
||
120 | * ), |
||
121 | * 'my_section_id2' => array( |
||
122 | * 'my_field_id' => array( ... ), |
||
123 | * ), |
||
124 | * ... |
||
125 | * ) |
||
126 | * </code> |
||
127 | * It will be converted to |
||
128 | * <code> |
||
129 | * array( |
||
130 | * 'my_field_id' => array( .... ), |
||
131 | * 'my_field_id2' => array( .... ), |
||
132 | * 'my_secion_id' => array( |
||
133 | * 'my_field_id' => array( ... ), |
||
134 | * 'my_field_id2' => array( ... ), |
||
135 | * 'my_field_id3' => array( ... ), |
||
136 | * |
||
137 | * ), |
||
138 | * 'my_section_id2' => array( |
||
139 | * 'my_field_id' => array( ... ), |
||
140 | * ), |
||
141 | * ... |
||
142 | * ) |
||
143 | * </code> |
||
144 | * @remark Just the `_default` section elements get extracted to the upper dimension. |
||
145 | * @since 3.0.0 |
||
146 | * @since DEVVER Moved from `AdminPageFramework_FormDefinition_Base`. |
||
147 | * Changed the name from `getFieldsModel()`. |
||
148 | * @return array |
||
149 | */ |
||
150 | public function getDataStructureFromAddedFieldsets() { |
||
169 | |||
170 | /** |
||
171 | * Drops repeatable section and field elements from the given array. |
||
172 | * |
||
173 | * This is used in the filtering method that merges user input data with the saved options. If the user input data includes repeatable sections |
||
174 | * and the user removed some elements, then the corresponding elements also need to be removed from the options array. Otherwise, the user's removing element |
||
175 | * remains in the saved option array as the framework performs recursive array merge. |
||
176 | * |
||
177 | * @remark The options array structure is slightly different from the fields array. An options array does not have '_default' section keys. |
||
178 | * @remark If the user capability is insufficient to display the element, it should not be removed because the element(field/section) itself is not submitted and |
||
179 | * if the merging saved options array misses the element(which this method is going to deal with), the element will be gone forever. |
||
180 | * @remark This method MUST be called after formatting the form elements because this checks the set user capability. |
||
181 | * @since 3.0.0 |
||
182 | * @since 3.1.1 Made it not remove the repeatable elements if the user capability is insufficient. |
||
183 | * @since 3.6.2 Changed the mechanism to detect repeatable elements. |
||
184 | * @since DEVVER Moved from `AdminPageFramework_FormDefinition_Base`. |
||
185 | * @param array $aSubject The subject array to modify. Usually the saved option data. |
||
186 | * @return array The modified options array. |
||
187 | */ |
||
188 | public function dropRepeatableElements( array $aSubject ) { |
||
198 | |||
199 | /** |
||
200 | * @callback action 'current_screen' by default but it depends on the factory class. |
||
201 | * @since DEVVERs |
||
202 | */ |
||
203 | public function _replyToRegisterFormItems( /* $oScreen */ ) { |
||
264 | /** |
||
265 | * Triggers callbacks before setting resources. |
||
266 | */ |
||
267 | private function _handleCallbacks() { |
||
286 | |||
287 | /** |
||
288 | * Stores the default field definitions. |
||
289 | * |
||
290 | * Once they are set, it no longer needs to be done. For this reason, the scope must be static. |
||
291 | * |
||
292 | * @since 3.1.3 |
||
293 | * @since DEVVER Moved from `AdminPageFramework_Factory_Model`. |
||
294 | * @internal |
||
295 | */ |
||
296 | static private $_aFieldTypeDefinitions = array(); |
||
297 | |||
298 | /** |
||
299 | * Loads the default field type definition. |
||
300 | * |
||
301 | * @since 2.1.5 |
||
302 | * @since 3.5.0 Changed the visibility scope to protected as it is internal. |
||
303 | * Changed the name from `_loadDefaultFieldTypeDefinitions()` as it applies filters so custom field types also get registered here. |
||
304 | * @since DEVVER Moved from `AdminPageFramework_Factory_Model`. Changed the visibility scope to private. |
||
305 | * @internal |
||
306 | */ |
||
307 | private function _setFieldTypeDefinitions() { |
||
328 | |||
329 | /** |
||
330 | * @return array |
||
331 | */ |
||
332 | private function _getSavedData( $aDefaultValues ) { |
||
356 | /** |
||
357 | * Returns the last user form input array. |
||
358 | * |
||
359 | * @remark This temporary data is not always set. This is only set when the form needs to show a confirmation message to the user such as for sending an email. |
||
360 | * @since 3.3.0 |
||
361 | * @since 3.4.1 Moved from `AdminPageFramework_Property_Page`. |
||
362 | * @since DEVVER Moved from `AdminPageFramework_Property_Base`. |
||
363 | * @internal |
||
364 | * @return array The last user form inputs. |
||
365 | */ |
||
366 | private function _getLastInputs() { |
||
377 | |||
378 | /** |
||
379 | * Returns the default values of all the added fields. |
||
380 | * |
||
381 | * Analyses the registered form elements and retrieve the default values. |
||
382 | * |
||
383 | * @since 3.0.0 |
||
384 | * @since DEVVER Changed the name from `getDefaultOptions()`. |
||
385 | * Moved from `AdminPageFramework_Property_Page`. |
||
386 | * @return array An array holding default values of form data. |
||
387 | */ |
||
388 | public function getDefaultFormValues() { |
||
394 | |||
395 | /** |
||
396 | * Formates the added section-sets and field-sets definition arrays. |
||
397 | * |
||
398 | * This method is called right before the form gets rendered. |
||
399 | * |
||
400 | * @since DEVVER |
||
401 | * @param array $aSavedData |
||
402 | * @param boolean $bOnlyFieldsets Whether to format only the fieldsets. The taxonomy field factory uses this parameter. |
||
403 | */ |
||
404 | protected function _formatElementDefinitions( array $aSavedData ) { |
||
428 | |||
429 | /** |
||
430 | * Retrieves the settings error array set by the user in the validation callback. |
||
431 | * |
||
432 | * @since 3.0.4 |
||
433 | * @since 3.6.3 Changed the visibility scope to public as a delegation class needs to access this method. |
||
434 | * @since DEVVER Moved from `AdminPageFramework_Factory_Model`. |
||
435 | * Changed the name from `_getFieldErrors()`. |
||
436 | * @access public The field type class accesses this method to render nested fields. |
||
437 | * @internal |
||
438 | * @param boolean $bDelete whether or not the transient should be deleted after retrieving it. |
||
439 | * @return array |
||
440 | */ |
||
441 | public function getFieldErrors() { |
||
446 | |||
447 | /** |
||
448 | * Saves user last input in the database as a transient. |
||
449 | * |
||
450 | * To get the set input, call `$this->oProp->aLastInput`. |
||
451 | * |
||
452 | * @since 3.4.1 |
||
453 | * @since DEVVER Changed the name from `_setLastInput()`. |
||
454 | * @since DEVVER Moved from `AdminPageFramework_Factory_Model`. |
||
455 | * @return boolean True if set; otherwise, false. |
||
456 | * @internal |
||
457 | */ |
||
458 | public function setLastInputs( array $aLastInputs ) { |
||
465 | |||
466 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.