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