Exemplo n.º 1
0
 public function insert_block()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('design/blocks');
     $this->loadLanguage('banner_manager/banner_manager');
     $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'];
     if ($this->request->is_POST() && $this->_validateBlockForm()) {
         if (isset($this->session->data['layout_params'])) {
             $layout = new ALayoutManager($this->session->data['layout_params']['tmpl_id'], $this->session->data['layout_params']['page_id'], $this->session->data['layout_params']['layout_id']);
             $blocks = $layout->getLayoutBlocks();
             if ($blocks) {
                 foreach ($blocks as $block) {
                     if ($block['block_id'] == $this->session->data['layout_params']['parent_block_id']) {
                         $parent_instance_id = $block['instance_id'];
                         $position = 0;
                         if ($block['children']) {
                             foreach ($block['children'] as $child) {
                                 $position = $child['position'] > $position ? $child['position'] : $position;
                             }
                         }
                         break;
                     }
                 }
             }
             $savedata = $this->session->data['layout_params'];
             $savedata['parent_instance_id'] = $parent_instance_id;
             $savedata['position'] = $position + 10;
             $savedata['status'] = 1;
         } else {
             $layout = new ALayoutManager();
         }
         $content = '';
         if ($this->request->post['banner_group_name']) {
             $content = serialize(array('banner_group_name' => $this->request->post['banner_group_name']));
         }
         $custom_block_id = $layout->saveBlockDescription($this->data['block_id'], 0, 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 custom_block in layout
         if (isset($this->session->data['layout_params'])) {
             $savedata['custom_block_id'] = $custom_block_id;
             $savedata['block_id'] = $this->data['block_id'];
             $layout->saveLayoutBlocks($savedata);
             unset($this->session->data['layout_params']);
         }
         // save list if it is custom
         if ($this->request->post['block_banners']) {
             $listing_manager = new AListingManager($custom_block_id);
             $listing_manager->deleteCustomListing();
             foreach ($this->request->post['block_banners'] as $k => $id) {
                 $listing_manager->saveCustomListItem(array('data_type' => 'banner_id', 'id' => (int) $id, 'sort_order' => (int) $k));
             }
         }
         $this->session->data['success'] = $this->language->get('text_banner_success');
         $this->redirect($this->html->getSecureURL('extension/banner_manager/edit_block', '&custom_block_id=' . $custom_block_id));
     }
     foreach ($this->request->post as $k => $v) {
         $this->data[$k] = $v;
     }
     $blocks = array();
     $custom_block_types = array('html_block', 'listing_block');
     foreach ($custom_block_types as $txt_id) {
         $block = $lm->getBlockByTxtId($txt_id);
         if ($block['block_id']) {
             $blocks[$block['block_id']] = $this->language->get('text_' . $txt_id);
         }
     }
     foreach ($blocks as $block_text) {
         $this->data['tabs'][] = array('href' => $this->html->getSecureURL('design/blocks/insert', '&block_id=' . $this->data['block_id']), 'text' => $block_text, 'active' => false);
     }
     $this->data['tabs'][] = 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__);
 }
 public function insert()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->setTitle($this->language->get('heading_title'));
     $block_id = (int) $this->request->get['block_id'] ? (int) $this->request->get['block_id'] : (int) $this->request->post['block_id'];
     // now need to know what custom block is this
     $lm = new ALayoutManager();
     $blocks = $lm->getAllBlocks();
     foreach ($blocks as $block) {
         if ($block['block_id'] == $block_id) {
             $block_txt_id = $block['block_txt_id'];
             break;
         }
     }
     if ($this->request->is_POST() && $this->_validateForm()) {
         if (isset($this->session->data['layout_params'])) {
             $layout = new ALayoutManager($this->session->data['layout_params']['tmpl_id'], $this->session->data['layout_params']['page_id'], $this->session->data['layout_params']['layout_id']);
             $blocks = $layout->getLayoutBlocks();
             if ($blocks) {
                 foreach ($blocks as $block) {
                     if ($block['block_id'] == $this->session->data['layout_params']['parent_block_id']) {
                         $parent_instance_id = $block['instance_id'];
                         $position = 0;
                         if ($block['children']) {
                             foreach ($block['children'] as $child) {
                                 $position = $child['position'] > $position ? $child['position'] : $position;
                             }
                         }
                         break;
                     }
                 }
             }
             $savedata = $this->session->data['layout_params'];
             $savedata['parent_instance_id'] = $parent_instance_id;
             $savedata['position'] = $position + 10;
             $savedata['status'] = 1;
         } else {
             $layout = new ALayoutManager();
         }
         switch ($block_txt_id) {
             case 'listing_block':
                 $content = array('listing_datasource' => $this->request->post['listing_datasource']);
                 if (strpos($content['listing_datasource'], 'custom_') === FALSE) {
                     $content['limit'] = $this->request->post['limit'];
                 }
                 if ($content['listing_datasource'] == 'media') {
                     $content['resource_type'] = $this->request->post['resource_type'];
                 }
                 $content = serialize($content);
                 break;
             case 'html_block':
                 $content = $this->request->post['block_content'];
                 break;
             default:
                 $this->redirect($this->html->getSecureURL('design/blocks'));
                 break;
         }
         $custom_block_id = $layout->saveBlockDescription($block_id, 0, 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']));
         // save custom_block in layout
         if (isset($this->session->data['layout_params'])) {
             $savedata['custom_block_id'] = $custom_block_id;
             $savedata['block_id'] = $block_id;
             $layout->saveLayoutBlocks($savedata);
             unset($this->session->data['layout_params']);
         }
         // save list if it is custom
         if (strpos($this->request->post['listing_datasource'], 'custom_') !== FALSE) {
             $listing_manager = new AListingManager($custom_block_id);
             if ($this->request->post['selected']) {
                 $listing_manager->deleteCustomListing();
                 $k = 0;
                 foreach ($this->request->post['selected'] as $id) {
                     $listing_manager->saveCustomListItem(array('listing_datasource' => $this->request->post['listing_datasource'], 'id' => $id, 'limit' => $this->request->post['limit'], 'sort_order' => (int) $k));
                     $k++;
                 }
             }
         }
         $this->session->data['success'] = $this->language->get('text_success');
         unset($this->session->data['custom_list_changes'][$custom_block_id], $this->session->data['layout_params']);
         $this->redirect($this->html->getSecureURL('design/blocks/edit', '&custom_block_id=' . $custom_block_id));
     }
     // if we need to save new block in layout - keep parameters in session
     if (!isset($this->session->data['layout_params']) && isset($this->request->get['layout_id'])) {
         $this->session->data['layout_params']['layout_id'] = $this->request->get['layout_id'];
         $this->session->data['layout_params']['page_id'] = $this->request->get['page_id'] ? $this->request->get['page_id'] : 1;
         $this->session->data['layout_params']['tmpl_id'] = $this->request->get['tmpl_id'];
         $this->session->data['layout_params']['parent_block_id'] = $this->request->get['parent_block_id'];
     }
     $this->initTabs();
     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__);
 }
