Пример #1
0
 public function testGetExistingTranslations()
 {
     $translations = i18n::get_existing_translations();
     $this->assertTrue(isset($translations['en_US']), 'Checking for en_US translation');
     $this->assertEquals($translations['en_US'], 'English (United States)');
     $this->assertTrue(isset($translations['de_DE']), 'Checking for de_DE translation');
 }
Пример #2
0
 public function testGetClosestTranslation()
 {
     // Validate necessary assumptions for this test
     $translations = i18n::get_existing_translations();
     $this->assertTrue(isset($translations['en_US']));
     $this->assertTrue(isset($translations['en_GB']));
     $this->assertTrue(isset($translations['es_ES']));
     $this->assertTrue(isset($translations['es_AR']));
     $this->assertFalse(isset($translations['en_ZZ']));
     $this->assertFalse(isset($translations['es_ZZ']));
     $this->assertFalse(isset($translations['zz_ZZ']));
     // Test indeterminate locales
     $this->assertEmpty(i18n::get_closest_translation('zz_ZZ'));
     // Test english fallback
     $this->assertEquals('en_US', i18n::get_closest_translation('en_US'));
     $this->assertEquals('en_GB', i18n::get_closest_translation('en_GB'));
     $this->assertEquals('en_US', i18n::get_closest_translation('en_ZZ'));
     // Test spanish fallbacks
     $this->assertEquals('es_AR', i18n::get_closest_translation('es_AR'));
     $this->assertEquals('es_ES', i18n::get_closest_translation('es_ES'));
     $this->assertEquals('es_ES', i18n::get_closest_translation('es_XX'));
 }
