/** * 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'); $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 */ protected function loadForm() { $rbtHiddenValues[] = array('label' => BL::lbl('Published'), 'value' => 'N'); $rbtHiddenValues[] = array('label' => BL::lbl('Hidden'), 'value' => 'Y'); $this->frm = new BackendForm('edit'); $this->frm->addText('company', $this->record['company']); $this->frm->addText('name', $this->record['name']); $this->frm->addText('firstname', $this->record['firstname']); $this->frm->addText('email', $this->record['email']); $this->frm->addText('address', $this->record['address']); $this->frm->addText('zipcode', $this->record['zipcode']); $this->frm->addText('city', $this->record['city']); // $this->frm->addText('country', $this->record['country']); $this->frm->addDropdown('country', Intl::getRegionBundle()->getCountryNames(BL::getInterfaceLanguage()), $this->record['country']); $this->frm->addText('phone', $this->record['phone']); $this->frm->addText('fax', $this->record['fax']); $this->frm->addText('website', $this->record['website']); $this->frm->addText('vat', $this->record['vat']); $this->frm->addTextArea('zipcodes', $this->record['zipcodes']); $this->frm->addText('remark', $this->record['remark']); //$this->frm->addText('assort', $this->record['assort']); //$this->frm->addText('open', $this->record['open']); //$this->frm->addText('closed', $this->record['closed']); //$this->frm->addText('visit', $this->record['visit']); //$this->frm->addText('size', $this->record['size']); //$this->frm->addEditor('text', $this->record['text']); $this->frm->addImage('image'); $this->frm->addCheckbox('delete_image'); $this->frm->addRadiobutton('hidden', $rbtHiddenValues, $this->record['hidden']); foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) { $addressesLanguage = BackendAddressesModel::getLanguage($this->id, $language); $fieldText = $this->frm->addEditor("text_" . strtolower($language), $addressesLanguage['text']); $fieldOpeningHours = $this->frm->addEditor("opening_hours_" . strtolower($language), $addressesLanguage['opening_hours']); $this->fieldLanguages[$key]["key"] = $key; $this->fieldLanguages[$key]["language"] = $language; $this->fieldLanguages[$key]["text"] = $fieldText->parse(); $this->fieldLanguages[$key]["opening_hours"] = $fieldOpeningHours->parse(); } //--Get all the groups $groups = BackendAddressesModel::getAllGroups(); if (!empty($groups)) { //--Loop all the users foreach ($groups as &$group) { $groupCheckboxes[] = array("label" => $group["title"], "value" => $group["id"]); } //--Get the users from the group $groupsAddress = BackendAddressesModel::getGroupsForAddress($this->id); //--Create a selected-array $groupCheckboxesSelected = count($groupsAddress) > 0 ? array_keys($groupsAddress) : null; //--Add multicheckboxes to form $this->frm->addMultiCheckbox("groups", $groupCheckboxes, $groupCheckboxesSelected); } $groups2 = BackendAddressesModel::getAllGroupsTreeArray(); $this->tpl->assign('groups2', $groups2); $this->tpl->assign('groups2selected', $groupCheckboxesSelected == null ? array() : $groupCheckboxesSelected); // meta $this->meta = new BackendMeta($this->frm, $this->record['meta_id'], 'company', true); $this->meta->setUrlCallback('Backend\\Modules\\Addresses\\Engine\\Model', 'getUrl', array($this->record['id'])); }
/** * 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); }
/** * Load the form */ private function loadForm() { $this->frm = new BackendForm('add'); $this->frm->addText('title', null, null, 'inputText title', 'inputTextError 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'); }
/** * Load the form */ protected function loadForm() { $rbtHiddenValues[] = array('label' => BL::lbl('Published'), 'value' => 'N'); $rbtHiddenValues[] = array('label' => BL::lbl('Hidden'), 'value' => 'Y'); $this->frm = new BackendForm('add'); $this->frm->addText('company'); $this->frm->addText('name'); $this->frm->addText('firstname'); $this->frm->addText('email'); $this->frm->addText('address'); $this->frm->addText('zipcode'); $this->frm->addText('city'); $this->frm->addDropdown('country', Intl::getRegionBundle()->getCountryNames(BL::getInterfaceLanguage()), 'BE'); $this->frm->addText('phone'); $this->frm->addText('fax'); $this->frm->addText('website'); $this->frm->addEditor('text'); $this->frm->addImage('image'); $this->frm->addText('vat'); $this->frm->addTextArea('zipcodes'); $this->frm->addText('remark'); //$this->frm->addText('assort'); //$this->frm->addText('open'); //$this->frm->addText('closed'); //$this->frm->addText('visit'); //$this->frm->addText('size'); $this->frm->addRadiobutton('hidden', $rbtHiddenValues, 'N'); foreach ((array) BackendModel::get('fork.settings')->get('Core', 'languages') as $key => $language) { $fieldText = $this->frm->addEditor("text_" . strtolower($language)); $fieldOpeningHours = $this->frm->addEditor("opening_hours_" . strtolower($language)); $this->fieldLanguages[$key]["key"] = $key; $this->fieldLanguages[$key]["language"] = $language; $this->fieldLanguages[$key]["text"] = $fieldText->parse(); $this->fieldLanguages[$key]["opening_hours"] = $fieldOpeningHours->parse(); } //--Get all the users $groups = BackendAddressesModel::getAllGroups(); if (!empty($groups)) { //--Loop all the group foreach ($groups as &$group) { $groupCheckboxes[] = array("label" => $group["title"], "value" => $group["id"]); } //--Add multicheckboxes to form $this->frm->addMultiCheckbox("groups", $groupCheckboxes); } $groups2 = BackendAddressesModel::getAllGroupsTreeArray(); $this->tpl->assign('groups2', $groups2); $this->meta = new BackendMeta($this->frm, null, 'company', true); }
/** * 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('/src/Backend/Core/Js/jquery/jquery.js', '/src/Backend/Core/Js/jquery/jquery.ui.js', '/src/Backend/Core/Js/ckeditor/jquery.ui.dialog.patch.js', '/src/Backend/Core/Js/jquery/jquery.tools.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 (substr($file['file'], 0, 11) == '/frontend/js') { $file = array('file' => $file['file'] . '&m=' . time()); } else { $modifiedTime = strpos($file['file'], '?') !== false ? '&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 = Language::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"); }
/** * 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'); // format the date return \SpoonDate::getDate($format, (int) $var, Language::getInterfaceLanguage()); }
/** * 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->addText('email', $this->profile['email']); $this->frm->addPassword('password'); $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(''); }
/** * Load the form */ private function loadForm() { $this->frm = new BackendForm('edit'); $this->frm->addText('title', $this->record['title'], null, 'inputText title', 'inputTextError 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'); }
/** * Load the form */ protected function loadForm() { // create form $this->frm = new BackendForm('edit'); // set array of recurring types $selectTypes = array('0' => ucfirst(BL::lbl('Daily')), '1' => ucfirst(BL::lbl('Weekly')), '2' => ucfirst(BL::lbl('Monthly')), '3' => ucfirst(BL::lbl('Yearly'))); // set array of recurring interval $selectInterval = array(); $i = 1; while ($i < $this->maxInterval) { $selectInterval[$i] = $i; $i++; } // set array of reservation values $radiobuttonSubscriptionsValues[] = array('label' => BL::lbl('Yes'), 'value' => 'Y'); $radiobuttonSubscriptionsValues[] = array('label' => BL::lbl('No'), 'value' => 'N'); // set array of possibilities which an item can end on $radiobuttonEndsOn[] = array('label' => ucfirst(BL::lbl('Never')), 'value' => '0'); $radiobuttonEndsOn[] = array('label' => ucfirst(BL::lbl('After')), 'value' => '1'); $radiobuttonEndsOn[] = array('label' => ucfirst(BL::lbl('On')), 'value' => '2'); // set array of recurring days of item $multiCheckboxDays[] = array('label' => ucfirst(BL::lbl('Monday')), 'value' => '0'); $multiCheckboxDays[] = array('label' => ucfirst(BL::lbl('Tuesday')), 'value' => '1'); $multiCheckboxDays[] = array('label' => ucfirst(BL::lbl('Wednesday')), 'value' => '2'); $multiCheckboxDays[] = array('label' => ucfirst(BL::lbl('Thursday')), 'value' => '3'); $multiCheckboxDays[] = array('label' => ucfirst(BL::lbl('Friday')), 'value' => '4'); $multiCheckboxDays[] = array('label' => ucfirst(BL::lbl('Saturday')), 'value' => '5'); $multiCheckboxDays[] = array('label' => ucfirst(BL::lbl('Sunday')), 'value' => '6'); // recurring item options $this->frm->addCheckbox('recurring', $this->record['recurring'] === 'Y' ? true : false); $this->frm->addDropdown('type', $selectTypes, $this->recurringOptions['type']); $this->frm->addDropdown('interval', $selectInterval, $this->recurringOptions['interval']); $this->frm->addMultiCheckbox('days', $multiCheckboxDays, $this->recurringOptionsDays); $this->frm->addRadioButton('ends_on', $radiobuttonEndsOn, $this->recurringOptions['ends_on']); $this->frm->addText('frequency', $this->recurringOptions['frequency']); $this->frm->addDate('recurr_end_date_date', $this->recurringOptions['end_date']); $this->frm->addTime('recurr_end_date_time', date('H:i', $this->recurringOptions['end_date'])); $this->frm->addCheckbox('whole_day', $this->record['whole_day'] === 'Y' ? true : false); // location options $this->frm->addText('name', $this->record['location_name']); $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', \SpoonLocale::getCountries(BL::getInterfaceLanguage()), $this->record['country']); $this->frm->addCheckbox('google_maps', $this->record['google_maps'] === 'Y' ? true : false); // standard options $this->frm->addText('title', $this->record['title'], null, 'inputText title', 'inputTextError title'); $this->frm->addEditor('text', $this->record['text']); $this->frm->addEditor('introduction', $this->record['introduction']); $this->frm->addDate('begin_date_date', $this->record['begin_date']); $this->frm->addTime('begin_date_time', date('H:i', $this->record['begin_date'])); $this->frm->addDate('end_date_date', $this->record['end_date']); $this->frm->addTime('end_date_time', date('H:i', $this->record['end_date'])); $this->frm->addImage('image'); $this->frm->addText('price', $this->record['price']); $this->frm->addCheckbox('delete_image'); $this->frm->addRadioButton('subscriptions', $radiobuttonSubscriptionsValues, $this->record['allow_subscriptions']); // get categories $categories = BackendAgendaModel::getCategories(); $this->frm->addDropdown('category_id', $categories, $this->record['category_id']); // meta $this->meta = new BackendMeta($this->frm, $this->record['meta_id'], 'title', true); $this->meta->setUrlCallBack('Backend\\Modules\\Agenda\\Engine\\Model', 'getUrl', array($this->record['id'])); $this->media = new BackendMediaHelper($this->frm, (string) $this->getModule(), (int) $this->id, (string) $this->getAction(), 'Agenda'); }
/** * 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, Language::getInterfaceLanguage(), $format); return '<abbr title="' . \SpoonDate::getDate($format, $timestamp, Language::getInterfaceLanguage()) . '">' . $timeAgo . '</abbr>'; }
/** * Load the form */ protected function loadForm() { $this->frm = new BackendForm('add'); // set array of recurring types $selectTypes = array('0' => ucfirst(BL::lbl('Daily')), '1' => ucfirst(BL::lbl('Weekly')), '2' => ucfirst(BL::lbl('Monthly')), '3' => ucfirst(BL::lbl('Yearly'))); // set array of recurring interval $selectInterval = array(); $i = 1; while ($i < $this->maxInterval) { $selectInterval[$i] = $i; $i++; } // set array of reservation values $radiobuttonSubscriptionsValues[] = array('label' => BL::lbl('Yes'), 'value' => 'Y'); $radiobuttonSubscriptionsValues[] = array('label' => BL::lbl('No'), 'value' => 'N'); // set array of possibilities which an item can end on $radiobuttonEndsOn[] = array('label' => ucfirst(BL::lbl('Never')), 'value' => '0'); $radiobuttonEndsOn[] = array('label' => ucfirst(BL::lbl('After')), 'value' => '1'); $radiobuttonEndsOn[] = array('label' => ucfirst(BL::lbl('On')), 'value' => '2'); // set array of recurring days of item $multiCheckboxDays[] = array('label' => ucfirst(BL::lbl('Monday')), 'value' => '0'); $multiCheckboxDays[] = array('label' => ucfirst(BL::lbl('Tuesday')), 'value' => '1'); $multiCheckboxDays[] = array('label' => ucfirst(BL::lbl('Wednesday')), 'value' => '2'); $multiCheckboxDays[] = array('label' => ucfirst(BL::lbl('Thursday')), 'value' => '3'); $multiCheckboxDays[] = array('label' => ucfirst(BL::lbl('Friday')), 'value' => '4'); $multiCheckboxDays[] = array('label' => ucfirst(BL::lbl('Saturday')), 'value' => '5'); $multiCheckboxDays[] = array('label' => ucfirst(BL::lbl('Sunday')), 'value' => '6'); // recurring item options $this->frm->addCheckbox('recurring'); $this->frm->addDropdown('type', $selectTypes, null); $this->frm->addDropdown('interval', $selectInterval, null); $this->frm->addMultiCheckbox('days', $multiCheckboxDays, 3); $this->frm->addRadioButton('ends_on', $radiobuttonEndsOn, null); $this->frm->addText('frequency'); $this->frm->addDate('recurr_end_date_date'); $this->frm->addTime('recurr_end_date_time'); $this->frm->addCheckbox('whole_day'); $this->frm->addRadioButton('subscriptions', $radiobuttonSubscriptionsValues, 'N'); // location options $this->frm->addText('name'); $this->frm->addText('street'); $this->frm->addText('number'); $this->frm->addText('zip'); $this->frm->addText('city'); $this->frm->addDropdown('country', \SpoonLocale::getCountries(BL::getInterfaceLanguage()), 'BE'); $this->frm->addCheckbox('google_maps'); // standard options $this->frm->addText('title', null, null, 'inputText title', 'inputTextError title'); $this->frm->addEditor('text'); $this->frm->addEditor('introduction'); $this->frm->addDate('begin_date_date'); $this->frm->addTime('begin_date_time'); $this->frm->addDate('end_date_date'); $this->frm->addTime('end_date_time'); $this->frm->addImage('image'); $this->frm->addText('price'); // get categories $categories = BackendAgendaModel::getCategories(); $this->frm->addDropdown('category_id', $categories); // meta $this->meta = new BackendMeta($this->frm, null, 'title', true); }
/** * 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); // define url $url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address) . '&sensor=false'; // define result $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); }