Source for file UriScript.php

Documentation is available at UriScript.php

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