ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilWebDAVMounInstructionsDocumentProcessorBase.php
Go to the documentation of this file.
1<?php
2
4{
5 public function parseInstructionsToAssocArray(string $a_raw_mount_instructions) : array
6 {
7 $processing_text = $a_raw_mount_instructions;
8
9 $found_instructions = array();
10
11 // Search for pairs, as long as pairs are found (search at a minimum 1 time)
12 do {
13 $pair_found = false;
14 $open_with_no_close_tag_found = false;
15
16 $open_tag_start_pos = strpos($processing_text, '[');
17 $open_tag_end_pos = strpos($processing_text, ']');
18
19 // Is there a [ and a ] and are they in this order?
20 if ($open_tag_start_pos !== false && $open_tag_end_pos !== false && $open_tag_start_pos < $open_tag_end_pos) {
21 // Extract text between the square brackets "[tag_name]" and create the end tag [/tag_name]
22 $tag_name = substr($processing_text, $open_tag_start_pos+1, $open_tag_end_pos - $open_tag_start_pos -1);
23 $close_tag = "[/$tag_name]";
24
25 $close_tag_pos = strpos($processing_text, $close_tag);
26
27 if ($close_tag_pos !== false && $open_tag_end_pos < $close_tag_pos) {
28 $found_instructions[$tag_name] = substr($processing_text, $open_tag_end_pos + 1, $close_tag_pos - $open_tag_end_pos - 1);
29
30 $processing_text = substr($processing_text, $close_tag_pos + strlen($close_tag));
31 $pair_found = true;
32 } else {
33 // If an open [tag] without a close [/tag] was found, we cut the string off at the end of the found [tag] and start searching again
34 $processing_text = substr($processing_text, $open_tag_end_pos + 1);
35 $open_with_no_close_tag_found = true;
36 }
37 }
38 } while ($pair_found || $open_with_no_close_tag_found);
39
40 if (count($found_instructions) === 0) {
41 $found_instructions = [ $a_raw_mount_instructions ];
42 }
43
44 return $found_instructions;
45 }
46}
An exception for terminatinating execution or to throw for unit testing.