Example #1
0
 public function main()
 {
     $layout_data = array();
     //use to init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->session->data['content_language_id'] = $this->config->get('storefront_language_id');
     $this->document->setTitle($this->language->get('heading_title'));
     $tmpl_id = $this->request->get['tmpl_id'];
     $page_id = $this->request->get['page_id'];
     $layout_id = $this->request->get['layout_id'];
     //Note yet implemented
     if (isset($this->request->get['preview_id'])) {
         $preview_id = $this->request->get['preview_id'];
         $layout_data['preview_id'] = $preview_id;
         $layout_data['preview_url'] = HTTP_CATALOG . '?preview=' . $preview_id . '&layout_id=' . $preview_id . '&page_id=' . $page_id;
     }
     $layout = new ALayoutManager($tmpl_id, $page_id, $layout_id);
     $layout_data['pages'] = $layout->getAllPages();
     $layout_data['current_page'] = $layout->getPageData();
     $params = array('page_id' => $layout_data['current_page']['page_id'], 'layout_id' => $layout->getLayoutId(), 'tmpl_id' => $layout->getTemplateId());
     $url = '&' . $this->html->buildURI($params);
     // get templates
     $layout_data['templates'] = array();
     $directories = glob(DIR_STOREFRONT . 'view/*', GLOB_ONLYDIR);
     foreach ($directories as $directory) {
         $layout_data['templates'][] = basename($directory);
     }
     $enabled_templates = $this->extensions->getExtensionsList(array('filter' => 'template', 'status' => 1));
     foreach ($enabled_templates->rows as $template) {
         $layout_data['templates'][] = $template['key'];
     }
     // breadcrumb path
     $this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home')));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('design/layout'), 'text' => $this->language->get('heading_title') . ' - ' . $params['tmpl_id'], 'current' => true));
     // Layout form data
     $form = new AForm('HT');
     $form->setForm(array('form_name' => 'layout_form'));
     $layout_data['form_begin'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'layout_form', 'attr' => 'data-confirm-exit="true"', 'action' => $this->html->getSecureURL('design/layout/save')));
     $layout_data['hidden_fields'] = '';
     foreach ($params as $name => $value) {
         $layout_data[$name] = $value;
         $layout_data['hidden_fields'] .= $form->getFieldHtml(array('type' => 'hidden', 'name' => $name, 'value' => $value));
     }
     $layout_data['page_url'] = $this->html->getSecureURL('design/layout');
     $layout_data['generate_preview_url'] = $this->html->getSecureURL('design/layout/preview');
     $layout_data['current_url'] = $this->html->getSecureURL('design/layout', $url);
     $layout_data['page_delete_url'] = $this->html->getSecureURL('design/layout/delete');
     $layout_data['insert_url'] = $this->html->getSecureURL('design/layout/insert', $url);
     $layout_data['help_url'] = $this->gen_help_url('layout');
     // Alert messages
     if (isset($this->session->data['warning'])) {
         $layout_data['error_warning'] = $this->session->data['warning'];
         unset($this->session->data['warning']);
     }
     if (isset($this->session->data['success'])) {
         $layout_data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     }
     $layoutform = $this->dispatch('common/page_layout', array($layout));
     $layout_data['layoutform'] = $layoutform->dispatchGetOutput();
     $this->view->batchAssign($layout_data);
     $this->processTemplate('pages/design/layout.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 public function main()
 {
     $page_controller = 'pages/product/product';
     $page_key_param = 'product_id';
     $product_id = (int) $this->request->get['product_id'];
     $page_url = $this->html->getSecureURL('catalog/product_layout', '&product_id=' . $product_id);
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('catalog/product');
     $this->loadLanguage('design/layout');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->loadModel('catalog/product');
     if (has_value($product_id) && $this->request->is_GET()) {
         $product_info = $this->model_catalog_product->getProduct($product_id);
         if (!$product_info) {
             unset($this->session->data['success']);
             $this->session->data['warning'] = $this->language->get('error_product_not_found');
             $this->redirect($this->html->getSecureURL('catalog/product'));
         }
     }
     $this->data['help_url'] = $this->gen_help_url('product_layout');
     $this->data['product_description'] = $this->model_catalog_product->getProductDescriptions($product_id);
     $this->data['heading_title'] = $this->language->get('text_edit') . $this->language->get('text_product') . ' - ' . $this->data['product_description'][$this->session->data['content_language_id']]['name'];
     $this->document->setTitle($this->data['heading_title']);
     // Alert messages
     if (isset($this->session->data['warning'])) {
         $this->data['error_warning'] = $this->session->data['warning'];
         unset($this->session->data['warning']);
     }
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $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('catalog/product'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product/update', '&product_id=' . $product_id), 'text' => $this->data['heading_title'], 'separator' => ' :: '));
     $this->document->addBreadcrumb(array('href' => $page_url, 'text' => $this->language->get('tab_layout'), 'separator' => ' :: ', 'current' => true));
     //active tab
     $this->data['active'] = 'layout';
     //load tabs controller
     $tabs_obj = $this->dispatch('pages/catalog/product_tabs', array($this->data));
     $this->data['product_tabs'] = $tabs_obj->dispatchGetOutput();
     unset($tabs_obj);
     $this->addChild('pages/catalog/product_summary', 'summary_form', 'pages/catalog/product_summary.tpl');
     $layout = new ALayoutManager();
     //get existing page layout or generic
     $page_layout = $layout->getPageLayoutIDs($page_controller, $page_key_param, $product_id);
     $page_id = $page_layout['page_id'];
     $layout_id = $page_layout['layout_id'];
     if (isset($this->request->get['tmpl_id'])) {
         $tmpl_id = $this->request->get['tmpl_id'];
     } else {
         $tmpl_id = $this->config->get('config_storefront_template');
     }
     $params = array('product_id' => $product_id, 'page_id' => $page_id, 'layout_id' => $layout_id, 'tmpl_id' => $tmpl_id);
     $url = '&' . $this->html->buildURI($params);
     // get templates
     $this->data['templates'] = array();
     $directories = glob(DIR_STOREFRONT . 'view/*', GLOB_ONLYDIR);
     foreach ($directories as $directory) {
         $this->data['templates'][] = basename($directory);
     }
     $enabled_templates = $this->extensions->getExtensionsList(array('filter' => 'template', 'status' => 1));
     foreach ($enabled_templates->rows as $template) {
         $this->data['templates'][] = $template['key'];
     }
     $action = $this->html->getSecureURL('catalog/product_layout/save');
     // Layout form data
     $form = new AForm('HT');
     $form->setForm(array('form_name' => 'layout_form'));
     $this->data['form_begin'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'layout_form', 'attr' => 'data-confirm-exit="true"', 'action' => $action));
     $this->data['hidden_fields'] = '';
     foreach ($params as $name => $value) {
         $this->data[$name] = $value;
         $this->data['hidden_fields'] .= $form->getFieldHtml(array('type' => 'hidden', 'name' => $name, 'value' => $value));
     }
     $this->data['page_url'] = $page_url;
     $this->data['current_url'] = $this->html->getSecureURL('catalog/product_layout', $url);
     // insert external form of layout
     $layout = new ALayoutManager($tmpl_id, $page_id, $layout_id);
     $layoutform = $this->dispatch('common/page_layout', array($layout));
     $this->data['layoutform'] = $layoutform->dispatchGetOutput();
     //build pages and available layouts for clonning
     $this->data['pages'] = $layout->getAllPages();
     $av_layouts = array("0" => $this->language->get('text_select_copy_layout'));
     foreach ($this->data['pages'] as $page) {
         if ($page['layout_id'] != $layout_id) {
             $av_layouts[$page['layout_id']] = $page['layout_name'];
         }
     }
     $form = new AForm('HT');
     $form->setForm(array('form_name' => 'cp_layout_frm'));
     $this->data['cp_layout_select'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'layout_change', 'value' => '', 'options' => $av_layouts));
     $this->data['cp_layout_frm'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'cp_layout_frm', 'attr' => 'class="aform form-inline"', 'action' => $action));
     if ($this->config->get('config_embed_status')) {
         $this->data['embed_url'] = $this->html->getSecureURL('common/do_embed/product', '&product_id=' . $this->request->get['product_id']);
     }
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/catalog/product_layout.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Example #3
0
 public function main()
 {
     //use to init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->session->data['content_language_id'] = $this->config->get('storefront_language_id');
     $this->document->setTitle($this->language->get('heading_title'));
     $url = '';
     if (isset($this->request->get['tmpl_id'])) {
         $url .= '&tmpl_id=' . $this->request->get['tmpl_id'];
         $tmpl_id = $this->request->get['tmpl_id'];
     } else {
         $tmpl_id = NULL;
     }
     if (isset($this->request->get['page_id'])) {
         $url .= '&page_id=' . $this->request->get['page_id'];
         $page_id = $this->request->get['page_id'];
     } else {
         $page_id = NULL;
     }
     if (isset($this->request->get['layout_id'])) {
         $url .= '&layout_id=' . $this->request->get['layout_id'];
         $layout_id = $this->request->get['layout_id'];
     } else {
         $layout_id = NULL;
     }
     $layout_data['templates'] = array();
     $directories = glob(DIR_STOREFRONT . 'view/*', GLOB_ONLYDIR);
     foreach ($directories as $directory) {
         $layout_data['templates'][] = basename($directory);
     }
     $enabled_templates = $this->extensions->getExtensionsList(array('filter' => 'template', 'status' => 1));
     foreach ($enabled_templates->rows as $template) {
         $layout_data['templates'][] = $template['key'];
     }
     $layout_id = !$layout_id ? 1 : $layout_id;
     $layout = new ALayoutManager($tmpl_id, $page_id, $layout_id);
     $layout_data['tmpl_id'] = $layout->getTemplateId();
     $layout_data['pages'] = $layout->getAllPages();
     $layout_data['page'] = $layout->getPageData();
     $settings = array();
     // hidden fields of layout form
     $settings['hidden']['page_id'] = $page_id;
     $settings['hidden']['layout_id'] = $layout_id;
     $settings['hidden']['tmpl_id'] = $layout_data['tmpl_id'];
     $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/layout', $url), 'text' => $this->language->get('heading_title') . ' - ' . $layout_data['tmpl_id'], 'separator' => ' :: '));
     $this->view->batchAssign($layout_data);
     $this->view->assign('page_url', $this->html->getSecureURL('design/layout'));
     $this->view->assign('page_delete_url', $this->html->getSecureURL('design/layout/delete'));
     $this->view->assign('insert', $this->html->getSecureURL('design/layout/insert', $url));
     $settings['action'] = $this->html->getSecureURL('design/layout/save', $url);
     $this->view->assign('error_warning', isset($this->session->data['warning']) ? $this->session->data['warning'] : '');
     $this->view->assign('success', isset($this->session->data['success']) ? $this->session->data['success'] : '');
     if (isset($this->session->data['warning'])) {
         unset($this->session->data['warning']);
     }
     if (isset($this->session->data['success'])) {
         unset($this->session->data['success']);
     }
     $layoutform = $this->dispatch('common/page_layout', array($settings, $layout));
     $this->view->assign('layoutform', $layoutform->dispatchGetOutput());
     $this->view->assign('help_url', $this->gen_help_url('layout'));
     $this->processTemplate('pages/design/layout.tpl');
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }