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