Get the current working language
public static getWorkingLanguage ( ) : string | ||
return | string |
/** * Execute the action * We will build the classname, require the class and call the execute method. */ public function execute() { $this->loadConfig(); // is the requested action available? If not we redirect to the error page. if (!$this->config->isActionAvailable($this->action)) { // build the url $errorUrl = '/' . NAMED_APPLICATION . '/' . $this->get('request')->getLocale() . '/error?type=action-not-allowed'; // redirect to the error page return $this->redirect($errorUrl, 307); } // build action-class $actionClass = 'Backend\\Modules\\' . $this->getModule() . '\\Actions\\' . $this->getAction(); if ($this->getModule() == 'Core') { $actionClass = 'Backend\\Core\\Actions\\' . $this->getAction(); } if (!class_exists($actionClass)) { throw new Exception('The class ' . $actionClass . ' could not be found.'); } // get working languages $languages = BackendLanguage::getWorkingLanguages(); $workingLanguages = array(); // loop languages and build an array that we can assign foreach ($languages as $abbreviation => $label) { $workingLanguages[] = array('abbr' => $abbreviation, 'label' => $label, 'selected' => $abbreviation == BackendLanguage::getWorkingLanguage()); } // assign the languages $this->tpl->assign('workingLanguages', $workingLanguages); // create action-object /** @var $object BackendBaseAction */ $object = new $actionClass($this->getKernel()); $this->getContainer()->get('logger')->info("Executing backend action '{$object->getAction()}' for module '{$object->getModule()}'."); $object->execute(); return $object->getContent(); }
/** * Execute the action */ public function execute() { parent::execute(); // get parameters $categoryTitle = trim(\SpoonFilter::getPostValue('value', null, '', 'string')); // validate if ($categoryTitle === '') { $this->output(self::BAD_REQUEST, null, BL::err('TitleIsRequired')); } else { // get the data // build array $item['title'] = \SpoonFilter::htmlspecialchars($categoryTitle); $item['language'] = BL::getWorkingLanguage(); $meta['keywords'] = $item['title']; $meta['keywords_overwrite'] = 'N'; $meta['description'] = $item['title']; $meta['description_overwrite'] = 'N'; $meta['title'] = $item['title']; $meta['title_overwrite'] = 'N'; $meta['url'] = BackendBlogModel::getURLForCategory(\SpoonFilter::urlise($item['title'])); // update $item['id'] = BackendBlogModel::insertCategory($item, $meta); // output $this->output(self::OK, $item, vsprintf(BL::msg('AddedCategory'), array($item['title']))); } }
/** * @param KernelInterface $kernel */ public function __construct(KernelInterface $kernel) { parent::__construct($kernel); // store for later use throughout the application $this->getContainer()->set('navigation', $this); $this->URL = $this->getContainer()->get('url'); // check if navigation cache file exists if (!is_file(self::getCacheDirectory() . 'navigation.php')) { $this->buildCache(); } // check if editor_link_list_LANGUAGE.js cache file exists if (!is_file(FRONTEND_CACHE_PATH . '/Navigation/editor_link_list_' . BackendLanguage::getWorkingLanguage() . '.js')) { BackendPagesModel::buildCache(BackendLanguage::getWorkingLanguage()); } $navigation = array(); // require navigation-file require self::getCacheDirectory() . 'navigation.php'; // load it $this->navigation = (array) $navigation; $this->navigation = $this->addActiveStateToNavigation($this->navigation); // cleanup navigation (not needed for god user) if (!Authentication::getUser()->isGod()) { $this->navigation = $this->cleanup($this->navigation); } }
/** * Validate the form */ private function validateForm() { // is the form submitted? if ($this->frm->isSubmitted()) { // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // validate field $this->frm->getField('synonym')->isFilled(BL::err('SynonymIsRequired')); $this->frm->getField('term')->isFilled(BL::err('TermIsRequired')); if (BackendSearchModel::existsSynonymByTerm($this->frm->getField('term')->getValue())) { $this->frm->getField('term')->addError(BL::err('TermExists')); } // no errors? if ($this->frm->isCorrect()) { // build item $item = array(); $item['term'] = $this->frm->getField('term')->getValue(); $item['synonym'] = $this->frm->getField('synonym')->getValue(); $item['language'] = BL::getWorkingLanguage(); // insert the item $id = BackendSearchModel::insertSynonym($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add_synonym', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('Synonyms') . '&report=added-synonym&var=' . rawurlencode($item['term']) . '&highlight=row-' . $id); } } }
/** * Sets the filter based on the $_GET array. */ private function setFilter() { $this->filter['language'] = $this->getParameter('language', 'array') != '' ? $this->getParameter('language', 'array') : BL::getWorkingLanguage(); $this->filter['application'] = $this->getParameter('application'); $this->filter['module'] = $this->getParameter('module'); $this->filter['type'] = $this->getParameter('type', 'array'); $this->filter['name'] = $this->getParameter('name'); $this->filter['value'] = $this->getParameter('value'); $this->filterQuery = BackendLocaleModel::buildURLQueryByFilter($this->filter); }
/** * Load the datagrids */ private function loadDataGrid() { $this->dataGrid = new BackendDataGridDB(BackendFormBuilderModel::QRY_BROWSE, BL::getWorkingLanguage()); $this->dataGrid->setHeaderLabels(array('email' => \SpoonFilter::ucfirst(BL::getLabel('Recipient')), 'sent_forms' => '')); $this->dataGrid->setSortingColumns(array('name', 'email', 'method', 'sent_forms'), 'name'); $this->dataGrid->setColumnFunction(array(new BackendFormBuilderModel(), 'formatRecipients'), array('[email]'), 'email'); $this->dataGrid->setColumnFunction(array(new BackendFormBuilderModel(), 'getLocale'), array('Method_[method]'), 'method'); $this->dataGrid->setColumnFunction(array(__CLASS__, 'parseNumForms'), array('[id]', '[sent_forms]'), 'sent_forms'); // check if edit action is allowed if (BackendAuthentication::isAllowedAction('Edit')) { $this->dataGrid->setColumnURL('name', BackendModel::createURLForAction('Edit') . '&id=[id]'); $this->dataGrid->addColumn('edit', null, BL::getLabel('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]', BL::getLabel('Edit')); } }
/** * Loads the datagrids */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendSearchModel::QRY_DATAGRID_BROWSE_SYNONYMS, BL::getWorkingLanguage()); // sorting columns $this->dataGrid->setSortingColumns(array('term'), 'term'); // column function $this->dataGrid->setColumnFunction('str_replace', array(',', ', ', '[synonym]'), 'synonym', true); // check if this action is allowed if (BackendAuthentication::isAllowedAction('EditSynonym')) { // set column URLs $this->dataGrid->setColumnURL('term', BackendModel::createURLForAction('EditSynonym') . '&id=[id]'); // add column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('EditSynonym') . '&id=[id]', BL::lbl('Edit')); } }
/** * Loads the datagrids */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendSearchModel::QRY_DATAGRID_BROWSE_STATISTICS, BL::getWorkingLanguage()); // hide column $this->dataGrid->setColumnsHidden('data'); // create column $this->dataGrid->addColumn('referrer', BL::lbl('Referrer')); // header labels $this->dataGrid->setHeaderLabels(array('time' => \SpoonFilter::ucfirst(BL::lbl('SearchedOn')))); // set column function $this->dataGrid->setColumnFunction(array(__CLASS__, 'setReferrer'), '[data]', 'referrer'); $this->dataGrid->setColumnFunction(array(new BackendDataGridFunctions(), 'getLongDate'), array('[time]'), 'time', true); // sorting columns $this->dataGrid->setSortingColumns(array('time', 'term'), 'time'); $this->dataGrid->setSortParameter('desc'); }
/** * Execute the action */ public function execute() { parent::execute(); $generalSettings = $this->get('fork.settings')->getForModule('Location'); // get parameters $itemId = \SpoonFilter::getPostValue('id', null, null, 'int'); $zoomLevel = trim(\SpoonFilter::getPostValue('zoom', null, 'auto')); $mapType = strtoupper(trim(\SpoonFilter::getPostValue('type', array('roadmap', 'satellite', 'hybrid', 'terrain', 'street_view'), 'roadmap'))); $mapStyle = trim(\SpoonFilter::getPostValue('style', array('standard', 'custom', 'gray', 'blue'), 'standard')); $centerLat = \SpoonFilter::getPostValue('centerLat', null, 1, 'float'); $centerlng = \SpoonFilter::getPostValue('centerLng', null, 1, 'float'); $height = \SpoonFilter::getPostValue('height', null, $generalSettings['height'], 'int'); $width = \SpoonFilter::getPostValue('width', null, $generalSettings['width'], 'int'); $showLink = \SpoonFilter::getPostValue('link', array('true', 'false'), 'false', 'string'); $showDirections = \SpoonFilter::getPostValue('directions', array('true', 'false'), 'false', 'string'); $showOverview = \SpoonFilter::getPostValue('showOverview', array('true', 'false'), 'true', 'string'); // reformat $center = array('lat' => $centerLat, 'lng' => $centerlng); $showLink = $showLink == 'true'; $showDirections = $showDirections == 'true'; $showOverview = $showOverview == 'true'; // standard dimensions if ($width > 800) { $width = 800; } if ($width < 300) { $width = $generalSettings['width']; } if ($height < 150) { $height = $generalSettings['height']; } // no id given, this means we should update the main map BackendLocationModel::setMapSetting($itemId, 'zoom_level', (string) $zoomLevel); BackendLocationModel::setMapSetting($itemId, 'map_type', (string) $mapType); BackendLocationModel::setMapSetting($itemId, 'map_style', (string) $mapStyle); BackendLocationModel::setMapSetting($itemId, 'center', (array) $center); BackendLocationModel::setMapSetting($itemId, 'height', (int) $height); BackendLocationModel::setMapSetting($itemId, 'width', (int) $width); BackendLocationModel::setMapSetting($itemId, 'directions', $showDirections); BackendLocationModel::setMapSetting($itemId, 'full_url', $showLink); $item = array('id' => $itemId, 'language' => BL::getWorkingLanguage(), 'show_overview' => $showOverview ? 'Y' : 'N'); BackendLocationModel::update($item); // output $this->output(self::OK, null, BL::msg('Success')); }
/** * Execute the action */ public function execute() { parent::execute(); // get parameters $itemId = trim(\SpoonFilter::getPostValue('id', null, '', 'int')); $lat = \SpoonFilter::getPostValue('lat', null, null, 'float'); $lng = \SpoonFilter::getPostValue('lng', null, null, 'float'); // validate id if ($itemId == 0) { $this->output(self::BAD_REQUEST, null, BL::err('NonExisting')); } else { //update $updateData = array('id' => $itemId, 'lat' => $lat, 'lng' => $lng, 'language' => BL::getWorkingLanguage()); BackendLocationModel::update($updateData); // output $this->output(self::OK); } }
public function configureOptions(OptionsResolver $optionsResolver) { $optionsResolver->setDefaults(['attr' => ['class' => 'inputEditor']]); if (!Model::has('header')) { return; } // add the needed javascript to the header; $header = Model::get('header'); // we add JS because we need CKEditor $header->addJS('ckeditor/ckeditor.js', 'Core', false); $header->addJS('ckeditor/adapters/jquery.js', 'Core', false); $header->addJS('ckfinder/ckfinder.js', 'Core', false); // add the internal link lists-file if (is_file(FRONTEND_CACHE_PATH . '/Navigation/editor_link_list_' . Language::getWorkingLanguage() . '.js')) { $timestamp = @filemtime(FRONTEND_CACHE_PATH . '/Navigation/editor_link_list_' . Language::getWorkingLanguage() . '.js'); $header->addJS('/src/Frontend/Cache/Navigation/editor_link_list_' . Language::getWorkingLanguage() . '.js?m=' . $timestamp, null, false, true, false); } }
/** * Execute the action */ public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendPagesModel::exists($this->id)) { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // init var $success = false; // cannot have children if (BackendPagesModel::getFirstChildId($this->id) !== false) { $this->redirect(BackendModel::createURLForAction('Edit') . '&error=non-existing'); } $revisionId = $this->getParameter('revision_id', 'int'); if ($revisionId == 0) { $revisionId = null; } // get page (we need the title) $page = BackendPagesModel::get($this->id, $revisionId); // valid page? if (!empty($page)) { // delete the page $success = BackendPagesModel::delete($this->id, null, $revisionId); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_delete', array('id' => $this->id)); // delete search indexes BackendSearchModel::removeIndex($this->getModule(), $this->id); // build cache BackendPagesModel::buildCache(BL::getWorkingLanguage()); } // page is deleted, so redirect to the overview if ($success) { $this->redirect(BackendModel::createURLForAction('Index') . '&id=' . $page['parent_id'] . '&report=deleted&var=' . rawurlencode($page['title'])); } else { $this->redirect(BackendModel::createURLForAction('Edit') . '&error=non-existing'); } } else { $this->redirect(BackendModel::createURLForAction('Edit') . '&error=non-existing'); } }
/** * Load the datagrid with the recently edited items */ private function loadDataGridRecentlyEdited() { // create dgRecentlyEdited $this->dgRecentlyEdited = new BackendDataGridDB(BackendPagesModel::QRY_BROWSE_RECENT, array('active', BL::getWorkingLanguage(), 7)); // disable paging $this->dgRecentlyEdited->setPaging(false); // hide columns $this->dgRecentlyEdited->setColumnsHidden(array('id')); // set functions $this->dgRecentlyEdited->setColumnFunction(array(new BackendDataGridFunctions(), 'getUser'), array('[user_id]'), 'user_id'); $this->dgRecentlyEdited->setColumnFunction(array(new BackendDataGridFunctions(), 'getTimeAgo'), array('[edited_on]'), 'edited_on'); // set headers $this->dgRecentlyEdited->setHeaderLabels(array('user_id' => \SpoonFilter::ucfirst(BL::lbl('By')), 'edited_on' => \SpoonFilter::ucfirst(BL::lbl('LastEdited')))); // check if allowed to edit if (BackendAuthentication::isAllowedAction('Edit', $this->getModule())) { // set column URL $this->dgRecentlyEdited->setColumnURL('title', BackendModel::createURLForAction('Edit') . '&id=[id]', BL::lbl('Edit')); // add column $this->dgRecentlyEdited->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]', BL::lbl('Edit')); } }
/** * Execute the action */ public function execute() { // call parent parent::execute(); // get parameters $id = \SpoonFilter::getPostValue('id', null, 0, 'int'); $droppedOn = \SpoonFilter::getPostValue('dropped_on', null, -1, 'int'); $typeOfDrop = \SpoonFilter::getPostValue('type', null, ''); $tree = \SpoonFilter::getPostValue('tree', array('main', 'meta', 'footer', 'root'), ''); // init validation $errors = array(); // validate if ($id === 0) { $errors[] = 'no id provided'; } if ($droppedOn === -1) { $errors[] = 'no dropped_on provided'; } if ($typeOfDrop == '') { $errors[] = 'no type provided'; } if ($tree == '') { $errors[] = 'no tree provided'; } // got errors if (!empty($errors)) { $this->output(self::BAD_REQUEST, array('errors' => $errors), 'not all fields were filled'); } else { // get page $success = BackendPagesModel::move($id, $droppedOn, $typeOfDrop, $tree); // build cache BackendPagesModel::buildCache(BL::getWorkingLanguage()); // output if ($success) { $this->output(self::OK, BackendPagesModel::get($id), 'page moved'); } else { $this->output(self::ERROR, null, 'page not moved'); } } }
/** * Loads the datagrids */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendBlogModel::QRY_DATAGRID_BROWSE_CATEGORIES, array('active', BL::getWorkingLanguage())); // set headers $this->dataGrid->setHeaderLabels(array('num_items' => \SpoonFilter::ucfirst(BL::lbl('Amount')))); // sorting columns $this->dataGrid->setSortingColumns(array('title', 'num_items'), 'title'); // convert the count into a readable and clickable one $this->dataGrid->setColumnFunction(array(__CLASS__, 'setClickableCount'), array('[num_items]', BackendModel::createURLForAction('Index') . '&category=[id]'), 'num_items', true); // disable paging $this->dataGrid->setPaging(false); // add attributes, so the inline editing has all the needed data $this->dataGrid->setColumnAttributes('title', array('data-id' => '{id:[id]}')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('EditCategory')) { // set column URLs $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('EditCategory') . '&id=[id]'); // add column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('EditCategory') . '&id=[id]', BL::lbl('Edit')); } }
/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { $this->meta->setURLCallback('Backend\\Modules\\Faq\\Engine\\Model', 'getURLForCategory'); $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired')); $this->meta->validate(); if ($this->frm->isCorrect()) { // build item $item['title'] = $this->frm->getField('title')->getValue(); $item['language'] = BL::getWorkingLanguage(); $item['meta_id'] = $this->meta->save(); $item['sequence'] = BackendFaqModel::getMaximumCategorySequence() + 1; // save the data $item['id'] = BackendFaqModel::insertCategory($item); BackendModel::triggerEvent($this->getModule(), 'after_add_category', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('Categories') . '&report=added-category&var=' . rawurlencode($item['title']) . '&highlight=row-' . $item['id']); } } }
/** * Loads the datagrids */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendTagsModel::QRY_DATAGRID_BROWSE, BL::getWorkingLanguage()); // header labels $this->dataGrid->setHeaderLabels(array('tag' => \SpoonFilter::ucfirst(BL::lbl('Name')), 'num_tags' => \SpoonFilter::ucfirst(BL::lbl('Amount')))); // sorting columns $this->dataGrid->setSortingColumns(array('tag', 'num_tags'), 'num_tags'); $this->dataGrid->setSortParameter('desc'); // add the multicheckbox column $this->dataGrid->setMassActionCheckboxes('check', '[id]'); // add mass action dropdown $ddmMassAction = new \SpoonFormDropdown('action', array('delete' => BL::lbl('Delete')), 'delete', false, 'form-control', 'form-control danger'); $ddmMassAction->setOptionAttributes('delete', array('data-target' => '#confirmDelete')); $this->dataGrid->setMassAction($ddmMassAction); // add attributes, so the inline editing has all the needed data $this->dataGrid->setColumnAttributes('tag', array('data-id' => '{id:[id]}')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('Edit')) { // add column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]', BL::lbl('Edit')); } }
/** * Loads the dataGrids */ private function loadDatagrids() { // load all categories $categories = BackendFaqModel::getCategories(true); // loop categories and create a dataGrid for each one foreach ($categories as $categoryId => $categoryTitle) { $dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage(), $categoryId)); $dataGrid->enableSequenceByDragAndDrop(); $dataGrid->setColumnsHidden(array('category_id', 'sequence')); $dataGrid->setColumnAttributes('question', array('class' => 'title')); $dataGrid->setRowAttributes(array('id' => '[id]')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('Edit')) { $dataGrid->setColumnURL('question', BackendModel::createURLForAction('Edit') . '&id=[id]'); $dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]', BL::lbl('Edit')); } // add dataGrid to list $this->dataGrids[] = array('id' => $categoryId, 'title' => $categoryTitle, 'content' => $dataGrid->getContent()); } // set empty datagrid $this->emptyDatagrid = new BackendDataGridArray(array(array('dragAndDropHandle' => '', 'question' => BL::msg('NoQuestionInCategory'), 'edit' => ''))); $this->emptyDatagrid->setAttributes(array('class' => 'table table-hover table-striped fork-data-grid jsDataGrid sequenceByDragAndDrop emptyGrid')); $this->emptyDatagrid->setHeaderLabels(array('edit' => null, 'dragAndDropHandle' => null)); }
/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { // cleanup the submitted fields, ignore fields that were added by hackers $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired')); // validate meta $this->meta->validate(); // no errors? if ($this->frm->isCorrect()) { // build item $item['title'] = $this->frm->getField('title')->getValue(); $item['language'] = BL::getWorkingLanguage(); $item['meta_id'] = $this->meta->save(); // insert the item $item['id'] = BackendBlogModel::insertCategory($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add_category', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('Categories') . '&report=added-category&var=' . rawurlencode($item['title']) . '&highlight=row-' . $item['id']); } } }
/** * Loads the dataGrid */ private function loadDataGrid() { // are multiple categories allowed? $this->multipleCategoriesAllowed = $this->get('fork.settings')->get('Faq', 'allow_multiple_categories', true); // create dataGrid $this->dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE_CATEGORIES, BL::getWorkingLanguage()); $this->dataGrid->setHeaderLabels(array('num_items' => \SpoonFilter::ucfirst(BL::lbl('Amount')))); if ($this->multipleCategoriesAllowed) { $this->dataGrid->enableSequenceByDragAndDrop(); } else { $this->dataGrid->setColumnsHidden(array('sequence')); } $this->dataGrid->setRowAttributes(array('id' => '[id]')); $this->dataGrid->setPaging(false); // check if this action is allowed if (BackendAuthentication::isAllowedAction('Index')) { $this->dataGrid->setColumnFunction(array(__CLASS__, 'setClickableCount'), array('[num_items]', BackendModel::createURLForAction('Index') . '&category=[id]'), 'num_items', true); } // check if this action is allowed if (BackendAuthentication::isAllowedAction('EditCategory')) { $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('EditCategory') . '&id=[id]'); $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('EditCategory') . '&id=[id]', BL::lbl('Edit')); } }
/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired')); $this->frm->getField('street')->isFilled(BL::err('FieldIsRequired')); $this->frm->getField('number')->isFilled(BL::err('FieldIsRequired')); $this->frm->getField('zip')->isFilled(BL::err('FieldIsRequired')); $this->frm->getField('city')->isFilled(BL::err('FieldIsRequired')); if ($this->frm->isCorrect()) { // build item $item['language'] = BL::getWorkingLanguage(); $item['title'] = $this->frm->getField('title')->getValue(); $item['street'] = $this->frm->getField('street')->getValue(); $item['number'] = $this->frm->getField('number')->getValue(); $item['zip'] = $this->frm->getField('zip')->getValue(); $item['city'] = $this->frm->getField('city')->getValue(); $item['country'] = $this->frm->getField('country')->getValue(); // define coordinates $coordinates = BackendLocationModel::getCoordinates($item['street'], $item['number'], $item['city'], $item['zip'], $item['country']); // define latitude and longitude $item['lat'] = $coordinates['latitude']; $item['lng'] = $coordinates['longitude']; // insert the item $item['id'] = BackendLocationModel::insert($item); // everything is saved, so redirect to the overview if ($item['lat'] && $item['lng']) { // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item)); } // redirect $this->redirect(BackendModel::createURLForAction('Edit') . '&id=' . $item['id'] . '&report=added&var=' . rawurlencode($item['title'])); } } }
/** * Sets the filter based on the $_GET array. */ private function setFilter() { $this->filter['language'] = isset($_GET['language']) ? $this->getParameter('language') : BL::getWorkingLanguage(); }
/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { $this->frm->cleanupFields(); // shorten the fields $txtName = $this->frm->getField('name'); $txtEmail = $this->frm->getField('email'); $ddmMethod = $this->frm->getField('method'); $txtSuccessMessage = $this->frm->getField('success_message'); $txtIdentifier = $this->frm->getField('identifier'); $emailAddresses = (array) explode(',', $txtEmail->getValue()); // validate fields $txtName->isFilled(BL::getError('NameIsRequired')); $txtSuccessMessage->isFilled(BL::getError('SuccessMessageIsRequired')); if ($ddmMethod->isFilled(BL::getError('NameIsRequired')) && $ddmMethod->getValue() == 'database_email') { $error = false; // check the addresses foreach ($emailAddresses as $address) { $address = trim($address); if (!\SpoonFilter::isEmail($address)) { $error = true; break; } } // add error if ($error) { $txtEmail->addError(BL::getError('EmailIsInvalid')); } } // identifier if ($txtIdentifier->isFilled()) { // invalid characters if (!\SpoonFilter::isValidAgainstRegexp('/^[a-zA-Z0-9\\.\\_\\-]+$/', $txtIdentifier->getValue())) { $txtIdentifier->setError(BL::getError('InvalidIdentifier')); } elseif (BackendFormBuilderModel::existsIdentifier($txtIdentifier->getValue())) { // unique identifier $txtIdentifier->setError(BL::getError('UniqueIdentifier')); } } if ($this->frm->isCorrect()) { // build array $values['language'] = BL::getWorkingLanguage(); $values['user_id'] = BackendAuthentication::getUser()->getUserId(); $values['name'] = $txtName->getValue(); $values['method'] = $ddmMethod->getValue(); $values['email'] = $ddmMethod->getValue() == 'database_email' ? serialize($emailAddresses) : null; $values['success_message'] = $txtSuccessMessage->getValue(true); $values['identifier'] = $txtIdentifier->isFilled() ? $txtIdentifier->getValue() : BackendFormBuilderModel::createIdentifier(); $values['created_on'] = BackendModel::getUTCDate(); $values['edited_on'] = BackendModel::getUTCDate(); // insert the item $id = BackendFormBuilderModel::insert($values); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $values)); // set frontend locale FL::setLocale(BL::getWorkingLanguage(), true); // create submit button $field['form_id'] = $id; $field['type'] = 'submit'; $field['settings'] = serialize(array('values' => \SpoonFilter::ucfirst(FL::getLabel('Send')))); BackendFormBuilderModel::insertField($field); // everything is saved, so redirect to the editform $this->redirect(BackendModel::createURLForAction('Edit') . '&id=' . $id . '&report=added&var=' . rawurlencode($values['name']) . '#tabFields'); } } }
/** * Get the current working language * * @deprecated * * @return string */ public static function getWorkingLanguage() { trigger_error('Backend\\Core\\Engine\\Language is deprecated. It has been moved to Backend\\Core\\Language\\Language', E_USER_DEPRECATED); return parent::getWorkingLanguage(); }
/** * Parse all user-defined constants */ private function parseConstants() { // constants that should be protected from usage in the template $notPublicConstants = array('DB_TYPE', 'DB_DATABASE', 'DB_HOSTNAME', 'DB_PORT', 'DB_USERNAME', 'DB_PASSWORD'); // get all defined constants $constants = get_defined_constants(true); // init var $realConstants = array(); // remove protected constants aka constants that should not be used in the template foreach ($constants['user'] as $key => $value) { if (!in_array($key, $notPublicConstants)) { $realConstants[$key] = $value; } } // we should only assign constants if there are constants to assign if (!empty($realConstants)) { $this->assign($realConstants); } // we use some abbreviations and common terms, these should also be assigned $this->assign('LANGUAGE', BL::getWorkingLanguage()); // check on url object if (Model::getContainer()->has('url')) { $url = Model::get('url'); if ($url instanceof Url) { // assign the current module $this->assign('MODULE', $url->getModule()); // assign the current action if ($url->getAction() != '') { $this->assign('ACTION', $url->getAction()); } if ($url->getModule() == 'Core') { $this->assign('BACKEND_MODULE_PATH', BACKEND_PATH . '/' . $url->getModule()); } else { $this->assign('BACKEND_MODULE_PATH', BACKEND_MODULES_PATH . '/' . $url->getModule()); } } } // is the user object filled? if (Authentication::getUser()->isAuthenticated()) { // assign the authenticated users secret key $this->assign('SECRET_KEY', Authentication::getUser()->getSecretKey()); // assign the authenticated users preferred interface language $this->assign('INTERFACE_LANGUAGE', (string) Authentication::getUser()->getSetting('interface_language')); } // assign some variable constants (such as site-title) $this->assign('SITE_TITLE', Model::get('fork.settings')->get('Core', 'site_title_' . BL::getWorkingLanguage(), SITE_DEFAULT_TITLE)); }
/** * @return self */ public static function workingLocale() { return new self(Language::getWorkingLanguage()); }
/** * Validates the settings form */ private function validateForm() { if ($this->frm->isSubmitted()) { // validation $this->frm->getField('rss_title')->isFilled(BL::err('FieldIsRequired')); if ($this->frm->isCorrect()) { // set our settings $this->get('fork.settings')->set($this->URL->getModule(), 'overview_num_items', (int) $this->frm->getField('overview_number_of_items')->getValue()); $this->get('fork.settings')->set($this->URL->getModule(), 'recent_articles_full_num_items', (int) $this->frm->getField('recent_articles_full_number_of_items')->getValue()); $this->get('fork.settings')->set($this->URL->getModule(), 'recent_articles_list_num_items', (int) $this->frm->getField('recent_articles_list_number_of_items')->getValue()); $this->get('fork.settings')->set($this->URL->getModule(), 'spamfilter', (bool) $this->frm->getField('spamfilter')->getValue()); $this->get('fork.settings')->set($this->URL->getModule(), 'allow_comments', (bool) $this->frm->getField('allow_comments')->getValue()); $this->get('fork.settings')->set($this->URL->getModule(), 'moderation', (bool) $this->frm->getField('moderation')->getValue()); $this->get('fork.settings')->set($this->URL->getModule(), 'notify_by_email_on_new_comment_to_moderate', (bool) $this->frm->getField('notify_by_email_on_new_comment_to_moderate')->getValue()); $this->get('fork.settings')->set($this->URL->getModule(), 'notify_by_email_on_new_comment', (bool) $this->frm->getField('notify_by_email_on_new_comment')->getValue()); // @TODO remove this when the api is kicked out $this->get('fork.settings')->set($this->URL->getModule(), 'ping_services', (bool) $this->frm->getField('ping_services')->getValue()); $this->get('fork.settings')->set($this->URL->getModule(), 'rss_title_' . BL::getWorkingLanguage(), $this->frm->getField('rss_title')->getValue()); $this->get('fork.settings')->set($this->URL->getModule(), 'rss_description_' . BL::getWorkingLanguage(), $this->frm->getField('rss_description')->getValue()); $this->get('fork.settings')->set($this->URL->getModule(), 'rss_meta_' . BL::getWorkingLanguage(), $this->frm->getField('rss_meta')->getValue()); if ($this->isGod) { $this->get('fork.settings')->set($this->URL->getModule(), 'show_image_form', (bool) $this->frm->getField('show_image_form')->getChecked()); } if ($this->get('fork.settings')->get('Core', 'akismet_key') === null) { $this->get('fork.settings')->set($this->URL->getModule(), 'spamfilter', false); } // trigger event BackendModel::triggerEvent($this->getModule(), 'after_saved_settings'); // redirect to the settings page $this->redirect(BackendModel::createURLForAction('Settings') . '&report=saved'); } } }
/** * Sets the filter based on the $_GET array. */ private function setFilter() { // if no language is selected, set the working language as the selected if ($this->getParameter('language', 'array') == null) { $_GET['language'] = array(BL::getWorkingLanguage()); $this->parameters['language'] = array(BL::getWorkingLanguage()); } // if no type is selected, set labels as the selected type if ($this->getParameter('type', 'array') == null) { $_GET['type'] = array('lbl'); $this->parameters['type'] = array('lbl', 'act', 'err', 'msg'); } // set filter $this->filter['application'] = $this->getParameter('application', 'string', null); $this->filter['module'] = $this->getParameter('module', 'string', null); $this->filter['type'] = $this->getParameter('type', 'array'); $this->filter['language'] = $this->getParameter('language', 'array'); $this->filter['name'] = $this->getParameter('name') == null ? '' : $this->getParameter('name'); $this->filter['value'] = $this->getParameter('value') == null ? '' : $this->getParameter('value'); // only allow values from our types checkboxes to be set $this->filter['type'] = array_filter($this->filter['type'], function ($type) { return array_key_exists($type, BackendLocaleModel::getTypesForMultiCheckbox()); }); // only allow languages from our language checkboxes to be set $isGod = $this->isGod; $this->filter['language'] = array_filter($this->filter['language'], function ($language) use($isGod) { return array_key_exists($language, BackendLocaleModel::getLanguagesForMultiCheckbox($isGod)); }); // build query for filter $this->filterQuery = BackendLocaleModel::buildURLQueryByFilter($this->filter); }
/** * Sets the filter based on the $_GET array. */ private function setFilter() { $this->filter['language'] = $this->getParameter('language', 'array') != '' ? $this->getParameter('language', 'array') : BL::getWorkingLanguage(); $this->filter['application'] = $this->getParameter('application'); $this->filter['module'] = $this->getParameter('module'); $this->filter['type'] = $this->getParameter('type', 'array'); $this->filter['name'] = $this->getParameter('name'); $this->filter['value'] = $this->getParameter('value'); // build query for filter $this->filterQuery = '&' . http_build_query($this->filter, null, '&', PHP_QUERY_RFC3986); }
/** * Loads the datagrid with the most recent posts. */ private function loadDataGridRecentPosts() { // filter on category? if ($this->categoryId != null) { // create datagrid $this->dgRecent = new BackendDataGridDB(BackendBlogModel::QRY_DATAGRID_BROWSE_RECENT_FOR_CATEGORY, array($this->categoryId, 'active', BL::getWorkingLanguage(), 4)); // set the URL $this->dgRecent->setURL('&category=' . $this->categoryId, true); } else { // create datagrid $this->dgRecent = new BackendDataGridDB(BackendBlogModel::QRY_DATAGRID_BROWSE_RECENT, array('active', BL::getWorkingLanguage(), 4)); } // set headers $this->dgRecent->setHeaderLabels(array('user_id' => \SpoonFilter::ucfirst(BL::lbl('Author')))); // hide columns $this->dgRecent->setColumnsHidden(array('revision_id')); // set paging $this->dgRecent->setPaging(false); // set column functions $this->dgRecent->setColumnFunction(array(new BackendDataGridFunctions(), 'getLongDate'), array('[edited_on]'), 'edited_on', true); $this->dgRecent->setColumnFunction(array(new BackendDataGridFunctions(), 'getUser'), array('[user_id]'), 'user_id', true); // our JS needs to know an id, so we can highlight it $this->dgRecent->setRowAttributes(array('id' => 'row-[revision_id]')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('Edit')) { // set colum URLs $this->dgRecent->setColumnURL('title', BackendModel::createURLForAction('Edit') . '&id=[id]&category=' . $this->categoryId); // add edit column $this->dgRecent->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('Edit') . '&id=[id]&category=' . $this->categoryId, BL::lbl('Edit')); } }