本文整理汇总了PHP中HtmlElementFactory::getAvailableElements方法的典型用法代码示例。如果您正苦于以下问题:PHP HtmlElementFactory::getAvailableElements方法的具体用法?PHP HtmlElementFactory::getAvailableElements怎么用?PHP HtmlElementFactory::getAvailableElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlElementFactory
的用法示例。
在下文中一共展示了HtmlElementFactory::getAvailableElements方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
public function main()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$this->loadLanguage('catalog/product');
$this->document->setTitle($this->language->get('heading_title'));
$this->loadModel('catalog/product');
$this->attribute_manager = new AAttribute_Manager();
if ($this->request->is_POST() && $this->_validateForm()) {
$this->model_catalog_product->addProductOption($this->request->get['product_id'], $this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->redirect($this->html->getSecureURL('catalog/product_options', '&product_id=' . $this->request->get['product_id']));
}
$product_info = $this->model_catalog_product->getProduct($this->request->get['product_id']);
if (!$product_info) {
$this->session->data['warning'] = $this->language->get('error_product_not_found');
$this->redirect($this->html->getSecureURL('catalog/product'));
}
$this->data['attributes'] = array('new' => $this->language->get('text_add_new_option'));
$results = $this->attribute_manager->getAttributes(array('search' => " ga.attribute_type_id = '" . $this->attribute_manager->getAttributeTypeID('product_option') . "'\n\t\t\t\tAND ga.status = 1\n\t\t\t\tAND ga.attribute_parent_id = 0 ", 'sort' => 'sort_order', 'order' => 'ASC', 'limit' => 1000), $this->session->data['content_language_id']);
foreach ($results as $type) {
$this->data['attributes'][$type['attribute_id']] = $type['name'];
}
$this->data['product_description'] = $this->model_catalog_product->getProductDescriptions($this->request->get['product_id']);
$product_options = $this->model_catalog_product->getProductOptions($this->request->get['product_id']);
$content_language_id = $this->language->getContentLanguageID();
$default_language_id = $this->language->getDefaultLanguageID();
foreach ($product_options as &$option) {
$option_name = trim($option['language'][$content_language_id]['name']);
$option['language'][$content_language_id]['name'] = $option_name ? $option_name : 'n/a';
$option_name = trim($option['language'][$default_language_id]['name']);
$option['language'][$default_language_id]['name'] = $option_name ? $option_name : 'n/a';
}
unset($option);
$this->data['product_options'] = $product_options;
$this->data['language_id'] = $this->session->data['content_language_id'];
$this->data['url']['load_option'] = $this->html->getSecureURL('product/product/load_option', '&product_id=' . $this->request->get['product_id']);
$this->data['url']['update_option'] = $this->html->getSecureURL('product/product/update_option', '&product_id=' . $this->request->get['product_id']);
$this->data['url']['get_options_list'] = $this->html->getSecureURL('product/product/get_options_list', '&product_id=' . $this->request->get['product_id']);
$this->view->assign('error', $this->error);
$this->view->assign('success', $this->session->data['success']);
if (isset($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')));
$this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product'), 'text' => $this->language->get('heading_title')));
$this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product/update', '&product_id=' . $this->request->get['product_id']), 'text' => $this->language->get('text_edit') . ' ' . $this->language->get('text_product') . ' - ' . $this->data['product_description'][$this->session->data['content_language_id']]['name']));
$this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/product_options', '&product_id=' . $this->request->get['product_id']), 'text' => $this->language->get('tab_option'), 'current' => true));
$this->data['active'] = 'options';
//load tabs controller
$tabs_obj = $this->dispatch('pages/catalog/product_tabs', array($this->data));
$this->data['product_tabs'] = $tabs_obj->dispatchGetOutput();
unset($tabs_obj);
$results = HtmlElementFactory::getAvailableElements();
$element_types = array('' => $this->language->get('text_select'));
foreach ($results as $key => $type) {
// allowed field types
if (in_array($key, array('I', 'T', 'S', 'M', 'R', 'C', 'G', 'H', 'U'))) {
$element_types[$key] = $type['type'];
}
}
$this->data['button_add_option'] = $this->html->buildButton(array('text' => $this->language->get('button_add_option'), 'style' => 'button1'));
$this->data['button_add_option_value'] = $this->html->buildButton(array('text' => $this->language->get('button_add_option_value'), 'style' => 'button1'));
$this->data['button_remove'] = $this->html->buildButton(array('text' => $this->language->get('button_remove'), 'style' => 'button1'));
$this->data['button_reset'] = $this->html->buildButton(array('text' => $this->language->get('button_reset'), 'style' => 'button2'));
$this->data['action'] = $this->html->getSecureURL('catalog/product_options', '&product_id=' . $this->request->get['product_id']);
$this->data['form_title'] = $this->language->get('text_edit') . ' ' . $this->language->get('text_product');
$this->data['update'] = '';
$form = new AForm('HT');
$product_opt = array();
foreach ($product_options as $option) {
$product_opt[$option['product_option_id']] = $option['language'][$content_language_id]['name'];
}
$this->data['options'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'option', 'value' => $this->data['product_option_id'], 'options' => $product_opt));
$form->setForm(array('form_name' => 'product_form', 'update' => $this->data['update']));
$this->data['form']['id'] = 'product_form';
$this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'product_form', 'action' => $this->data['action'], 'attr' => 'data-confirm-exit="true" class="form-horizontal"'));
$this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_add'), 'style' => 'button1'));
$this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
$form->setForm(array('form_name' => 'new_option_form', 'update' => ''));
$this->data['attributes'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'attribute_id', 'options' => $this->data['attributes'], 'style' => 'chosen'));
$this->data['option_name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'option_name', 'required' => true));
$this->data['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => 1, 'style' => 'btn_switch'));
$this->data['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order', 'style' => 'small-field'));
$this->data['required'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'required', 'style' => 'btn_switch'));
$this->data['element_type'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'element_type', 'required' => true, 'options' => $element_types));
$this->addChild('pages/catalog/product_summary', 'summary_form', 'pages/catalog/product_summary.tpl');
$object_title = $this->language->get('text_product') . ' ' . $this->language->get('text_option_value');
$params = '&object_name=product_option_value&object_title=' . $object_title;
$this->data['rl_resource_library'] = $this->html->getSecureURL('common/resource_library', $params);
$this->data['rl_resources'] = $this->html->getSecureURL('common/resource_library/resources', $params);
$this->data['rl_resource_single'] = $this->html->getSecureURL('common/resource_library/get_resource_details', $params);
$this->data['rl_delete'] = $this->html->getSecureURL('common/resource_library/delete');
$this->data['rl_unmap'] = $this->html->getSecureURL('common/resource_library/unmap', $params);
$this->data['rl_map'] = $this->html->getSecureURL('common/resource_library/map', $params);
$this->data['rl_download'] = $this->html->getSecureURL('common/resource_library/get_resource_preview');
$this->data['rl_upload'] = $this->html->getSecureURL('common/resource_library/upload', $params);
$resources_scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array('object_name' => 'product_option_value', 'object_id' => '', 'types' => array('image'), 'onload' => false));
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']);
//.........这里部分代码省略.........
示例2: getOrderProductOptions
public function getOrderProductOptions($product_id)
{
if (!(int) $product_id) {
return array();
}
$language_id = $this->language->getContentLanguageID();
$elements = HtmlElementFactory::getAvailableElements();
$product_option_data = array();
$product_option_query = $this->db->query("SELECT po.*, pod.option_placeholder, pod.error_text\n\t\t\tFROM " . $this->db->table("product_options") . " po\n\t\t\tLEFT JOIN " . $this->db->table("product_option_descriptions") . " pod\n\t\t\t\tON pod.product_option_id = po.product_option_id AND pod.language_id = '" . $language_id . "'\n\t\t\tWHERE po.product_id = '" . (int) $product_id . "'\n\t\t\t\tAND po.group_id = 0\n\t\t\t\tAND po.status = 1\n\t\t\tORDER BY po.sort_order");
if ($product_option_query) {
foreach ($product_option_query->rows as $product_option) {
$attribute_values = array();
$product_option_value_data = array();
$product_option_value_query = $this->db->query("SELECT *\n\t\t\t\t\t\tFROM " . $this->db->table("product_option_values") . "\n\t\t\t\t\t\tWHERE product_option_id = '" . (int) $product_option['product_option_id'] . "'\n\t\t\t\t\t\tORDER BY sort_order");
if ($product_option_value_query) {
foreach ($product_option_value_query->rows as $product_option_value) {
if ($product_option_value['attribute_value_id']) {
//skip duplicate attributes values if it is not grouped parent/child
if (in_array($product_option_value['attribute_value_id'], $attribute_values)) {
continue;
}
$attribute_values[] = $product_option_value['attribute_value_id'];
}
$pd_opt_val_description_qr = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\tFROM " . $this->db->table("product_option_value_descriptions") . "\n\t\t\t\t\t\t\t\tWHERE product_option_value_id = '" . (int) $product_option_value['product_option_value_id'] . "'\n\t\t\t\t\t\t\t\tAND language_id = '" . (int) $language_id . "'");
$product_option_value_data[$product_option_value['product_option_value_id']] = array('product_option_value_id' => $product_option_value['product_option_value_id'], 'attribute_value_id' => $product_option_value['attribute_value_id'], 'grouped_attribute_data' => $product_option_value['grouped_attribute_data'], 'group_id' => $product_option_value['group_id'], 'name' => $pd_opt_val_description_qr->row['name'], 'option_placeholder' => $product_option['option_placeholder'], 'regexp_pattern' => $product_option['regexp_pattern'], 'error_text' => $product_option['error_text'], 'settings' => $product_option['settings'], 'children_options_names' => $pd_opt_val_description_qr->row['children_options_names'], 'sku' => $product_option_value['sku'], 'price' => $product_option_value['price'], 'prefix' => $product_option_value['prefix'], 'weight' => $product_option_value['weight'], 'weight_type' => $product_option_value['weight_type'], 'quantity' => $product_option_value['quantity'], 'subtract' => $product_option_value['subtract'], 'default' => $product_option_value['default']);
}
}
$prd_opt_description_qr = $this->db->query("SELECT *\n\t\t\t\t\tFROM " . $this->db->table("product_option_descriptions") . "\n\t\t\t\t\tWHERE product_option_id = '" . (int) $product_option['product_option_id'] . "'\n\t\t\t\t\t\tAND language_id = '" . (int) $language_id . "'");
$product_option_data[$product_option['product_option_id']] = array('product_option_id' => $product_option['product_option_id'], 'attribute_id' => $product_option['attribute_id'], 'group_id' => $product_option['group_id'], 'name' => $prd_opt_description_qr->row['name'], 'option_placeholder' => $product_option['option_placeholder'], 'option_value' => $product_option_value_data, 'sort_order' => $product_option['sort_order'], 'element_type' => $product_option['element_type'], 'html_type' => $elements[$product_option['element_type']]['type'], 'required' => $product_option['required'], 'regexp_pattern' => $product_option['regexp_pattern'], 'error_text' => $product_option['error_text'], 'settings' => $product_option['settings']);
}
}
return $product_option_data;
}
示例3: _buildAttributesSubform
/**
* @param AForm $form
*/
private function _buildAttributesSubform($form)
{
$attributes = $this->model_catalog_download->getDownloadAttributes($this->data['download_id']);
$elements = HtmlElementFactory::getAvailableElements();
$html_multivalue_elements = HtmlElementFactory::getMultivalueElements();
$html_elements_with_options = HtmlElementFactory::getElementsWithOptions();
if (!$attributes) {
$attr_mng = new AAttribute_Manager('download_attribute');
$attr_type_id = $attr_mng->getAttributeTypeID('download_attribute');
$this->data['form']['fields']['attributes']['no_attr'] = sprintf($this->language->get('text_no_download_attributes_yet'), $this->html->getSecureURL('catalog/attribute/insert', '&attribute_type_id=' . $attr_type_id));
} else {
foreach ($attributes as $attribute) {
$html_type = $elements[$attribute['element_type']]['type'];
if (!$html_type || !$attribute['status']) {
continue;
}
$values = $value = array();
//values that was setted
if (in_array($attribute['element_type'], $html_elements_with_options) && $attribute['element_type'] != 'R') {
if (is_array($attribute['selected_values'])) {
foreach ($attribute['selected_values'] as $val) {
$value[$val] = $val;
}
} else {
$value = $attribute['selected_values'];
}
} else {
if (isset($attribute['selected_values'])) {
$value = $attribute['selected_values'];
if ($attribute['element_type'] == 'R' && is_array($value)) {
$value = current($value);
}
} else {
$value = $attribute['values'][0]['value'];
}
}
$checked = false;
if ($attribute['element_type'] == 'C') {
if ($value) {
$checked = true;
//if value of attribute presents
} else {
$value = 1;
}
}
if ($attribute['element_type'] == 'S') {
$values[''] = $this->language->get('text_select');
// give ability to select nothing for selectbox
}
// possible values
foreach ($attribute['values'] as $val) {
$values[$val['attribute_value_id']] = $val['value'];
}
if (!in_array($attribute['element_type'], $html_multivalue_elements)) {
$option_name = 'attributes[' . $this->data['download_id'] . '][' . $attribute['attribute_id'] . ']';
} else {
$option_name = 'attributes[' . $this->data['download_id'] . '][' . $attribute['attribute_id'] . '][' . $attribute['attribute_value_id'] . ']';
}
$disabled = '';
$required = $attribute['required'];
$option_data = array('type' => $html_type, 'name' => $option_name, 'value' => $value, 'options' => $values, 'required' => $required, 'attr' => $disabled, 'style' => 'large-field');
if ($html_type == 'checkboxgroup') {
$option_data['scrollbox'] = true;
}
if ($html_type == 'checkbox') {
$option_data['checked'] = $checked;
$option_data['style'] .= ' btn_switch';
}
$this->data['entry_' . $attribute['attribute_id']] = $attribute['name'];
$this->data['form']['fields']['attributes'][$attribute['attribute_id']] = $form->getFieldHtml($option_data);
}
}
}
示例4: getDownloadAttributeSubform
/**
* method that return part of attribute form for download attribute
* @internal param array $param
* @param array $params
*/
public function getDownloadAttributeSubform($params = array())
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$this->data = array_merge($this->data, $params['data']);
unset($this->data['form']['fields']);
// remove form fields that do not needed here
$this->data['elements_with_options'] = HtmlElementFactory::getElementsWithOptions();
$results = HtmlElementFactory::getAvailableElements();
$element_types = array('' => $this->language->get('text_select'));
foreach ($results as $key => $type) {
// allowed field types
if (in_array($key, array('I', 'T', 'S', 'M', 'R', 'C'))) {
$element_types[$key] = $type['type'];
}
}
$form = $params['aform'];
$attribute_manager = $params['attribute_manager'];
$this->data['form']['fields']['element_type'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'element_type', 'value' => $this->data['element_type'], 'required' => true, 'options' => $element_types));
$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']['show_to_customer'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'settings[show_to_customer]', 'value' => 1, 'checked' => $this->data['settings'] && $this->data['settings']['show_to_customer'] ? true : false, 'style' => 'btn_switch'));
//Build atribute values part of the form
if ($this->request->get['attribute_id']) {
$this->data['child_count'] = $attribute_manager->totalChildren($this->request->get['attribute_id']);
if ($this->data['child_count'] > 0) {
$children_attr = $attribute_manager->getAttributes(array(), 0, $this->request->get['attribute_id']);
foreach ($children_attr as $attr) {
$this->data['children'][] = array('name' => $attr['name'], 'link' => $this->html->getSecureURL('catalog/attribute/update', '&attribute_id=' . $attr['attribute_id']));
}
}
$attribute_values = $attribute_manager->getAttributeValues($this->request->get['attribute_id']);
foreach ($attribute_values as $atr_val) {
$atr_val_id = $atr_val['attribute_value_id'];
$attributes_fields[$atr_val_id]['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_orders[' . $atr_val_id . ']', 'value' => $atr_val['sort_order'], 'style' => 'small-field'));
$attributes_fields[$atr_val_id]['values'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'values[' . $atr_val_id . ']', 'value' => $atr_val['value'], 'style' => 'medium-field'));
$attributes_fields[$atr_val_id]['attribute_value_ids'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'attribute_value_ids[' . $atr_val_id . ']', 'value' => $atr_val_id, 'style' => 'medium-field'));
}
}
if (!$attributes_fields) {
$attributes_fields[0]['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_orders[]', 'value' => '', 'style' => 'small-field no-save'));
$attributes_fields[0]['values'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'values[]', 'value' => '', 'style' => 'medium-field no-save'));
$attributes_fields[0]['attribute_value_ids'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'attribute_value_ids[' . $atr_val_id . ']', 'value' => 'new', 'style' => 'medium-field'));
}
$this->data['form']['attribute_values'] = $attributes_fields;
$this->view->batchAssign($this->data);
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->processTemplate('responses/catalog/global_attribute_product_option_subform.tpl');
}
示例5: load_field
public function load_field()
{
$this->loadLanguage('forms_manager/forms_manager');
$this->loadModel('tool/forms_manager');
$this->data['error_warning'] = $this->session->data['warning'];
if (isset($this->session->data['warning'])) {
unset($this->session->data['warning']);
}
$this->view->assign('success', $this->session->data['success']);
unset($this->session->data['success']);
$this->data['language_id'] = $this->session->data['content_language_id'];
$this->data['field_data'] = $this->model_tool_forms_manager->getField($this->request->get['field_id']);
$this->data['element_types'] = HtmlElementFactory::getAvailableElements();
$this->data['elements_with_options'] = HtmlElementFactory::getElementsWithOptions();
$this->data['no_set_values_elements'] = array('K' => 'captcha', 'D' => 'date', 'A' => 'IPaddress', 'O' => 'countries', 'Z' => 'zones');
$this->data['selectable'] = in_array($this->data['field_data']['element_type'], $this->data['elements_with_options']) ? 1 : 0;
$this->data['field_type'] = $this->data['element_types'][$this->data['field_data']['element_type']]['type'];
$this->data['field_name'] = $this->html->buildInput(array('name' => 'field_name', 'value' => $this->data['field_data']['field_name'], 'required' => true));
$this->data['field_description'] = $this->html->buildElement(array('type' => 'input', 'name' => 'field_description', 'value' => $this->data['field_data']['name'], 'required' => true));
$this->data['field_note'] = $this->html->buildElement(array('type' => 'input', 'name' => 'field_note', 'value' => $this->data['field_data']['description']));
$this->data['entry_status'] = $this->language->get('forms_manager_status');
$this->data['status'] = $this->html->buildElement(array('type' => 'checkbox', 'name' => 'status', 'value' => $this->data['field_data']['status'], 'style' => 'btn_switch btn-group-xs'));
$this->data['field_sort_order'] = $this->html->buildElement(array('type' => 'input', 'name' => 'sort_order', 'value' => $this->data['field_data']['sort_order'], 'style' => 'small-field'));
$this->data['required'] = $this->html->buildElement(array('type' => 'checkbox', 'name' => 'required', 'value' => $this->data['field_data']['required'] == 'Y' ? 1 : 0, 'style' => 'btn_switch btn-group-xs'));
if (!in_array($this->data['field_data']['element_type'], array('U', 'K'))) {
$this->data['field_regexp_pattern'] = $this->html->buildElement(array('type' => 'input', 'name' => 'regexp_pattern', 'value' => $this->data['field_data']['regexp_pattern'], 'style' => 'large-field'));
$this->data['field_error_text'] = $this->html->buildElement(array('type' => 'input', 'name' => 'error_text', 'value' => $this->data['field_data']['error_text'], 'style' => 'large-field'));
}
if ($this->data['field_data']['element_type'] == 'U') {
$this->data['field_settings'] = $this->_file_upload_settings_form();
}
$this->data['hidden_element_type'] = $this->html->buildElement(array('type' => 'hidden', 'name' => 'element_type', 'value' => $this->data['field_data']['element_type']));
$this->data['button_remove_field'] = $this->html->buildElement(array('type' => 'button', 'href' => $this->html->getSecureURL('tool/forms_manager/removeField', '&form_id=' . $this->request->get['form_id'] . '&field_id=' . $this->request->get['field_id']), 'text' => $this->language->get('button_remove_field')));
$this->data['button_save'] = $this->html->buildElement(array('type' => 'button', 'text' => $this->language->get('button_save')));
$this->data['button_reset'] = $this->html->buildElement(array('type' => 'button', 'text' => $this->language->get('button_reset')));
$this->data['update_field_values'] = $this->html->getSecureURL('forms_manager/fields/update_field_values', '&form_id=' . $this->request->get['form_id'] . '&field_id=' . $this->request->get['field_id']);
$this->data['remove_field_link'] = $this->html->getSecureURL('forms_manager/fields/remove_field', '&form_id=' . $this->request->get['form_id'] . '&field_id=' . $this->request->get['field_id']);
// form of option values list
$form = new AForm('HT');
$form->setForm(array('form_name' => 'update_field_values'));
$this->data['form']['id'] = 'update_field_values';
$this->data['update_field_values_form']['open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'update_field_values', 'action' => $this->data['update_field_values']));
//form of option
$form = new AForm('HT');
$form->setForm(array('form_name' => 'field_value_form'));
$this->data['form']['id'] = 'field_value_form';
$this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'field_value_form', 'action' => $this->data['update_field_values']));
//Load option values rows
$this->data['field_values'] = array();
if (!in_array($this->data['field_data']['element_type'], array('U', 'K'))) {
if (!empty($this->data['field_data']['values'])) {
usort($this->data['field_data']['values'], array('self', '_sort_by_sort_order'));
foreach ($this->data['field_data']['values'] as $key => $item) {
$item['id'] = $key;
$this->data['field_values'][$key]['row'] = $this->_field_value_form($item, $form);
}
} else {
$this->data['field_values']['new']['row'] = $this->_field_value_form(array(), $form);
}
}
$this->data['new_field_row'] = '';
if (in_array($this->data['field_data']['element_type'], $this->data['elements_with_options']) || $this->data['empty_values'] && !in_array($this->data['field_type'], $this->data['no_set_values_elements'])) {
$this->data['new_value_row'] = $this->_field_value_form(array(), $form);
}
$this->data['new_value_row'] = $this->_field_value_form(array(), $form);
$this->view->batchAssign($this->data);
$this->processTemplate('responses/forms_manager/field_values.tpl');
}
示例6: _getForm
private function _getForm()
{
//check is set sender name and email for settings
if (!$this->config->get('forms_manager_default_sender_name') || !$this->config->get('forms_manager_default_sender_email')) {
$this->data['error_warning'] = $this->html->convertLinks($this->language->get('forms_manager_error_empty_sender'));
}
$this->data['form_data'] = $this->model_tool_forms_manager->getFormById($this->request->get['form_id']);
$this->data['form_edit_title'] = isset($this->data['form_data']['description']) ? $this->data['form_data']['description'] : $this->language->get('entry_add_new_form');
$this->data['cancel'] = $this->html->getSecureURL('tool/forms_manager');
$this->data['heading_title'] = $this->language->get('forms_manager_name');
$this->data['update'] = $this->html->getSecureURL('grid/form/update_field', '&form_id=' . $this->data['form_data']['form_id']);
$this->data['field_id'] = (int) $this->request->get['field_id'];
if ($this->request->get['form_id']) {
$head_form = new AForm('HS');
$this->data['entry_edit_form'] = $this->language->get('text_edit') . ' ' . $this->language->get('text_form');
$this->data['form_id'] = $this->request->get['form_id'];
$this->data['action'] = $this->html->getSecureURL('tool/forms_manager/update', '&form_id=' . $this->data['form_data']['form_id']);
} else {
$head_form = new AForm('HT');
$this->data['action'] = $this->html->getSecureURL('tool/forms_manager/update');
}
$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('tool/forms_manager'), 'text' => $this->language->get('forms_manager_name'), 'separator' => ' :: '));
$this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('tool/forms_manager'), 'text' => $this->data['entry_edit_form'] . ' ' . $this->data['form_data']['form_name'], 'separator' => ' :: ', 'current' => true));
$head_form->setForm(array('form_name' => 'extFrm', 'update' => $this->data['update']));
$this->data['head_form']['id'] = 'extFrm';
$this->data['head_form']['form_open'] = $head_form->getFieldHtml(array('type' => 'form', 'name' => 'extFrm', 'action' => $this->data['action']));
$this->data['head_form']['button_save'] = $head_form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1'));
$this->data['head_form']['button_reset'] = $head_form->getFieldHtml(array('type' => 'button', 'name' => 'reset', 'href' => $this->data['action'], 'text' => $this->language->get('button_reset'), 'style' => 'button2'));
$this->data['head_form']['fields']['form_status'] = $head_form->getFieldHtml(array('type' => 'checkbox', 'name' => 'form_status', 'value' => isset($this->data['form_data']['status']) ? $this->data['form_data']['status'] : '', 'required' => true, 'style' => 'btn_switch status_switch'));
$this->data['entry_form_status'] = $this->language->get('forms_manager_status');
$this->data['head_form']['fields']['form_name'] = $head_form->getFieldHtml(array('type' => 'input', 'name' => 'form_name', 'value' => isset($this->data['form_data']['form_name']) ? $this->data['form_data']['form_name'] : '', 'required' => true, 'style' => 'large-field'));
$this->data['head_form']['fields']['form_description'] = $head_form->getFieldHtml(array('type' => 'input', 'name' => 'form_description', 'value' => isset($this->data['form_data']['description']) ? $this->data['form_data']['description'] : '', 'required' => true, 'style' => 'large-field', 'multilingual' => true));
$this->data['head_form']['fields']['controller_path'] = $head_form->getFieldHtml(array('type' => 'selectbox', 'name' => 'controller_path', 'options' => $this->controllers, 'value' => isset($this->data['form_data']['controller']) ? $this->data['form_data']['controller'] : 'forms_manager/default_email', 'required' => true, 'style' => 'large-field'));
$this->data['head_form']['fields']['success_page'] = $head_form->getFieldHtml(array('type' => 'input', 'name' => 'success_page', 'value' => isset($this->data['form_data']['success_page']) ? $this->data['form_data']['success_page'] : 'forms_manager/default_email/success', 'style' => 'large-field'));
$this->data['error_required'] = $this->language->get('error_required');
$this->data['forms_fields'] = array();
$fields_data = $this->model_tool_forms_manager->getFields($this->data['form_data']['form_id']);
$this->data['fields'] = array();
if ($fields_data) {
foreach ($fields_data as $field_data) {
$this->data['fields'][$field_data['field_id']] = $field_data['field_name'];
$fields[$field_data['field_id']] = $field_data['field_name'];
}
$this->data['field_id'] = !$this->data['field_id'] ? current(array_keys($fields)) : $this->data['field_id'];
} else {
$fields = array('new' => $this->language->get('text_add_new_field'));
}
$form = new AForm('HT');
$form->setForm(array('form_name' => 'new_fieldFrm', 'update' => ''));
$this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'new_fieldFrm', 'action' => $this->html->getSecureURL('forms_manager/fields/addField', '&form_id=' . $this->data['form_data']['form_id'])));
$this->data['form']['fields'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'field_id', 'options' => $fields));
$this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_add_field')));
$this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'text' => $this->language->get('button_cancel')));
$results = HtmlElementFactory::getAvailableElements();
$element_types = array('' => $this->language->get('text_select_field_type'));
foreach ($results as $key => $type) {
// file and multivalue element types disabled for now,
//J = reCaptcha is not selectable, it will be used automatically if instead of captcha if enabled
if (!in_array($key, array('P', 'L', 'J'))) {
$element_types[$key] = $type['type'];
}
}
$this->data['entry_new_field_description'] = $this->language->get('entry_field_description');
$this->data['new_field_description'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'field_description', 'required' => true));
$this->data['entry_new_field_name'] = $this->language->get('entry_field_name');
$this->data['new_field_name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'field_name', 'required' => true));
$this->data['entry_new_field_note'] = $this->language->get('entry_field_note');
$this->data['new_field_note'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'field_note', 'required' => false));
$this->data['entry_status'] = $this->language->get('forms_manager_status');
$this->data['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => 1, 'style' => 'btn_switch btn-group-xs'));
$this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
$this->data['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order', 'style' => 'small-field'));
$this->data['entry_required'] = $this->language->get('entry_required');
$this->data['required'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'required', 'style' => 'btn_switch btn-group-xs'));
$this->data['entry_element_type'] = $this->language->get('text_field_type');
$this->data['element_type'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'element_type', 'required' => true, 'options' => $element_types));
$this->data['urls'] = array();
$this->data['urls']['get_fields_list'] = $this->html->getSecureURL('forms_manager/fields/get_fields_list', '&form_id=' . $this->request->get['form_id']);
$this->data['urls']['load_field'] = $this->html->getSecureURL('forms_manager/fields/load_field', '&form_id=' . $this->request->get['form_id']);
$this->data['urls']['update_field'] = $this->html->getSecureURL('forms_manager/fields/updateField', '&form_id=' . $this->request->get['form_id']);
$this->data['urls']['update_form'] = $this->html->getSecureURL('forms_manager/fields/update_form', '&form_id=' . $this->request->get['form_id']);
$this->data['text_success_field'] = $this->language->get('text_success_field');
$this->data['help_url'] = $this->gen_help_url('forms_manager');
$this->data['form_language_switch'] = $this->html->getContentLanguageSwitcher();
$this->data['note'] = sprintf($this->language->get('note_create_form_block'), $this->html->getSecureURL('design/blocks'), $this->html->getSecureURL('design/layout'));
$this->view->batchAssign($this->data);
$this->processTemplate('pages/tool/forms_manager_form.tpl');
}
示例7: getProductOptions
/**
* @param int $product_id
* @return array
*/
public function getProductOptions($product_id)
{
if (!(int) $product_id) {
return array();
}
$language_id = (int) $this->config->get('storefront_language_id');
$cache_key = 'product.options.' . $product_id . '.lang_' . $language_id;
$product_option_data = $this->cache->pull($cache_key);
$elements = HtmlElementFactory::getAvailableElements();
if ($product_option_data === false) {
$product_option_data = array();
$product_option_query = $this->db->query("SELECT po.*, pod.option_placeholder, pod.error_text\n FROM " . $this->db->table("product_options") . " po\n LEFT JOIN " . $this->db->table("product_option_descriptions") . " pod\n \tON pod.product_option_id = po.product_option_id AND pod.language_id = '" . $language_id . "'\n WHERE po.product_id = '" . (int) $product_id . "'\n AND po.group_id = 0\n AND po.status = 1\n ORDER BY po.sort_order");
if ($product_option_query) {
foreach ($product_option_query->rows as $product_option) {
$attribute_values = array();
$product_option_value_data = array();
$product_option_value_query = $this->db->query("SELECT *\n FROM " . $this->db->table("product_option_values") . "\n WHERE product_option_id = '" . (int) $product_option['product_option_id'] . "'\n ORDER BY sort_order");
if ($product_option_value_query) {
foreach ($product_option_value_query->rows as $product_option_value) {
if ($product_option_value['attribute_value_id']) {
//skip duplicate attributes values if it is not grouped parent/child
if (in_array($product_option_value['attribute_value_id'], $attribute_values)) {
continue;
}
$attribute_values[] = $product_option_value['attribute_value_id'];
}
$pd_opt_val_description_qr = $this->db->query("SELECT *\n FROM " . $this->db->table("product_option_value_descriptions") . "\n WHERE product_option_value_id = '" . (int) $product_option_value['product_option_value_id'] . "'\n AND language_id = '" . (int) $language_id . "'");
// ignore option value with 0 quantity and disabled subtract
if (!$product_option_value['subtract'] || !$this->config->get('config_nostock_autodisable') || $product_option_value['quantity'] && $product_option_value['subtract']) {
$product_option_value_data[$product_option_value['product_option_value_id']] = array('product_option_value_id' => $product_option_value['product_option_value_id'], 'attribute_value_id' => $product_option_value['attribute_value_id'], 'grouped_attribute_data' => $product_option_value['grouped_attribute_data'], 'group_id' => $product_option_value['group_id'], 'name' => $pd_opt_val_description_qr->row['name'], 'option_placeholder' => $product_option['option_placeholder'], 'regexp_pattern' => $product_option['regexp_pattern'], 'error_text' => $product_option['error_text'], 'settings' => $product_option['settings'], 'children_options_names' => $pd_opt_val_description_qr->row['children_options_names'], 'sku' => $product_option_value['sku'], 'price' => $product_option_value['price'], 'prefix' => $product_option_value['prefix'], 'weight' => $product_option_value['weight'], 'weight_type' => $product_option_value['weight_type'], 'quantity' => $product_option_value['quantity'], 'subtract' => $product_option_value['subtract'], 'default' => $product_option_value['default']);
}
}
}
$prd_opt_description_qr = $this->db->query("SELECT *\n FROM " . $this->db->table("product_option_descriptions") . "\n WHERE product_option_id = '" . (int) $product_option['product_option_id'] . "'\n AND language_id = '" . (int) $language_id . "'");
$product_option_data[$product_option['product_option_id']] = array('product_option_id' => $product_option['product_option_id'], 'attribute_id' => $product_option['attribute_id'], 'group_id' => $product_option['group_id'], 'name' => $prd_opt_description_qr->row['name'], 'option_placeholder' => $product_option['option_placeholder'], 'option_value' => $product_option_value_data, 'sort_order' => $product_option['sort_order'], 'element_type' => $product_option['element_type'], 'html_type' => $elements[$product_option['element_type']]['type'], 'required' => $product_option['required'], 'regexp_pattern' => $product_option['regexp_pattern'], 'error_text' => $product_option['error_text'], 'settings' => $product_option['settings']);
}
}
$this->cache->push($cache_key, $product_option_data);
}
return $product_option_data;
}
示例8: buildDownloadForm
/**
* @param array $file_data
* @param string $tpl
*/
public function buildDownloadForm($file_data, $tpl)
{
$this->data = array();
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$this->loadLanguage('catalog/files');
$this->loadModel('localisation/order_status');
$this->loadModel('catalog/download');
$product_id = $file_data['product_id'];
$order_statuses = $this->model_localisation_order_status->getOrderStatuses();
$this->data['date_added'] = dateISO2Display($file_data['date_added'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
$this->data['date_modified'] = dateISO2Display($file_data['date_modified'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format'));
$this->data['action'] = $this->html->getSecureURL('r/product/product/processDownloadForm', '&product_id=' . $product_id);
$this->data['form_title'] = $this->language->get('text_edit') . ' ' . $this->language->get('text_product');
$this->data['download_id'] = (int) $file_data['download_id'];
if ($this->data['download_id']) {
$form = new AForm('HS');
$this->data['update'] = $this->html->getSecureURL('listing_grid/download/update_field', '&id=' . $this->data['download_id']);
} else {
$form = new AForm('HT');
}
$form->setForm(array('form_name' => 'downloadFrm' . $file_data['download_id'], 'update' => $this->data['update']));
$this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'downloadFrm' . $file_data['download_id'], 'attr' => 'confirm-exit="true"', 'action' => $this->data['action']));
$this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => (int) $this->data['download_id'] ? $this->language->get('button_save') : $this->language->get('text_add'), 'style' => 'button1'));
$this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'href' => $this->html->getSecureURL('catalog/product_files', '&product_id=' . $product_id), 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
$rl = new AResource('download');
$rl_dir = $rl->getTypeDir();
$resource_id = $rl->getIdFromHexPath(str_replace($rl_dir, '', $file_data['filename']));
$resource_info = $rl->getResource($resource_id);
$thumbnail = $rl->getResourceThumb($resource_id, 30, 30);
if ($resource_info['resource_path']) {
$this->data['icon'] = $this->html->buildResourceImage(array('url' => $thumbnail, 'width' => 30, 'height' => 30, 'attr' => 'alt="' . $resource_info['title'] . '"'));
} else {
$this->data['icon'] = $resource_info['resource_code'];
}
if ($resource_id) {
$this->data['preview']['href'] = $this->html->getSecureURL('common/resource_library/get_resource_preview', '&resource_id=' . $resource_id, true);
$this->data['preview']['path'] = 'resources/' . $file_data['filename'];
}
$r = $this->dispatch('responses/common/resource_library/get_resource_html_single', array('type' => 'download', 'wrapper_id' => 'download_' . (int) $this->data['download_id'], 'resource_id' => $resource_id, 'field' => 'download_rl_path_' . $this->data['download_id']));
$this->data['resource'] = $r->dispatchGetOutput();
$resources_scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array('object_name' => 'downloads', 'object_id' => (int) $this->data['download_id'], 'types' => 'download', 'mode' => 'url'));
$this->data['resources_scripts'] = $resources_scripts->dispatchGetOutput();
$this->data['form']['fields']['download_rl_path'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'download_rl_path_' . $this->data['download_id'], 'value' => htmlspecialchars($file_data['filename'], ENT_COMPAT, 'UTF-8')));
$this->data['form']['fields']['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => 1, 'checked' => $file_data['status'] ? true : false, 'style' => 'btn_switch'));
$orders_count = $this->model_catalog_download->getTotalOrdersWithProduct($product_id);
if ($orders_count) {
$this->data['push_to_customers'] = $this->html->buildElement(array('type' => 'button', 'name' => 'push_to_customers', 'title' => sprintf($this->language->get('text_push_to_orders'), $orders_count), 'text' => $this->language->get('text_push'), 'href' => $this->html->getSecureURL('r/product/product/pushToCustomers', '&product_id=' . $product_id . '&download_id=' . $this->data['download_id']), 'style' => 'button2', 'attr' => 'data-orders-count="' . $orders_count . '"'));
}
$this->data['maplist'] = array();
$file_data['map_list'] = (array) $file_data['map_list'];
foreach ($file_data['map_list'] as $map_id => $map_name) {
if ($map_id == $product_id) {
continue;
}
$this->data['maplist'][] = array('href' => $this->html->getSecureURL('catalog/product_files', '&product_id=' . $map_id . '&download_id=' . $this->data['download_id'], true), 'text' => $map_name);
}
if (!sizeof($this->data['maplist'])) {
$this->data['already_shared'] = false;
} else {
$this->data['already_shared'] = true;
}
$this->data['delete_unmap_href'] = $this->html->getSecureURL('catalog/product_files', '&act=' . ($file_data['shared'] ? 'unmap' : 'delete') . '&product_id=' . $product_id . '&download_id=' . $this->data['download_id'], true);
$this->data['form']['fields']['shared'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'shared', 'value' => $file_data['shared'], 'attr' => $this->data['already_shared'] ? ' disabled=disabled' : ''));
if ($file_data['shared']) {
$this->data['text_attention_shared'] = $this->language->get('attention_shared');
}
$this->data['form']['fields']['download_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'download_id', 'value' => $this->data['download_id']));
$this->data['form']['fields']['name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'name', 'value' => $file_data['name'], 'attr' => ' maxlength="64" '));
$this->data['form']['fields']['mask'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'mask', 'value' => $file_data['mask']));
$this->data['form']['fields']['max_downloads'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'max_downloads', 'value' => $file_data['max_downloads'], 'style' => 'small-field'));
$this->data['form']['fields']['activate'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'activate', 'value' => $file_data['activate'], 'options' => array('' => $this->language->get('text_select'), 'before_order' => $this->language->get('text_before_order'), 'immediately' => $this->language->get('text_immediately'), 'order_status' => $this->language->get('text_on_order_status'), 'manually' => $this->language->get('text_manually')), 'required' => true, 'style' => 'download_activate no-save'));
$options = array('' => $this->language->get('text_select'));
foreach ($order_statuses as $order_status) {
$options[$order_status['order_status_id']] = $order_status['name'];
}
$this->data['form']['fields']['order_statuses'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'activate_order_status_id', 'value' => $file_data['activate_order_status_id'], 'options' => $options, 'required' => true, 'style' => 'no-save'));
$this->data['form']['fields']['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order', 'style' => 'small-field', 'value' => $file_data['sort_order']));
$this->data['form']['fields']['expire_days'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'expire_days', 'style' => 'small-field', 'value' => $file_data['expire_days']));
/*
* DOWNLOAD ATTRIBUTES PIECE OF FORM
* */
$attributes = $this->model_catalog_download->getDownloadAttributes($this->data['download_id']);
$elements = HtmlElementFactory::getAvailableElements();
$html_multivalue_elements = HtmlElementFactory::getMultivalueElements();
$html_elements_with_options = HtmlElementFactory::getElementsWithOptions();
if (!$attributes) {
$attr_mng = new AAttribute_Manager('download_attribute');
$attr_type_id = $attr_mng->getAttributeTypeID('download_attribute');
$this->data['text_no_download_attributes_yet'] = sprintf($this->language->get('text_no_download_attributes_yet'), $this->html->getSecureURL('catalog/attribute/insert', '&attribute_type_id=' . $attr_type_id));
} else {
foreach ($attributes as $attribute) {
$html_type = $elements[$attribute['element_type']]['type'];
if (!$html_type || !$attribute['status']) {
continue;
}
//.........这里部分代码省略.........