getInterfaceLanguage() public static method

Get the current interface language
public static getInterfaceLanguage ( ) : string
return string
Beispiel #1
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // gender dropdown values
     $genderValues = array('male' => \SpoonFilter::ucfirst(BL::getLabel('Male')), 'female' => \SpoonFilter::ucfirst(BL::getLabel('Female')));
     // birthdate dropdown values
     $days = range(1, 31);
     $months = \SpoonLocale::getMonths(BL::getInterfaceLanguage());
     $years = range(date('Y'), 1900);
     // create form
     $this->frm = new BackendForm('add');
     // create elements
     $this->frm->addText('email')->setAttribute('type', 'email');
     $this->frm->addPassword('password');
     $this->frm->addText('display_name');
     $this->frm->addText('first_name');
     $this->frm->addText('last_name');
     $this->frm->addText('city');
     $this->frm->addDropdown('gender', $genderValues);
     $this->frm->addDropdown('day', array_combine($days, $days));
     $this->frm->addDropdown('month', $months);
     $this->frm->addDropdown('year', array_combine($years, $years));
     $this->frm->addDropdown('country', Intl::getRegionBundle()->getCountryNames(BL::getInterfaceLanguage()));
     // set default elements dropdowns
     $this->frm->getField('gender')->setDefaultElement('');
     $this->frm->getField('day')->setDefaultElement('');
     $this->frm->getField('month')->setDefaultElement('');
     $this->frm->getField('year')->setDefaultElement('');
     $this->frm->getField('country')->setDefaultElement('');
 }
Beispiel #2
0
 /**
  * Parse the action into the template
  */
 public function parse()
 {
     parent::parse();
     // assign the interface language ourself, because it won't be assigned automagically
     $this->tpl->assign('INTERFACE_LANGUAGE', BL::getInterfaceLanguage());
     $this->frm->parse($this->tpl);
     $this->frmForgotPassword->parse($this->tpl);
 }
Beispiel #3
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     $this->frm = new BackendForm('add');
     $this->frm->addText('title', null, null, 'form-control title', 'form-control danger title');
     $this->frm->addText('street');
     $this->frm->addText('number');
     $this->frm->addText('zip');
     $this->frm->addText('city');
     $this->frm->addDropdown('country', Intl::getRegionBundle()->getCountryNames(BL::getInterfaceLanguage()), 'BE');
 }
Beispiel #4
0
 /**
  * Get the current interface language
  *
  * @deprecated
  *
  * @return string
  */
 public static function getInterfaceLanguage()
 {
     trigger_error('Backend\\Core\\Engine\\Language is deprecated.
          It has been moved to Backend\\Core\\Language\\Language', E_USER_DEPRECATED);
     return parent::getInterfaceLanguage();
 }
Beispiel #5
0
 /**
  * Parse the locale (things like months, days, ...)
  */
 private function parseLocale()
 {
     // init vars
     $localeToAssign = array();
     // get months
     $monthsLong = \SpoonLocale::getMonths(BL::getInterfaceLanguage(), false);
     $monthsShort = \SpoonLocale::getMonths(BL::getInterfaceLanguage(), true);
     // get days
     $daysLong = \SpoonLocale::getWeekDays(BL::getInterfaceLanguage(), false, 'sunday');
     $daysShort = \SpoonLocale::getWeekDays(BL::getInterfaceLanguage(), true, 'sunday');
     // build labels
     foreach ($monthsLong as $key => $value) {
         $localeToAssign['locMonthLong' . \SpoonFilter::ucfirst($key)] = $value;
     }
     foreach ($monthsShort as $key => $value) {
         $localeToAssign['locMonthShort' . \SpoonFilter::ucfirst($key)] = $value;
     }
     foreach ($daysLong as $key => $value) {
         $localeToAssign['locDayLong' . \SpoonFilter::ucfirst($key)] = $value;
     }
     foreach ($daysShort as $key => $value) {
         $localeToAssign['locDayShort' . \SpoonFilter::ucfirst($key)] = $value;
     }
     // assign
     $this->assignArray($localeToAssign);
 }
Beispiel #6
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     $this->frm = new BackendForm('edit');
     $this->frm->addText('title', $this->record['title'], null, 'form-control title', 'form-control danger title');
     $this->frm->addText('street', $this->record['street']);
     $this->frm->addText('number', $this->record['number']);
     $this->frm->addText('zip', $this->record['zip']);
     $this->frm->addText('city', $this->record['city']);
     $this->frm->addDropdown('country', Intl::getRegionBundle()->getCountryNames(BL::getInterfaceLanguage()), $this->record['country']);
     $this->frm->addHidden('redirect', 'overview');
 }
