public function save() { if ($this->request->is_GET()) { $this->redirect($this->html->getSecureURL('catalog/product_layout')); } $page_controller = 'pages/product/product'; $page_key_param = 'product_id'; $product_id = $this->request->post['product_id']; //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('catalog/product'); if (!has_value($product_id)) { unset($this->session->data['success']); $this->session->data['warning'] = $this->language->get('error_product_not_found'); $this->redirect($this->html->getSecureURL('catalog/product/update')); } // need to know if unique page existing $post_data = $this->request->post; $tmpl_id = $post_data['tmpl_id']; $layout = new ALayoutManager(); $pages = $layout->getPages($page_controller, $page_key_param, $product_id); if (count($pages)) { $page_id = $pages[0]['page_id']; $layout_id = $pages[0]['layout_id']; } else { $page_info = array('controller' => $page_controller, 'key_param' => $page_key_param, 'key_value' => $product_id); $this->loadModel('catalog/product'); $product_info = $this->model_catalog_product->getProductDescriptions($product_id); if ($product_info) { foreach ($product_info as $language_id => $description) { if (!(int) $language_id) { continue; } $page_info['page_descriptions'][$language_id] = $description; } } $page_id = $layout->savePage($page_info); $layout_id = ''; // need to generate layout name $default_language_id = $this->language->getDefaultLanguageID(); $post_data['layout_name'] = 'Product: ' . $product_info[$default_language_id]['name']; } //create new instance with specific template/page/layout data $layout = new ALayoutManager($tmpl_id, $page_id, $layout_id); if (has_value($post_data['layout_change'])) { //update layout request. Clone source layout $layout->clonePageLayout($post_data['layout_change'], $layout_id, $post_data['layout_name']); $this->session->data['success'] = $this->language->get('text_success_layout'); } else { //save new layout $layout_data = $layout->prepareInput($post_data); if ($layout_data) { $layout->savePageLayout($layout_data); $this->session->data['success'] = $this->language->get('text_success_layout'); } } $this->redirect($this->html->getSecureURL('catalog/product_layout', '&product_id=' . $product_id)); }
public function save_layout() { $page_controller = 'pages/content/content'; $page_key_param = 'content_id'; $content_id = $this->_get_content_id($this->request->get_or_post('content_id')); //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->acm = new AContentManager(); if (!has_value($content_id)) { $this->redirect($this->html->getSecureURL('design/content')); } if ($this->request->is_POST()) { // need to know unique page existing $post_data = $this->request->post; $tmpl_id = $post_data['tmpl_id']; $layout = new ALayoutManager(); $pages = $layout->getPages($page_controller, $page_key_param, $content_id); if (count($pages)) { $page_id = $pages[0]['page_id']; $layout_id = $pages[0]['layout_id']; } else { // create new page record $page_info = array('controller' => $page_controller, 'key_param' => $page_key_param, 'key_value' => $content_id); $default_language_id = $this->language->getDefaultLanguageID(); $content_info = $this->acm->getContent($content_id, $default_language_id); if ($content_info) { if ($content_info['title']) { $page_info['page_descriptions'][$default_language_id]['name'] = $content_info['title']; } else { $page_info['page_descriptions'][$default_language_id]['name'] = 'Unnamed content page'; } } $page_id = $layout->savePage($page_info); $layout_id = ''; // need to generate layout name $post_data['layout_name'] = 'Content: ' . $content_info['title']; } //create new instance with specific template/page/layout data $layout = new ALayoutManager($tmpl_id, $page_id, $layout_id); if (has_value($post_data['layout_change'])) { //update layout request. Clone source layout $layout->clonePageLayout($post_data['layout_change'], $layout_id, $post_data['layout_name']); $this->session->data['success'] = $this->language->get('text_success_layout'); } else { //save new layout $layout_data = $layout->prepareInput($post_data); if ($layout_data) { $layout->savePageLayout($layout_data); $this->session->data['success'] = $this->language->get('text_success_layout'); } } $this->redirect($this->html->getSecureURL('design/content/edit_layout', '&content_id=' . $content_id)); } $this->redirect($this->html->getSecureURL('design/content/')); }
public function save() { if ($this->request->server['REQUEST_METHOD'] != 'POST') { $this->redirect($this->html->getSecureURL('catalog/manufacturer_layout')); } $page_controller = 'pages/product/manufacturer'; $page_key_param = 'manufacturer_id'; $manufacturer_id = (int) $this->request->post['manufacturer_id']; //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('catalog/manufacturer'); if (!has_value($manufacturer_id)) { $this->session->data['error'] = $this->language->get('error_product_not_found'); $this->redirect($this->html->getSecureURL('catalog/manufacturer/update')); } $tmpl_id = $this->config->get('config_storefront_template'); $post_data = $this->request->post; // need to know unique page existing $layout = new ALayoutManager(); $pages = $layout->getPages($page_controller, $page_key_param, $manufacturer_id); if (count($pages)) { $page_id = $pages[0]['page_id']; $layout_id = $pages[0]['layout_id']; } else { $page_info = array('controller' => $page_controller, 'key_param' => $page_key_param, 'key_value' => $manufacturer_id); $languages = $this->language->getAvailableLanguages(); $this->loadModel('catalog/manufacturer'); $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($manufacturer_id); if ($manufacturer_info) { foreach ($languages as $l) { $page_info['page_descriptions'][$l['language_id']] = $manufacturer_info; } } $page_id = $layout->savePage($page_info); $layout_id = ''; // need to generate layout name $post_data['layout_name'] = 'Manufacturer: ' . $manufacturer_info['name']; } //create new instance with specific template/page/layout data $layout = new ALayoutManager($tmpl_id, $page_id, $layout_id); if (has_value($post_data['layout_change'])) { //update layout request. Clone source layout $layout->clonePageLayout($post_data['layout_change'], $layout_id, $post_data['layout_name']); } else { //save new layout $post_data['controller'] = $page_controller; $layout->savePageLayout($post_data); } $this->session->data['success'] = $this->language->get('text_success_layout'); $this->redirect($this->html->getSecureURL('catalog/manufacturer_layout', '&manufacturer_id=' . $manufacturer_id)); }
public function save() { //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $url = ''; if ($this->request->is_POST()) { $tmpl_id = $this->request->post['tmpl_id']; $page_id = $this->request->post['page_id']; $layout_id = $this->request->post['layout_id']; $url = '&' . $this->html->buildURI(array('tmpl_id' => $tmpl_id, 'page_id' => $page_id, 'layout_id' => $layout_id)); $layout = new ALayoutManager($tmpl_id, $page_id, $layout_id); $layout_data = $layout->prepareInput($this->request->post); if ($layout_data) { $layout->savePageLayout($layout_data); $this->session->data['success'] = $this->language->get('text_success'); } } $this->redirect($this->html->getSecureURL('design/layout', $url)); }
public function save() { //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $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; } if ($this->request->server['REQUEST_METHOD'] == 'POST') { $layout = new ALayoutManager($tmpl_id, $page_id, $layout_id); if (has_value($this->request->post['layout_change'])) { //update layout request. Clone source layout $layout->clonePageLayout($this->request->post['layout_change'], $layout_id, $this->request->post['layout_name']); } else { //save new layout $layout->savePageLayout($this->request->post); } $this->session->data['success'] = $this->language->get('text_success'); } $this->redirect($this->html->getSecureURL('design/layout', $url)); }
public function save_layout() { if ($this->request->server['REQUEST_METHOD'] != 'POST') { $this->redirect($this->html->getSecureURL('catalog/category')); } $page_controller = 'pages/product/category'; $page_key_param = 'path'; $category_id = (int) $this->request->get_or_post('category_id'); //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('catalog/category'); if (!has_value($category_id)) { $this->redirect($this->html->getSecureURL('catalog/category')); } $url = '&category_id=' . $category_id; $tmpl_id = $this->config->get('config_storefront_template'); // need to know unique page existing $post_data = $this->request->post; $layout = new ALayoutManager(); $pages = $layout->getPages($page_controller, $page_key_param, $category_id); if (count($pages)) { $page_id = $pages[0]['page_id']; $layout_id = $pages[0]['layout_id']; } else { $page_info = array('controller' => $page_controller, 'key_param' => $page_key_param, 'key_value' => $category_id); $this->loadModel('catalog/category'); $category_info = $this->model_catalog_category->getCategoryDescriptions($category_id); if ($category_info) { foreach ($category_info as $language_id => $description) { if (!has_value($language_id)) { continue; } $page_info['page_descriptions'][$language_id] = $description; } } $page_id = $layout->savePage($page_info); $layout_id = ''; // need to generate layout name $default_language_id = $this->language->getDefaultLanguageID(); $post_data['layout_name'] = 'Category: ' . $category_info[$default_language_id]['name']; } //create new instance with specific template/page/layout data $layout = new ALayoutManager($tmpl_id, $page_id, $layout_id); if (has_value($post_data['layout_change'])) { //update layout request. Clone source layout $layout->clonePageLayout($post_data['layout_change'], $layout_id, $post_data['layout_name']); } else { //save new layout $post_data['controller'] = $page_controller; $layout->savePageLayout($post_data); } $url .= '&layout_id=' . $layout_id; $this->session->data['success'] = $this->language->get('text_success_layout'); $this->redirect($this->html->getSecureURL('catalog/category/edit_layout', $url)); }