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