| 95 | | // The follow garbage is the biggest hack ever, and shows my total |
| 96 | | // lack of advanced regex skills. Hopefully Geert can replace this |
| 97 | | // with a "lookahead" or some kind of fancy-pants regex. :) -Woody |
| 98 | | |
| 99 | | // Final keys |
| 100 | | $keys = array(); |
| 101 | | |
| 102 | | // Break token and token buffer |
| 103 | | $break = '.'; |
| 104 | | $buffer = ''; |
| 105 | | |
| 106 | | // Parse each letter of the string... ick |
| 107 | | for ($i = 0, $max = strlen($key); $i <= $max; $i++) |
| 108 | | { |
| 109 | | if ($i === $max AND ! empty($buffer)) |
| 110 | | { |
| 111 | | if ($break === '}.' AND substr($buffer, -1) === '}') |
| 112 | | { |
| 113 | | // Remove the ending "unquote" |
| 114 | | $buffer = substr($buffer, 0, -1); |
| 115 | | } |
| 116 | | |
| 117 | | // Add the final buffer |
| 118 | | $keys[] = $buffer; |
| 119 | | break; |
| 120 | | } |
| 121 | | |
| 122 | | // Current token |
| 123 | | $token = $key{$i}; |
| 124 | | |
| 125 | | if ($token === '{' AND $break === '.') |
| 126 | | { |
| 127 | | // Change the break token to "unquote dot" |
| 128 | | $break = '}.'; |
| 129 | | } |
| 130 | | elseif ($token === '.' AND $break === '.') |
| 131 | | { |
| 132 | | // Add the key and reset the buffer |
| 133 | | $keys[] = $buffer; |
| 134 | | $buffer = ''; |
| 135 | | } |
| 136 | | elseif ($break === '}.' AND substr($key, $i, 2) === '}.') |
| 137 | | { |
| 138 | | // Add the key and reset the buffer |
| 139 | | $keys[] = $buffer; |
| 140 | | $buffer = ''; |
| 141 | | |
| 142 | | // Reset the break token |
| 143 | | $break = '.'; |
| 144 | | |
| 145 | | // Increase the buffer to skip the next "dot" |
| 146 | | $i++; |
| 147 | | } |
| 148 | | else |
| 149 | | { |
| 150 | | // Add the token to the buffer |
| 151 | | $buffer = $buffer.$token; |
| 152 | | } |
| 153 | | } |
| | 98 | // Routes cannot contain sub keys due to possible dots in regex |
| | 99 | $keys = explode('.', $key, 2); |