<commit_before><?php

/**
 * LeftAndMain is the parent class of all the two-pane views in the CMS.
 * If you are wanting to add more areas to the CMS, you can do it by subclassing LeftAndMain.
 */
abstract class LeftAndMain extends Controller {
	static $tree_class = null;
	static $extra_menu_items = array(), $removed_menu_items = array(), $replaced_menu_items = array();
	static $ForceReload;

	function init() {
		Director::set_site_mode('cms');
		
		// set language
		$member = Member::currentUser();
		if(!empty($member->Lang)) {
			i18n::set_locale($member->Lang);
		}

		parent::init();
		
		// Allow customisation of the access check by a decorator
		if($this->hasMethod('alternateAccessCheck')) {
			$isAllowed = $this->alternateAccessCheck();
			
		// Default security check for LeftAndMain sub-class permissions
		} else {
			$isAllowed = Permission::check("CMS_ACCESS_$this->class");
			if(!$isAllowed && $this->class == 'CMSMain') {
				// When access /admin/, we should try a redirect to another part of the admin rather than be locked out
				$menu = $this->MainMenu();
				if(($first = $menu->First()) && $first->Link) {
					Director::redirect($first->Link);
				}
			}
		}

		// Don't continue if there's already been a redirection request.
		if(Director::redirected_to()) return;

		// Access failure!		
		if(!$isAllowed) {
			$messageSet = array(
				'default' => _t('LeftAndMain.PERMDEFAULT',"Please choose an authentication method and enter your credentials to access the CMS."),<commit_msg>FEATURE Respects 'lang' stored in cookies ENHANCEMENT choose_site_lang() accepts $availableLang (useful to check if a certain page has a translation, and fall back to default language) ENHANCEMENT Added documentation BUGFIX Rewrote Member->Lang to Member->Locale (CMS-translations are stored in locales as well), limited Locale Varchar to 6 characters, changed profile dropdown accordingly<commit_after><?php

/**
 * LeftAndMain is the parent class of all the two-pane views in the CMS.
 * If you are wanting to add more areas to the CMS, you can do it by subclassing LeftAndMain.
 */
abstract class LeftAndMain extends Controller {
	static $tree_class = null;
	static $extra_menu_items = array(), $removed_menu_items = array(), $replaced_menu_items = array();
	static $ForceReload;

	function init() {
		Director::set_site_mode('cms');
		
		// set language
		$member = Member::currentUser();
		if(!empty($member->Locale)) {
			i18n::set_locale($member->Locale);
		}

		parent::init();
		
		// Allow customisation of the access check by a decorator
		if($this->hasMethod('alternateAccessCheck')) {
			$isAllowed = $this->alternateAccessCheck();
			
		// Default security check for LeftAndMain sub-class permissions
		} else {
			$isAllowed = Permission::check("CMS_ACCESS_$this->class");
			if(!$isAllowed && $this->class == 'CMSMain') {
				// When access /admin/, we should try a redirect to another part of the admin rather than be locked out
				$menu = $this->MainMenu();
				if(($first = $menu->First()) && $first->Link) {
					Director::redirect($first->Link);
				}
			}
		}

		// Don't continue if there's already been a redirection request.
		if(Director::redirected_to()) return;

		// Access failure!		
		if(!$isAllowed) {
			$messageSet = array(
				'default' => _t('LeftAndMain.PERMDEFAULT',"Please choose an authentication method and enter your credentials to access the CMS."),
{'fraction_non_alphanumeric': 0.12712859659424544, 'fraction_numerical': 0.001467997651203758, 'mean_word_length': 4.131024096385542, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4698026', 'n_tokens_mistral': 1132, 'n_tokens_neox': 991, 'n_words': 327}