/** * We register the common forms for SilvercartPages here. * * @return void * * @author Sebastian Diel <*****@*****.**>, * Sascha Koehler <*****@*****.**>, * Patrick Schneider <*****@*****.**> * @since 08.07.2014 */ public function onBeforeInit() { SilvercartTools::initSession(); i18n::set_default_locale(Translatable::get_current_locale()); i18n::set_locale(Translatable::get_current_locale()); $controllerParams = Controller::curr()->getURLParams(); $anonymousCustomer = SilvercartCustomer::currentAnonymousCustomer(); if ($anonymousCustomer) { Session::set('MemberLoginForm.force_message', true); if ($controllerParams['Action'] == 'changepassword') { $anonymousCustomer->logOut(); } } else { Session::set('MemberLoginForm.force_message', false); // used to redirect the logged in user to my-account page $backURL = SilvercartTools::PageByIdentifierCodeLink(self::$newPasswordBackURLIdentifierCode); $this->owner->extend('updateNewPasswordBackURL', $backURL); Session::set('BackURL', $backURL); Session::save(); } $this->owner->registerCustomHtmlForm('SilvercartQuickSearchForm', new SilvercartQuickSearchForm($this->owner)); $this->owner->registerCustomHtmlForm('SilvercartQuickLoginForm', new SilvercartQuickLoginForm($this->owner)); SilvercartPlugin::call($this->owner, 'init', array($this->owner)); }
public function __destruct() { i18n::set_default_locale($this->local); }
function testCollectFromFilesystemAndWriteMasterTables() { $defaultlocal = i18n::default_locale(); $local = i18n::get_locale(); i18n::set_locale('en_US'); //set the locale to the US locale expected in the asserts i18n::set_default_locale('en_US'); $c = new i18nTextCollector(); $c->basePath = $this->alternateBasePath; $c->baseSavePath = $this->alternateBaseSavePath; $c->run(); // i18ntestmodule $moduleLangFile = "{$this->alternateBaseSavePath}/i18ntestmodule/lang/" . $c->getDefaultLocale() . '.php'; $this->assertTrue(file_exists($moduleLangFile), 'Master language file can be written to modules /lang folder'); $moduleLangFileContent = file_get_contents($moduleLangFile); $this->assertContains("\$lang['en_US']['i18nTestModule']['ADDITION'] = 'Addition';", $moduleLangFileContent); $this->assertContains("\$lang['en_US']['i18nTestModule']['ENTITY'] = array(\n\t'Entity with \"Double Quotes\"',\n\tPR_LOW,\n\t'Comment for entity'\n);", $moduleLangFileContent); $this->assertContains("\$lang['en_US']['i18nTestModule']['MAINTEMPLATE'] = 'Main Template';", $moduleLangFileContent); $this->assertContains("\$lang['en_US']['i18nTestModule']['OTHERENTITY'] = 'Other Entity';", $moduleLangFileContent); $this->assertContains("\$lang['en_US']['i18nTestModule']['WITHNAMESPACE'] = 'Include Entity with Namespace';", $moduleLangFileContent); $this->assertContains("\$lang['en_US']['i18nTestModuleInclude.ss']['NONAMESPACE'] = 'Include Entity without Namespace';", $moduleLangFileContent); // i18nothermodule $otherModuleLangFile = "{$this->alternateBaseSavePath}/i18nothermodule/lang/" . $c->getDefaultLocale() . '.php'; $this->assertTrue(file_exists($otherModuleLangFile), 'Master language file can be written to modules /lang folder'); $otherModuleLangFileContent = file_get_contents($otherModuleLangFile); $this->assertContains("\$lang['en_US']['i18nOtherModule']['ENTITY'] = 'Other Module Entity';", $otherModuleLangFileContent); $this->assertContains("\$lang['en_US']['i18nOtherModule']['MAINTEMPLATE'] = 'Main Template Other Module';", $otherModuleLangFileContent); // testtheme1 $theme1LangFile = "{$this->alternateBaseSavePath}/themes/testtheme1/lang/" . $c->getDefaultLocale() . '.php'; $this->assertTrue(file_exists($theme1LangFile), 'Master theme language file can be written to themes/testtheme1 /lang folder'); $theme1LangFileContent = file_get_contents($theme1LangFile); $this->assertContains("\$lang['en_US']['i18nTestTheme1']['MAINTEMPLATE'] = 'Theme1 Main Template';", $theme1LangFileContent); $this->assertContains("\$lang['en_US']['i18nTestTheme1']['LAYOUTTEMPLATE'] = 'Theme1 Layout Template';", $theme1LangFileContent); $this->assertContains("\$lang['en_US']['i18nTestTheme1']['SPRINTFNAMESPACE'] = 'Theme1 My replacement: %s';", $theme1LangFileContent); $this->assertContains("\$lang['en_US']['i18nTestTheme1.ss']['LAYOUTTEMPLATENONAMESPACE'] = 'Theme1 Layout Template no namespace';", $theme1LangFileContent); $this->assertContains("\$lang['en_US']['i18nTestTheme1.ss']['SPRINTFNONAMESPACE'] = 'Theme1 My replacement no namespace: %s';", $theme1LangFileContent); $this->assertContains("\$lang['en_US']['i18nTestTheme1Include']['SPRINTFINCLUDENAMESPACE'] = 'Theme1 My include replacement: %s';", $theme1LangFileContent); $this->assertContains("\$lang['en_US']['i18nTestTheme1Include']['WITHNAMESPACE'] = 'Theme1 Include Entity with Namespace';", $theme1LangFileContent); $this->assertContains("\$lang['en_US']['i18nTestTheme1Include.ss']['NONAMESPACE'] = 'Theme1 Include Entity without Namespace';", $theme1LangFileContent); $this->assertContains("\$lang['en_US']['i18nTestTheme1Include.ss']['SPRINTFINCLUDENONAMESPACE'] = 'Theme1 My include replacement no namespace: %s';", $theme1LangFileContent); // testtheme2 $theme2LangFile = "{$this->alternateBaseSavePath}/themes/testtheme2/lang/" . $c->getDefaultLocale() . '.php'; $this->assertTrue(file_exists($theme2LangFile), 'Master theme language file can be written to themes/testtheme2 /lang folder'); $theme2LangFileContent = file_get_contents($theme2LangFile); $this->assertContains("\$lang['en_US']['i18nTestTheme2']['MAINTEMPLATE'] = 'Theme2 Main Template';", $theme2LangFileContent); i18n::set_locale($local); //set the locale to the US locale expected in the asserts +i18n::set_default_locale($defaultlocal); }
/** * Creates a SilvercartPage_Controller * * @param array $dataRecord Data record * * @return void * * @author Sebastian Diel <*****@*****.**> * @since 21.02.2013 */ public function __construct($dataRecord = null) { i18n::set_default_locale(Translatable::get_current_locale()); i18n::set_locale(Translatable::get_current_locale()); parent::__construct($dataRecord); $this->registerWidgetSet('WidgetSetContent', $this->WidgetSetContent()); $this->registerWidgetSet('WidgetSetSidebar', $this->WidgetSetSidebar()); }