Guest User

Untitled

a guest
Jun 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <?php
  2.  
  3. class MultiLingual extends ModelAsController {
  4. static $lang;
  5. function init() {
  6. $baseUrl = Director::baseUrl();
  7. $requestUri = $_SERVER['REQUEST_URI'];
  8. $lang = substr($requestUri, strlen($baseUrl), 2);
  9. self::$lang = $lang;
  10. //prevents default behaviour of redirecting to '/' for '/en/'
  11. if($this->URLParams['URLSegment'] == "" || $this->URLParams['URLSegment'] == 'home') {
  12. $urlparams = array('URLSegment' => 'home', 'Action' => ' ');
  13. if(self::$lang == 'mr'){
  14. $_POST['this_is_a_hack_to_stop_the_home_redirect'] = true;
  15. }
  16. $this->setURLParams($urlparams);
  17. }
  18. parent::init();
  19. }
  20. static function currentLang() {
  21. return self::$lang;
  22. }
  23. }
  24.  
  25. ?>
Add Comment
Please, Sign In to add comment