1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6: */
7:
8: namespace Nette\Http;
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: */
29: class UrlScript extends Url
30: {
31: /** @var string */
32: private $scriptPath = '/';
33:
34:
35: /**
36: * Sets the script-path part of URI.
37: * @param string
38: * @return self
39: */
40: public function setScriptPath($value)
41: {
42: $this->scriptPath = (string) $value;
43: return $this;
44: }
45:
46:
47: /**
48: * Returns the script-path part of URI.
49: * @return string
50: */
51: public function getScriptPath()
52: {
53: return $this->scriptPath;
54: }
55:
56:
57: /**
58: * Returns the base-path.
59: * @return string
60: */
61: public function getBasePath()
62: {
63: $pos = strrpos($this->scriptPath, '/');
64: return $pos === FALSE ? '' : substr($this->getPath(), 0, $pos + 1);
65: }
66:
67:
68: /**
69: * Returns the additional path information.
70: * @return string
71: */
72: public function getPathInfo()
73: {
74: return (string) substr($this->getPath(), strlen($this->scriptPath));
75: }
76:
77: }
78: