Guest User

Untitled

a guest
Jul 16th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Default page model class
  5. * Collects required data for the controller
  6. */
  7. class Page extends SiteTree {
  8.  
  9. public static $db = array(
  10. );
  11.  
  12. public static $has_one = array(
  13. );
  14.  
  15. // rewrites the link targets
  16. public function Link($action = null) {
  17.  
  18. // URL locale issues
  19. $URLLocale = Translatable::get_current_locale();
  20. if(preg_match('/(^[a-z]{2})_([A-Z]{2})$/', $URLLocale, $matches)) {
  21. $URLLocale = strtolower($matches[1])."-".strtolower($matches[2]);
  22. }
  23.  
  24. // URL Live/ Stage issues
  25. $URLStage = Versioned::current_stage();
  26. if($URLStage == "Stage") $stage = "/?stage=Stage";
  27. else $stage = "";
  28.  
  29. // Homepage rewriting
  30. if($action == "index") {
  31. $action = "home";
  32. }
  33.  
  34. // Final link
  35. if($this->URLSegment == 'home' && !$action) return $URLLocale.$stage;
  36. else return $URLLocale."/".$this->URLSegment."/".$action.$stage;
  37. }
  38.  
  39. }
  40.  
  41. /**
  42. * Default page controller class
  43. * Delivers content and handles actions
  44. */
  45. class Page_Controller extends ContentController {
  46.  
  47. public function init() {
  48. parent::init();
  49.  
  50. // Note: you should use SS template require tags inside your templates
  51. // instead of putting Requirements calls here. However these are
  52. // included so that our older themes still work
  53. Requirements::themedCSS("layout");
  54. Requirements::themedCSS("typography");
  55. Requirements::themedCSS("form");
  56. }
  57.  
  58. public function setLocale($locale) {
  59.  
  60. Translatable::set_current_locale($locale);
  61. }
  62.  
  63. }
  64.  
  65. ?>
Add Comment
Please, Sign In to add comment