Beispiel #1
0
 function init()
 {
     Director::set_site_mode('cms');
     // set language
     $member = Member::currentUser();
     if (!empty($member->Locale)) {
         i18n::set_locale($member->Locale);
     }
     // set reading lang
     if (Translatable::is_enabled() && !Director::is_ajax()) {
         Translatable::choose_site_lang(array_keys(i18n::get_existing_content_languages('SiteTree')));
     }
     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."), 'alreadyLoggedIn' => _t('LeftAndMain.PERMALREADY', "I'm sorry, but you can't access that part of the CMS.  If you want to log in as someone else, do so below"), 'logInAgain' => _t('LeftAndMain.PERMAGAIN', "You have been logged out of the CMS.  If you would like to log in again, enter a username and password below."));
         Security::permissionFailure($this, $messageSet);
         return;
     }
     Requirements::javascript('jsparty/prototype.js');
     Requirements::javascript('jsparty/behaviour.js');
     Requirements::javascript('jsparty/prototype_improvements.js');
     Requirements::javascript('jsparty/loader.js');
     Requirements::javascript('jsparty/hover.js');
     Requirements::javascript('jsparty/layout_helpers.js');
     Requirements::javascript(MCE_ROOT . 'tiny_mce_src.js');
     Requirements::javascript('cms/javascript/ImageEditor/Activator.js');
     Requirements::javascript('jsparty/tiny_mce_improvements.js');
     Requirements::javascript('jsparty/scriptaculous/effects.js');
     Requirements::javascript('jsparty/scriptaculous/dragdrop.js');
     Requirements::javascript('jsparty/scriptaculous/controls.js');
     Requirements::css('jsparty/greybox/greybox.css');
     Requirements::javascript('jsparty/greybox/AmiJS.js');
     Requirements::javascript('jsparty/greybox/greybox.js');
     Requirements::javascript('jsparty/tree/tree.js');
     Requirements::css('jsparty/tree/tree.css');
     Requirements::javascript('jsparty/tabstrip/tabstrip.js');
     Requirements::css('jsparty/tabstrip/tabstrip.css');
     Requirements::css('cms/css/TinyMCEImageEnhancement.css');
     Requirements::javascript('cms/javascript/TinyMCEImageEnhancement.js');
     Requirements::javascript('cms/javascript/LeftAndMain.js');
     Requirements::javascript('cms/javascript/LeftAndMain_left.js');
     Requirements::javascript('cms/javascript/LeftAndMain_right.js');
     Requirements::css('sapphire/css/Form.css');
     // Requirements::javascript('cms/javascript/MemberList.js');
     Requirements::javascript('cms/javascript/ForumAdmin.js');
     Requirements::javascript('cms/javascript/SideTabs.js');
     Requirements::javascript('cms/javascript/TaskList.js');
     Requirements::javascript('cms/javascript/CommentList.js');
     Requirements::javascript('cms/javascript/SideReports.js');
     Requirements::javascript('cms/javascript/LangSelector.js');
     Requirements::javascript('cms/javascript/TranslationTab.js');
     Requirements::javascript('sapphire/javascript/Validator.js');
     Requirements::javascript('sapphire/javascript/UniqueFields.js');
     Requirements::javascript('sapphire/javascript/RedirectorPage.js');
     Requirements::javascript('sapphire/javascript/DataReport.js');
     Requirements::javascript('sapphire/javascript/ToggleCompositeField.js');
     Requirements::css('sapphire/css/SubmittedFormReportField.css');
     Requirements::javascript('sapphire/javascript/FieldEditor.js');
     Requirements::css('sapphire/css/FieldEditor.css');
     Requirements::css('sapphire/css/TableListField.css');
     Requirements::css('sapphire/css/ComplexTableField.css');
     Requirements::javascript('sapphire/javascript/TableListField.js');
     Requirements::javascript('sapphire/javascript/TableField.js');
     Requirements::javascript('sapphire/javascript/ComplexTableField.js');
     Requirements::javascript('sapphire/javascript/RelationComplexTableField.js');
     Requirements::css('sapphire/css/TreeDropdownField.css');
     Requirements::css('sapphire/css/CheckboxSetField.css');
     Requirements::javascript('jsparty/calendar/calendar.js');
     Requirements::javascript('jsparty/calendar/lang/calendar-en.js');
     Requirements::javascript('jsparty/calendar/calendar-setup.js');
     Requirements::css('sapphire/css/CalendarDateField.css');
     Requirements::css('jsparty/calendar/calendar-win2k-1.css');
     Requirements::javascript('sapphire/javascript/DropdownTimeField.js');
     Requirements::css('sapphire/css/DropdownTimeField.css');
     Requirements::css('sapphire/css/PopupDateTimeField.css');
     Requirements::javascript('sapphire/javascript/SelectionGroup.js');
     Requirements::css('sapphire/css/SelectionGroup.css');
     Requirements::javascript('jsparty/SWFUpload/SWFUpload.js');
     Requirements::javascript('cms/javascript/Upload.js');
     Requirements::javascript('sapphire/javascript/HasManyFileField.js');
     Requirements::css('sapphire/css/HasManyFileField.css');
     Requirements::themedCSS('typography');
     // For Widgets
     Requirements::css('cms/css/WidgetAreaEditor.css');
     Requirements::javascript('cms/javascript/WidgetAreaEditor.js');
     // For Blog
     Requirements::javascript('blog/javascript/bbcodehelp.js');
     Requirements::javascript("sapphire/javascript/Security_login.js");
     $dummy = null;
     $this->extend('augmentInit', $dummy);
 }
	/**
	 * @uses LeftAndMainDecorator->init()
	 * @uses LeftAndMainDecorator->accessedCMS()
	 * @uses CMSMenu
	 * @uses Director::set_site_mode()
	 */
	function init() {
		parent::init();

		Director::set_site_mode('cms');
		
		// set language
		$member = Member::currentUser();
		if(!empty($member->Locale)) {
			i18n::set_locale($member->Locale);
		}
		
		// can't be done in cms/_config.php as locale is not set yet
		CMSMenu::add_link(
			'Help', 
			_t('LeftAndMain.HELP', 'Help', PR_HIGH, 'Menu title'), 
			'http://userhelp.silverstripe.com'
		);
		
		// set reading lang
		if(Translatable::is_enabled() && !Director::is_ajax()) {
			Translatable::choose_site_lang(array_keys(Translatable::get_existing_content_languages('SiteTree')));
		}

		// Allow customisation of the access check by a decorator
		if(!$this->canView()) {
			// When access /admin/, we should try a redirect to another part of the admin rather than be locked out
			$menu = $this->MainMenu();
			foreach($menu as $candidate) {
				if(
					$candidate->Link && 
					$candidate->Link != $this->Link() 
					&& $candidate->MenuItem->controller 
					&& singleton($candidate->MenuItem->controller)->canView()
				) {
					return Director::redirect($candidate->Link);
				}
			}
			
			if(Member::currentUser()) {
				Session::set("BackURL", null);
			}
			
			// if no alternate menu items have matched, return a permission error
			$messageSet = array(
				'default' => _t('LeftAndMain.PERMDEFAULT',"Please choose an authentication method and enter your credentials to access the CMS."),
				'alreadyLoggedIn' => _t('LeftAndMain.PERMALREADY',"I'm sorry, but you can't access that part of the CMS.  If you want to log in as someone else, do so below"),
				'logInAgain' => _t('LeftAndMain.PERMAGAIN',"You have been logged out of the CMS.  If you would like to log in again, enter a username and password below."),
			);

			return Security::permissionFailure($this, $messageSet);
		}

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

		// Audit logging hook
		if(empty($_REQUEST['executeForm']) && !Director::is_ajax()) $this->extend('accessedCMS');
		
		Requirements::css(CMS_DIR . '/css/typography.css');
		Requirements::css(CMS_DIR . '/css/layout.css');
		Requirements::css(CMS_DIR . '/css/cms_left.css');
		Requirements::css(CMS_DIR . '/css/cms_right.css');
		Requirements::css(SAPPHIRE_DIR . '/css/Form.css');
		
		if(isset($_REQUEST['debug_firebug'])) {
			// Firebug is a useful console for debugging javascript
			// Its available as a Firefox extension or a javascript library
			// for easy inclusion in other browsers (just append ?debug_firebug=1 to the URL)
			Requirements::javascript(THIRDPARTY_DIR . '/firebug/firebug-lite-compressed.js');
		} else {
			// By default, we include fake-objects for all firebug calls
			// to avoid javascript errors when referencing console.log() etc in javascript code
			Requirements::javascript(THIRDPARTY_DIR . '/firebug/firebugx.js');
		}
		
		Requirements::javascript(THIRDPARTY_DIR . '/prototype.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery_improvements.js');
		Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/livequery/jquery.livequery.js');
		Requirements::javascript(SAPPHIRE_DIR . '/javascript/core/jquery.ondemand.js');
		Requirements::javascript(THIRDPARTY_DIR . '/prototype_improvements.js');
		Requirements::javascript(THIRDPARTY_DIR . '/loader.js');
		Requirements::javascript(THIRDPARTY_DIR . '/hover.js');
		Requirements::javascript(THIRDPARTY_DIR . '/layout_helpers.js');
		Requirements::javascript(SAPPHIRE_DIR . "/javascript/i18n.js");
		
		Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js');
		Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/dragdrop.js');
		Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/controls.js');

		Requirements::css(THIRDPARTY_DIR . '/greybox/greybox.css');
		Requirements::javascript(THIRDPARTY_DIR . '/greybox/AmiJS.js');
		Requirements::javascript(THIRDPARTY_DIR . '/greybox/greybox.js');
		
		Requirements::javascript(THIRDPARTY_DIR . '/tree/tree.js');
		Requirements::css(THIRDPARTY_DIR . '/tree/tree.css');
		
		Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain.js');
		Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain_left.js');
		Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain_right.js');
	
		Requirements::javascript(CMS_DIR . '/javascript/SideTabs.js');
		Requirements::javascript(CMS_DIR . '/javascript/SideReports.js');
		Requirements::javascript(CMS_DIR . '/javascript/LangSelector.js');
		Requirements::javascript(CMS_DIR . '/javascript/TranslationTab.js');
		
		Requirements::themedCSS('typography');

		foreach (self::$extra_requirements['javascript'] as $file) {
			Requirements::javascript($file[0]);
		}
		
		foreach (self::$extra_requirements['css'] as $file) {
			Requirements::css($file[0], $file[1]);
		}
		
		foreach (self::$extra_requirements['themedcss'] as $file) {
			Requirements::css($file[0], $file[1]);
		}
		
		Requirements::customScript('Behaviour.addLoader(hideLoading);');
		
		// Javascript combined files
		Requirements::combine_files(
			'assets/base.js',
			array(
				'jsparty/prototype.js',
				'jsparty/behaviour.js',
				'jsparty/prototype_improvements.js',
				'jsparty/jquery/jquery.js',
				'jsparty/jquery/plugins/livequery/jquery.livequery.js',
				'jsparty/jquery/plugins/effen/jquery.fn.js',
				'sapphire/javascript/core/jquery.ondemand.js',
				'jsparty/jquery/jquery_improvements.js',
				'jsparty/firebug/firebugx.js',
				'sapphire/javascript/i18n.js',
			)
		);

		Requirements::combine_files(
			'assets/leftandmain.js',
			array(
				'jsparty/loader.js',
				'jsparty/hover.js',
				'jsparty/layout_helpers.js',
				'jsparty/scriptaculous/effects.js',
				'jsparty/scriptaculous/dragdrop.js',
				'jsparty/scriptaculous/controls.js',
				'jsparty/greybox/AmiJS.js',
				'jsparty/greybox/greybox.js',
				'cms/javascript/LeftAndMain.js',
				'cms/javascript/LeftAndMain_left.js',
				'cms/javascript/LeftAndMain_right.js',
				//'jsparty/tiny_mce2/tiny_mce_src.js',
				'jsparty/tree/tree.js',
				'jsparty/tabstrip/tabstrip.js',
				'cms/javascript/TinyMCEImageEnhancement.js',
				'jsparty/SWFUpload/SWFUpload.js',
				'cms/javascript/Upload.js',
				'sapphire/javascript/TreeSelectorField.js',
		 		'cms/javascript/ThumbnailStripField.js',
			)
		);

		Requirements::combine_files(
			'assets/cmsmain.js',
			array(
				'cms/javascript/CMSMain.js',
				'cms/javascript/CMSMain_left.js',
				'cms/javascript/CMSMain_right.js',
				'cms/javascript/SideTabs.js',
				'cms/javascript/SideReports.js',
				'cms/javascript/LangSelector.js',
				'cms/javascript/TranslationTab.js',
				'jsparty/calendar/calendar.js',
				'jsparty/calendar/lang/calendar-en.js',
				'jsparty/calendar/calendar-setup.js',
			)
		);

		// DEPRECATED 2.3: Use init()
		$dummy = null;
		$this->extend('augmentInit', $dummy);
		
		$dummy = null;
		$this->extend('init', $dummy);
	}
Beispiel #3
0
	function init() {
		// set language
		$member = Member::currentUser();
		if(!empty($member->Locale)) {
			i18n::set_locale($member->Locale);
		}
		
		// set reading lang
		if(Translatable::is_enabled() && !Director::is_ajax()) {
			Translatable::choose_site_lang(array_keys(Translatable::get_existing_content_languages('SiteTree')));
		}
		
		parent::init();
	}