public function edit_block() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('forms_manager/forms_manager'); $this->loadLanguage('design/blocks'); $this->document->setTitle($this->language->get('forms_manager_name')); $this->data['heading_title'] = $this->language->get('custom_forms_block'); $lm = new ALayoutManager(); $block = $lm->getBlockByTxtId('custom_form_block'); $this->data['block_id'] = $block['block_id']; $custom_block_id = (int) $this->request->get['custom_block_id']; if (!$custom_block_id) { $this->redirect($this->html->getSecureURL('tool/forms_manager/insert_block')); } $tabs = array(array('name' => '', 'text' => $this->language->get('custom_forms_block'), 'href' => '', 'active' => true, 'sort_order' => 0)); $obj = $this->dispatch('responses/common/tabs', array('tool/forms_manager/edit_block', array('tabs' => $tabs))); $this->data['tabs'] = $obj->dispatchGetOutput(); if ($this->request->is_POST() && $this->_validateBlockForm()) { // get form html $content = array(); if (isset($this->request->post['form_id'])) { $content['form_id'] = $this->request->post['form_id']; } $content = serialize($content); // saving $lm->saveBlockDescription($this->data['block_id'], $custom_block_id, array('name' => $this->request->post['block_name'], 'title' => $this->request->post['block_title'], 'description' => $this->request->post['block_description'], 'content' => $content, 'block_wrapper' => $this->request->post['block_wrapper'], 'block_framed' => $this->request->post['block_framed'], 'language_id' => $this->language->getContentLanguageID())); $lm->editBlockStatus((int) $this->request->post['block_status'], $this->data['block_id'], $custom_block_id); // save list if it is custom $this->request->post['selected'] = json_decode(html_entity_decode($this->request->post['selected'][0]), true); if ($this->request->post['selected']) { $listing_manager = new AListingManager($custom_block_id); foreach ($this->request->post['selected'] as $id => $info) { if ($info['status']) { $listing_manager->saveCustomListItem(array('data_type' => 'form_id', 'id' => $id, 'sort_order' => (int) $info['sort_order'])); } else { $listing_manager->deleteCustomListItem(array('data_type' => 'form_id', 'id' => $id)); } } } $this->session->data['success'] = $this->language->get('text_success'); $this->redirect($this->html->getSecureURL('tool/forms_manager/edit_block', '&custom_block_id=' . $custom_block_id)); } $this->_getBlockForm(); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function update_field() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!$this->user->canModify('listing_grid/blocks_grid')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/blocks_grid'), 'reset_value' => true)); } $this->loadLanguage('design/blocks'); $custom_block_id = (int) $this->request->get['custom_block_id']; $layout = new ALayoutManager(); if ($this->request->is_POST()) { $tmp = array(); if (isset($this->request->post['block_status'])) { $tmp['status'] = (int) $this->request->post['block_status']; } if (isset($this->request->post['block_name'])) { $tmp['name'] = $this->request->post['block_name']; } if (isset($this->request->post['block_title'])) { $tmp['title'] = $this->request->post['block_title']; } if (isset($this->request->post['block_description'])) { $tmp['description'] = $this->request->post['block_description']; } if (isset($this->request->post['block_content'])) { $tmp['content'] = $this->request->post['block_content']; } if (isset($this->request->post['block_wrapper'])) { $tmp['block_wrapper'] = $this->request->post['block_wrapper']; } if (isset($this->request->post['block_framed'])) { $tmp['block_framed'] = (int) $this->request->post['block_framed']; } $tmp['language_id'] = $this->language->getContentLanguageID(); $layout->saveBlockDescription((int) $this->request->post['block_id'], $custom_block_id, $tmp); if (isset($tmp['status'])) { $layout->editBlockStatus($tmp['status'], (int) $this->request->post['block_id'], $custom_block_id); $info = $layout->getBlockDescriptions($custom_block_id); if ($info[$tmp['language_id']]['status'] != $tmp['status']) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_406', array('error_text' => $this->language->get('error_text_status'), 'reset_value' => true)); } } } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function edit() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->document->setTitle($this->language->get('heading_title')); if (is_int(strpos($this->request->get['custom_block_id'], '_'))) { $t = explode('_', $this->request->get['custom_block_id']); $custom_block_id = $t[1]; } else { $custom_block_id = (int) $this->request->get['custom_block_id']; } // now need to know what custom block is this $lm = new ALayoutManager(); $blocks = $lm->getAllBlocks(); foreach ($blocks as $block) { if ($block['custom_block_id'] == $custom_block_id) { $block_txt_id = $block['block_txt_id']; break; } } $layout = new ALayoutManager(); // saving if ($this->request->is_POST() && $this->_validateForm()) { switch ($block_txt_id) { case 'listing_block': $content = array('listing_datasource' => $this->request->post['listing_datasource']); $listing_manager = new AListingManager($custom_block_id); // need to check previous listing_datasource of that block $block_info = $lm->getBlockDescriptions($custom_block_id); $block_info = current($block_info); $block_info['content'] = unserialize($block_info['content']); // if datasource changed - drop custom list if ($block_info['content']['listing_datasource'] != $content['listing_datasource']) { $listing_manager->deleteCustomListing(); } if (strpos($content['listing_datasource'], 'custom_') !== FALSE) { if ($this->request->post['selected']) { $listing_manager->deleteCustomListing(); $k = 0; foreach ($this->request->post['selected'] as $id) { $listing_manager->saveCustomListItem(array('listing_datasource' => $content['listing_datasource'], 'id' => $id, 'limit' => $this->request->post['limit'], 'sort_order' => $k)); $k++; } } } else { if ($content['listing_datasource'] == 'media') { $content['resource_type'] = $this->request->post['resource_type']; } $content['limit'] = $this->request->post['limit']; } $content = serialize($content); break; case 'html_block': $content = $this->request->post['block_content']; break; default: $this->redirect($this->html->getSecureURL('design/blocks')); break; } $layout->saveBlockDescription(0, $custom_block_id, array('name' => $this->request->post['block_name'], 'title' => $this->request->post['block_title'], 'description' => $this->request->post['block_description'], 'content' => $content, 'block_wrapper' => $this->request->post['block_wrapper'], 'block_framed' => (int) $this->request->post['block_framed'], 'language_id' => $this->session->data['content_language_id'])); $layout->editBlockStatus((int) $this->request->post['block_status'], 0, $custom_block_id); $this->session->data['success'] = $this->language->get('text_success'); $this->redirect($this->html->getSecureURL('design/blocks/edit', '&custom_block_id=' . $custom_block_id)); } // end of saving $info = $layout->getBlockDescriptions($custom_block_id); if (isset($info[$this->session->data['content_language_id']])) { $info = $info[$this->session->data['content_language_id']]; } else { $info = current($info); unset($info['name'], $info['title'], $info['description']); } foreach ($info as $k => $v) { $this->data[$k] = $v; } $this->data['tabs'][0] = array('href' => '', 'text' => $this->language->get('text_' . $block_txt_id), 'active' => true); switch ($block_txt_id) { case 'listing_block': $this->_getListingForm(); break; case 'html_block': default: $this->_getHTMLForm(); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }