X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Furlmapper.php;h=bb288f8322f7c3e71b6b8109b2e4bbe3fc621fef;hb=1ae5ea8f4cf40113a14a183b754101177f99ba32;hp=f16bf128ef83339efbaadfc8553b653923710f21;hpb=384a093639cf57a1e8e8f8347e7cbdcf5f40617d;p=quix0rs-gnu-social.git diff --git a/lib/urlmapper.php b/lib/urlmapper.php index f16bf128ef..bb288f8322 100644 --- a/lib/urlmapper.php +++ b/lib/urlmapper.php @@ -4,7 +4,7 @@ * Copyright (C) 2011, StatusNet, Inc. * * URL mapper - * + * * PHP version 5 * * This program is free software: you can redistribute it and/or modify @@ -20,7 +20,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * - * @category Cache + * @category URL * @package StatusNet * @author Evan Prodromou * @copyright 2011 StatusNet, Inc. @@ -39,8 +39,8 @@ if (!defined('STATUSNET')) { * * Converts a path into a set of parameters, and vice versa * - * We used to use Net_URL_Mapper, so there's a wrapper class at Router, q.v. - * + * We used to use URLMapper, so there's a wrapper class at Router, q.v. + * * NUM's vagaries are the main reason we have weirdnesses here. * * @category URL @@ -58,6 +58,7 @@ class URLMapper protected $statics = array(); protected $variables = array(); protected $reverse = array(); + protected $allpaths = array(); function connect($path, $args, $paramPatterns=array()) { @@ -65,6 +66,8 @@ class URLMapper throw new Exception(sprintf("Can't connect %s; path has no action.", $path)); } + $allpaths[] = $path; + $action = $args[self::ACTION]; $paramNames = $this->getParamNames($path); @@ -119,7 +122,7 @@ class URLMapper return $results; } } - + throw new Exception(sprintf('No match for path "%s"', $path)); } @@ -173,7 +176,7 @@ class URLMapper $path = vsprintf($format, $toFormat); } - if (!empty($qstring)) { + if (!empty($qstring)) { $formatted = http_build_query($qstring); $path .= '?' . $formatted; } @@ -212,7 +215,7 @@ class URLMapper array($pr, 'toPattern'), $path); - $regex = '#' . str_replace('#', '\#', $regex) . '#'; + $regex = '#^' . str_replace('#', '\#', $regex) . '$#'; return $regex; } @@ -223,6 +226,11 @@ class URLMapper return $format; } + + public function getPaths() + { + return $this->allpaths; + } } class PatternReplacer