/** * @return array */ public function getContents() { $contents = array(); $content_manager = new AContentManager(); $results = $content_manager->getContents(); $contents[] = array('content_id' => '0', 'title' => $this->language->get('text_none')); foreach ($results as $r) { $contents[] = array('content_id' => $r['content_id'], 'title' => $r['title']); } return $contents; }
public function save_layout() { $page_controller = 'pages/content/content'; $page_key_param = 'content_id'; //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->acm = new AContentManager(); if (!(int) $this->request->get['content_id'] && !(int) $this->request->post['content_id']) { $this->redirect($this->html->getSecureURL('design/content')); } $url = ''; if (isset($this->request->get['content_id'])) { $content_id = (int) $this->request->get['content_id']; $url .= '&content_id=' . $this->request->get['content_id']; } elseif (isset($this->request->post['content_id'])) { $content_id = (int) $this->request->post['content_id']; $url .= '&content_id=' . $this->request->post['content_id']; } if ($this->request->server['REQUEST_METHOD'] == 'POST') { $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, $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']); } 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('design/content/edit_layout', $url)); } $this->redirect($this->html->getSecureURL('design/content/')); }
/** * update only one field * * @return void */ public function update_field() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('design/content'); $this->acm = new AContentManager(); if (!$this->user->canModify('listing_grid/content')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/content'), 'reset_value' => true)); } $allowedFields = array('title', 'description', 'keyword', 'store_id', 'sort_order', 'status', 'parent_content_id'); if (isset($this->request->get['id'])) { //request sent from edit form. ID in url foreach ($this->request->post as $field => $value) { if (!in_array($field, $allowedFields)) { continue; } if ($field == 'keyword') { if ($err = $this->html->isSEOkeywordExists('content_id=' . $this->request->get['id'], $value)) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $err)); } } if ($field == 'sort_order') { // NOTE: grid quicksave ids are not the same as id from form quick save request! list($void, $parent_content_id) = explode('_', key($value)); $value = current($value); } $this->acm->editContentField($this->request->get['id'], $field, $value, $parent_content_id); } return null; } //request sent from jGrid. ID is key of array foreach ($this->request->post as $field => $value) { if (!in_array($field, $allowedFields)) { continue; } // NOTE: grid quicksave ids are not the same as id from form quick save request! list($parent_content_id, $content_id) = explode('_', key($value)); $this->acm->editContentField($content_id, $field, current($value), $parent_content_id); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
/** * @param AForm $form * @param array $data * @return array * */ private function _build_form_checkout($form, $data) { $fields = array(); //checkout section $this->load->model('sale/customer_group'); $results = $this->model_sale_customer_group->getCustomerGroups(); $customer_groups = array(); foreach ($results as $item) { $customer_groups[$item['customer_group_id']] = $item['name']; } $this->load->model('localisation/order_status'); $order_statuses = array(); $results = $this->model_localisation_order_status->getOrderStatuses(); foreach ($results as $item) { $order_statuses[$item['order_status_id']] = $item['name']; } $cntmnr = new AContentManager(); $results = $cntmnr->getContents(); $contents = array('' => $this->language->get('text_none')); foreach ($results as $item) { if (!$item['status']) { continue; } $contents[$item['content_id']] = $item['title']; } $fields['tax'] = $form->getFieldHtml($props[] = array('type' => 'checkbox', 'name' => 'config_tax', 'value' => $data['config_tax'], 'style' => 'btn_switch')); $fields['tax_store'] = $form->getFieldHtml($props[] = array('type' => 'selectbox', 'name' => 'config_tax_store', 'value' => $data['config_tax_store'], 'options' => array($this->language->get('entry_tax_store_0'), $this->language->get('entry_tax_store_1')))); $fields['tax_customer'] = $form->getFieldHtml($props[] = array('type' => 'selectbox', 'name' => 'config_tax_customer', 'value' => $data['config_tax_customer'], 'options' => array($this->language->get('entry_tax_customer_0'), $this->language->get('entry_tax_customer_1')))); $fields['start_order_id'] = $form->getFieldHtml($props[] = array('type' => 'input', 'name' => 'config_start_order_id', 'value' => $data['config_start_order_id'], 'style' => 'small-field')); $fields['invoice'] = $form->getFieldHtml($props[] = array('type' => 'input', 'name' => 'starting_invoice_id', 'value' => $data['starting_invoice_id'], 'style' => 'small-field')); $fields['invoice_prefix'] = $form->getFieldHtml($props[] = array('type' => 'input', 'name' => 'invoice_prefix', 'value' => $data['invoice_prefix'], 'style' => 'small-field')); $fields['customer_group'] = $form->getFieldHtml($props[] = array('type' => 'selectbox', 'name' => 'config_customer_group_id', 'value' => $data['config_customer_group_id'], 'options' => $customer_groups)); $fields['customer_price'] = $form->getFieldHtml($props[] = array('type' => 'checkbox', 'name' => 'config_customer_price', 'value' => $data['config_customer_price'], 'style' => 'btn_switch')); $fields['customer_approval'] = $form->getFieldHtml($props[] = array('type' => 'checkbox', 'name' => 'config_customer_approval', 'value' => $data['config_customer_approval'], 'style' => 'btn_switch')); $fields['customer_email_activation'] = $form->getFieldHtml($props[] = array('type' => 'checkbox', 'name' => 'config_customer_email_activation', 'value' => $data['config_customer_email_activation'], 'style' => 'btn_switch')); $fields['prevent_email_as_login'] = $form->getFieldHtml($props[] = array('type' => 'checkbox', 'name' => 'prevent_email_as_login', 'value' => $data['prevent_email_as_login'], 'style' => 'btn_switch')); $fields['guest_checkout'] = $form->getFieldHtml($props[] = array('type' => 'checkbox', 'name' => 'config_guest_checkout', 'value' => $data['config_guest_checkout'], 'style' => 'btn_switch')); $fields['account'] = $form->getFieldHtml($props[] = array('type' => 'selectbox', 'name' => 'config_account_id', 'value' => $data['config_account_id'], 'options' => $contents)); $fields['checkout'] = $form->getFieldHtml($props[] = array('type' => 'selectbox', 'name' => 'config_checkout_id', 'value' => $data['config_checkout_id'], 'options' => $contents)); $fields['stock_checkout'] = $form->getFieldHtml($props[] = array('type' => 'checkbox', 'name' => 'config_stock_checkout', 'value' => $data['config_stock_checkout'], 'style' => 'btn_switch')); $fields['total_order_maximum'] = $form->getFieldHtml($props[] = array('type' => 'input', 'name' => 'total_order_maximum', 'value' => $data['total_order_maximum'], 'style' => 'small-field')); $fields['total_order_minimum'] = $form->getFieldHtml($props[] = array('type' => 'input', 'name' => 'total_order_minimum', 'value' => $data['total_order_minimum'], 'style' => 'small-field')); $fields['order_status'] = $form->getFieldHtml($props[] = array('type' => 'selectbox', 'name' => 'config_order_status_id', 'value' => $data['config_order_status_id'], 'options' => $order_statuses)); $fields['customer_cancelation_order_status'] = $form->getFieldHtml($props[] = array('type' => 'multiselectbox', 'name' => 'config_customer_cancelation_order_status_id[]', 'value' => $data['config_customer_cancelation_order_status_id'] ? $data['config_customer_cancelation_order_status_id'] : array(), 'options' => $order_statuses, 'style' => 'chosen')); $fields['expire_order_days'] = $form->getFieldHtml($props[] = array('type' => 'input', 'name' => 'config_expire_order_days', 'value' => $data['config_expire_order_days'], 'style' => 'small-field')); $fields['cart_weight'] = $form->getFieldHtml($props[] = array('type' => 'checkbox', 'name' => 'config_cart_weight', 'value' => $data['config_cart_weight'], 'style' => 'btn_switch')); $fields['shipping_session'] = $form->getFieldHtml($props[] = array('type' => 'checkbox', 'name' => 'config_shipping_session', 'value' => $data['config_shipping_session'], 'style' => 'btn_switch')); $fields['cart_ajax'] = $form->getFieldHtml($props[] = array('type' => 'checkbox', 'name' => 'config_cart_ajax', 'value' => $data['config_cart_ajax'], 'style' => 'btn_switch')); $fields['zero_customer_balance'] = $form->getFieldHtml($props[] = array('type' => 'checkbox', 'name' => 'config_zero_customer_balance', 'value' => $data['config_zero_customer_balance'], 'style' => 'btn_switch')); $fields['shipping_tax_estimate'] = $form->getFieldHtml($props[] = array('type' => 'checkbox', 'name' => 'config_shipping_tax_estimate', 'value' => $data['config_shipping_tax_estimate'], 'style' => 'btn_switch')); $fields['coupon_on_cart_page'] = $form->getFieldHtml($props[] = array('type' => 'checkbox', 'name' => 'config_coupon_on_cart_page', 'value' => $data['config_coupon_on_cart_page'], 'style' => 'btn_switch')); if (isset($data['one_field'])) { $fields = $this->_filterField($fields, $props, $data['one_field']); } return $fields; }
private function _getForm() { if (isset($this->error['warning'])) { $this->data['error_warning'] = $this->error['warning']; } else { $this->data['error_warning'] = ''; } $this->data['error'] = $this->error; $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/menu'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ')); $this->data['cancel'] = $this->html->getSecureURL('design/menu'); $menu_item = null; $parent_id = array(); $menu_ids = $this->menu->getItemIds(); foreach ($menu_ids as $v) { $parent_id[$v] = $v; } if (isset($this->request->get['item_id'])) { $menu_item = $this->menu->getMenuItem($this->request->get['item_id']); unset($parent_id[array_search($this->request->get['item_id'], $parent_id)]); } foreach ($this->columns as $column) { if (isset($this->request->post[$column])) { $this->data[$column] = $this->request->post[$column]; } elseif (!empty($menu_item)) { $this->data[$column] = $menu_item[$column]; } else { $this->data[$column] = ''; } } if (!isset($this->request->get['item_id'])) { $this->data['action'] = $this->html->getSecureURL('design/menu/insert'); $this->data['heading_title'] = $this->language->get('text_insert') . ' ' . $this->language->get('heading_title'); $this->data['update'] = ''; $form = new AForm('ST'); } else { //do not allow to edit item_id $this->data['item_id'] = $menu_item['item_id']; $this->data['action'] = $this->html->getSecureURL('design/menu/update', '&item_id=' . $this->request->get['item_id']); $this->data['heading_title'] = $this->language->get('text_edit') . $this->language->get('heading_title'); $this->data['update'] = $this->html->getSecureURL('listing_grid/menu/update_field', '&id=' . $this->request->get['item_id']); $form = new AForm('HS'); } $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['heading_title'], 'separator' => ' :: ')); $form->setForm(array('form_name' => 'menuFrm', 'update' => $this->data['update'])); $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'menuFrm', 'attr' => '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['item_id'])) { $this->data['form']['fields']['item_id'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'item_id', 'value' => $this->data['item_id'], 'required' => true)); } else { $this->data['form']['fields']['item_id'] = $this->data['item_id']; } $this->data['form']['fields']['item_text'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'item_text[' . $this->session->data['content_language_id'] . ']', 'value' => $this->data['item_text'][$this->session->data['content_language_id']], 'required' => true, 'style' => 'large-field')); $this->data['form']['fields']['item_url'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'item_url', 'value' => $this->data['item_url'], 'style' => 'large-field', 'help_url' => $this->gen_help_url('item_url'))); $this->data['form']['fields']['parent_id'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'parent_id', 'options' => array_merge(array('' => $this->language->get('text_none')), $parent_id), 'value' => $this->data['parent_id'], 'style' => 'medium-field')); $this->data['form']['fields']['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order', 'value' => $this->data['sort_order'], 'style' => 'small-field')); $this->data['form']['fields']['item_icon'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'item_icon', 'value' => htmlspecialchars($this->data['item_icon'], ENT_COMPAT, 'UTF-8'))); //Added this hidden filed to save selected RL ID. Field is set from RL dialog same as item_icon //TODO: Need to add this filed to menu dataset $this->data['form']['fields']['item_icon_rl_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'item_icon_rl_id', 'value' => $this->data['item_icon_rl_id'])); $this->loadModel('catalog/category'); $categories = $this->model_catalog_category->getCategories(0); $options = array('' => $this->language->get('text_select')); foreach ($categories as $c) { if (!$c['status']) { continue; } $options[$c['category_id']] = $c['name']; } $this->data['categories'] = $this->html->buildSelectbox(array('type' => 'selectbox', 'name' => 'menu_categories', 'options' => $options, 'style' => 'no-save large-field')); $acm = new AContentManager(); $results = $acm->getContents(); $options = array('' => $this->language->get('text_select')); foreach ($results as $c) { if (!$c['status']) { continue; } $options[$c['content_id']] = $c['title']; } $this->data['pages'] = $this->html->buildSelectbox(array('type' => 'selectbox', 'name' => 'menu_information', 'options' => $options, 'style' => 'no-save large-field')); $this->data['button_link'] = $this->html->buildButton(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('text_link'), 'style' => 'button1')); $resource = new AResource('image'); //TODO: Need to complete item_icon_rl_id if ($menu_item['item_icon_rl_id'] > 0) { $this->data['icon'] = $this->dispatch('responses/common/resource_library/get_resource_html_single', array('type' => 'image', 'wrapper_id' => 'item_icon', 'resource_id' => $menu_item['item_icon_rl_id'], 'field' => 'item_icon')); } else { $this->data['icon'] = $this->dispatch('responses/common/resource_library/get_resource_html_single', array('type' => 'image', 'wrapper_id' => 'item_icon', 'resource_id' => $resource->getIdFromHexPath(str_replace('image/', '', $menu_item['item_icon'])), 'field' => 'item_icon')); } $this->data['icon'] = $this->data['icon']->dispatchGetOutput(); $resources_scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array('object_name' => 'storefront_menu_item', 'object_id' => $this->request->get['item_id'], 'types' => 'image', 'mode' => 'url')); $this->data['resources_scripts'] = $resources_scripts->dispatchGetOutput(); $this->view->batchAssign($this->language->getASet()); $this->view->batchAssign($this->data); $this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher()); $this->view->assign('help_url', $this->gen_help_url('menu_edit')); $this->processTemplate('pages/design/menu_form.tpl'); }
private function _getForm() { if (isset($this->error['warning'])) { $this->data['error_warning'] = $this->error['warning']; } else { $this->data['error_warning'] = ''; } $this->data['error'] = $this->error; $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/menu'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ')); $this->data['cancel'] = $this->html->getSecureURL('design/menu'); $language_id = $this->language->getContentLanguageID(); $item_id = $this->request->get['item_id']; $menu_item = null; $parent_id = array(); $this->menu_items = $this->menu->getMenuItems(); $this->_buildMenuTree(''); if ($item_id) { unset($this->menu_tree[$item_id]); } foreach ($this->menu_tree as $item) { $parent_id[$item['item_id']] = $item['text']; } foreach ($this->columns as $column) { if (isset($this->request->post[$column])) { $this->data[$column] = $this->request->post[$column]; } elseif (!empty($menu_item)) { $this->data[$column] = $menu_item[$column]; } else { $this->data[$column] = ''; } } if (!$item_id) { $this->data['action'] = $this->html->getSecureURL('design/menu/insert'); $this->data['heading_title'] = $this->language->get('text_insert') . ' ' . $this->language->get('heading_title'); $this->data['update'] = ''; $form = new AForm('ST'); } else { //get menu item details $this->data = array_merge($this->data, $this->menu->getMenuItem($item_id)); $this->data['action'] = $this->html->getSecureURL('design/menu/update', '&item_id=' . $item_id); $this->data['heading_title'] = $this->language->get('text_edit') . $this->language->get('heading_title'); $this->data['update'] = $this->html->getSecureURL('listing_grid/menu/update_field', '&id=' . $item_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' => 'menuFrm', 'update' => $this->data['update'])); $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'menuFrm', 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"', 'action' => $this->data['action'])); $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'))); $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'))); $this->data['form']['fields']['item_id'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'item_id', 'value' => $this->data['item_id'], 'required' => true, 'attr' => $item_id ? 'disabled' : '')); $this->data['form']['fields']['item_text'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'item_text[' . $language_id . ']', 'value' => $this->data['item_text'][$language_id], 'required' => true, 'style' => 'large-field')); $this->data['form']['fields']['item_url'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'item_url', 'value' => $this->data['item_url'], 'style' => 'large-field', 'help_url' => $this->gen_help_url('item_url'))); $this->data['form']['fields']['parent_id'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'parent_id', 'options' => array_merge(array('' => $this->language->get('text_none')), $parent_id), 'value' => $this->data['parent_id'], 'style' => 'medium-field')); $this->data['form']['fields']['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order', 'value' => $this->data['sort_order'], 'style' => 'small-field')); $this->data['form']['fields']['item_icon'] = $form->getFieldHtml(array('type' => 'resource', 'name' => 'item_icon', 'resource_path' => htmlspecialchars($this->data['item_icon'], ENT_COMPAT, 'UTF-8'), 'resource_id' => $this->data['item_icon_rl_id'], 'rl_type' => 'image')); //adds scripts for RL work $resources_scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array('object_name' => 'storefront_menu_item', 'object_id' => $this->request->get['item_id'], 'types' => array('image'), 'onload' => true, 'mode' => 'single')); $this->data['resources_scripts'] = $resources_scripts->dispatchGetOutput(); $this->loadModel('catalog/category'); $categories = $this->model_catalog_category->getCategories(0); $options = array('' => $this->language->get('text_select')); foreach ($categories as $c) { if (!$c['status']) { continue; } $options[$c['category_id']] = $c['name']; } $this->data['form']['fields']['link_category'] = $this->html->buildElement(array('type' => 'selectbox', 'name' => 'menu_categories', 'options' => $options, 'style' => 'no-save large-field')); $acm = new AContentManager(); $results = $acm->getContents(); $options = array('' => $this->language->get('text_select')); foreach ($results as $c) { if (!$c['status']) { continue; } $options[$c['content_id']] = $c['title']; } $this->data['form']['fields']['link_page'] = $this->html->buildElement(array('type' => 'selectbox', 'name' => 'menu_information', 'options' => $options, 'style' => 'no-save large-field')); $this->data['button_link'] = $this->html->buildElement(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('text_link'))); $this->view->batchAssign($this->language->getASet()); $this->view->batchAssign($this->data); $this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher()); $this->view->assign('help_url', $this->gen_help_url('menu_edit')); $this->processTemplate('pages/design/menu_form.tpl'); }