Example #1
0
 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__);
 }
Example #2
0
 public function edit_block()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('banner_manager/banner_manager');
     $this->loadLanguage('design/blocks');
     $this->document->setTitle($this->language->get('banner_manager_name'));
     $this->data['heading_title'] = $this->language->get('text_banner_block');
     $lm = new ALayoutManager();
     $block = $lm->getBlockByTxtId('banner_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('extension/banner_manager/insert_block'));
     }
     $layout = new ALayoutManager();
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->_validateBlockForm()) {
         $content = '';
         if ($this->request->post['banner_group_name']) {
             $content = serialize(array('banner_group_name' => $this->request->post['banner_group_name']));
         }
         // saving
         $layout->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, 'status' => (int) $this->request->post['block_status'], 'block_wrapper' => $this->request->post['block_wrapper'], 'block_framed' => $this->request->post['block_framed'], 'language_id' => $this->session->data['content_language_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' => 'banner_id', 'id' => $id, 'sort_order' => (int) $info['sort_order']));
                 } else {
                     $listing_manager->deleteCustomListItem(array('data_type' => 'banner_id', 'id' => $id));
                 }
             }
         }
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect($this->html->getSecureURL('extension/banner_manager/edit_block', '&custom_block_id=' . $custom_block_id));
     }
     $this->data['tabs'][0] = array('href' => $this->html->getSecureURL('extension/banner_manager/insert_block', '&block_id=' . $this->data['block_id']), 'text' => $this->language->get('text_banner_block'), 'active' => true);
     $this->_getBlockForm();
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Example #3
0
 public function edit()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->setTitle($this->language->get('heading_title'));
     $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->server['REQUEST_METHOD'] == '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) {
                     $this->request->post['selected'] = json_decode(html_entity_decode($this->request->post['selected'][0]), true);
                     if ($this->request->post['selected']) {
                         foreach ($this->request->post['selected'] as $id => $info) {
                             if ($info['status']) {
                                 $listing_manager->saveCustomListItem(array('listing_datasource' => $content['listing_datasource'], 'id' => $id, 'limit' => $this->request->post['limit'], 'sort_order' => $info['sort_order']));
                             } else {
                                 $listing_manager->deleteCustomListItem(array('listing_datasource' => $content['listing_datasource'], 'id' => $id));
                             }
                         }
                     }
                 } 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, 'status' => (int) $this->request->post['block_status'], 'block_wrapper' => $this->request->post['block_wrapper'], 'block_framed' => (int) $this->request->post['block_framed'], 'language_id' => $this->session->data['content_language_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__);
 }