Beispiel #7
0
 /**
  * Get time ago as a string for use in a datagrid
  *
  * @param int $timestamp The UNIX-timestamp to convert in a time-ago-string.
  *
  * @return string
  */
 public static function getTimeAgo($timestamp)
 {
     $timestamp = (int) $timestamp;
     // get user setting for long dates
     $format = Authentication::getUser()->getSetting('datetime_format');
     // get the time ago as a string
     $timeAgo = \SpoonDate::getTimeAgo($timestamp, BackendLanguage::getInterfaceLanguage(), $format);
     return '<time data-toggle="tooltip" datetime="' . \SpoonDate::getDate('Y-m-d H:i:s', $timestamp) . '" title="' . \SpoonDate::getDate($format, $timestamp, BackendLanguage::getInterfaceLanguage()) . '">' . $timeAgo . '</time>';
 }
Beispiel #8
0
 /**
  * Parse the JS-files
  */
 public function parseJS()
 {
     $jsFiles = array();
     $existingJSFiles = $this->getJSFiles();
     // if there aren't any JS-files added we don't need to do something
     if (!empty($existingJSFiles)) {
         // some files should be cached, even if we don't want cached (mostly libraries)
         $ignoreCache = array('/bower_components/jquery/dist/jquery.min.js', '/bower_components/jquery-migrate/jquery-migrate.min.js', '/bower_components/jquery-ui/jquery-ui.min.js', '/bower_components/bootstrap-sass/assets/javascripts/bootstrap.min.js', '/bower_components/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js', '/src/Backend/Core/Js/jquery/jquery.ui.dialog.patch.js', '/src/Backend/Core/Js/jquery/jquery.backend.js', '/src/Backend/Core/Js/ckeditor/ckeditor.js', '/src/Backend/Core/Js/ckeditor/adapters/jquery.js', '/src/Backend/Core/Js/ckfinder/ckfinder.js');
         foreach ($existingJSFiles as $file) {
             // some files shouldn't be uncachable
             if (in_array($file['file'], $ignoreCache) || $file['add_timestamp'] === false) {
                 $file = array('file' => $file['file']);
             } else {
                 if (mb_substr($file['file'], 0, 11) == '/frontend/js') {
                     $file = array('file' => $file['file'] . '&amp;m=' . time());
                 } else {
                     $modifiedTime = mb_strpos($file['file'], '?') !== false ? '&amp;m=' . LAST_MODIFIED_TIME : '?m=' . LAST_MODIFIED_TIME;
                     $file = array('file' => $file['file'] . $modifiedTime);
                 }
             }
             // add
             $jsFiles[] = $file;
         }
     }
     // assign JS-files
     $this->tpl->assign('jsFiles', $jsFiles);
     // fetch preferred interface language
     if (Authentication::getUser()->isAuthenticated()) {
         $interfaceLanguage = (string) Authentication::getUser()->getSetting('interface_language');
     } else {
         $interfaceLanguage = BL::getInterfaceLanguage();
     }
     // some default stuff
     $this->jsData['debug'] = $this->getContainer()->getParameter('kernel.debug');
     $this->jsData['site']['domain'] = SITE_DOMAIN;
     $this->jsData['editor']['language'] = $interfaceLanguage;
     $this->jsData['interface_language'] = $interfaceLanguage;
     // is the user object filled?
     if (Authentication::getUser()->isAuthenticated()) {
         $this->jsData['editor']['language'] = (string) Authentication::getUser()->getSetting('interface_language');
     }
     // CKeditor has support for simplified Chinese, but the language is called zh-cn instead of zn
     if ($this->jsData['editor']['language'] == 'zh') {
         $this->jsData['editor']['language'] = 'zh-cn';
     }
     // theme
     if ($this->get('fork.settings')->get('Core', 'theme') !== null) {
         $this->jsData['theme']['theme'] = $this->get('fork.settings')->get('Core', 'theme');
         $this->jsData['theme']['path'] = FRONTEND_PATH . '/Themes/' . $this->get('fork.settings')->get('Core', 'theme');
         $this->jsData['theme']['has_css'] = is_file(FRONTEND_PATH . '/Themes/' . $this->get('fork.settings')->get('Core', 'theme') . '/Core/Layout/Css/screen.css');
         $this->jsData['theme']['has_editor_css'] = is_file(FRONTEND_PATH . '/Themes/' . $this->get('fork.settings')->get('Core', 'theme') . '/Core/Layout/Css/editor_content.css');
     }
     // encode and add
     $jsData = json_encode($this->jsData);
     $this->tpl->assign('jsData', 'var jsData = ' . $jsData . ';' . "\n");
 }
Beispiel #9
0
 /**
  * Install the module.
  */
 public function install()
 {
     // load install.sql
     $this->importSQL(__DIR__ . '/Data/install.sql');
     // add 'profiles' as a module
     $this->addModule('Profiles');
     // import locale
     $this->importLocale(__DIR__ . '/Data/locale.xml');
     // general settings
     $this->setSetting('Profiles', 'allow_gravatar', true);
     $this->setSetting('Profiles', 'overwrite_profile_notification_email', false);
     $this->setSetting('Profiles', 'profile_notification_email', null);
     $this->setSetting('Profiles', 'send_mail_for_new_profile_to_admin', false);
     $this->setSetting('Profiles', 'send_mail_for_new_profile_to_profile', false);
     // add folders
     $filesystem = new Filesystem();
     $filesystem->mkdir(PATH_WWW . '/src/Frontend/Files/Profiles/avatars/source/');
     $filesystem->mkdir(PATH_WWW . '/src/Frontend/Files/Profiles/avatars/240x240/');
     $filesystem->mkdir(PATH_WWW . '/src/Frontend/Files/Profiles/avatars/64x64/');
     $filesystem->mkdir(PATH_WWW . '/src/Frontend/Files/Profiles/avatars/32x32/');
     // module rights
     $this->setModuleRights(1, 'Profiles');
     // action rights
     $this->setActionRights(1, 'Profiles', 'Add');
     $this->setActionRights(1, 'Profiles', 'AddGroup');
     $this->setActionRights(1, 'Profiles', 'AddProfileGroup');
     $this->setActionRights(1, 'Profiles', 'Block');
     $this->setActionRights(1, 'Profiles', 'DeleteGroup');
     $this->setActionRights(1, 'Profiles', 'DeleteProfileGroup');
     $this->setActionRights(1, 'Profiles', 'Delete');
     $this->setActionRights(1, 'Profiles', 'EditGroup');
     $this->setActionRights(1, 'Profiles', 'EditProfileGroup');
     $this->setActionRights(1, 'Profiles', 'Edit');
     $this->setActionRights(1, 'Profiles', 'ExportTemplate');
     $this->setActionRights(1, 'Profiles', 'Groups');
     $this->setActionRights(1, 'Profiles', 'Import');
     $this->setActionRights(1, 'Profiles', 'Index');
     $this->setActionRights(1, 'Profiles', 'MassAction');
     // set navigation
     $navigationModulesId = $this->setNavigation(null, 'Modules');
     $navigationProfilesId = $this->setNavigation($navigationModulesId, 'Profiles');
     $this->setNavigation($navigationProfilesId, 'Overview', 'profiles/index', array('profiles/add', 'profiles/edit', 'profiles/add_profile_group', 'profiles/edit_profile_group', 'profiles/import'));
     $this->setNavigation($navigationProfilesId, 'Groups', 'profiles/groups', array('profiles/add_group', 'profiles/edit_group'));
     // settings navigation
     $navigationSettingsId = $this->setNavigation(null, 'Settings');
     $navigationModulesId = $this->setNavigation($navigationSettingsId, 'Modules');
     $this->setNavigation($navigationModulesId, 'Profiles', 'profiles/settings');
     // add extra
     $activateId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'Activate', 'Activate', null, 'N', 5000);
     $forgotPasswordId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'ForgotPassword', 'ForgotPassword', null, 'N', 5001);
     $indexId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'Dashboard', null, null, 'N', 5002);
     $loginId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'Login', 'Login', null, 'N', 5003);
     $logoutId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'Logout', 'Logout', null, 'N', 5004);
     $changeEmailId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'ChangeEmail', 'ChangeEmail', null, 'N', 5005);
     $changePasswordId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'ChangePassword', 'ChangePassword', null, 'N', 5006);
     $settingsId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'Settings', 'Settings', null, 'N', 5007);
     $registerId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'Register', 'Register', null, 'N', 5008);
     $resetPasswordId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'ResetPassword', 'ResetPassword', null, 'N', 5008);
     $resendActivationId = $this->insertExtra('Profiles', ModuleExtraType::block(), 'ResendActivation', 'ResendActivation', null, 'N', 5009);
     $this->insertExtra('Profiles', ModuleExtraType::widget(), 'LoginBox', 'LoginBox', null, 'N', 5010);
     $this->insertExtra('Profiles', ModuleExtraType::widget(), 'LoginLink', 'LoginLink', null, 'N', 5011);
     $this->insertExtra('Profiles', ModuleExtraType::widget(), 'SecurePage', 'SecurePage', null, 'N', 5012);
     // get search widget id
     $searchId = (int) $this->getDB()->getVar('SELECT id FROM modules_extras WHERE module = ? AND action = ?', array('search', 'form'));
     $originalLocale = Language::getInterfaceLanguage();
     // loop languages
     foreach ($this->getLanguages() as $language) {
         // only add pages if profiles isn't linked anywhere
         // @todo refactor me, syntax sucks atm
         if (!(bool) $this->getDB()->getVar('SELECT 1
              FROM pages AS p
              INNER JOIN pages_blocks AS b ON b.revision_id = p.revision_id
              INNER JOIN modules_extras AS e ON e.id = b.extra_id
              WHERE e.module = ? AND p.language = ?
              LIMIT 1', array('Profiles', $language))) {
             // We must define the locale we want to insert the page into
             Language::setLocale($language);
             // activate page
             $this->insertPage(array('title' => ucfirst(Language::lbl('Activate')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $activateId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // forgot password page
             $this->insertPage(array('title' => ucfirst(Language::lbl('ForgotPassword')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $forgotPasswordId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // reset password page
             $this->insertPage(array('title' => ucfirst(Language::lbl('ResetPassword')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $resetPasswordId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // resend activation email page
             $this->insertPage(array('title' => ucfirst(Language::lbl('ResendActivation')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $resendActivationId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // login page
             $this->insertPage(array('title' => ucfirst(Language::lbl('Login')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $loginId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // register page
             $this->insertPage(array('title' => ucfirst(Language::lbl('Register')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $registerId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // logout page
             $this->insertPage(array('title' => ucfirst(Language::lbl('Logout')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $logoutId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // index page
             $indexPageId = $this->insertPage(array('title' => ucfirst(Language::lbl('Profile')), 'type' => 'root', 'language' => $language), null, array('extra_id' => $indexId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // settings page
             $this->insertPage(array('title' => ucfirst(Language::lbl('ProfileSettings')), 'parent_id' => $indexPageId, 'language' => $language), null, array('extra_id' => $settingsId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // change email page
             $this->insertPage(array('title' => ucfirst(Language::lbl('ChangeEmail')), 'parent_id' => $indexPageId, 'language' => $language), null, array('extra_id' => $changeEmailId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
             // change password page
             $this->insertPage(array('title' => ucfirst(Language::lbl('ChangePassword')), 'parent_id' => $indexPageId, 'language' => $language), null, array('extra_id' => $changePasswordId, 'position' => 'main'), array('extra_id' => $searchId, 'position' => 'top'));
         }
     }
     // restore the original locale
     if (!empty($originalLocale)) {
         Language::setLocale($originalLocale);
     }
 }
Beispiel #10
0
 /**
  * Get coordinates latitude/longitude
  *
  * @param  string $street
  * @param  string $streetNumber
  * @param  string $city
  * @param  string $zip
  * @param  string $country
  *
  * @return array  Contains 'latitude' and 'longitude' as variables
  */
 public static function getCoordinates($street = null, $streetNumber = null, $city = null, $zip = null, $country = null)
 {
     // init item
     $item = array();
     // building item
     if (!empty($street)) {
         $item[] = $street;
     }
     if (!empty($streetNumber)) {
         $item[] = $streetNumber;
     }
     if (!empty($city)) {
         $item[] = $city;
     }
     if (!empty($zip)) {
         $item[] = $zip;
     }
     if (!empty($country)) {
         $item[] = Intl::getRegionBundle()->getCountryName($country, BL::getInterfaceLanguage());
     }
     // define address
     $address = implode(' ', $item);
     // fetch the geo coordinates
     $url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . rawurlencode($address);
     $geocodes = json_decode(file_get_contents($url), true);
     // return coordinates latitude/longitude
     return array('latitude' => array_key_exists(0, $geocodes['results']) ? $geocodes['results'][0]['geometry']['location']['lat'] : null, 'longitude' => array_key_exists(0, $geocodes['results']) ? $geocodes['results'][0]['geometry']['location']['lng'] : null);
 }
Beispiel #11
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // gender dropdown values
     $genderValues = array('male' => \SpoonFilter::ucfirst(BL::getLabel('Male')), 'female' => \SpoonFilter::ucfirst(BL::getLabel('Female')));
     // birthdate dropdown values
     $days = range(1, 31);
     $months = \SpoonLocale::getMonths(BL::getInterfaceLanguage());
     $years = range(date('Y'), 1900);
     // get settings
     $birthDate = BackendProfilesModel::getSetting($this->id, 'birth_date');
     // get day, month and year
     if ($birthDate) {
         list($birthYear, $birthMonth, $birthDay) = explode('-', $birthDate);
     } else {
         // no birth date setting
         $birthDay = '';
         $birthMonth = '';
         $birthYear = '';
     }
     // create form
     $this->frm = new BackendForm('edit');
     // create elements
     $this->frm->addCheckbox('new_email');
     $this->frm->addText('email', $this->profile['email']);
     $this->frm->addCheckbox('new_password');
     $this->frm->addPassword('password');
     $this->frm->addPassword('password_repeat');
     $this->frm->addText('display_name', $this->profile['display_name']);
     $this->frm->addText('first_name', BackendProfilesModel::getSetting($this->id, 'first_name'));
     $this->frm->addText('last_name', BackendProfilesModel::getSetting($this->id, 'last_name'));
     $this->frm->addText('city', BackendProfilesModel::getSetting($this->id, 'city'));
     $this->frm->addDropdown('gender', $genderValues, BackendProfilesModel::getSetting($this->id, 'gender'));
     $this->frm->addDropdown('day', array_combine($days, $days), $birthDay);
     $this->frm->addDropdown('month', $months, $birthMonth);
     $this->frm->addDropdown('year', array_combine($years, $years), (int) $birthYear);
     $this->frm->addDropdown('country', Intl::getRegionBundle()->getCountryNames(BL::getInterfaceLanguage()), BackendProfilesModel::getSetting($this->id, 'country'));
     // set default elements dropdowns
     $this->frm->getField('gender')->setDefaultElement('');
     $this->frm->getField('day')->setDefaultElement('');
     $this->frm->getField('month')->setDefaultElement('');
     $this->frm->getField('year')->setDefaultElement('');
     $this->frm->getField('country')->setDefaultElement('');
 }
Beispiel #12
0
 /**
  * Format a UNIX-timestamp as a date
  * syntax: {{ $var|formatdate }}
  *
  * @param int $var The UNIX-timestamp to format.
  *
  * @return string
  */
 public static function formatTime($var)
 {
     // get setting
     $format = Authentication::getUser()->getSetting('time_format');
     if ($var instanceof \DateTime) {
         $var = $var->getTimestamp();
     }
     // format the date
     return SpoonDate::getDate($format, (int) $var, BackendLanguage::getInterfaceLanguage());
 }