| Conditions | 6 |
| Paths | 6 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function parse($text) |
||
| 30 | { |
||
| 31 | if (!preg_match_all('/' . self::TEMPLATE_REGEXP . '/i', $text, $matches)) { |
||
| 32 | return $text; |
||
| 33 | } |
||
| 34 | |||
| 35 | for ($i = 0, $count = count($matches[0]); $i < $count; $i++) { |
||
| 36 | $path = str_replace(' ', '_', $matches[1][$i]); |
||
| 37 | $args = $matches[3][$i] ? explode('|', $matches[3][$i]) : []; |
||
| 38 | |||
| 39 | $wiki = $this->wiki->findByPath($path); |
||
| 40 | |||
| 41 | if ($wiki) { |
||
| 42 | foreach ($args as $key => $value) { |
||
| 43 | $wiki->text = str_replace('{{' . ($key + 1) . '}}', $value, $wiki->text); |
||
| 44 | } |
||
| 45 | |||
| 46 | $text = str_replace($matches[0][$i], $wiki->text, $text); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | return $text; |
||
| 51 | } |
||
| 52 | } |
||
| 53 |