Exemplo n.º 3
0
 public function insert_block()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('design/blocks');
     $this->loadLanguage('forms_manager/forms_manager');
     $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'];
     if ($this->request->is_POST() && $this->_validateBlockForm()) {
         if (isset($this->session->data['layout_params'])) {
             $layout = new ALayoutManager($this->session->data['layout_params']['tmpl_id'], $this->session->data['layout_params']['page_id'], $this->session->data['layout_params']['layout_id']);
             $blocks = $layout->getLayoutBlocks();
             if ($blocks) {
                 foreach ($blocks as $block) {
                     if ($block['block_id'] == $this->session->data['layout_params']['parent_block_id']) {
                         $parent_instance_id = $block['instance_id'];
                         $position = 10;
                         if ($block['children']) {
                             foreach ($block['children'] as $child) {
                                 $position = $position > $child['position'] ? $child['position'] : $position;
                             }
                         }
                         break;
                     }
                 }
             } else {
                 $position = 0;
             }
             $savedata = $this->session->data['layout_params'];
             $savedata['parent_instance_id'] = $parent_instance_id;
             $savedata['position'] = $position + 10;
             $savedata['status'] = 1;
         } else {
             $layout = new ALayoutManager();
         }
         $content = isset($this->request->post['form_id']) ? serialize(array('form_id' => $this->request->post['form_id'])) : array();
         $custom_block_id = $layout->saveBlockDescription($this->data['block_id'], 0, 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'] > 0 ? 1 : 0, 'language_id' => $this->language->getContentLanguageID()));
         $layout->editBlockStatus((int) $this->request->post['block_status'], $this->data['block_id'], $custom_block_id);
         // save custom_block in layout
         if (isset($this->session->data['layout_params'])) {
             $savedata['custom_block_id'] = $custom_block_id;
             $savedata['block_id'] = $this->data['block_id'];
             $layout->saveLayoutBlocks($savedata);
             unset($this->session->data['layout_params']);
         }
         // 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));
     }
     foreach ($this->request->post as $k => $v) {
         $this->data[$k] = $v;
     }
     $this->_init_tabs();
     $this->_getBlockForm();
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 public function insert_block()
 {
     $this->loadLanguage('design/blocks');
     $this->loadLanguage('developer_tools/developer_tools');
     if ($this->request->is_POST() && $this->_validateBlockForm()) {
         if (isset($this->session->data['layout_params'])) {
             $layout = new ALayoutManager($this->session->data['layout_params']['tmpl_id'], $this->session->data['layout_params']['page_id'], $this->session->data['layout_params']['layout_id']);
             $blocks = $layout->getLayoutBlocks();
             if ($blocks) {
                 foreach ($blocks as $block) {
                     if ($block['block_id'] == $this->session->data['layout_params']['parent_block_id']) {
                         $parent_instance_id = $block['instance_id'];
                         $position = 10;
                         if ($block['children']) {
                             foreach ($block['children'] as $child) {
                                 $position = $position > $child['position'] ? $child['position'] : $position;
                             }
                         }
                         break;
                     }
                 }
             }
             $savedata = $this->session->data['layout_params'];
             $savedata['parent_instance_id'] = $parent_instance_id;
             $savedata['position'] = $position + 10;
             $savedata['status'] = 1;
         } else {
             $layout = new ALayoutManager();
         }
         //prepare data
         $data = $this->request->post;
         foreach ($data['templates'] as $i => $tpl) {
             if (!$tpl['template']) {
                 unset($data['templates'][$i]);
             }
         }
         //check is templates already in main.php file of extension
         $this->_check4NewTemplates($data);
         // saving block
         $block_id = $layout->saveBlock($data);
         // save block in layout
         if (isset($this->session->data['layout_params'])) {
             $savedata['block_id'] = $block_id;
             $layout->saveLayoutBlocks($savedata);
             unset($this->session->data['layout_params']);
         }
         $this->session->data['success'] = $this->language->get('developer_tools_text_success_block_save');
         $this->redirect($this->html->getSecureURL('tool/developer_tools/edit_block', '&block_id=' . $block_id));
     }
     $this->document->setTitle($this->language->get('developer_tools_text_create_block'));
     $this->data['heading_title'] = $this->language->get('developer_tools_text_create_block');
     foreach ($this->request->post as $k => $v) {
         $this->data[$k] = $v;
     }
     $this->_check4NewTemplates($data);
     $this->_getBlockForm();
 }