function __construct($name, $url, $template, $action, $permission, $code, $message, $content_type) { $this->name = $name; $this->template = $template; $this->action = $action; $this->permission = $permission; $this->code = $code; $this->message = $message; $this->content_type = $content_type; if ($url) { if (preg_match_all('/\\(([\\w:]+) +\\-> +([\\w:]+)\\)/', $url, $match)) { $patterns = $match[2]; $this->params = $match[1]; $url = preg_replace('/(\\([\\w:]+ +\\-> +[\\w:]+\\))/i', '%', $url); $url = preg_escape($url); foreach ($patterns as $pattern) { $url = preg_replace('/%/', '(' . validate::get($pattern) . ')', $url, 1); } $this->url = '/\\A' . $url . '\\Z/'; } else { $url = preg_escape($url); $this->url = '/\\A' . $url . '\\Z/'; } } else { $this->data['template'] = null; } }
function CToken($token) { if ($token['attributes']['START']) { $start = preg_escape($token['attributes']['START']); $end = preg_escape($token['attributes']['END']); if ($token['attributes']['ESCAPE']) { $esc = preg_escape($token['attributes']['ESCAPE']); $this->pattern = "/" . $start . "(.*?)" . "(?<!{$esc}){$end}" . "/s"; } else { $this->pattern = "/" . $start . "(.*?)" . $end . "/s"; } } else { if ($token['attributes']['ANY']) { $this->pattern = "/" . preg_escape($token['value']) . "/"; } else { $this->pattern = "/\\b(" . preg_escape($token['value']) . ")\\b/"; } } if ($token['attributes']['LINK']) { $this->link = $token['attributes']['LINK']; } if ($token['attributes']['TIP']) { $this->tip = $token['attributes']['TIP']; } $this->token = $token['value']; }
function __construct($uri, $access = []) { $this->access = $access; $this->patterns = (object) []; $pattern = (object) ['regex' => '/\\A' . preg_replace('/\\{\\$[^\\}]+\\}/', '(.+)', preg_escape($uri)) . '\\Z/']; if (preg_match_all('/\\{\\$([^\\}]+)\\}/', $uri, $matches) and isset($matches[1])) { $pattern->params = []; foreach ($matches[1] as $param) { $pattern->params[] = (object) ['name' => $param]; } } $this->patterns->uri = $pattern; }
function path() { return preg_replace('#^' . preg_escape($this->path_prefix) . '#', '', $this->request_uri()); }