Пример #3
0
 /**
  * Return a {@link FieldSet} of fields that would appropriate for editing
  * this member.
  *
  * @return FieldSet Return a FieldSet of fields that would appropriate for
  *                  editing this member.
  */
 public function getCMSFields()
 {
     require_once 'Zend/Date.php';
     $fields = parent::getCMSFields();
     $mainFields = $fields->fieldByName("Root")->fieldByName("Main")->Children;
     $password = new ConfirmedPasswordField('Password', null, null, null, true);
     $password->setCanBeEmpty(true);
     if (!$this->ID) {
         $password->showOnClick = false;
     }
     $mainFields->replaceField('Password', $password);
     $mainFields->insertBefore(new HeaderField('MemberDetailsHeader', _t('Member.PERSONALDETAILS', "Personal Details", PR_MEDIUM, 'Headline for formfields')), 'FirstName');
     $mainFields->insertBefore(new HeaderField('MemberUserDetailsHeader', _t('Member.USERDETAILS', "User Details", PR_MEDIUM, 'Headline for formfields')), 'Email');
     $mainFields->replaceField('Locale', new DropdownField("Locale", _t('Member.INTERFACELANG', "Interface Language", PR_MEDIUM, 'Language of the CMS'), i18n::get_existing_translations()));
     $mainFields->removeByName('Bounced');
     $mainFields->removeByName('RememberLoginToken');
     $mainFields->removeByName('AutoLoginHash');
     $mainFields->removeByName('AutoLoginExpired');
     $mainFields->removeByName('PasswordEncryption');
     $mainFields->removeByName('PasswordExpiry');
     $mainFields->removeByName('LockedOutUntil');
     if (!self::$lock_out_after_incorrect_logins) {
         $mainFields->removeByName('FailedLoginCount');
     }
     $mainFields->removeByName('Salt');
     $mainFields->removeByName('NumVisit');
     $mainFields->removeByName('LastVisited');
     $fields->removeByName('Subscriptions');
     // Groups relation will get us into logical conflicts because
     // Members are displayed within  group edit form in SecurityAdmin
     $fields->removeByName('Groups');
     if (Permission::check('EDIT_PERMISSIONS')) {
         $groupsField = new TreeMultiselectField('Groups', false, 'Group');
         $fields->findOrMakeTab('Root.Groups', singleton('Group')->i18n_plural_name());
         $fields->addFieldToTab('Root.Groups', $groupsField);
         // Add permission field (readonly to avoid complicated group assignment logic).
         // This should only be available for existing records, as new records start
         // with no permissions until they have a group assignment anyway.
         if ($this->ID) {
             $permissionsField = new PermissionCheckboxSetField_Readonly('Permissions', singleton('Permission')->i18n_plural_name(), 'Permission', 'GroupID', $this->getManyManyComponents('Groups'));
             $fields->findOrMakeTab('Root.Permissions', singleton('Permission')->i18n_plural_name());
             $fields->addFieldToTab('Root.Permissions', $permissionsField);
         }
     }
     $defaultDateFormat = Zend_Locale_Format::getDateFormat($this->Locale);
     $dateFormatMap = array('MMM d, yyyy' => Zend_Date::now()->toString('MMM d, yyyy'), 'yyyy/MM/dd' => Zend_Date::now()->toString('yyyy/MM/dd'), 'MM/dd/yyyy' => Zend_Date::now()->toString('MM/dd/yyyy'), 'dd/MM/yyyy' => Zend_Date::now()->toString('dd/MM/yyyy'));
     $dateFormatMap[$defaultDateFormat] = Zend_Date::now()->toString($defaultDateFormat) . sprintf(' (%s)', _t('Member.DefaultDateTime', 'default'));
     $mainFields->push($dateFormatField = new Member_DatetimeOptionsetField('DateFormat', $this->fieldLabel('DateFormat'), $dateFormatMap));
     $dateFormatField->setValue($this->DateFormat);
     $defaultTimeFormat = Zend_Locale_Format::getTimeFormat($this->Locale);
     $timeFormatMap = array('h:mm a' => Zend_Date::now()->toString('h:mm a'), 'H:mm' => Zend_Date::now()->toString('H:mm'));
     $timeFormatMap[$defaultTimeFormat] = Zend_Date::now()->toString($defaultTimeFormat) . sprintf(' (%s)', _t('Member.DefaultDateTime', 'default'));
     $mainFields->push($timeFormatField = new Member_DatetimeOptionsetField('TimeFormat', $this->fieldLabel('TimeFormat'), $timeFormatMap));
     $timeFormatField->setValue($this->TimeFormat);
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Пример #4
0
 /**
  * Return a {@link FieldList} of fields that would appropriate for editing
  * this member.
  *
  * @return FieldList Return a FieldList of fields that would appropriate for
  *                   editing this member.
  */
 public function getCMSFields()
 {
     require_once 'Zend/Date.php';
     $self = $this;
     $this->beforeUpdateCMSFields(function ($fields) use($self) {
         $mainFields = $fields->fieldByName("Root")->fieldByName("Main")->Children;
         $password = new ConfirmedPasswordField('Password', null, null, null, true);
         $password->setCanBeEmpty(true);
         if (!$self->ID) {
             $password->showOnClick = false;
         }
         $mainFields->replaceField('Password', $password);
         $mainFields->replaceField('Locale', new DropdownField("Locale", _t('Member.INTERFACELANG', "Interface Language", 'Language of the CMS'), i18n::get_existing_translations()));
         $mainFields->removeByName('RememberLoginToken');
         $mainFields->removeByName('AutoLoginHash');
         $mainFields->removeByName('AutoLoginExpired');
         $mainFields->removeByName('PasswordEncryption');
         $mainFields->removeByName('PasswordExpiry');
         $mainFields->removeByName('LockedOutUntil');
         if (!$self->config()->lock_out_after_incorrect_logins) {
             $mainFields->removeByName('FailedLoginCount');
         }
         $mainFields->removeByName('Salt');
         $mainFields->removeByName('NumVisit');
         $mainFields->makeFieldReadonly('LastVisited');
         $fields->removeByName('Subscriptions');
         // Groups relation will get us into logical conflicts because
         // Members are displayed within  group edit form in SecurityAdmin
         $fields->removeByName('Groups');
         if (Permission::check('EDIT_PERMISSIONS')) {
             $groupsMap = array();
             foreach (Group::get() as $group) {
                 // Listboxfield values are escaped, use ASCII char instead of »
                 $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
             }
             asort($groupsMap);
             $fields->addFieldToTab('Root.Main', ListboxField::create('DirectGroups', singleton('Group')->i18n_plural_name())->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('Member.ADDGROUP', 'Add group', 'Placeholder text for a dropdown')));
             // Add permission field (readonly to avoid complicated group assignment logic).
             // This should only be available for existing records, as new records start
             // with no permissions until they have a group assignment anyway.
             if ($self->ID) {
                 $permissionsField = new PermissionCheckboxSetField_Readonly('Permissions', false, 'Permission', 'GroupID', $self->getManyManyComponents('Groups'));
                 $fields->findOrMakeTab('Root.Permissions', singleton('Permission')->i18n_plural_name());
                 $fields->addFieldToTab('Root.Permissions', $permissionsField);
             }
         }
         $permissionsTab = $fields->fieldByName("Root")->fieldByName('Permissions');
         if ($permissionsTab) {
             $permissionsTab->addExtraClass('readonly');
         }
         $defaultDateFormat = Zend_Locale_Format::getDateFormat(new Zend_Locale($self->Locale));
         $dateFormatMap = array('MMM d, yyyy' => Zend_Date::now()->toString('MMM d, yyyy'), 'yyyy/MM/dd' => Zend_Date::now()->toString('yyyy/MM/dd'), 'MM/dd/yyyy' => Zend_Date::now()->toString('MM/dd/yyyy'), 'dd/MM/yyyy' => Zend_Date::now()->toString('dd/MM/yyyy'));
         $dateFormatMap[$defaultDateFormat] = Zend_Date::now()->toString($defaultDateFormat) . sprintf(' (%s)', _t('Member.DefaultDateTime', 'default'));
         $mainFields->push($dateFormatField = new MemberDatetimeOptionsetField('DateFormat', $self->fieldLabel('DateFormat'), $dateFormatMap));
         $dateFormatField->setValue($self->DateFormat);
         $defaultTimeFormat = Zend_Locale_Format::getTimeFormat(new Zend_Locale($self->Locale));
         $timeFormatMap = array('h:mm a' => Zend_Date::now()->toString('h:mm a'), 'H:mm' => Zend_Date::now()->toString('H:mm'));
         $timeFormatMap[$defaultTimeFormat] = Zend_Date::now()->toString($defaultTimeFormat) . sprintf(' (%s)', _t('Member.DefaultDateTime', 'default'));
         $mainFields->push($timeFormatField = new MemberDatetimeOptionsetField('TimeFormat', $self->fieldLabel('TimeFormat'), $timeFormatMap));
         $timeFormatField->setValue($self->TimeFormat);
     });
     return parent::getCMSFields();
 }
