Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Default page model class
- * Collects required data for the controller
- */
- class Page extends SiteTree {
- public static $db = array(
- );
- public static $has_one = array(
- );
- // rewrites the link targets
- public function Link($action = null) {
- // URL locale issues
- $URLLocale = Translatable::get_current_locale();
- if(preg_match('/(^[a-z]{2})_([A-Z]{2})$/', $URLLocale, $matches)) {
- $URLLocale = strtolower($matches[1])."-".strtolower($matches[2]);
- }
- // URL Live/ Stage issues
- $URLStage = Versioned::current_stage();
- if($URLStage == "Stage") $stage = "/?stage=Stage";
- else $stage = "";
- // Homepage rewriting
- if($action == "index") {
- $action = "home";
- }
- // Final link
- if($this->URLSegment == 'home' && !$action) return $URLLocale.$stage;
- else return $URLLocale."/".$this->URLSegment."/".$action.$stage;
- }
- }
- /**
- * Default page controller class
- * Delivers content and handles actions
- */
- class Page_Controller extends ContentController {
- public function init() {
- parent::init();
- // Note: you should use SS template require tags inside your templates
- // instead of putting Requirements calls here. However these are
- // included so that our older themes still work
- Requirements::themedCSS("layout");
- Requirements::themedCSS("typography");
- Requirements::themedCSS("form");
- }
- public function setLocale($locale) {
- Translatable::set_current_locale($locale);
- }
- }
- ?>
Add Comment
Please, Sign In to add comment