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: use Nette;
11:
12:
13: /**
14: * Extended HTTP URL.
15: *
16: * <pre>
17: * https://nette.org/admin/script.php/pathinfo/?name=param#fragment
18: * \_______________/\________/
19: * | |
20: * scriptPath pathInfo
21: * </pre>
22: *
23: * - scriptPath: /admin/script.php (or simply /admin/ when script is directory index)
24: * - pathInfo: /pathinfo/ (additional path information)
25: *
26: * @author David Grudl
27: *
28: * @property string $scriptPath
29: * @property-read string $pathInfo
30: */
31: class UrlScript extends Url
32: {
33: /** @var string */
34: private $scriptPath = '/';
35:
36:
37: /**
38: * Sets the script-path part of URI.
39: * @param string
40: * @return self
41: */
42: public function setScriptPath($value)
43: {
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: