/** * Execute the action * * @return void */ public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); // does the item exist if ($this->id !== null && BackendPagesModel::existsTemplate($this->id)) { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // init var $success = false; // get template (we need the title) $item = BackendPagesModel::getTemplate($this->id); // valid template? if (!empty($item)) { // delete the page $success = BackendPagesModel::deleteTemplate($this->id); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_delete_template', array('id' => $this->id)); // build cache BackendPagesModel::buildCache(BL::getWorkingLanguage()); } // page is deleted, so redirect to the overview if ($success) { $this->redirect(BackendModel::createURLForAction('templates') . '&theme=' . $item['theme'] . '&report=deleted-template&var=' . urlencode($item['label'])); } else { $this->redirect(BackendModel::createURLForAction('templates') . '&error=non-existing'); } } else { $this->redirect(BackendModel::createURLForAction('templates') . '&error=non-existing'); } }
/** * 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')); } // 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']))); }
/** * 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->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop')); $dataGrid->setColumnsHidden(array('category_id', 'sequence')); $dataGrid->addColumn('dragAndDropHandle', null, '<span>' . BL::lbl('Move') . '</span>'); $dataGrid->setColumnsSequence('dragAndDropHandle'); $dataGrid->setColumnAttributes('question', array('class' => 'title')); $dataGrid->setColumnAttributes('dragAndDropHandle', array('class' => 'dragAndDropHandle')); $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' => 'dataGrid sequenceByDragAndDrop emptyGrid')); $this->emptyDatagrid->setHeaderLabels(array('edit' => null, 'dragAndDropHandle' => null)); }
/** * Load the form * * @return void */ private function loadForm() { // create form $this->frm = new BackendForm('add'); // fetch the campaigns $campaigns = BackendMailmotorModel::getCampaignsAsPairs(); // fetch the groups $groupIds = BackendMailmotorModel::getGroupIDs(); $groups = BackendMailmotorModel::getGroupsWithRecipientsForCheckboxes(); // no groups were made yet if (empty($groups) && empty($groupIds)) { $this->redirect(BackendModel::createURLForAction('add_group') . '&error=add-mailing-no-groups'); } elseif (empty($groups)) { $this->redirect(BackendModel::createURLForAction('addresses') . '&error=no-subscribers'); } // fetch the languages $languages = BackendMailmotorModel::getLanguagesForCheckboxes(); // settings $this->frm->addText('name'); if (count($campaigns) > 1) { $this->frm->addDropdown('campaign', $campaigns); } // sender $this->frm->addText('from_name', BackendModel::getModuleSetting($this->getModule(), 'from_name')); $this->frm->addText('from_email', BackendModel::getModuleSetting($this->getModule(), 'from_email')); // reply-to address $this->frm->addText('reply_to_email', BackendModel::getModuleSetting($this->getModule(), 'reply_to_email')); // groups - if there is only 1 group present, we select it by default $this->frm->addMultiCheckbox('groups', $groups, count($groups) == 1 && isset($groups[0]) ? $groups[0]['value'] : false); // languages $this->frm->addRadiobutton('languages', $languages, BL::getWorkingLanguage()); }
/** * Validate the form * * @return void */ 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=' . urlencode($item['term']) . '&highlight=row-' . $id); } } }
/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('QuestionIsRequired')); $this->frm->getField('answer')->isFilled(BL::err('AnswerIsRequired')); $this->frm->getField('category_id')->isFilled(BL::err('CategoryIsRequired')); $this->meta->validate(); if ($this->frm->isCorrect()) { // build item $item['meta_id'] = $this->meta->save(); $item['category_id'] = $this->frm->getField('category_id')->getValue(); $item['user_id'] = BackendAuthentication::getUser()->getUserId(); $item['language'] = BL::getWorkingLanguage(); $item['question'] = $this->frm->getField('title')->getValue(); $item['answer'] = $this->frm->getField('answer')->getValue(true); $item['created_on'] = BackendModel::getUTCDate(); $item['hidden'] = $this->frm->getField('hidden')->getValue(); $item['sequence'] = BackendFaqModel::getMaximumSequence($this->frm->getField('category_id')->getValue()) + 1; // save the data $item['id'] = BackendFaqModel::insert($item); BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule()); BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item)); // add search index BackendSearchModel::saveIndex('faq', $item['id'], array('title' => $item['question'], 'text' => $item['answer'])); $this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['question']) . '&highlight=row-' . $item['id']); } } }
/** * Execute the action * * @return void */ 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, ''); // validate if ($id === 0) { $this->output(self::BAD_REQUEST, null, 'no id provided'); } if ($droppedOn === -1) { $this->output(self::BAD_REQUEST, null, 'no id provided'); } if ($typeOfDrop == '') { $this->output(self::BAD_REQUEST, null, 'no type provided'); } // get page $success = BackendPagesModel::move($id, $droppedOn, $typeOfDrop); // 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'); } }
/** * Validate the form * * @return void */ private function validateForm() { // is the form submitted? if ($this->frm->isSubmitted()) { // set callback for generating an unique URL $this->meta->setURLCallback('BackendBlogModel', 'getURLForCategory'); // 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=' . urlencode($item['title']) . '&highlight=row-' . $item['id']); } } }
/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { $this->frm->cleanupFields(); // validate fields $this->frm->getField('title')->isFilled(BL::err('TitleIsRequired')); if ($this->frm->isCorrect()) { // build item $item['id'] = BackendContentBlocksModel::getMaximumId() + 1; $item['user_id'] = BackendAuthentication::getUser()->getUserId(); $item['template'] = count($this->templates) > 1 ? $this->frm->getField('template')->getValue() : $this->templates[0]; $item['language'] = BL::getWorkingLanguage(); $item['title'] = $this->frm->getField('title')->getValue(); $item['text'] = $this->frm->getField('text')->getValue(); $item['hidden'] = $this->frm->getField('hidden')->getValue() ? 'N' : 'Y'; $item['status'] = 'active'; $item['created_on'] = BackendModel::getUTCDate(); $item['edited_on'] = BackendModel::getUTCDate(); // insert the item $item['revision_id'] = BackendContentBlocksModel::insert($item); // trigger event BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item)); // everything is saved, so redirect to the overview $this->redirect(BackendModel::createURLForAction('index') . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']); } } }
/** * Load the datagrids * * @return void */ private function loadDataGrids() { // load all categories $categories = BackendFaqModel::getCategories(); // run over categories and create datagrid for each one foreach ($categories as $category) { // create datagrid $dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage(), $category['id'])); // set attributes $dataGrid->setAttributes(array('class' => 'dataGrid sequenceByDragAndDrop')); // disable paging $dataGrid->setPaging(false); // set colum URLs $dataGrid->setColumnURL('question', BackendModel::createURLForAction('edit') . '&id=[id]'); // set colums hidden $dataGrid->setColumnsHidden(array('category_id', 'sequence')); // add edit column $dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit')); // add a column for the handle, so users have something to hold while draging $dataGrid->addColumn('dragAndDropHandle', null, '<span>' . BL::lbl('Move') . '</span>'); // make sure the column with the handler is the first one $dataGrid->setColumnsSequence('dragAndDropHandle'); // add a class on the handler column, so JS knows this is just a handler $dataGrid->setColumnAttributes('dragAndDropHandle', array('class' => 'dragAndDropHandle')); // our JS needs to know an id, so we can send the new order $dataGrid->setRowAttributes(array('id' => '[id]')); // add datagrid to list $this->dataGrids[] = array('id' => $category['id'], 'name' => $category['name'], 'content' => $dataGrid->getContent()); } }
/** * Load the datagrids */ private function loadDataGrid() { $this->dataGrid = new BackendDataGridDB(BackendContentBlocksModel::QRY_BROWSE, array('active', BL::getWorkingLanguage())); $this->dataGrid->setSortingColumns(array('title')); // check if this action is allowed if (BackendAuthentication::isAllowedAction('edit')) { $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('edit') . '&id=[id]'); $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit')); } }
/** * 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); }
/** * 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); }
/** * Loads the datagrid * * @return void */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendLocationModel::QRY_DATAGRID_BROWSE, array(BL::getWorkingLanguage())); // sorting columns $this->dataGrid->setSortingColumns(array('address', 'title'), 'address'); $this->dataGrid->setSortParameter('ASC'); // set colum URLs $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('edit') . '&id=[id]'); // add edit column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit')); }
/** * Loads the datagrid * * @return void */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE_CATEGORIES, BL::getWorkingLanguage()); // disable paging $this->dataGrid->setPaging(false); // enable drag and drop $this->dataGrid->enableSequenceByDragAndDrop(); // set column URLs $this->dataGrid->setColumnURL('name', BackendModel::createURLForAction('edit_category') . '&id=[id]'); // add edit column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_category') . '&id=[id]', BL::lbl('Edit')); }
/** * Loads the datagrids * * @return void */ 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); // set colum URLs $this->dataGrid->setColumnURL('term', BackendModel::createURLForAction('edit_synonym') . '&id=[id]'); // add column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_synonym') . '&id=[id]', BL::lbl('Edit')); }
/** * 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('BackendFormBuilderModel', 'formatRecipients'), array('[email]'), 'email'); $this->dataGrid->setColumnFunction(array('BackendFormBuilderModel', 'getLocale'), array('Method_[method]'), 'method'); $this->dataGrid->setColumnFunction(array('BackendFormBuilderIndex', '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')); } }
/** * 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'); if ($itemId == 0) { $this->output(self::BAD_REQUEST, null, BL::err('NonExisting')); } $updateData = array('id' => $itemId, 'lat' => $lat, 'lng' => $lng, 'language' => BL::getWorkingLanguage()); BackendLocationModel::update($updateData); // output $this->output(self::OK); }
/** * Checks if a client ID was already set or not * * @return void */ private function checkForClientID() { // fetch client ID $clientId = BackendMailmotorCMHelper::getClientID(); // no client ID set, so redirect to settings with an appropriate error message. if (empty($clientId)) { SpoonHTTP::redirect(BackendModel::createURLForAction('settings', 'mailmotor', BL::getWorkingLanguage())); } // get price per email $pricePerEmail = BackendModel::getModuleSetting('mailmotor', 'price_per_email'); // check if a price per e-mail is set if (empty($pricePerEmail) && $pricePerEmail != 0) { SpoonHTTP::redirect(BackendModel::createURLForAction('settings', 'mailmotor', BL::getWorkingLanguage()) . '&error=no-price-per-email'); } }
/** * 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('BackendDataGridFunctions', 'getLongDate'), array('[time]'), 'time', true); // sorting columns $this->dataGrid->setSortingColumns(array('time', 'term'), 'time'); $this->dataGrid->setSortParameter('desc'); }
/** * Load the datagrids * * @return void */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendFormBuilderModel::QRY_BROWSE, BL::getWorkingLanguage()); // set headers $this->dataGrid->setHeaderLabels(array('email' => ucfirst(BL::getLabel('Recipient')), 'sent_forms' => '')); // sorting columns $this->dataGrid->setSortingColumns(array('name', 'email', 'method', 'sent_forms'), 'name'); // set colum URLs $this->dataGrid->setColumnURL('name', BackendModel::createURLForAction('edit') . '&id=[id]'); // set method label $this->dataGrid->setColumnFunction(array('BackendFormBuilderModel', 'getLocale'), array('Method_[method]'), 'method'); // set the amount of sent forms $this->dataGrid->setColumnFunction(array('BackendFormBuilderIndex', 'parseNumForms'), array('[id]', '[sent_forms]'), 'sent_forms'); // add edit column $this->dataGrid->addColumn('edit', null, BL::getLabel('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]', BL::getLabel('Edit')); }
/** * Load the datagrid with the recently edited items * * @return void */ 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('BackendDataGridFunctions', 'getUser'), array('[user_id]'), 'user_id'); $this->dgRecentlyEdited->setColumnFunction(array('BackendDataGridFunctions', 'getTimeAgo'), array('[edited_on]'), 'edited_on'); // 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')); // set headers $this->dgRecentlyEdited->setHeaderLabels(array('user_id' => ucfirst(BL::lbl('By')), 'edited_on' => ucfirst(BL::lbl('LastEdited')))); }
/** * Loads the dataGrid */ private function loadDataGrid() { // create dataGrid $this->dataGrid = new BackendDataGridDB(BackendFaqModel::QRY_DATAGRID_BROWSE_CATEGORIES, BL::getWorkingLanguage()); $this->dataGrid->setHeaderLabels(array('num_items' => SpoonFilter::ucfirst(BL::lbl('Amount')))); $this->dataGrid->enableSequenceByDragAndDrop(); $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('edit_category')) { $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('edit_category') . '&id=[id]'); $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_category') . '&id=[id]', BL::lbl('Edit')); } }
/** * Execute the action */ public function execute() { parent::execute(); $generalSettings = BackendModel::getModuleSettings(); $generalSettings = $generalSettings['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', 'satelitte', 'hybrid', 'terrain'), 'roadmap'))); $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, '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, FL::msg('Success')); }
/** * Validate the form * * @return void */ 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 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')); // no errors? if ($this->frm->isCorrect()) { // build item $item['language'] = BL::getWorkingLanguage(); $item['title'] = $this->frm->getField('title')->getValue(); $item['text'] = $this->frm->getField('text')->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(); // geocode address $url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($item['street'] . ' ' . $item['number'] . ', ' . $item['zip'] . ' ' . $item['city'] . ', ' . SpoonLocale::getCountry($item['country'], BL::getWorkingLanguage())) . '&sensor=false'; $geocode = json_decode(SpoonHTTP::getContent($url)); $item['lat'] = isset($geocode->results[0]->geometry->location->lat) ? $geocode->results[0]->geometry->location->lat : null; $item['lng'] = isset($geocode->results[0]->geometry->location->lng) ? $geocode->results[0]->geometry->location->lng : null; // insert the item $id = BackendLocationModel::insert($item); // add search index // if(is_callable(array('BackendSearchModel', 'addIndex'))) BackendSearchModel::addIndex($this->getModule(), (int) $id, array('title' => $item['title'], 'text' => $item['text'])); // 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('index') . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $id); } else { $this->redirect(BackendModel::createURLForAction('edit') . '&id=' . $id); } } } }
/** * Loads the datagrids * * @return void */ 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' => ucfirst(BL::lbl('Amount')))); // sorting columns $this->dataGrid->setSortingColumns(array('title', 'num_items'), 'title'); // set column URLs $this->dataGrid->setColumnURL('title', BackendModel::createURLForAction('edit_category') . '&id=[id]'); // 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); // add column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit_category') . '&id=[id]', BL::lbl('Edit')); // 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]}')); }
/** * Load the form */ private function loadForm() { // create form $this->frm = new BackendForm('import'); // create elements $this->frm->addFile('csv'); // dropdown for languages $this->frm->addDropdown('languages', BL::getWorkingLanguages(), BL::getWorkingLanguage()); // fetch groups $groups = BackendMailmotorModel::getGroupsForCheckboxes(); // if no groups are found, redirect to overview if (empty($groups)) { $this->redirect(BackendModel::createURLForAction('addresses') . '&error=no-groups'); } // add radiobuttons for groups $this->frm->addRadiobutton('groups', $groups, empty($this->groupId) ? null : $this->groupId); // show the form $this->tpl->assign('import', true); }
/** * Loads the datagrids * * @return void */ private function loadDataGrid() { // create datagrid $this->dataGrid = new BackendDataGridDB(BackendTagsModel::QRY_DATAGRID_BROWSE, BL::getWorkingLanguage()); // header labels $this->dataGrid->setHeaderLabels(array('tag' => ucfirst(BL::lbl('Name')), 'num_tags' => 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('checkbox', '[id]'); // add mass action dropdown $ddmMassAction = new SpoonFormDropdown('action', array('delete' => BL::lbl('Delete')), 'delete'); $ddmMassAction->setOptionAttributes('delete', array('message-id' => 'confirmDelete')); $this->dataGrid->setMassAction($ddmMassAction); // add column $this->dataGrid->addColumn('edit', null, BL::lbl('Edit'), BackendModel::createURLForAction('edit') . '&id=[id]', BL::lbl('Edit')); // add attributes, so the inline editing has all the needed data $this->dataGrid->setColumnAttributes('tag', array('data-id' => '{id:[id]}')); }
/** * 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=' . urlencode($page['title'])); } else { $this->redirect(BackendModel::createURLForAction('edit') . '&error=non-existing'); } } else { $this->redirect(BackendModel::createURLForAction('edit') . '&error=non-existing'); } }
/** * Validate the form */ private function validateForm() { if ($this->frm->isSubmitted()) { $this->meta->setURLCallback('BackendFaqModel', '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=' . urlencode($item['title']) . '&highlight=row-' . $item['id']); } } }