No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

118 líneas
3.4KB

  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. }