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: * http://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: * @property string $scriptPath
25: * @property-read string $pathInfo
26: */
27: class UrlScript extends Url
28: {
29: /** @var string */
30: private $scriptPath = '/';
31:
32:
33: /**
34: * Sets the script-path part of URI.
35: * @param string
36: * @return static
37: */
38: public function setScriptPath($value)
39: {
40: $this->scriptPath = (string) $value;
41: return $this;
42: }
43:
44:
45: /**
46: * Returns the script-path part of URI.
47: * @return string
48: */
49: public function getScriptPath()
50: {
51: return $this->scriptPath;
52: }
53:
54:
55: /**
56: * Returns the base-path.
57: * @return string
58: */
59: public function getBasePath()
60: {
61: $pos = strrpos($this->scriptPath, '/');
62: return $pos === FALSE ? '' : substr($this->getPath(), 0, $pos + 1);
63: }
64:
65:
66: /**
67: * Returns the additional path information.
68: * @return string
69: */
70: public function getPathInfo()
71: {
72: return (string) substr($this->getPath(), strlen($this->scriptPath));
73: }
74:
75: }
76: