public function insert() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->document->setTitle($this->language->get('heading_title')); $this->menu = new AMenu_Storefront(); if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->_validateForm()) { $languages = $this->language->getAvailableLanguages(); foreach ($languages as $l) { if ($l['language_id'] == $this->session->data['content_language_id']) { continue; } $this->request->post['item_text'][$l['language_id']] = $this->request->post['item_text'][$this->session->data['content_language_id']]; } //TODO!. Remove post/get update and access in many places. Copy to local array to proccess and work with. $this->request->post['item_icon'] = html_entity_decode($this->request->post['item_icon'], ENT_COMPAT, 'UTF-8'); $textid = preformatTextID($this->request->post['item_id']); $result = $this->menu->insertMenuItem(array('item_id' => $textid, 'item_icon' => $this->request->post['item_icon'], 'item_icon_rl_id' => $this->request->post['item_icon_rl_id'], 'item_text' => $this->request->post['item_text'], 'parent_id' => $this->request->post['parent_id'], 'item_url' => $this->request->post['item_url'], 'sort_order' => $this->request->post['sort_order'], 'item_type' => 'core')); if ($result !== true) { $this->error['warning'] = $result; } else { $this->session->data['success'] = $this->language->get('text_success'); $this->redirect($this->html->getSecureURL('design/menu/update', '&item_id=' . $textid)); } } $this->_getForm(); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function insert() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->document->setTitle($this->language->get('heading_title')); $this->menu = new AMenu_Storefront(); $language_id = $this->language->getContentLanguageID(); if ($this->request->is_POST() && $this->_validateForm()) { $post = $this->request->post; $languages = $this->language->getAvailableLanguages(); foreach ($languages as $l) { if ($l['language_id'] == $language_id) { continue; } $post['item_text'][$l['language_id']] = $post['item_text'][$language_id]; } $post['item_icon'] = html_entity_decode($post['item_icon'], ENT_COMPAT, 'UTF-8'); $textid = preformatTextID($post['item_id']); $result = $this->menu->insertMenuItem(array('item_id' => $textid, 'item_icon' => $post['item_icon'], 'item_icon_rl_id' => $post['item_icon_resource_id'], 'item_text' => $post['item_text'], 'parent_id' => $post['parent_id'], 'item_url' => $post['item_url'], 'sort_order' => $post['sort_order'], 'item_type' => 'core')); if ($result !== true) { $this->error['warning'] = $result; } else { $this->session->data['success'] = $this->language->get('text_success'); $this->redirect($this->html->getSecureURL('design/menu/update', '&item_id=' . $textid)); } } $this->_getForm(); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }