@@ -103,17 +103,26 @@ public static function sanitizeData($data, $task)
103103 // Update database with all the exceptions ..
104104 $ task ->processRequest ->do_not_sanitize = $ except ;
105105 $ task ->processRequest ->save ();
106+
106107 return self ::sanitizeWithExceptions ($ data , $ except );
107108 }
108109
109- private static function sanitizeWithExceptions (Array $ data , Array $ except , $ level = 0 )
110+ private static function sanitizeWithExceptions (Array $ data , Array $ except , $ parent = null )
110111 {
112+ print_r ($ except );
111113 foreach ($ data as $ key => $ value ) {
114+ if (!is_int ($ key )) {
115+ $ searchKey = ($ parent ? $ parent . '. ' . $ key : $ key );
116+ } else {
117+ $ searchKey = $ parent ;
118+ }
112119 if (is_array ($ value )) {
113- $ data [$ key ] = self ::sanitizeWithExceptions ($ value , $ except , $ level + 1 );
120+ $ data [$ key ] = self ::sanitizeWithExceptions ($ value , $ except , $ searchKey );
114121 } else {
115122 // Only allow skipping on top-level data for now
116- $ strip_tags = !in_array ($ key , $ except );
123+ $ strip_tags = !in_array ($ searchKey , $ except );
124+ echo $ searchKey ;
125+ echo $ strip_tags ;
117126 $ data [$ key ] = self ::sanitize ($ value , $ strip_tags );
118127 }
119128 }
@@ -135,36 +144,76 @@ private static function getExceptions($screen)
135144 return $ except ;
136145 }
137146
138- private static function getRichTextElements ($ items )
147+ private static function getRichTextElements ($ items, $ parent = null )
139148 {
149+ //"loop_1.loop_2.form_text_area_2"
140150 $ elements = [];
151+
141152 foreach ($ items as $ item ) {
142153 if (isset ($ item ['items ' ]) && is_array ($ item ['items ' ])) {
143- // Inside a table
144- foreach ($ item ['items ' ] as $ cell ) {
145- if (
146- isset ($ cell ['component ' ]) &&
147- $ cell ['component ' ] === 'FormTextArea ' &&
148- isset ($ cell ['config ' ]['richtext ' ]) &&
149- $ cell ['config ' ]['richtext ' ] === true
150- ) {
151- $ elements [] = $ cell ['config ' ]['name ' ];
152- }
153- if (is_array ($ cell )) {
154- $ elements = array_merge ($ elements , self ::getRichTextElements ($ cell ));
155- }
154+ if ($ item ['component ' ] == 'FormLoop ' ) {
155+ $ elements = array_merge ($ elements , self ::getRichTextElements ($ item ['items ' ], ($ parent ? $ parent . '. ' . $ item ['config ' ]['name ' ] : $ item ['config ' ]['name ' ])));
156+ } else if (isset ($ item ['component ' ]) && $ item ['component ' ] === 'FormTextArea ' && isset ($ item ['config ' ]['richtext ' ]) && $ item ['config ' ]['richtext ' ] === true ) {
157+ $ elements [] = ($ parent ? $ parent . '. ' . $ item ['config ' ]['name ' ] : $ item ['config ' ]['name ' ]);
156158 }
157159 } else {
158- if (
159- isset ($ item ['component ' ]) &&
160- $ item ['component ' ] === 'FormTextArea ' &&
161- isset ($ item ['config ' ]['richtext ' ]) &&
162- $ item ['config ' ]['richtext ' ] === true
163- ) {
164- $ elements [] = $ item ['config ' ]['name ' ];
160+ if (isset ($ item ['component ' ]) && $ item ['component ' ] === 'FormTextArea ' && isset ($ item ['config ' ]['richtext ' ]) && $ item ['config ' ]['richtext ' ] === true ) {
161+ $ elements [] = ($ parent ? $ parent . '. ' . $ item ['config ' ]['name ' ] : $ item ['config ' ]['name ' ]);
165162 }
166163 }
167164 }
165+
166+ // foreach ($items as $item) {
167+ // if (isset($item['items']) && is_array($item['items'])) {
168+ // foreach ($item['items'] as $cell) {
169+ // if ($item['component'] == 'FormLoop') {
170+ // // $path = ($parent ? $parent . '.' . $cell['config']['name'] : $item['config']['name']);
171+ // $elements = array_merge($elements, self::getRichTextElements($cell, $item['config']['name']));
172+ // } else if (
173+ // isset($cell['component']) &&
174+ // $cell['component'] === 'FormTextArea' &&
175+ // isset($cell['config']['richtext']) &&
176+ // $cell['config']['richtext'] === true
177+ // ) {
178+ // // \Log::info($path);
179+ // $elements[] = $parent . '.' . $cell['config']['name'];
180+ // }
181+ // }
182+ // }
183+ // }
184+
185+ // foreach ($items as $item) {
186+ // if (isset($item['items']) && is_array($item['items'])) {
187+ // // Inside a table
188+ // foreach ($item['items'] as $cell) {
189+ // if($item['component'] == 'FormLoop') {
190+ // // $path = ($path ? $path . '.' . $cell['config']['name'] : $item['config']['name']);
191+ // $elements = array_merge($elements, self::getRichTextElements($cell, $item));
192+ // }
193+ // if (
194+ // isset($cell['component']) &&
195+ // $cell['component'] === 'FormTextArea' &&
196+ // isset($cell['config']['richtext']) &&
197+ // $cell['config']['richtext'] === true
198+ // ) {
199+ // // \Log::info($path);
200+ // $elements[] = $path;
201+ // }
202+ // if (is_array($cell)) {
203+ // $elements = array_merge($elements, self::getRichTextElements($cell));
204+ // }
205+ // }
206+ // } else {
207+ // if (
208+ // isset($item['component']) &&
209+ // $item['component'] === 'FormTextArea' &&
210+ // isset($item['config']['richtext']) &&
211+ // $item['config']['richtext'] === true
212+ // ) {
213+ // $elements[] = $item['config']['name'];
214+ // }
215+ // }
216+ // }
168217 return $ elements ;
169218 }
170219
0 commit comments