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'); }
public function getCustomListListingGridData() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); // json-response for jqgrid $this->load->library('json'); // if datasource was switched $layout_manager = new ALayoutManager(); $custom_block_id = (int) $this->request->get['custom_block_id']; $listing_datasource = $this->request->post_or_get('listing_datasource'); $info = $layout_manager->getBlockDescriptions($custom_block_id); $info = is_array($info) ? current($info) : ''; $info = unserialize($info['content']); $custom_list = array(); $lm = new AListingManager($custom_block_id); $this->data['data_sources'] = $lm->getListingDataSources(); if ($info['listing_datasource'] == $listing_datasource) { $list = $lm->getCustomList(); if ($list) { foreach ($list as $row) { $custom_list[$row['id']] = $row['sort_order']; } } } //load data source language and model $this->loadLanguage($this->data['data_sources'][$listing_datasource]['language']); $this->loadModel($this->data['data_sources'][$listing_datasource]['model']); $this->loadModel('tool/image'); //Prepare filter config $grid_filter_params = array('name', 'sort_order', 'model'); $filter = new AFilter(array('method' => 'post', 'grid_filter_params' => $grid_filter_params)); $filter_data = $filter->getFilterData(); //call data source model total method to get total based on set filter $model = $this->{'model_' . str_replace('/', '_', $this->data['data_sources'][$listing_datasource]['model'])}; $total = call_user_func_array(array($model, $this->data['data_sources'][$listing_datasource]['total_method']), array($filter_data)); $response = new stdClass(); $response->page = $filter->getParam('page'); $response->total = $filter->calcTotalPages($total); $response->records = $total; $response->userdata = (object) array(''); //call data source model method to get all records based on set filter $model = $this->{'model_' . str_replace('/', '_', $this->data['data_sources'][$listing_datasource]['model'])}; $results = call_user_func_array(array($model, $this->data['data_sources'][$listing_datasource]['method']), array($filter_data)); $i = 0; $resource = new AResource('image'); $response->userdata = (object) array('page' => '', 'selId' => array()); $data_type = $this->data['data_sources'][$listing_datasource]['data_type']; //product_id, category_id etc $id_list = $custom_list ? array_keys($custom_list) : array(); if ($results) { foreach ($results as $result) { $list_item_id = $result[$data_type]; //for pre-select if (in_array($list_item_id, $id_list) || in_array($list_item_id, array_keys($this->session->data['listing_selected']))) { $response->userdata->selId[] = $list_item_id; } $thumbnail = $resource->getMainThumb($this->data['data_sources'][$listing_datasource]['rl_object_name'], $list_item_id, 36, 36, true); $response->rows[$i]['id'] = $list_item_id; $response->rows[$i]['cell'] = array($thumbnail['thumb_html'], $result['name']); if (strpos($listing_datasource, 'product') !== FALSE) { $response->rows[$i]['cell'][] = $result['model']; } if ($custom_list[$list_item_id]) { $value = $custom_list[$list_item_id]; } else { $value = $this->session->data['listing_selected'][$list_item_id]['sort_order']; } //TODO: need find solution to replace html hardcode in all response controllers $response->rows[$i]['cell'][] = '<a class="btn_action" href="JavaScript:void(0);" onclick="showPopup(\'' . $this->html->getSecureURL($this->data['data_sources'][$listing_datasource]['view_path'], '&' . $data_type . '=' . $list_item_id) . '\')" title="' . $this->language->get('text_view') . '">' . '<img src="' . RDIR_TEMPLATE . 'image/icons/icon_grid_view.png" alt="' . $this->language->get('text_edit') . '" /></a>'; $i++; } } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($response)); }
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'); }
public function getCustomListingSubForm() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->load->library('json'); $lm = new ALayoutManager(); $form_name = has_value($this->request->get['form_name']) ? $this->request->get['form_name'] : 'BlockFrm'; $custom_block_id = (int) $this->request->get['custom_block_id']; $listing_datasource = $this->request->post_or_get('listing_datasource'); // need to get data of custom listing if ($custom_block_id) { $content = $lm->getBlockDescriptions($custom_block_id); $content = $content[$this->language->getContentLanguageID()]['content']; $content = unserialize($content); if ($content['listing_datasource'] == $listing_datasource) { $lm = new AListingManager($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); switch ($listing_datasource) { case 'custom_products': $this->loadModel('catalog/product'); $filter = array('subsql_filter' => 'p.product_id in (' . implode(',', $ids) . ')'); $results = $this->model_catalog_product->getProducts($filter); $id_name = 'product_id'; $rl_object_name = 'products'; break; case 'custom_categories': $this->loadModel('catalog/category'); $filter = array('subsql_filter' => 'c.category_id in (' . implode(',', $ids) . ')'); $results = $this->model_catalog_category->getCategoriesData($filter); $id_name = 'category_id'; $rl_object_name = 'categories'; break; case 'custom_manufacturers': $this->loadModel('catalog/manufacturer'); $filter = array('subsql_filter' => 'm.manufacturer_id in (' . implode(',', $ids) . ')'); $results = $this->model_catalog_manufacturer->getManufacturers($filter); $id_name = 'manufacturer_id'; $rl_object_name = 'manufacturers'; break; } $rm = new AResourceManager(); $rm->setType('image'); foreach ($results as $item) { $id = $item[$id_name]; if (in_array($id, $ids)) { $thumbnail = $rm->getMainThumb($rl_object_name, $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' => $item['name'], 'meta' => $item['model'], 'sort_order' => (int) $item['sort_order']); } } } } } switch ($listing_datasource) { case 'custom_products': $ajax_url = $this->html->getSecureURL('r/product/product/products'); break; case 'custom_categories': $ajax_url = $this->html->getSecureURL('r/listing_grid/category/categories'); break; case 'custom_manufacturers': $ajax_url = $this->html->getSecureURL('r/listing_grid/manufacturer/manufacturers'); break; } $form = new AForm('ST'); $form->setForm(array('form_name' => $form_name)); $multivalue_html = $form->getFieldHtml(array('type' => 'multiselectbox', 'name' => 'selected[]', 'value' => $ids, 'options' => $options_list, 'style' => 'chosen', 'ajax_url' => $ajax_url, 'placeholder' => $this->language->get('text_select_from_lookup'))); $this->view->assign('multivalue_html', $multivalue_html); $this->view->assign('form_name', $form_name); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->processTemplate('responses/design/block_custom_listing_subform.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']); } $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', 'forms_manager/forms_manager'); $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'); }