private function _getForm($content_id) { if (isset($this->error['warning'])) { $this->data['error_warning'] = $this->error['warning']; } else { $this->data['error_warning'] = ''; } $this->view->assign('success', $this->session->data['success']); if (isset($this->session->data['success'])) { unset($this->session->data['success']); } $this->data['error'] = $this->error; $this->data['language_id'] = $this->config->get('storefront_language_id'); if (has_value($content_id) && $this->request->is_GET()) { $content_info = $this->acm->getContent($content_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/content'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: ')); if (has_value($content_id)) { $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('design/content/update', '&content_id=' . $content_id), 'text' => $this->language->get('update_title') . ' - ' . $content_info['title'], 'separator' => ' :: ', 'current' => true)); } else { $this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('design/content/insert'), 'text' => $this->language->get('insert_title'), 'separator' => ' :: ', 'current' => true)); } $this->data['cancel'] = $this->html->getSecureURL('design/content'); $allowedFields = array('status', 'description', 'title', 'content', 'parent_content_id', 'sort_order', 'store_id', 'keyword'); foreach ($allowedFields as $field) { if (isset($this->request->post[$field])) { $this->data[$field] = $this->request->post[$field]; } elseif (isset($content_info)) { $this->data[$field] = $content_info[$field]; } else { $this->data[$field] = ''; } } //if get parent_id, we create new content for parent if ($this->request->get['parent_content_id']) { $this->data['parent_content_id'][] = $this->request->get['parent_content_id']; } if (!has_value($content_id)) { $this->data['action'] = $this->html->getSecureURL('design/content/insert'); $this->data['form_title'] = $this->language->get('insert_title'); $this->data['update'] = ''; $form = new AForm('ST'); } else { $this->data['action'] = $this->html->getSecureURL('design/content/update', '&content_id=' . $content_id); $this->data['form_title'] = $this->language->get('update_title'); $this->data['update'] = $this->html->getSecureURL('listing_grid/content/update_field', '&id=' . $content_id); $form = new AForm('HS'); } $form->setForm(array('form_name' => 'contentFrm', 'update' => $this->data['update'])); $this->data['form']['id'] = 'contentFrm'; $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'contentFrm', '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'), 'style' => 'button1')); $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2')); $this->data['form']['fields']['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => $this->data['status'], 'style' => 'btn_switch')); // we need get contents list for multiselect $multiSelect = $this->acm->getContentsForSelect(false); $selected_parents = array(); $this->data['parent_content_id'] = (array) $this->data['parent_content_id']; foreach ($this->data['parent_content_id'] as $parent_id) { //check if we have combined ID if (preg_match('/\\d+_\\d+/', $parent_id)) { list($void, $parent_id) = explode('_', $parent_id); } foreach ($multiSelect as $option_id => $option_value) { list($void, $p_content_id) = explode('_', $option_id); if ($parent_id == $p_content_id) { $selected_parents[$option_id] = $option_id; } if ($p_content_id == $content_id) { $disabled_parents[$option_id] = $option_id; } } } if (!$selected_parents) { $selected_parents = array('0_0' => '0_0'); } $this->data['form']['fields']['parent'] = $form->getFieldHtml(array('type' => 'multiSelectbox', 'name' => 'parent_content_id[]', 'options' => $multiSelect, 'value' => $selected_parents, 'disabled' => $disabled_parents, 'attr' => 'size = "' . (sizeof($multiSelect) > 10 ? 10 : sizeof($multiSelect)) . '"')); $this->data['form']['fields']['title'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'title', 'value' => $this->data['title'], 'required' => true, 'multilingual' => true)); $this->data['form']['fields']['description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'description', 'value' => $this->data['description'], 'multilingual' => true)); $this->data['form']['fields']['content'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'content', 'value' => $this->data['content'], 'required' => true, 'multilingual' => true)); $this->data['keyword_button'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'generate_seo_keyword', 'text' => $this->language->get('button_generate'), 'style' => 'btn btn-info')); $this->data['generate_seo_url'] = $this->html->getSecureURL('common/common/getseokeyword', '&object_key_name=content_id&id=' . $content_id); $this->data['form']['fields']['keyword'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'keyword', 'value' => $this->data['keyword'], 'style' => 'large-field', 'multilingual' => true, 'help_url' => $this->gen_help_url('seo_keyword'))); // get array with stores looks like array (store_id=>array(content_id=>store_name)) $store_values = $store_selected = array(); $store_values[0] = $this->language->get('text_default'); $stores = $this->acm->getContentStores($content_id); foreach ($stores as $store_id => $store) { $store_values[$store_id] = trim(current($store)); if (isset($store[$content_id])) { $store_selected[$store_id] = $store_id; } } if (!$store_selected) { $store_selected[0] = 0; } $this->data['form']['fields']['store'] = $form->getFieldHtml(array('type' => 'checkboxgroup', 'name' => 'store_id[]', 'value' => $store_selected, 'options' => $store_values, 'scrollbox' => true, 'style' => 'chosen')); $this->data['form']['fields']['sort_order'] = array(); foreach ($selected_parents as $option_id) { list($void, $parent_id) = explode('_', $option_id); $this->data['form']['fields']['sort_order'][$option_id] = array('label' => $multiSelect[$option_id], 'field' => $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order[' . $option_id . ']', 'value' => $this->data['sort_order'][$parent_id], 'style' => 'tiny-field'))); } $this->view->assign('help_url', $this->gen_help_url('content_edit')); $resources_scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array('object_name' => 'contents', 'object_id' => $p_content_id_id, 'types' => array('image'))); $this->data['resources_scripts'] = $resources_scripts->dispatchGetOutput(); $this->data['rl'] = $this->html->getSecureURL('common/resource_library', '&action=list_library&object_name=&object_id&type=image&mode=single'); $this->view->batchAssign($this->data); $this->processTemplate('pages/design/content_form.tpl'); }