public function onControllerPagesDesignBlocks_InitData() { $method_name = func_get_arg(0); if ($method_name == 'insert') { $lm = new ALayoutManager(); $this->baseObject->loadLanguage('banner_manager/banner_manager'); $this->baseObject->loadLanguage('design/blocks'); $block = $lm->getBlockByTxtId('banner'); $block_id = $block['block_id']; $this->baseObject->data['tabs'][1000] = array('href' => $this->html->getSecureURL('extension/banner_manager/insert_block', '&block_id=' . $block_id), 'text' => $this->language->get('text_banner_block'), 'active' => false); } if ($method_name == 'edit') { $lm = new ALayoutManager(); $blocks = $lm->getAllBlocks(); foreach ($blocks as $block) { if ($block['custom_block_id'] == (int) $this->request->get['custom_block_id']) { $block_txt_id = $block['block_txt_id']; break; } } if ($block_txt_id == 'banner_block') { header('Location: ' . $this->html->getSecureURL('extension/banner_manager/edit_block', '&custom_block_id=' . (int) $this->request->get['custom_block_id'])); exit; } } }
public function onControllerPagesExtensionBannerManager_UpdateData() { if ($this->baseObject_method == 'edit') { $lm = new ALayoutManager(); $blocks = $lm->getAllBlocks(); foreach ($blocks as $block) { if ($block['custom_block_id'] == (int) $this->request->get['custom_block_id']) { $block_txt_id = $block['block_txt_id']; break; } } if ($block_txt_id == 'custom_form_block') { header('Location: ' . $this->html->getSecureURL('tool/forms_manager/edit_block', '&custom_block_id=' . (int) $this->request->get['custom_block_id'])); exit; } } }
public function onControllerPagesDesignBlocks_InitData() { $this->baseObject->loadLanguage('banner_manager/banner_manager'); $method_name = $this->baseObject_method; if ($method_name == 'edit') { $lm = new ALayoutManager(); $blocks = $lm->getAllBlocks(); foreach ($blocks as $block) { if ($block['custom_block_id'] == (int) $this->request->get['custom_block_id']) { $block_txt_id = $block['block_txt_id']; break; } } if ($block_txt_id == 'banner_block') { header('Location: ' . $this->html->getSecureURL('extension/banner_manager/edit_block', '&custom_block_id=' . (int) $this->request->get['custom_block_id'])); exit; } } }
public function onControllerPagesExtensionBannerManager_UpdateData() { if ($this->baseObject_method == 'insert_block') { $lm = new ALayoutManager(); $block = $lm->getBlockByTxtId('custom_form_block'); $block_id = $block['block_id']; $this->baseObject->data['tabs'][1001] = array('href' => $this->html->getSecureURL('tool/forms_manager/insert_block', '&block_id=' . $block_id), 'text' => $this->language->get('custom_forms_block'), 'active' => false); $this->baseObject->view->assign('tabs', $this->baseObject->data['tabs']); } if ($this->baseObject_method == 'edit') { $lm = new ALayoutManager(); $blocks = $lm->getAllBlocks(); foreach ($blocks as $block) { if ($block['custom_block_id'] == (int) $this->request->get['custom_block_id']) { $block_txt_id = $block['block_txt_id']; break; } } if ($block_txt_id == 'custom_form_block') { header('Location: ' . $this->html->getSecureURL('tool/forms_manager/edit_block', '&custom_block_id=' . (int) $this->request->get['custom_block_id'])); exit; } } }
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__); }
public function edit_block() { $this->loadLanguage('developer_tools/developer_tools'); $this->loadLanguage('design/blocks'); $block_id = (int) $this->request->get['block_id']; if (!$block_id) { $this->redirect($this->html->getSecureURL('tool/developer_tools/insert_block')); } $layout = new ALayoutManager(); if ($this->request->is_POST() && $this->_validateBlockForm()) { // saving //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, $block_id); $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_edit_block')); $this->data['heading_title'] = $this->language->get('developer_tools_text_edit_block'); $all_blocks = $layout->getAllBlocks(); foreach ($all_blocks as $k => $block) { if ($block_id == $block['block_id'] && !$block['custom_block_id']) { $this->data['block_info']['block_txt_id'] = $block['block_txt_id']; $this->data['block_info']['controller'] = $block['controller']; if ($block['parent_block_id']) { foreach ($all_blocks as $b) { if ($b['block_id'] == $block['parent_block_id']) { $this->data['block_info']['templates'][$k]['parent_block_txt_id'] = $b['block_txt_id']; } } } $this->data['block_info']['templates'][$k]['template'] = $block['template']; } } $this->data['block_info']['templates'] = array_values($this->data['block_info']['templates']); $this->_getBlockForm(); }