Source of file ContentModuleMainTranslatableExtension.php
Size: 1,255 Bytes - Last Modified: 2021-12-23T10:59:17+00:00
/var/www/docs.ssmods.com/process/src/code/translatable/ContentModuleMainTranslatableExtension.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344 | <?php /** * Created by PhpStorm. * User: Conrad * Date: 9/11/2015 * Time: 2:51 PM */ class ContentModuleMainTranslatableExtension extends Extension { /** * Returns a form with all languages with languages already used appearing first. * * @return Form */ public function updateSearchForm(Form $form) { $member = Member::currentUser(); //check to see if the current user can switch langs or not if (Permission::checkMember($member, 'VIEW_LANGS')) { $field = new LanguageDropdownField( 'Locale', _t('CMSMain.LANGUAGEDROPDOWNLABEL', 'Language'), array(), 'SiteTree', 'Locale-English', singleton('SiteTree') ); $field ->setValue(Translatable::get_current_locale()) ->setForm($form); } else { // user doesn't have permission to switch langs // so just show a string displaying current language $field = new LiteralField( 'Locale', i18n::get_locale_name(Translatable::get_current_locale()) ); } $form->Fields()->unshift($field); } } |