Example #1
0
	private static function getPage(array $path) {

		$parts = array();
		foreach ($path as $path_part) {
			$part = '';
			if ($path_part && self::specialParameters($path_part)) {
                            if(!self::$urlfirst && $path_part)
                                self::$urlfirst = $path_part;
				if (is_numeric($path_part)) {
					$part = '%d';
				} else {
					$part = $path_part;
				}
				$parts[] = $part;
			}
		}
		$path_mapped = implode('/', $parts);


		if (!isset(LibMap::$map[$path_mapped])) {
			$path_mapped_reduce = $parts;
			for ($i = count($parts); $i > -1; $i--) {
				unset($path_mapped_reduce[$i]);

				// path with *
				$reduced_uri = implode('/', $path_mapped_reduce) . '/*';
				if ($pageName = self::getPageByPath($reduced_uri))
					return $pageName;
				// path with %s
				$reduced_uri = implode('/', $path_mapped_reduce) . '/%s';
				if ($pageName = self::getPageByPath($reduced_uri))
					return $pageName;
				// path
				$reduced_uri = implode('/', $path_mapped_reduce);
				if ($pageName = self::getPageByPath($reduced_uri))
					return $pageName;
			}
		} else {
			return LibMap::$map[$path_mapped];
		}
		return 'p404';
	}