/** * @static * @param $_r a conventional querystring (i.e. ?action=mlist;sa=search) or URL * including $scripturl. * @return string a prettyfied URL * * create a SEF URL for all instances for which we don't have a faster URL crafting method. * this is inherently slower than topic() or user(), so don't use this if you can generate * the URL with one of the more specific and faster methods. */ public function parse($_r) { $matches = array(); $url = stripos($_r, $this->scripturl) === false ? $this->scripturl . $_r . ' ' : $_r . ' '; preg_match_all('~(' . preg_quote($this->scripturl) . '[-a-zA-Z0-9+&@#/%?=\\~_|!:,.;\\[\\]]*[-a-zA-Z0-9+&@#/%=\\~_|\\[\\]]?)([^-a-zA-Z0-9+&@#/%=\\~_|])~', $url, $matches); if (!empty($matches[0])) { $replacements = array(); foreach (array_unique($matches[1]) as $i => $_url) { $replacement = SimpleSEF::create_sef_url($_url); if ($_url != $replacement) { $replacements[$matches[0][$i]] = $replacement . $matches[2][$i]; } } $url = str_replace(array_keys($replacements), array_values($replacements), $url); } return rtrim(trim($url), '/') . $this->sid; }