You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Url.php 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. namespace common\helpers;
  8. class Url
  9. {
  10. public static function frontend($action = '')
  11. {
  12. $server_name = Yii::$app->getRequest()->serverName ;
  13. $address = '' ;
  14. if($server_name == 'localhost')
  15. {
  16. $address = 'http://localhost/reservation_pain/frontend/web/' ;
  17. }
  18. elseif($server_name == 'www.laboiteapain.net' ||
  19. $server_name == 'boulanger.laboiteapain.net')
  20. {
  21. $address = 'http://www.laboiteapain.net/' ;
  22. }
  23. elseif($server_name == 'dev.laboiteapain.net' ||
  24. $server_name == 'boulanger-dev.laboiteapain.net')
  25. {
  26. $address = 'http://dev.laboiteapain.net/' ;
  27. }
  28. elseif($server_name == 'demo.laboiteapain.net' ||
  29. $server_name == 'boulanger-demo.laboiteapain.net')
  30. {
  31. $address = 'http://demo.laboiteapain.net/' ;
  32. }
  33. if(strlen($action))
  34. {
  35. $address .= 'index.php?r='.$action ;
  36. }
  37. return $address ;
  38. }
  39. public static function backend($action = '')
  40. {
  41. $server_name = Yii::$app->getRequest()->serverName ;
  42. $address = '' ;
  43. if($server_name == 'localhost')
  44. {
  45. $address = 'http://localhost/reservation_pain/backend/web/' ;
  46. }
  47. elseif($server_name == 'www.laboiteapain.net' ||
  48. $server_name == 'boulanger.laboiteapain.net')
  49. {
  50. $address = 'http://boulanger.laboiteapain.net/' ;
  51. }
  52. elseif($server_name == 'dev.laboiteapain.net' ||
  53. $server_name == 'boulanger-dev.laboiteapain.net')
  54. {
  55. $address = 'http://boulanger-dev.laboiteapain.net/' ;
  56. }
  57. elseif($server_name == 'demo.laboiteapain.net' ||
  58. $server_name == 'boulanger-demo.laboiteapain.net')
  59. {
  60. $address = 'http://boulanger-demo.laboiteapain.net/' ;
  61. }
  62. if(strlen($action))
  63. {
  64. $address .= 'index.php?r='.$action ;
  65. }
  66. return $address ;
  67. }
  68. public static function env($env, $section)
  69. {
  70. $server_name = Yii::$app->getRequest()->serverName ;
  71. if($section == 'backend')
  72. {
  73. if($server_name == 'localhost')
  74. {
  75. return 'http://localhost/reservation_pain/backend/web/' ;
  76. }
  77. else {
  78. if($env == 'prod')
  79. {
  80. return 'http://boulanger.laboiteapain.net/' ;
  81. }
  82. else {
  83. return 'http://boulanger-'.$env.'.laboiteapain.net/' ;
  84. }
  85. }
  86. }
  87. else {
  88. if($server_name == 'localhost')
  89. {
  90. return 'http://localhost/reservation_pain/frontend/web/' ;
  91. }
  92. else {
  93. if($env == 'prod')
  94. {
  95. return 'http://www.laboiteapain.net/' ;
  96. }
  97. else {
  98. return 'http://'.$env.'.laboiteapain.net/' ;
  99. }
  100. }
  101. }
  102. }
  103. public static function slugify($string) {
  104. return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $string)));
  105. }
  106. }