1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
6: * @package Nette\Http
7: */
8:
9:
10:
11: /**
12: * Extended HTTP URL.
13: *
14: * <pre>
15: * https://nette.org/admin/script.php/pathinfo/?name=param#fragment
16: * \_______________/\________/
17: * | |
18: * scriptPath pathInfo
19: * </pre>
20: *
21: * - scriptPath: /admin/script.php (or simply /admin/ when script is directory index)
22: * - pathInfo: /pathinfo/ (additional path information)
23: *
24: * @author David Grudl
25: *
26: * @property string $scriptPath
27: * @property-read string $pathInfo
28: * @package Nette\Http
29: */
30: class NUrlScript extends NUrl
31: {
32: /** @var string */
33: private $scriptPath = '/';
34:
35:
36: /**
37: * Sets the script-path part of URI.
38: * @param string
39: * @return self
40: */
41: public function setScriptPath($value)
42: {
43: $this->updating();
44: $this->scriptPath = (string) $value;
45: return $this;
46: }
47:
48:
49: /**
50: * Returns the script-path part of URI.
51: * @return string
52: */
53: public function getScriptPath()
54: {
55: return $this->scriptPath;
56: }
57:
58:
59: /**
60: * Returns the base-path.
61: * @return string
62: */
63: public function getBasePath()
64: {
65: $pos = strrpos($this->scriptPath, '/');
66: return $pos === FALSE ? '' : substr($this->path, 0, $pos + 1);
67: }
68:
69:
70: /**
71: * Returns the additional path information.
72: * @return string
73: */
74: public function getPathInfo()
75: {
76: return (string) substr($this->path, strlen($this->scriptPath));
77: }
78:
79: }
80: