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 == '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; } } }
private function _getBlockForm() { if (isset($this->session->data['warning'])) { $this->data['error_warning'] = $this->session->data['warning']; $this->session->data['warning'] = ''; } else { $this->data['error_warning'] = ''; } $this->load->library('json'); $this->view->assign('success', $this->session->data['success']); if (isset($this->session->data['success'])) { unset($this->session->data['success']); } $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('design/blocks'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ')); $this->data['cancel'] = $this->html->getSecureURL('design/blocks'); $custom_block_id = (int) $this->request->get['custom_block_id']; // need to get data of custom listing $options_list = array(); if ($custom_block_id) { $lm = new ALayoutManager(); $block_info = $lm->getBlockDescriptions($custom_block_id); $language_id = $this->session->data['content_language_id']; if (!isset($block_info[$language_id])) { $language_id = key($block_info); } foreach ($block_info[$language_id] as $k => $v) { $this->data[$k] = $v; } $content = $block_info[$this->language->getContentLanguageID()]['content']; if ($content) { $content = unserialize($content); } else { $content = current($block_info); $content = unserialize($content['content']); } $this->data['banner_group_name'] = $content['banner_group_name']; $lm = new AListingManager($this->request->get['custom_block_id']); $list = $lm->getCustomList(); $options_list = array(); if ($list) { foreach ($list as $row) { $options_list[(int) $row['id']] = array(); } $ids = array_keys($options_list); $assigned_banners = $this->model_extension_banner_manager->getBanners(array('subsql_filter' => 'b.banner_id IN (' . implode(', ', $ids) . ')')); $rm = new AResourceManager(); $rm->setType('image'); foreach ($assigned_banners as $banner) { $id = $banner['banner_id']; if (in_array($id, $ids)) { $thumbnail = $rm->getMainThumb('banners', $banner['banner_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), false); $icon = $thumbnail['thumb_html'] ? $thumbnail['thumb_html'] : '<i class="fa fa-code fa-4x"></i> '; $options_list[$id] = array('image' => $icon, 'id' => $id, 'name' => $banner['name'], 'sort_order' => (int) $banner['sort_order']); } } } } if (!$custom_block_id) { $this->data['action'] = $this->html->getSecureURL('extension/banner_manager/insert_block'); $this->data['form_title'] = $this->language->get('text_create_block'); $this->data['update'] = ''; $form = new AForm('ST'); } else { $this->data['action'] = $this->html->getSecureURL('extension/banner_manager/edit_block', '&custom_block_id=' . $custom_block_id); $this->data['form_title'] = $this->language->get('text_edit') . ' ' . $this->data['name']; $this->data['update'] = $this->html->getSecureURL('listing_grid/blocks_grid/update_field', '&custom_block_id=' . $custom_block_id); $form = new AForm('HS'); } $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['form_title'], 'separator' => ' :: ', 'current' => true)); $form->setForm(array('form_name' => 'BannerBlockFrm', 'update' => $this->data['update'])); $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'BannerBlockFrm', 'action' => $this->data['action'], 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"')); $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1')); $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2')); if ($custom_block_id) { $this->data['form']['fields']['block_status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'block_status', 'value' => $this->data['status'], 'style' => 'btn_switch')); $this->data['form']['text']['block_status'] = $this->html->convertLinks($this->language->get('entry_block_status')); $this->data['form']['fields']['block_status_note'] = ''; $this->data['form']['text']['block_status_note'] = $this->html->convertLinks($this->language->get('entry_block_status_note')); } $this->data['form']['fields']['block_name'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'block_id', 'value' => $this->data['block_id'])); $this->data['form']['fields']['block_name'] .= $form->getFieldHtml(array('type' => 'input', 'name' => 'block_name', 'value' => $this->data['name'], 'required' => true)); $this->data['form']['text']['block_name'] = $this->language->get('entry_block_name'); $this->data['form']['fields']['block_title'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'block_title', 'required' => true, 'value' => $this->data['title'])); $this->data['form']['text']['block_title'] = $this->language->get('entry_block_title'); // list of templates for block $tmpl_ids = $this->extensions->getInstalled('template'); $tmpl_ids[] = 'default'; $this->data['block_wrappers'] = array(); foreach ($tmpl_ids as $tmpl_id) { // for tpls of block that stores in db $layout_manager = new ALayoutManager($tmpl_id); $block = $layout_manager->getBlockByTxtId('banner_block'); $block_templates = (array) $layout_manager->getBlockTemplates($block['block_id']); foreach ($block_templates as $item) { if ($item['template']) { $this->data['block_wrappers'][$item['template']] = $item['template']; } } //Automatic block template selection mode based on parent is limited to 1 template per location //To extend, allow custom block's template to be selected to suppress automatic selection //for tpls that stores in main.php (other extensions templates) $ext_tpls = $this->extensions->getExtensionTemplates(); foreach ($ext_tpls as $section) { foreach ($section as $s => $tpls) { if ($s != 'storefront') { continue; } foreach ($tpls as $tpl) { if (isset($this->data['block_wrappers'][$tpl]) || strpos($tpl, 'blocks/banner_block/') === false) { continue; } $this->data['block_wrappers'][$tpl] = $tpl; } } } $tpls = glob(DIR_STOREFRONT . 'view/*/template/blocks/banner_block/*.tpl'); foreach ($tpls as $tpl) { $pos = strpos($tpl, 'blocks/banner_block/'); $tpl = substr($tpl, $pos); if (!isset($this->data['block_wrappers'][$tpl])) { $this->data['block_wrappers'][$tpl] = $tpl; } } } ksort($this->data['block_wrappers']); array_unshift($this->data['block_wrappers'], $this->language->get('text_automatic')); if ($this->data['block_wrapper'] && !isset($this->data['block_wrappers'][$this->data['block_wrapper']])) { $this->data['block_wrappers'] = array_merge(array($this->data['block_wrapper'] => $this->data['block_wrapper']), $this->data['block_wrappers']); } $this->data['form']['fields']['block_wrapper'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'block_wrapper', 'options' => $this->data['block_wrappers'], 'value' => $this->data['block_wrapper'], 'help_url' => $this->gen_help_url('block_wrapper'))); $this->data['form']['text']['block_wrapper'] = $this->language->get('entry_block_wrapper'); $this->data['form']['fields']['block_framed'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'block_framed', 'value' => $this->data['block_framed'], 'style' => 'btn_switch', 'help_url' => $this->gen_help_url('block_framed'))); $this->data['form']['text']['block_framed'] = $this->language->get('entry_block_framed'); $this->data['form']['fields']['block_description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'block_description', 'value' => $this->data['description'], 'attr' => ' style="height: 50px;"')); $this->data['form']['text']['block_description'] = $this->language->get('entry_block_description'); // groups of banners $this->loadModel('extension/banner_manager'); $result = $this->model_extension_banner_manager->getBannerGroups(); $groups = array('0' => $this->language->get('text_select')); if ($result) { foreach ($result as $row) { $groups[$row['banner_group_name']] = $row['banner_group_name']; } } $this->data['form']['fields']['banner_group_name'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'banner_group_name', 'options' => $groups, 'value' => $this->data['banner_group_name'], 'style' => 'no-save')); $this->data['form']['text']['banner_group_name'] = $this->language->get('entry_banner_group_name'); $this->data['form']['text']['listed_banners'] = $this->language->get('entry_banners_selected'); //load only prior saved products $this->data['banners'] = array(); $this->data['form']['fields']['listed_banners'] = $form->getFieldHtml(array('type' => 'multiselectbox', 'name' => 'block_banners[]', 'value' => $ids, 'options' => $options_list, 'style' => 'no-save chosen', 'ajax_url' => $this->html->getSecureURL('listing_grid/banner_manager/banners'), 'placeholder' => $this->language->get('text_select_from_lookup'))); $this->view->batchAssign($this->language->getASet()); $this->view->batchAssign($this->data); $this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher()); $this->view->assign('language_code', $this->session->data['language']); $this->view->assign('help_url', $this->gen_help_url('banner_edit')); $this->view->assign('rl', $this->html->getSecureURL('common/resource_library', '&object_name=banners&type=image&mode=url')); $this->processTemplate('pages/extension/banner_manager_block_form.tpl'); }
private function _getBlockForm() { if (isset($this->session->data['warning'])) { $this->data['error_warning'] = $this->session->data['warning']; $this->session->data['warning'] = ''; } else { $this->data['error_warning'] = ''; } $this->load->library('json'); $this->view->assign('success', $this->session->data['success']); if (isset($this->session->data['success'])) { unset($this->session->data['success']); } $locale = $this->session->data['language']; if (!file_exists(DIR_ROOT . '/' . RDIR_TEMPLATE . 'javascript/jqgrid/js/i18n/grid.locale-' . $locale . '.js')) { $locale = 'en'; } $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/i18n/grid.locale-' . $locale . '.js'); $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/jquery.jqGrid.min.js'); $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/plugins/jquery.grid.fluid.js'); $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/jquery.ba-bbq.min.js'); $this->document->addScript(RDIR_TEMPLATE . 'javascript/jqgrid/js/grid.history.js'); $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('design/blocks'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ')); $this->data['cancel'] = $this->html->getSecureURL('design/blocks'); $custom_block_id = (int) $this->request->get['custom_block_id']; // need to get data of custom listing $listing_data = array(); if ($custom_block_id) { $lm = new ALayoutManager(); $block_info = $lm->getBlockDescriptions($custom_block_id); $language_id = $this->session->data['content_language_id']; if (!isset($block_info[$language_id])) { $language_id = key($block_info); } foreach ($block_info[$language_id] as $k => $v) { $this->data[$k] = $v; } $content = $block_info[$this->session->data['content_language_id']]['content']; if ($content) { $content = unserialize($content); } else { $content = current($block_info); $content = unserialize($content['content']); } $this->data['banner_group_name'] = $content['banner_group_name']; $lm = new AListingManager($this->request->get['custom_block_id']); $list = $lm->getCustomList(); if ($list) { foreach ($list as $row) { $listing_data[$row['id']] = array('status' => true, 'sort_order' => $row['sort_order']); } } } if (!$custom_block_id) { $this->data['action'] = $this->html->getSecureURL('extension/banner_manager/insert_block'); $this->data['form_title'] = $this->language->get('text_create_block'); $this->data['update'] = ''; $form = new AForm('ST'); } else { $this->data['action'] = $this->html->getSecureURL('extension/banner_manager/edit_block', '&custom_block_id=' . $custom_block_id); $this->data['form_title'] = $this->language->get('text_edit') . ' ' . $this->data['name']; $this->data['update'] = $this->html->getSecureURL('listing_grid/blocks_grid/update_field', '&custom_block_id=' . $custom_block_id); $form = new AForm('HS'); } $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['form_title'], 'separator' => ' :: ')); $form->setForm(array('form_name' => 'BannerBlockFrm', 'update' => $this->data['update'])); $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'BannerBlockFrm', 'action' => $this->data['action'])); $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1')); $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2')); if ($custom_block_id) { $this->data['form']['fields']['block_status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'block_status', 'value' => $this->data['status'], 'style' => 'btn_switch')); $this->data['form']['text']['block_status'] = $this->html->convertLinks($this->language->get('entry_block_status')); $this->data['form']['fields']['block_status_note'] = ''; $this->data['form']['text']['block_status_note'] = $this->html->convertLinks($this->language->get('entry_block_status_note')); } $this->data['form']['fields']['block_name'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'block_id', 'value' => $this->data['block_id'])); $this->data['form']['fields']['block_name'] .= $form->getFieldHtml(array('type' => 'input', 'name' => 'block_name', 'value' => $this->data['name'], 'required' => true)); $this->data['form']['text']['block_name'] = $this->language->get('entry_block_name'); $this->data['form']['fields']['block_title'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'block_title', 'required' => true, 'value' => $this->data['title'])); $this->data['form']['text']['block_title'] = $this->language->get('entry_block_title'); // list of templates for block $tmpl_ids = $this->extensions->getInstalled('template'); $tmpl_ids[] = 'default'; $tmpl_ids[] = 'default_html5'; $this->data['block_wrappers'] = array(); foreach ($tmpl_ids as $tmpl_id) { // for tpls of block that stores in db $layout_manager = new ALayoutManager($tmpl_id); $block = $layout_manager->getBlockByTxtId('banner_block'); $block_templates = (array) $layout_manager->getBlockTemplates($block['block_id']); foreach ($block_templates as $item) { if ($item['template']) { $this->data['block_wrappers'][$item['template']] = $item['template']; } } //Automatic block template selection mode based on parent is limited to 1 template per location //To extend, allow custom block's template to be selected to suppress automatic selection //for tpls that stores in main.php (other extensions templates) $ext_tpls = $this->extensions->getExtensionTemplates(); foreach ($ext_tpls as $section) { foreach ($section as $s => $tpls) { if ($s != 'storefront') { continue; } foreach ($tpls as $tpl) { if (isset($this->data['block_wrappers'][$tpl]) || strpos($tpl, 'blocks/banner_block/') === false) { continue; } $this->data['block_wrappers'][$tpl] = $tpl; } } } $tpls = glob(DIR_STOREFRONT . 'view/*/template/blocks/banner_block/*.tpl'); foreach ($tpls as $tpl) { $pos = strpos($tpl, 'blocks/banner_block/'); $tpl = substr($tpl, $pos); if (!isset($this->data['block_wrappers'][$tpl])) { $this->data['block_wrappers'][$tpl] = $tpl; } } } ksort($this->data['block_wrappers']); array_unshift($this->data['block_wrappers'], $this->language->get('text_automatic')); if ($this->data['block_wrapper'] && !isset($this->data['block_wrappers'][$this->data['block_wrapper']])) { $this->data['block_wrappers'] = array_merge(array($this->data['block_wrapper'] => $this->data['block_wrapper']), $this->data['block_wrappers']); } $this->data['form']['fields']['block_wrapper'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'block_wrapper', 'options' => $this->data['block_wrappers'], 'value' => $this->data['block_wrapper'], 'help_url' => $this->gen_help_url('block_wrapper'))); $this->data['form']['text']['block_wrapper'] = $this->language->get('entry_block_wrapper'); $this->data['form']['fields']['block_framed'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'block_framed', 'value' => $this->data['block_framed'], 'style' => 'btn_switch', 'help_url' => $this->gen_help_url('block_framed'))); $this->data['form']['text']['block_framed'] = $this->language->get('entry_block_framed'); $this->data['form']['fields']['block_description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'block_description', 'value' => $this->data['description'], 'attr' => ' style="height: 50px;"')); $this->data['form']['text']['block_description'] = $this->language->get('entry_block_description'); // groups of banners $this->loadModel('extension/banner_manager'); $result = $this->model_extension_banner_manager->getBannerGroups(); $groups = array('0' => $this->language->get('text_select')); if ($result) { foreach ($result as $row) { $groups[$row['banner_group_name']] = $row['banner_group_name']; } } $this->data['form']['fields']['banner_group_name'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'banner_group_name', 'options' => $groups, 'value' => $this->data['banner_group_name'], 'style' => 'no-save')); $this->data['form']['text']['banner_group_name'] = $this->language->get('entry_banner_group_name'); //single banners $this->data['form']['fields']['listed_banners'] = $form->getFieldHtml(array('id' => 'popup', 'type' => 'multivalue', 'name' => 'popup', 'title' => $this->language->get('text_select_from_list'), 'selected' => $listing_data ? AJson::encode($listing_data) : "{}", 'content_url' => $this->html->getSecureUrl('listing_grid/banner_manager/getlisting', '&custom_block_id=' . $custom_block_id), 'return_to' => '', 'no_save' => $custom_block_id ? false : true, 'text' => array('selected' => $this->language->get('text_selected'), 'edit' => $this->language->get('text_save_edit'), 'apply' => $this->language->get('text_apply'), 'save' => $this->language->get('button_save'), 'reset' => $this->language->get('button_reset')))); $this->data['form']['text']['listed_banners'] = $this->language->get('entry_banners_selected'); $this->view->batchAssign($this->language->getASet()); $this->view->batchAssign($this->data); $this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher()); $this->view->assign('language_code', $this->session->data['language']); $this->view->assign('help_url', $this->gen_help_url('banner_edit')); $this->view->assign('rl', $this->html->getSecureURL('common/resource_library', '&object_name=banners&type=image&mode=url')); $this->processTemplate('pages/extension/banner_manager_block_form.tpl'); }
private function _init_tabs() { $blocks = array(); $lm = new ALayoutManager(); $default_block_type = ''; foreach (array('html_block', 'listing_block') as $txt_id) { $block = $lm->getBlockByTxtId($txt_id); if ($block['block_id']) { $blocks[$block['block_id']] = $this->language->get('text_' . $txt_id); } if ($txt_id == 'html_block') { $default_block_type = $block['block_id']; } } $this->data['block_id'] = !(int) $this->request->get['block_id'] ? $default_block_type : $this->request->get['block_id']; $i = 0; $tabs = array(); foreach ($blocks as $block_id => $block_text) { $tabs[] = array('name' => $block_id, 'text' => $block_text, 'href' => $this->html->getSecureURL('design/blocks/insert', '&block_id=' . $block_id), 'active' => $block_id == $this->data['block_id'] ? true : false, 'sort_order' => $i); $i++; } $obj = $this->dispatch('responses/common/tabs', array('design/blocks', array('tabs' => $tabs))); $this->data['tabs'] = $obj->dispatchGetOutput(); }
private function _getBlockForm() { if (isset($this->session->data['warning'])) { $this->data['error_warning'] = $this->session->data['warning']; $this->session->data['warning'] = ''; } else { $this->data['error_warning'] = ''; } $this->load->library('json'); $this->view->assign('success', $this->session->data['success']); if (isset($this->session->data['success'])) { unset($this->session->data['success']); } $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('design/blocks'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ')); $this->data['cancel'] = $this->html->getSecureURL('design/blocks'); $custom_block_id = (int) $this->request->get['custom_block_id']; // need to get data of custom listing $listing_data = array(); if ($custom_block_id) { $lm = new ALayoutManager(); $block_info = $lm->getBlockDescriptions($custom_block_id); $language_id = $this->language->getContentLanguageID(); if (!isset($block_info[$language_id])) { $language_id = key($block_info); } foreach ($block_info[$language_id] as $k => $v) { $this->data[$k] = $v; } $content = $block_info[$this->language->getContentLanguageID()]['content']; if ($content) { $content = unserialize($content); } else { $content = current($block_info); $content = unserialize($content['content']); } $this->data['form_id'] = $content['form_id']; $lm = new AListingManager($this->request->get['custom_block_id']); $list = $lm->getCustomList(); if ($list) { foreach ($list as $row) { $listing_data[$row['id']] = array('status' => true, 'sort_order' => $row['sort_order']); } } } if (!$custom_block_id) { $this->data['action'] = $this->html->getSecureURL('tool/forms_manager/insert_block'); $this->data['form_title'] = $this->language->get('text_create_block'); $this->data['update'] = ''; $form = new AForm('ST'); } else { $this->data['action'] = $this->html->getSecureURL('tool/forms_manager/edit_block', '&custom_block_id=' . $custom_block_id); $this->data['form_title'] = $this->language->get('text_edit') . ' ' . $this->data['name']; $this->data['update'] = $this->html->getSecureURL('listing_grid/blocks_grid/update_field', '&custom_block_id=' . $custom_block_id); $form = new AForm('HS'); } $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['form_title'], 'separator' => ' :: ', 'current' => true)); $form->setForm(array('form_name' => 'CustomFormBlockFrm', 'update' => $this->data['update'])); $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'CustomFormBlockFrm', 'action' => $this->data['action'], 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"')); $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1')); $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2')); if ($custom_block_id) { $this->data['form']['fields']['block_status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'block_status', 'value' => $this->data['status'], 'style' => 'btn_switch')); $this->data['entry_block_status_note'] = $this->html->convertLinks($this->language->get('entry_block_status_note')); $this->data['form']['fields']['block_status_note'] = ''; $this->data['entry_block_status_note'] = $this->html->convertLinks($this->language->get('entry_block_status_note')); } $this->data['form']['fields']['block_name'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'block_id', 'value' => $this->data['block_id'])); $this->data['form']['fields']['block_name'] .= $form->getFieldHtml(array('type' => 'input', 'name' => 'block_name', 'value' => $this->data['name'], 'required' => true)); $this->data['form']['text']['block_name'] = $this->language->get('entry_block_name'); $this->data['form']['fields']['block_title'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'block_title', 'required' => true, 'value' => $this->data['title'])); $this->data['form']['text']['block_title'] = $this->language->get('entry_block_title'); // list of templates for block $tmpl_ids = $this->extensions->getInstalled('template'); array_unshift($tmpl_ids, (string) $this->session->data['layout_params']['tmpl_id']); $this->data['block_wrappers'] = array(); foreach ($tmpl_ids as $tmpl_id) { $layout_manager = new ALayoutManager($tmpl_id); $block = $layout_manager->getBlockByTxtId('custom_form_block'); $block_templates = (array) $layout_manager->getBlockTemplates($block['block_id']); foreach ($block_templates as $item) { $this->data['block_wrappers'][$item['template']] = $item['template']; } } array_unshift($this->data['block_wrappers'], 'Default'); $this->data['form']['fields']['block_wrapper'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'block_wrapper', 'options' => $this->data['block_wrappers'], 'value' => $this->data['block_wrapper'], 'help_url' => $this->gen_help_url('block_wrapper'))); $this->data['form']['text']['block_wrapper'] = $this->language->get('entry_block_wrapper'); $this->data['form']['fields']['block_framed'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'block_framed', 'value' => $this->data['block_framed'], 'style' => 'btn_switch', 'help_url' => $this->gen_help_url('block_framed'))); $this->data['form']['text']['block_framed'] = $this->language->get('entry_block_framed'); $this->data['form']['fields']['block_description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'block_description', 'value' => $this->data['description'], 'attr' => ' style="height: 50px;"')); $this->data['form']['text']['block_description'] = $this->language->get('entry_block_description'); $result = $this->model_tool_forms_manager->getForms(array('filter' => array('status' => 1))); $forms = array(); if ($result) { foreach ($result as $row) { $forms[$row['form_id']] = $row['form_name']; } } $this->data['form']['fields']['form'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'form_id', 'options' => $forms, 'value' => $this->data['form_id'], 'style' => 'no-save', 'attr' => 'multiple="multiple"')); $this->data['form']['text']['form'] = $this->language->get('text_form'); $this->data['note'] = sprintf($this->language->get('note_edit_layout'), $this->html->getSecureURL('design/layout'), $this->html->getSecureURL('tool/forms_manager')); $this->view->batchAssign($this->language->getASet()); $this->view->batchAssign($this->data); $this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher()); $this->view->assign('language_code', $this->session->data['language']); $this->view->assign('help_url', $this->gen_help_url('form_block_edit')); $this->processTemplate('pages/tool/forms_manager_block_form.tpl'); }
private function _getListingForm() { if (isset($this->session->data['warning'])) { $this->data['error_warning'] = $this->session->data['warning']; $this->session->data['warning'] = ''; } else { $this->data['error_warning'] = ''; } $this->view->assign('success', $this->session->data['success']); if (isset($this->session->data['success'])) { unset($this->session->data['success']); } $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('design/blocks'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ')); $this->data['cancel'] = $this->html->getSecureURL('design/blocks'); if (!isset($this->request->get['custom_block_id'])) { $this->data['action'] = $this->html->getSecureURL('design/blocks/insert'); $this->data['heading_title'] = $this->language->get('text_create'); $this->data['update'] = ''; $form = new AForm('ST'); } else { $this->data['action'] = $this->html->getSecureURL('design/blocks/edit', '&custom_block_id=' . $this->request->get['custom_block_id']); $this->data['heading_title'] = $this->language->get('text_edit') . ' ' . $this->data['name']; $this->data['update'] = $this->html->getSecureURL('listing_grid/blocks_grid/update_field', '&custom_block_id=' . $this->request->get['custom_block_id']); $form = new AForm('HS'); } $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['heading_title'], 'separator' => ' :: ', 'current' => true)); $form->setForm(array('form_name' => 'BlockFrm', 'update' => $this->data['update'])); $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'BlockFrm', 'attr' => 'data-confirm-exit="true"', 'action' => $this->data['action'])); $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1')); $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2')); if (isset($this->request->get['custom_block_id'])) { $this->data['form']['fields']['block_status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'block_status', 'value' => $this->data['status'], 'style' => 'btn_switch status_switch')); $this->data['form']['text']['block_status'] = $this->html->convertLinks($this->language->get('entry_block_status')); $this->data['form']['fields']['block_status_note'] = ''; $this->data['form']['text']['block_status_note'] = $this->html->convertLinks($this->language->get('entry_block_status_note')); } $lm = new ALayoutManager(); foreach ($this->data['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); if ($txt_id == 'listing_block') { $default_block_type = $block['block_id']; } } } if (isset($this->request->get['custom_block_id'])) { // need to khow what type of listing is that $this->data['content'] = unserialize($this->data['content']); $this->data['autoload'] = 'load_subform({\'listing_datasource\': \'' . $this->data['content']['listing_datasource'] . '\'});'; } $this->data['form']['fields']['block_name'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'block_id', 'value' => $default_block_type)); $this->data['form']['fields']['block_name'] .= $form->getFieldHtml(array('type' => 'input', 'name' => 'block_name', 'value' => $this->data['name'], 'multilingual' => true, 'required' => true)); $this->data['form']['text']['block_name'] = $this->language->get('entry_block_name'); $this->data['form']['fields']['block_title'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'block_title', 'required' => true, 'multilingual' => true, 'value' => $this->data['title'])); $this->data['form']['text']['block_title'] = $this->language->get('entry_block_title'); // list of templates for block $tmpl_ids = $this->extensions->getInstalled('template'); $tmpl_ids[] = 'default'; $this->data['block_wrappers'] = array(); foreach ($tmpl_ids as $tmpl_id) { // for tpls of block that stores in db $layout_manager = new ALayoutManager($tmpl_id); $block = $layout_manager->getBlockByTxtId('listing_block'); $block_templates = (array) $layout_manager->getBlockTemplates($block['block_id']); foreach ($block_templates as $item) { if ($item['template']) { $this->data['block_wrappers'][$item['template']] = $item['template']; } } } //Automatic block template selection mode based on parent is limited to 1 template per location //To extend, allow custom block's template to be selected to suppress automatic selection //for tpls that stores in main.php (other extensions templates) $ext_tpls = $this->extensions->getExtensionTemplates(); foreach ($ext_tpls as $section) { foreach ($section as $s => $tpls) { if ($s != 'storefront') { continue; } foreach ($tpls as $tpl) { if (isset($this->data['block_wrappers'][$tpl]) || strpos($tpl, 'blocks/listing_block/') === false) { continue; } $this->data['block_wrappers'][$tpl] = $tpl; } } } $tpls = glob(DIR_STOREFRONT . 'view/*/template/blocks/listing_block/*.tpl'); foreach ($tpls as $tpl) { $pos = strpos($tpl, 'blocks/listing_block/'); $tpl = substr($tpl, $pos); if (!isset($this->data['block_wrappers'][$tpl])) { $this->data['block_wrappers'][$tpl] = $tpl; } } ksort($this->data['block_wrappers']); array_unshift($this->data['block_wrappers'], $this->language->get('text_automatic')); $this->data['form']['fields']['block_wrapper'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'block_wrapper', 'options' => $this->data['block_wrappers'], 'value' => $this->data['block_wrapper'])); $this->data['form']['text']['block_wrapper'] = $this->language->get('entry_block_wrapper'); $this->data['form']['fields']['block_framed'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'block_framed', 'value' => $this->data['block_framed'], 'style' => 'btn_switch')); $this->data['form']['text']['block_framed'] = $this->language->get('entry_block_framed'); $this->data['form']['fields']['block_description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'block_description', 'value' => $this->data['description'], 'attr' => ' style="height: 50px;"', 'multilingual' => true)); $this->data['form']['text']['block_description'] = $this->language->get('entry_block_description'); $listing_manager = new AListingManager((int) $this->request->get['custom_block_id']); $listing_datasources = array('' => array('text' => 'text_select_listing')); $listing_datasources = array_merge($listing_datasources, $listing_manager->getListingDataSources()); foreach ($listing_datasources as $k => $v) { $listing_datasources[$k] = $this->language->get($v['text']); } $default_listing_datasource = $this->data['content']['listing_datasource']; $this->data['form']['fields']['listing_datasource'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'listing_datasource', 'options' => $listing_datasources, 'value' => $default_listing_datasource, 'style' => 'no-save')); $this->data['form']['text']['listing_datasource'] = $this->language->get('entry_listing_datasource'); if (!isset($this->data['subform_url'])) { $this->data['subform_url'] = $this->html->getSecureURL('listing_grid/blocks_grid/getsubform', $this->request->get['custom_block_id'] ? '&custom_block_id=' . $this->request->get['custom_block_id'] : ''); } $this->view->batchAssign($this->language->getASet()); $this->view->batchAssign($this->data); $this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher()); $this->view->assign('language_code', $this->session->data['language']); $this->view->assign('help_url', $this->gen_help_url('block_edit')); $this->view->assign('rl', $this->html->getSecureURL('common/resource_library', '&object_name=custom_block&type=image&mode=url')); $this->processTemplate('pages/design/blocks_form_listing.tpl'); }
public function onControllerResponsesCommonTabs_InitData() { if ($this->baseObject->parent_controller == 'design/blocks') { $that = $this->baseObject; $lm = new ALayoutManager(); $that->loadLanguage('forms_manager/forms_manager'); $that->loadLanguage('design/blocks'); $block = $lm->getBlockByTxtId('custom_form_block'); $block_id = $block['block_id']; $that->data['tabs'][] = array('name' => $block_id, 'text' => $that->language->get('custom_forms_block'), 'href' => $that->html->getSecureURL('tool/forms_manager/insert_block', '&block_id=' . $block_id), 'active' => $block_id == $this->request->get['block_id'] ? true : false, 'sort_order' => 4); } }