PageRenderTime 53ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Nette/Web/UriScript.php

https://github.com/DocX/nette
PHP | 131 lines | 32 code | 27 blank | 72 comment | 0 complexity | 226661d2058c071e720c388e951df5d8 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * Nette Framework
  4. *
  5. * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
  6. *
  7. * This source file is subject to the "Nette license" that is bundled
  8. * with this package in the file license.txt.
  9. *
  10. * For more information please see http://nettephp.com
  11. *
  12. * @copyright Copyright (c) 2004, 2009 David Grudl
  13. * @license http://nettephp.com/license Nette license
  14. * @link http://nettephp.com
  15. * @category Nette
  16. * @package Nette\Web
  17. */
  18. /*namespace Nette\Web;*/
  19. require_once dirname(__FILE__) . '/../Web/Uri.php';
  20. /**
  21. * Extended HTTP URL.
  22. *
  23. * <pre>
  24. * basePath relativeUri
  25. * | |
  26. * /-----\/------------------\
  27. * http://nettephp.com/admin/script.php/pathinfo/?name=param#fragment
  28. * \_______________/\________/
  29. * | |
  30. * scriptPath pathInfo
  31. * </pre>
  32. *
  33. * - basePath: /admin/ (everything before relative URI not including the script name)
  34. * - baseUri: http://nettephp.com/admin/
  35. * - scriptPath: /admin/script.php
  36. * - relativeUri: script.php/pathinfo/
  37. * - pathInfo: /pathinfo/ (additional path information)
  38. *
  39. * @author David Grudl
  40. * @copyright Copyright (c) 2004, 2009 David Grudl
  41. * @package Nette\Web
  42. *
  43. * @property string $scriptPath
  44. * @property-read string $basePath
  45. * @property-read string $baseUri
  46. * @property-read string $relativeUri
  47. * @property-read string $pathInfo
  48. */
  49. class UriScript extends Uri
  50. {
  51. /** @var string */
  52. private $scriptPath = '';
  53. /**
  54. * Sets the script-path part of URI.
  55. * @param string
  56. * @return UriScript provides a fluent interface
  57. */
  58. public function setScriptPath($value)
  59. {
  60. $this->updating();
  61. $this->scriptPath = (string) $value;
  62. return $this;
  63. }
  64. /**
  65. * Returns the script-path part of URI.
  66. * @return string
  67. */
  68. public function getScriptPath()
  69. {
  70. return $this->scriptPath;
  71. }
  72. /**
  73. * Returns the base-path.
  74. * @return string
  75. */
  76. public function getBasePath()
  77. {
  78. return (string) substr($this->scriptPath, 0, strrpos($this->scriptPath, '/') + 1);
  79. }
  80. /**
  81. * Returns the base-URI.
  82. * @return string
  83. */
  84. public function getBaseUri()
  85. {
  86. return $this->scheme . '://' . $this->getAuthority() . $this->getBasePath();
  87. }
  88. /**
  89. * Returns the relative-URI.
  90. * @return string
  91. */
  92. public function getRelativeUri()
  93. {
  94. return (string) substr($this->path, strrpos($this->scriptPath, '/') + 1);
  95. }
  96. /**
  97. * Returns the additional path information.
  98. * @return string
  99. */
  100. public function getPathInfo()
  101. {
  102. return (string) substr($this->path, strlen($this->scriptPath));
  103. }
  104. }