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 https://nette.org
  12. 12:  *
  13. 13:  * @copyright  Copyright (c) 2004, 2009 David Grudl
  14. 14:  * @license    https://nette.org/license  Nette license
  15. 15:  * @link       https://nette.org
  16. 16:  * @category   Nette
  17. 17:  * @package    Nette\Web
  18. 18:  * @version    $Id$
  19. 19:  */
  20. 20:  
  21. 21:  
  22. 22:  
  23. 23: require_once dirname(__FILE__'/../Web/Uri.php';
  24. 24:  
  25. 25:  
  26. 26:  
  27. 27: /**
  28. 28:  * Extended HTTP URL.
  29. 29:  *
  30. 30:  * <pre>
  31. 31:  *                    basePath   relativeUri
  32. 32:  *                       |           |
  33. 33:  *                    /-----\/------------------\
  34. 34:  * https://nette.org/admin/script.php/pathinfo/?name=param#fragment
  35. 35:  *                    \_______________/\________/
  36. 36:  *                           |              |
  37. 37:  *                      scriptPath       pathInfo
  38. 38:  * </pre>
  39. 39:  *
  40. 40:  * - basePath:    /admin/ (everything before relative URI not including the script name)
  41. 41:  * - baseUri:     https://nette.org/admin/
  42. 42:  * - scriptPath:  /admin/script.php
  43. 43:  * - relativeUri: script.php/pathinfo/
  44. 44:  * - pathInfo:    /pathinfo/ (additional path information)
  45. 45:  *
  46. 46:  * @author     David Grudl
  47. 47:  * @copyright  Copyright (c) 2004, 2009 David Grudl
  48. 48:  * @package    Nette\Web
  49. 49:  */
  50. 50: class UriScript extends Uri
  51. 51: {
  52. 52:     /** @var string */
  53. 53:     public $scriptPath;
  54. 54:  
  55. 55:  
  56. 56:  
  57. 57:     /**
  58. 58:      * Returns the base-path.
  59. 59:      * @return string 
  60. 60:      */
  61. 61:     public function getBasePath()
  62. 62:     {
  63. 63:         return substr($this->scriptPath0strrpos($this->scriptPath'/'1);
  64. 64:     }
  65. 65:  
  66. 66:  
  67. 67:  
  68. 68:     /**
  69. 69:      * Returns the base-URI.
  70. 70:      * @return string 
  71. 71:      */
  72. 72:     public function getBaseUri()
  73. 73:     {
  74. 74:         return $this->scheme . '://' $this->getAuthority($this->getBasePath();
  75. 75:     }
  76. 76:  
  77. 77:  
  78. 78:  
  79. 79:     /**
  80. 80:      * Returns the relative-URI.
  81. 81:      * @return string 
  82. 82:      */
  83. 83:     public function getRelativeUri()
  84. 84:     {
  85. 85:         return (string) substr($this->pathstrrpos($this->scriptPath'/'1);
  86. 86:     }
  87. 87:  
  88. 88:  
  89. 89:  
  90. 90:     /**
  91. 91:      * Returns the additional path information.
  92. 92:      * @return string 
  93. 93:      */
  94. 94:     public function getPathInfo()
  95. 95:     {
  96. 96:         return (string) substr($this->pathstrlen($this->scriptPath));
  97. 97:     }
  98. 98:  
  99. 99: }