sfNoRouting.class.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * sfNoRouting class is a very simple routing class that uses GET parameters.
  11. *
  12. * @package symfony
  13. * @subpackage routing
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfNoRouting.class.php 11313 2008-09-03 17:28:33Z fabien $
  16. */
  17. class sfNoRouting extends sfRouting
  18. {
  19. /**
  20. * @see sfRouting
  21. */
  22. public function getCurrentInternalUri($with_route_name = false)
  23. {
  24. $parameters = $this->mergeArrays($this->defaultParameters, $_GET);
  25. $action = sprintf('%s/%s', $parameters['module'], $parameters['action']);
  26. // other parameters
  27. unset($parameters['module'], $parameters['action']);
  28. ksort($parameters);
  29. $parameters = count($parameters) ? '?'.http_build_query($parameters, null, '&') : '';
  30. return sprintf('%s%s', $action, $parameters);
  31. }
  32. /**
  33. * @see sfRouting
  34. */
  35. public function generate($name, $params = array(), $absolute = false)
  36. {
  37. $parameters = $this->mergeArrays($this->defaultParameters, $params);
  38. if ($this->getDefaultParameter('module') == $parameters['module'])
  39. {
  40. unset($parameters['module']);
  41. }
  42. if ($this->getDefaultParameter('action') == $parameters['action'])
  43. {
  44. unset($parameters['action']);
  45. }
  46. $parameters = http_build_query($parameters, null, '&');
  47. return $this->fixGeneratedUrl('/'.($parameters ? '?'.$parameters : ''), $absolute);
  48. }
  49. /**
  50. * @see sfRouting
  51. */
  52. public function parse($url)
  53. {
  54. return array();
  55. }
  56. /**
  57. * @see sfRouting
  58. */
  59. public function getRoutes()
  60. {
  61. return array();
  62. }
  63. /**
  64. * @see sfRouting
  65. */
  66. public function setRoutes($routes)
  67. {
  68. return array();
  69. }
  70. /**
  71. * @see sfRouting
  72. */
  73. public function hasRoutes()
  74. {
  75. return false;
  76. }
  77. /**
  78. * @see sfRouting
  79. */
  80. public function clearRoutes()
  81. {
  82. }
  83. }