PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/Nette/Http/UrlScript.php

http://github.com/nette/nette
PHP | 89 lines | 26 code | 19 blank | 44 comment | 0 complexity | 1a176b13d982efd8db3c48a753d8bcb5 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * This file is part of the Nette Framework (http://nette.org)
  4. *
  5. * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
  6. *
  7. * For the full copyright and license information, please view
  8. * the file license.txt that was distributed with this source code.
  9. */
  10. namespace Nette\Http;
  11. use Nette;
  12. /**
  13. * Extended HTTP URL.
  14. *
  15. * <pre>
  16. * http://nette.org/admin/script.php/pathinfo/?name=param#fragment
  17. * \_______________/\________/
  18. * | |
  19. * scriptPath pathInfo
  20. * </pre>
  21. *
  22. * - scriptPath: /admin/script.php (or simply /admin/ when script is directory index)
  23. * - pathInfo: /pathinfo/ (additional path information)
  24. *
  25. * @author David Grudl
  26. *
  27. * @property string $scriptPath
  28. * @property-read string $pathInfo
  29. */
  30. class UrlScript extends Url
  31. {
  32. /** @var string */
  33. private $scriptPath = '/';
  34. /**
  35. * Sets the script-path part of URI.
  36. * @param string
  37. * @return UrlScript provides a fluent interface
  38. */
  39. public function setScriptPath($value)
  40. {
  41. $this->updating();
  42. $this->scriptPath = (string) $value;
  43. return $this;
  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. * Returns the base-path.
  55. * @return string
  56. */
  57. public function getBasePath()
  58. {
  59. $pos = strrpos($this->scriptPath, '/');
  60. return $pos === FALSE ? '' : substr($this->path, 0, $pos + 1);
  61. }
  62. /**
  63. * Returns the additional path information.
  64. * @return string
  65. */
  66. public function getPathInfo()
  67. {
  68. return (string) substr($this->path, strlen($this->scriptPath));
  69. }
  70. }