Пример #1
0
 public function init()
 {
     // set reading lang
     if (SiteTree::has_extension('Translatable') && !$this->getRequest()->isAjax()) {
         Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SiteTree')));
     }
     parent::init();
     Versioned::reading_stage("Stage");
     Requirements::css(CMS_DIR . '/css/screen.css');
     Requirements::customCSS($this->generatePageIconsCss());
     Requirements::combine_files('cmsmain.js', array_merge(array(CMS_DIR . '/javascript/CMSMain.js', CMS_DIR . '/javascript/CMSMain.EditForm.js', CMS_DIR . '/javascript/CMSMain.AddForm.js', CMS_DIR . '/javascript/CMSPageHistoryController.js', CMS_DIR . '/javascript/CMSMain.Tree.js', CMS_DIR . '/javascript/SilverStripeNavigator.js', CMS_DIR . '/javascript/SiteTreeURLSegmentField.js'), Requirements::add_i18n_javascript(CMS_DIR . '/javascript/lang', true, true)));
     CMSBatchActionHandler::register('publish', 'CMSBatchAction_Publish');
     CMSBatchActionHandler::register('unpublish', 'CMSBatchAction_Unpublish');
     // Check legacy actions
     $legacy = $this->config()->enabled_legacy_actions;
     // Delete from live is unnecessary since we have unpublish which does the same thing
     if (in_array('CMSBatchAction_DeleteFromLive', $legacy)) {
         Deprecation::notice('4.0', 'Delete From Live is deprecated. Use Un-publish instead');
         CMSBatchActionHandler::register('deletefromlive', 'CMSBatchAction_DeleteFromLive');
     }
     // Delete action
     if (in_array('CMSBatchAction_Delete', $legacy)) {
         Deprecation::notice('4.0', 'Delete from Stage is deprecated. Use Archive instead.');
         CMSBatchActionHandler::register('delete', 'CMSBatchAction_Delete');
     } else {
         CMSBatchActionHandler::register('archive', 'CMSBatchAction_Archive');
         CMSBatchActionHandler::register('restore', 'CMSBatchAction_Restore');
     }
 }
Пример #2
0
	public function init() {
		// set reading lang
		if(Object::has_extension('SiteTree', 'Translatable') && !$this->request->isAjax()) {
			Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SiteTree')));
		}
		
		parent::init();
		
		Requirements::css(CMS_DIR . '/css/screen.css');
		
		Requirements::combine_files(
			'cmsmain.js',
			array_merge(
				array(
					CMS_DIR . '/javascript/CMSMain.js',
					CMS_DIR . '/javascript/CMSMain.EditForm.js',
					CMS_DIR . '/javascript/CMSMain.AddForm.js',
					CMS_DIR . '/javascript/CMSPageHistoryController.js',
					CMS_DIR . '/javascript/CMSMain.Tree.js',
					CMS_DIR . '/javascript/SilverStripeNavigator.js'
				),
				Requirements::add_i18n_javascript(CMS_DIR . '/javascript/lang', true, true)
			)
		);

		CMSBatchActionHandler::register('publish', 'CMSBatchAction_Publish');
		CMSBatchActionHandler::register('unpublish', 'CMSBatchAction_Unpublish');
		CMSBatchActionHandler::register('delete', 'CMSBatchAction_Delete');
		CMSBatchActionHandler::register('deletefromlive', 'CMSBatchAction_DeleteFromLive');
	}
 public function init()
 {
     // set reading lang
     if (Object::has_extension('ContentModule', 'Translatable') && !$this->request->isAjax()) {
         Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('ContentModule')));
     }
     parent::init();
     Versioned::reading_stage("Stage");
     Requirements::css(CMS_DIR . '/css/screen.css');
     Requirements::css(INPAGE_MODULES_DIR . '/css/ContentModule_Admin.css');
     Requirements::combine_files('contentmodulemain.js', array_merge(array(CMS_DIR . '/javascript/CMSPageHistoryController.js')));
     //CMSBatchActionHandler::register('publish', 'CMSBatchAction_Publish');
     //CMSBatchActionHandler::register('unpublish', 'CMSBatchAction_Unpublish');
     //CMSBatchActionHandler::register('delete', 'CMSBatchAction_Delete');
     //CMSBatchActionHandler::register('deletefromlive', 'CMSBatchAction_DeleteFromLive');
     if (isset($_REQUEST['ID'])) {
         $this->setCurrentPageID($_REQUEST['ID']);
     }
 }
