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: */
11:
12: namespace Nette\Http;
13:
14: use Nette;
15:
16:
17: /**
18: * Extended HTTP URL.
19: *
20: * <pre>
21: * http://nette.org/admin/script.php/pathinfo/?name=param#fragment
22: * \_______________/\________/
23: * | |
24: * scriptPath pathInfo
25: * </pre>
26: *
27: * - scriptPath: /admin/script.php (or simply /admin/ when script is directory index)
28: * - pathInfo: /pathinfo/ (additional path information)
29: *
30: * @author David Grudl
31: *
32: * @property string $scriptPath
33: * @property-read string $pathInfo
34: */
35: class UrlScript extends Url
36: {
37: /** @var string */
38: private $scriptPath = '/';
39:
40:
41: /**
42: * Sets the script-path part of URI.
43: * @param string
44: * @return self
45: */
46: public function setScriptPath($value)
47: {
48: $this->updating();
49: $this->scriptPath = (string) $value;
50: return $this;
51: }
52:
53:
54: /**
55: * Returns the script-path part of URI.
56: * @return string
57: */
58: public function getScriptPath()
59: {
60: return $this->scriptPath;
61: }
62:
63:
64: /**
65: * Returns the base-path.
66: * @return string
67: */
68: public function getBasePath()
69: {
70: $pos = strrpos($this->scriptPath, '/');
71: return $pos === FALSE ? '' : substr($this->path, 0, $pos + 1);
72: }
73:
74:
75: /**
76: * Returns the additional path information.
77: * @return string
78: */
79: public function getPathInfo()
80: {
81: return (string) substr($this->path, strlen($this->scriptPath));
82: }
83:
84: }
85: