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: */
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->updating();
45: $this->scriptPath = (string) $value;
46: return $this;
47: }
48:
49:
50: /**
51: * Returns the script-path part of URI.
52: * @return string
53: */
54: public function getScriptPath()
55: {
56: return $this->scriptPath;
57: }
58:
59:
60: /**
61: * Returns the base-path.
62: * @return string
63: */
64: public function getBasePath()
65: {
66: $pos = strrpos($this->scriptPath, '/');
67: return $pos === FALSE ? '' : substr($this->path, 0, $pos + 1);
68: }
69:
70:
71: /**
72: * Returns the additional path information.
73: * @return string
74: */
75: public function getPathInfo()
76: {
77: return (string) substr($this->path, strlen($this->scriptPath));
78: }
79:
80: }
81: