/** * 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(''); }
/** * Load the form. */ private function loadForm() { // gender dropdown values $genderValues = array('male' => \SpoonFilter::ucfirst(FL::getLabel('Male')), 'female' => \SpoonFilter::ucfirst(FL::getLabel('Female'))); // birthdate dropdown values $days = range(1, 31); $months = \SpoonLocale::getMonths(LANGUAGE); $years = range(date('Y'), 1900); // get settings $birthDate = $this->profile->getSetting('birth_date'); $nameChanges = (int) $this->profile->getSetting('display_name_changes'); // get day, month and year if ($birthDate) { list($birthYear, $birthMonth, $birthDay) = explode('-', $birthDate); } else { // no birth date setting $birthDay = ''; $birthMonth = ''; $birthYear = ''; } // create the form $this->frm = new FrontendForm('updateSettings', null, null, 'updateSettingsForm'); // create & add elements $this->frm->addText('display_name', $this->profile->getDisplayName()); $this->frm->addText('first_name', $this->profile->getSetting('first_name')); $this->frm->addText('last_name', $this->profile->getSetting('last_name')); $this->frm->addText('email', $this->profile->getEmail()); $this->frm->addText('city', $this->profile->getSetting('city')); $this->frm->addDropdown('country', Intl::getRegionBundle()->getCountryNames(LANGUAGE), $this->profile->getSetting('country')); $this->frm->addDropdown('gender', $genderValues, $this->profile->getSetting('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); // set default elements drop-downs $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(''); // set email disabled $this->frm->getField('email')->setAttribute('disabled', 'disabled'); // set avatar $this->frm->addImage('avatar'); // when user exceeded the number of name changes set field disabled if ($nameChanges >= FrontendProfilesModel::MAX_DISPLAY_NAME_CHANGES) { $this->frm->getField('display_name')->setAttribute('disabled', 'disabled'); } }
/** * An alias for php's date function that makes weekdays and months language dependant. * * @return string A formatted date. * @param string $format The wanted format. * @param int[optional] $timestamp A UNIX-timestamp representing the date that should be formatted. * @param string[optional] $language The language to use (available languages can be found in SpoonLocale). * @param bool[optional] $GMT Should we consider this timestamp to be GMT/UTC? */ public static function getDate($format, $timestamp = null, $language = 'en', $GMT = false) { // redefine arguments $format = (string) $format; $timestamp = $timestamp === null ? time() : (int) $timestamp; $language = SpoonFilter::getValue($language, SpoonLocale::getAvailableLanguages(), 'en'); // create date $date = !$GMT ? date($format, $timestamp) : gmdate($format, $timestamp); // only for non-english versions if ($language != 'en') { // weekdays (short & long) $date = str_replace(array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'), SpoonLocale::getWeekDays($language), $date); $date = str_replace(array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'), SpoonLocale::getWeekDays($language, true), $date); // months (short & long) $date = str_replace(array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'), SpoonLocale::getMonths($language), $date); $date = str_replace(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), SpoonLocale::getMonths($language, true), $date); } return $date; }
/** * 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(''); }
/** * Adds months and days from spoonLocale to the json * * @param array $json * @param string $language */ protected function addSpoonLocale(&$json, $language) { // get months $monthsLong = \SpoonLocale::getMonths($language, false); $monthsShort = \SpoonLocale::getMonths($language, true); // get days $daysLong = \SpoonLocale::getWeekDays($language, false, 'sunday'); $daysShort = \SpoonLocale::getWeekDays($language, true, 'sunday'); // build labels foreach ($monthsLong as $key => $value) { $json['loc']['MonthLong' . \SpoonFilter::ucfirst($key)] = $value; } foreach ($monthsShort as $key => $value) { $json['loc']['MonthShort' . \SpoonFilter::ucfirst($key)] = $value; } foreach ($daysLong as $key => $value) { $json['loc']['DayLong' . \SpoonFilter::ucfirst($key)] = $value; } foreach ($daysShort as $key => $value) { $json['loc']['DayShort' . \SpoonFilter::ucfirst($key)] = $value; } }
/** * 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); }
/** * Parse the locale (things like months, days, ...) */ private function parseLocale() { // init vars $locale = array(); // get months $monthsLong = SpoonLocale::getMonths(FRONTEND_LANGUAGE, false); $monthsShort = SpoonLocale::getMonths(FRONTEND_LANGUAGE, true); // get days $daysLong = SpoonLocale::getWeekDays(FRONTEND_LANGUAGE, false, 'sunday'); $daysShort = SpoonLocale::getWeekDays(FRONTEND_LANGUAGE, true, 'sunday'); // build labels foreach ($monthsLong as $key => $value) { $locale['locMonthLong' . SpoonFilter::ucfirst($key)] = $value; } foreach ($monthsShort as $key => $value) { $locale['locMonthShort' . SpoonFilter::ucfirst($key)] = $value; } foreach ($daysLong as $key => $value) { $locale['locDayLong' . SpoonFilter::ucfirst($key)] = $value; } foreach ($daysShort as $key => $value) { $locale['locDayShort' . SpoonFilter::ucfirst($key)] = $value; } // assign $this->assignArray($locale); }