Пример #5
0
 /**
  * Return a {@link FieldSet} of fields that would appropriate for editing
  * this member.
  *
  * @return FieldSet Return a FieldSet of fields that would appropriate for
  *                  editing this member.
  */
 public function getCMSFields()
 {
     $locale = $this->Locale ? $this->Locale : i18n::get_locale();
     $password = new ConfirmedPasswordField('Password', 'Password');
     $password->setCanBeEmpty(true);
     $fields = new FieldSet(new HeaderField(_t('Member.PERSONALDETAILS', "Personal Details", PR_MEDIUM, 'Headline for formfields')), new TextField("FirstName", _t('Member.FIRSTNAME')), new TextField("Surname", _t('Member.SURNAME')), new HeaderField(_t('Member.USERDETAILS', "User Details", PR_MEDIUM, 'Headline for formfields')), new TextField("Email", _t('Member.EMAIL')), new DropdownField("Locale", _t('Member.INTERFACELANG', "Interface Language", PR_MEDIUM, 'Language of the CMS'), i18n::get_existing_translations(), $locale), $password);
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
Пример #6
0
 function testGetExistingTranslations()
 {
     $translations = i18n::get_existing_translations();
     $this->assertTrue(isset($translations['en_US']), 'Checking for en_US translation');
     $this->assertTrue(isset($translations['de_DE']), 'Checking for de_DE translation');
 }
Пример #7
0
	/**
	 * Return a {@link FieldSet} of fields that would appropriate for editing
	 * this member.
	 *
	 * @return FieldSet Return a FieldSet of fields that would appropriate for
	 *                  editing this member.
	 */
	public function getCMSFields() {
		$fields = parent::getCMSFields();
		
		$mainFields = $fields->fieldByName("Root")->fieldByName("Main")->Children;
		
		$password = new ConfirmedPasswordField(
			'Password', 
			null, 
			null, 
			null, 
			true // showOnClick
		);
		$password->setCanBeEmpty(true);
		if(!$this->ID) $password->showOnClick = false;
		$mainFields->replaceField('Password', $password);
		
		$mainFields->insertBefore(
			new HeaderField('MemberDetailsHeader',_t('Member.PERSONALDETAILS', "Personal Details", PR_MEDIUM, 'Headline for formfields')),
			'FirstName'
		);
		
		$mainFields->insertBefore(
			new HeaderField('MemberUserDetailsHeader',_t('Member.USERDETAILS', "User Details", PR_MEDIUM, 'Headline for formfields')),
			'Email'
		);
		
		$locale = ($this->Locale) ? $this->Locale : i18n::get_locale();
		$mainFields->replaceField('Locale', new DropdownField(
			"Locale", 
			_t('Member.INTERFACELANG', "Interface Language", PR_MEDIUM, 'Language of the CMS'), 
			i18n::get_existing_translations(), 
			$locale
		));
		
		$mainFields->removeByName('Bounced');
		$mainFields->removeByName('RememberLoginToken');
		$mainFields->removeByName('AutoLoginHash');
		$mainFields->removeByName('AutoLoginExpired');
		$mainFields->removeByName('PasswordEncryption');
		$mainFields->removeByName('PasswordExpiry');
		$mainFields->removeByName('LockedOutUntil');
		$mainFields->removeByName('Salt');
		$mainFields->removeByName('NumVisit');
		$mainFields->removeByName('LastVisited');
	
		$fields->removeByName('Subscriptions');
		// Groups relation will get us into logical conflicts because
		// Members are displayed within  group edit form in SecurityAdmin
		$fields->removeByName('Groups');

		$this->extend('updateCMSFields', $fields);
		
		return $fields;
	}