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 void 
  66. 66:      */
  67. 67:     public function setScriptPath($value)
  68. 68:     {
  69. 69:         $this->updating();
  70. 70:         $this->scriptPath = (string) $value;
  71. 71:     }
  72. 72:  
  73. 73:  
  74. 74:  
  75. 75:     /**
  76. 76:      * Returns the script-path part of URI.
  77. 77:      * @return string 
  78. 78:      */
  79. 79:     public function getScriptPath()
  80. 80:     {
  81. 81:         return $this->scriptPath;
  82. 82:     }
  83. 83:  
  84. 84:  
  85. 85:  
  86. 86:     /**
  87. 87:      * Returns the base-path.
  88. 88:      * @return string 
  89. 89:      */
  90. 90:     public function getBasePath()
  91. 91:     {
  92. 92:         return (string) substr($this->scriptPath0strrpos($this->scriptPath'/'1);
  93. 93:     }
  94. 94:  
  95. 95:  
  96. 96:  
  97. 97:     /**
  98. 98:      * Returns the base-URI.
  99. 99:      * @return string 
  100. 100:      */
  101. 101:     public function getBaseUri()
  102. 102:     {
  103. 103:         return $this->scheme '://' $this->getAuthority($this->getBasePath();
  104. 104:     }
  105. 105:  
  106. 106:  
  107. 107:  
  108. 108:     /**
  109. 109:      * Returns the relative-URI.
  110. 110:      * @return string 
  111. 111:      */
  112. 112:     public function getRelativeUri()
  113. 113:     {
  114. 114:         return (string) substr($this->pathstrrpos($this->scriptPath'/'1);
  115. 115:     }
  116. 116:  
  117. 117:  
  118. 118:  
  119. 119:     /**
  120. 120:      * Returns the additional path information.
  121. 121:      * @return string 
  122. 122:      */
  123. 123:     public function getPathInfo()
  124. 124:     {
  125. 125:         return (string) substr($this->pathstrlen($this->scriptPath));
  126. 126:     }
  127. 127: