@@ -11,7 +11,7 @@ class IndexFieldOperations {
11
11
* Setting ajax elements when editing newly added index fields.
12
12
*/
13
13
public static function setIndexFieldsAjaxElementsOnAdd (array $ indexFields ) {
14
- if ($ indexFields [" data " ]) {
14
+ if ($ indexFields [' data ' ]) {
15
15
foreach ($ indexFields ['data ' ]['#rows ' ] as $ row => $ data ) {
16
16
$ edit_index_button = $ indexFields ['edit_index_buttons ' ]['index_field_key_ ' . $ row ] ?? NULL ;
17
17
$ edit_index_fields = $ indexFields ['edit_index_fields ' ]['index_field_key_ ' . $ row ] ?? NULL ;
@@ -35,16 +35,18 @@ public static function setIndexFieldsAjaxElementsOnAdd(array $indexFields) {
35
35
36
36
/**
37
37
* Setting ajax elements when editing existing index fields.
38
+ *
39
+ * Currently, not being used as index fields cannot be edited once added.
38
40
*/
39
41
public static function setIndexFieldsAjaxElements (array $ indexFields ) {
40
- if ($ indexFields [" data " ]) {
42
+ if ($ indexFields [' data ' ]) {
41
43
foreach ($ indexFields ['data ' ]['#rows ' ] as $ row => $ data ) {
42
44
$ edit_index_fields_button = $ indexFields ['fields ' ]['edit_index_fields_buttons ' ]['index_field_key_ ' . $ row ] ?? NULL ;
43
45
$ edit_index_fields = $ indexFields ['fields ' ]['edit_index_fields ' ]['index_field_key_ ' . $ row ] ?? NULL ;
44
46
// Setting the ajax fields if they exist.
45
47
if ($ edit_index_fields_button ) {
46
- $ indexFields [" data " ][ " #rows " ][$ row ] = array_merge ($ data , $ edit_index_fields_button );
47
- unset($ indexFields [" fields " ][ " edit_index_fields_buttons " ]['index_field_key_ ' . $ row ]);
48
+ $ indexFields [' data ' ][ ' #rows ' ][$ row ] = array_merge ($ data , $ edit_index_fields_button );
49
+ unset($ indexFields [' fields ' ][ ' edit_index_fields_buttons ' ]['index_field_key_ ' . $ row ]);
48
50
}
49
51
elseif ($ edit_index_fields ) {
50
52
unset($ indexFields ['data ' ]['#rows ' ]['index_field_key_ ' . $ row ]);
@@ -118,14 +120,14 @@ public static function processIndexDataResults($index_results, $current_indexes,
118
120
$ index_results = $ current_indexes ;
119
121
}
120
122
121
- if (isset ($ index_values [" field_json_metadata " ][0 ][" indexes " ][ " field_collection " ])) {
122
- $ index_group = $ index_values [" field_json_metadata " ][0 ][" indexes " ][ " field_collection " ][ " group " ];
123
+ if (isset ($ index_values [' field_json_metadata ' ][0 ][' indexes ' ][ ' field_collection ' ])) {
124
+ $ index_group = $ index_values [' field_json_metadata ' ][0 ][' indexes ' ][ ' field_collection ' ][ ' group ' ];
123
125
124
126
$ data_index_pre = [
125
127
[
126
- " description " => $ index_group ['index ' ][" description " ],
127
- " type " => $ index_group ['index ' ][" type " ],
128
- " fields " => $ index_fields_data_results ,
128
+ ' description ' => $ index_group ['index ' ][' description ' ],
129
+ ' type ' => $ index_group ['index ' ][' type ' ],
130
+ ' fields ' => $ index_fields_data_results ,
129
131
],
130
132
];
131
133
}
@@ -215,7 +217,7 @@ public static function createIndexFieldOptions($op_index, $index_data_results, $
215
217
/**
216
218
* Create edit and update fields for indexes.
217
219
*/
218
- public static function createIndexOptions ($ op_index , $ index_data_results , $ index_being_modified , $ index_field_being_modified , $ element , $ form_state ) {
220
+ public static function createIndexOptions ($ op_index , $ index_data_results , $ index_being_modified , $ element , $ form_state ) {
219
221
$ current_indexes = $ element ['current_index ' ];
220
222
221
223
// Creating ajax buttons/fields to be placed in correct location later.
@@ -237,13 +239,13 @@ public static function createIndexOptions($op_index, $index_data_results, $index
237
239
*/
238
240
public static function checkIndexEditingField ($ indexKey , $ op_index , $ index_fields_being_modified ) {
239
241
$ action_list = IndexFieldOperations::editIndexActions ();
240
- $ indexKeyExplode = explode ("_ " , $ indexKey );
241
- if (isset ($ op_index [0 ]) && in_array ($ op_index [0 ], $ action_list ) && array_key_exists ($ indexKeyExplode [3 ], $ index_fields_being_modified )) {
242
- return TRUE ;
243
- }
244
- else {
245
- return FALSE ;
242
+ if (isset ($ op_index [0 ]) && in_array ($ op_index [0 ], $ action_list )) {
243
+ $ indexKeyExplode = explode ('_ ' , $ indexKey );
244
+ if (array_key_exists ($ indexKeyExplode [3 ], $ index_fields_being_modified )) {
245
+ return TRUE ;
246
+ }
246
247
}
248
+ return FALSE ;
247
249
}
248
250
249
251
/**
@@ -254,9 +256,11 @@ public static function checkIndexEditing($indexKey, $op_index, $index_being_modi
254
256
$ op_index_string = implode ('_ ' , $ op_index );
255
257
if (str_contains ($ op_index_string , 'edit_index_key ' )) {
256
258
$ action_list = IndexFieldOperations::editIndexActions ();
257
- $ indexKeyExplode = explode ("_ " , $ indexKey );
258
- if (isset ($ op_index [0 ]) && in_array ($ op_index [0 ], $ action_list ) && array_key_exists ($ indexKeyExplode [2 ], $ index_being_modified )) {
259
- return TRUE ;
259
+ if (isset ($ op_index [0 ]) && in_array ($ op_index [0 ], $ action_list )) {
260
+ $ indexKeyExplode = explode ('_ ' , $ indexKey );
261
+ if (array_key_exists ($ indexKeyExplode [2 ], $ index_being_modified )) {
262
+ return TRUE ;
263
+ }
260
264
}
261
265
}
262
266
}
0 commit comments