Пример #4
0
 /**
  * @uses LeftAndMainDecorator->init()
  * @uses LeftAndMainDecorator->accessedCMS()
  * @uses CMSMenu
  */
 function init()
 {
     parent::init();
     SSViewer::setOption('rewriteHashlinks', false);
     // set language
     $member = Member::currentUser();
     if (!empty($member->Locale)) {
         i18n::set_locale($member->Locale);
     }
     if (!empty($member->DateFormat)) {
         i18n::set_date_format($member->DateFormat);
     }
     if (!empty($member->TimeFormat)) {
         i18n::set_time_format($member->TimeFormat);
     }
     // 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'), self::$help_link);
     // set reading lang
     if (Object::has_extension('SiteTree', 'Translatable') && !$this->isAjax()) {
         Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SiteTree')));
     }
     // Allow customisation of the access check by a decorator
     // Also all the canView() check to execute Director::redirect()
     if (!$this->canView() && !$this->response->isFinished()) {
         // 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']) && !$this->isAjax()) {
         $this->extend('accessedCMS');
     }
     // Set the members html editor config
     HtmlEditorConfig::set_active(Member::currentUser()->getHtmlEditorConfigForCMS());
     // Set default values in the config if missing.  These things can't be defined in the config
     // file because insufficient information exists when that is being processed
     $htmlEditorConfig = HtmlEditorConfig::get_active();
     $htmlEditorConfig->setOption('language', i18n::get_tinymce_lang());
     if (!$htmlEditorConfig->getOption('content_css')) {
         $cssFiles = 'cms/css/editor.css';
         // Use theme from the site config
         if (($config = SiteConfig::current_site_config()) && $config->Theme) {
             $theme = $config->Theme;
         } elseif (SSViewer::current_theme()) {
             $theme = SSViewer::current_theme();
         } else {
             $theme = false;
         }
         if ($theme) {
             $cssFiles .= ',' . THEMES_DIR . "/{$theme}/css/editor.css";
         } else {
             if (project()) {
                 $cssFiles .= ',' . project() . '/css/editor.css';
             }
         }
         $htmlEditorConfig->setOption('content_css', $cssFiles);
     }
     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(SAPPHIRE_DIR . '/thirdparty/firebug-lite/firebug.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(SAPPHIRE_DIR . '/thirdparty/firebug-lite/firebugx.js');
     }
     Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototypefix/intro.js');
     Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js');
     Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototypefix/outro.js');
     Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery/jquery.js');
     Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery_improvements.js');
     Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
     //import all of jquery ui
     Requirements::javascript(CMS_DIR . '/thirdparty/jquery-layout/jquery.layout.js');
     Requirements::javascript(CMS_DIR . '/thirdparty/jquery-layout/jquery.layout.state.js');
     Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/json-js/json2.js');
     Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-metadata/jquery.metadata.js');
     Requirements::javascript(CMS_DIR . '/javascript/jquery-fitheighttoparent/jquery.fitheighttoparent.js');
     Requirements::javascript(CMS_DIR . '/javascript/ssui.core.js');
     // @todo Load separately so the CSS files can be inlined
     Requirements::css(SAPPHIRE_DIR . '/thirdparty/jquery-ui-themes/smoothness/jquery.ui.all.css');
     // entwine
     Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
     // Required for TreeTools panel above tree
     Requirements::javascript(SAPPHIRE_DIR . '/javascript/TabSet.js');
     Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js');
     Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/jquery-cookie/jquery.cookie.js');
     Requirements::javascript(CMS_DIR . '/thirdparty/jquery-notice/jquery.notice.js');
     Requirements::javascript(SAPPHIRE_DIR . '/javascript/jquery-ondemand/jquery.ondemand.js');
     Requirements::javascript(CMS_DIR . '/javascript/jquery-changetracker/lib/jquery.changetracker.js');
     Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
     Requirements::add_i18n_javascript(CMS_DIR . '/javascript/lang');
     Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/scriptaculous/effects.js');
     Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/scriptaculous/dragdrop.js');
     Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/scriptaculous/controls.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.Tree.js');
     Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain.EditForm.js');
     Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain.AddForm.js');
     Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain.BatchActions.js');
     // navigator
     Requirements::css(SAPPHIRE_DIR . '/css/SilverStripeNavigator.css');
     Requirements::javascript(SAPPHIRE_DIR . '/javascript/SilverStripeNavigator.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::themedCSS($file[0], $file[1]);
     }
     Requirements::css(CMS_DIR . '/css/unjquery.css');
     // Javascript combined files
     Requirements::combine_files('base.js', array('sapphire/thirdparty/prototype/prototype.js', 'sapphire/thirdparty/behaviour/behaviour.js', 'sapphire/thirdparty/jquery/jquery.js', 'sapphire/thirdparty/jquery-livequery/jquery.livequery.js', 'sapphire/javascript/jquery-ondemand/jquery.ondemand.js', 'sapphire/thirdparty/jquery-ui/jquery-ui.js', 'sapphire/thirdparty/firebug-lite/firebug.js', 'sapphire/thirdparty/firebug-lite/firebugx.js', 'sapphire/javascript/i18n.js'));
     Requirements::combine_files('leftandmain.js', array('sapphire/thirdparty/scriptaculous/effects.js', 'sapphire/thirdparty/scriptaculous/dragdrop.js', 'sapphire/thirdparty/scriptaculous/controls.js', 'cms/javascript/LeftAndMain.js', 'sapphire/javascript/tree/tree.js', 'sapphire/javascript/TreeSelectorField.js', 'cms/javascript/ThumbnailStripField.js'));
     $dummy = null;
     $this->extend('init', $dummy);
     // The user's theme shouldn't affect the CMS, if, for example, they have replaced
     // TableListField.ss or Form.ss.
     SSViewer::set_theme(null);
 }
Пример #5
0
 /**
  * Note: The bulk of logic is in ModelAsController->getNestedController()
  * and ContentController->handleRequest()
  */
 function contentcontrollerInit($controller)
 {
     $controller->Locale = Translatable::choose_site_locale();
 }
Пример #6
0
 function init()
 {
     // set language
     $member = Member::currentUser();
     if (!empty($member->Locale)) {
         i18n::set_locale($member->Locale);
     }
     // set reading lang
     if (singleton('SiteTree')->hasExtension('Translatable') && !Director::is_ajax()) {
         Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SiteTree')));
     }
     parent::init();
 }
Пример #7
0
 /**
  * @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_locale(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');
     }
     // Set the members html editor config
     HtmlEditorConfig::set_active(Member::currentUser()->getHtmlEditorConfigForCMS());
     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::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
     Requirements::add_i18n_javascript(CMS_DIR . '/javascript/lang');
     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/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);
 }