当前位置: 首页>>代码示例>>PHP>>正文


PHP HtmlElementFactory::getElementsWithOptions方法代码示例

本文整理汇总了PHP中HtmlElementFactory::getElementsWithOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP HtmlElementFactory::getElementsWithOptions方法的具体用法?PHP HtmlElementFactory::getElementsWithOptions怎么用?PHP HtmlElementFactory::getElementsWithOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HtmlElementFactory的用法示例。


在下文中一共展示了HtmlElementFactory::getElementsWithOptions方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addProductOption

 /**
  * @param int $product_id
  * @param array $data
  * @return int
  */
 public function addProductOption($product_id, $data)
 {
     $am = new AAttribute_Manager();
     $attribute = $am->getAttribute($data['attribute_id']);
     if ($attribute) {
         $data['element_type'] = $attribute['element_type'];
         $data['required'] = $attribute['required'];
         $data['regexp_pattern'] = $attribute['regexp_pattern'];
         $data['sort_order'] = $attribute['sort_order'];
         $data['settings'] = $attribute['settings'];
     }
     $this->db->query("INSERT INTO " . $this->db->table("product_options") . "\n\t\t\t\t\t\t\t(product_id,\n\t\t\t\t\t\t\t attribute_id,\n\t\t\t\t\t\t\t element_type,\n\t\t\t\t\t\t\t required,\n\t\t\t\t\t\t\t sort_order,\n\t\t\t\t\t\t\t group_id,\n\t\t\t\t\t\t\t status,\n\t\t\t\t\t\t\t regexp_pattern,\n\t\t\t\t\t\t\t settings)\n\t\t\t\t\t\tVALUES ('" . (int) $product_id . "',\n\t\t\t\t\t\t\t'" . (int) $data['attribute_id'] . "',\n\t\t\t\t\t\t\t'" . $this->db->escape($data['element_type']) . "',\n\t\t\t\t\t\t\t'" . (int) $data['required'] . "',\n\t\t\t\t\t\t\t'" . (int) $data['sort_order'] . "',\n\t\t\t\t\t\t\t'" . (int) $data['group_id'] . "',\n\t\t\t\t\t\t\t'" . (int) $data['status'] . "',\n\t\t\t\t\t\t\t'" . $this->db->escape($data['regexp_pattern']) . "',\n\t\t\t\t\t\t\t'" . $this->db->escape($data['settings']) . "'\n\t\t\t\t\t\t\t)");
     $product_option_id = $this->db->getLastId();
     if (!empty($data['option_name'])) {
         $attributeDescriptions = array($this->language->getContentLanguageID() => array('name' => $data['option_name'], 'error_text' => $data['error_text']));
     } else {
         $attributeDescriptions = $am->getAttributeDescriptions($data['attribute_id']);
     }
     foreach ($attributeDescriptions as $language_id => $descr) {
         $this->language->replaceDescriptions('product_option_descriptions', array('product_option_id' => (int) $product_option_id, 'product_id' => (int) $product_id), array($language_id => array('name' => $descr['name'], 'error_text' => $descr['error_text'])));
     }
     //add empty option value for single value attributes
     $elements_with_options = HtmlElementFactory::getElementsWithOptions();
     if (!in_array($data['element_type'], $elements_with_options)) {
         $this->insertProductOptionValue($product_id, $product_option_id, '', '', array());
     }
     $this->cache->remove('product');
     return $product_option_id;
 }
开发者ID:siddht1,项目名称:abantecart-src,代码行数:34,代码来源:product.php

示例2: orderProductForm

 /**
  * Form to edit product from order
  */
 public function orderProductForm()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadModel('catalog/product');
     $this->loadModel('sale/order');
     $this->loadLanguage('catalog/product');
     $this->loadLanguage('sale/order');
     $this->load->library('json');
     $elements_with_options = HtmlElementFactory::getElementsWithOptions();
     $order_product_id = (int) $this->request->get['order_product_id'];
     $order_id = (int) $this->request->get['order_id'];
     $order_info = $this->model_sale_order->getOrder($order_id);
     $tax = new ATax($this->registry);
     $tax->setZone($order_info['country_id'], $order_info['zone_id']);
     $product_id = (int) $this->request->get['product_id'];
     $preset_values = array();
     if ($order_product_id) {
         //if unknown product_id but order_product_id we know
         $order_product_info = $this->model_sale_order->getOrderProducts($order_id, $order_product_id);
         $preset_values['price'] = $this->currency->format($order_product_info[0]['price'], $order_info['currency'], $order_info['value'], false);
         $preset_values['total'] = $this->currency->format($order_product_info[0]['price'] * $order_product_info[0]['quantity'], $order_info['currency'], $order_info['value'], false);
         $preset_values['quantity'] = $order_product_info[0]['quantity'];
         if (!$product_id) {
             $product_id = $order_product_info[0]['product_id'];
         }
         $product_info = $this->model_catalog_product->getProduct($product_id);
         $order_product_options = $this->model_sale_order->getOrderOptions($order_id, $order_product_id);
         foreach ($order_product_options as $v) {
             if ($v['element_type'] == 'R') {
                 $preset_values[$v['product_option_id']] = $v['product_option_value_id'];
             } elseif (in_array($v['element_type'], $elements_with_options)) {
                 $preset_values[$v['product_option_id']][] = $v['product_option_value_id'];
             } else {
                 $preset_values[$v['product_option_id']] = $v['value'];
             }
         }
         $this->data['text_title'] = $this->language->get('text_edit_order_product');
         $form_action = $this->html->getSecureURL('sale/order/update', '&order_id=' . $order_id . '&order_product_id=' . $order_product_id);
     } else {
         $product_info = $this->model_catalog_product->getProduct($product_id);
         $this->data['text_title'] = sprintf($this->language->get('text_add_product_to_order'), $order_id);
         $preset_values['quantity'] = $product_info['minimum'] ? $product_info['minimum'] : 1;
         $preset_values['price'] = $this->currency->format($product_info['price'], $order_info['currency'], $order_info['value'], false);
         $preset_values['total'] = $this->currency->format($product_info['price'] * $preset_values['quantity'], $order_info['currency'], $order_info['value'], false);
         $form_action = $this->html->getSecureURL('sale/order/update', '&order_id=' . $order_id . '&product_id=' . $product_id);
     }
     $this->data['product_href'] = $this->html->getSecureURL('catalog/product/update', '&product_id=' . $product_id);
     $form = new AForm('HT');
     $form->setForm(array('form_name' => 'orderProductFrm'));
     $this->data['form']['id'] = 'orderProductFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'orderProductFrm', 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"', 'action' => $form_action));
     $this->data['text_title'] .= ' - ' . $product_info['name'];
     // Prepare options and values for display
     $product_options = $this->model_catalog_product->getOrderProductOptions($product_id);
     $option_values_prices = array();
     foreach ($product_options as $option) {
         if (in_array($option['element_type'], array('U'))) {
             continue;
         }
         //skip files for now. TODO: add edit file-option in the future
         $values = $prices = array();
         $price = $preset_value = $default_value = '';
         foreach ($option['option_value'] as $option_value) {
             //default value
             $default_value = $option_value['default'] && !$order_product_id ? $option_value['product_option_value_id'] : $default_value;
             //early saved value
             $preset_value = $preset_values[$option['product_option_id']];
             //when adds new product in the order
             if (!$order_product_id) {
                 if ($option_value['default'] == 1) {
                     $preset_value = $option_value['product_option_value_id'];
                 } elseif (!in_array($option['element_type'], $elements_with_options)) {
                     $preset_value = $option_value['name'];
                 }
             }
             //Apply option price modifier
             if ($option_value['prefix'] == '%') {
                 $price = $tax->calculate($product_info['price'] * $option_value['price'] / 100, $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
             } else {
                 $price = $tax->calculate($option_value['price'], $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
             }
             if ($price != 0) {
                 $price = $this->currency->format($price);
             } else {
                 $price = '';
             }
             //Check stock and status
             $opt_stock_message = '';
             if ($option_value['subtract']) {
                 if ($option_value['quantity'] <= 0) {
                     //show out of stock message
                     $opt_stock_message = ' (' . $this->language->get('text_product_out_of_stock') . ')';
                 } else {
                     if ($this->config->get('config_stock_display')) {
                         $opt_stock_message = ' (' . $option_value['quantity'] . " " . $this->language->get('text_product_in_stock') . ')';
                     }
//.........这里部分代码省略.........
开发者ID:vglide,项目名称:abantecart-src,代码行数:101,代码来源:product.php

示例3: 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');
 }
开发者ID:InquisitiveQuail,项目名称:abantecart-src,代码行数:54,代码来源:attribute.php

示例4: updateAttribute

 /**
  * @param int $attribute_id
  * @param array $data
  */
 public function updateAttribute($attribute_id, $data)
 {
     //Note: update is done per 1 language
     $language_id = $this->session->data['content_language_id'];
     $fields = array('attribute_type_id', 'attribute_group_id', 'attribute_parent_id', 'element_type', 'required', 'sort_order', 'settings', 'status', 'regexp_pattern');
     $elements_with_options = HtmlElementFactory::getElementsWithOptions();
     $attribute = $this->getAttribute($attribute_id, $language_id);
     //check if we change element type and clean options if it does not require it
     if (isset($data['element_type']) && $data['element_type'] != $attribute['element_type']) {
         if (!in_array($data['element_type'], $elements_with_options)) {
             $sql = "DELETE FROM `" . DB_PREFIX . "global_attributes_values`\n\t\t\t\t\t\tWHERE attribute_id = '" . (int) $attribute_id . "'";
             $this->db->query($sql);
             $sql = "DELETE FROM `" . DB_PREFIX . "global_attributes_value_descriptions`\n\t\t\t\t\t\tWHERE attribute_id = '" . (int) $attribute_id . "'";
             $this->db->query($sql);
         }
     }
     if (has_value($data['settings'])) {
         $data['settings'] = serialize($data['settings']);
     }
     $update = array();
     foreach ($fields as $f) {
         if (isset($data[$f])) {
             $update[] = "{$f} = '" . $this->db->escape($data[$f]) . "'";
         }
     }
     if (!empty($update)) {
         $sql = "UPDATE " . DB_PREFIX . "global_attributes\n                SET " . implode(',', $update) . "\n                WHERE attribute_id = '" . (int) $attribute_id . "'";
         $this->db->query($sql);
     }
     $update = array();
     if (isset($data['name'])) {
         $update['name'] = $data['name'];
     }
     if (isset($data['error_text'])) {
         $update['error_text'] = $data['error_text'];
     }
     $this->language->replaceDescriptions('global_attributes_descriptions', array('attribute_id' => (int) $attribute_id), array($language_id => $update));
     //Update Attribute Values
     if (!empty($data['values']) && in_array($data['element_type'], $elements_with_options)) {
         foreach ($data['values'] as $atr_val_id => $value) {
             //Check if new or update
             if ($data['attribute_value_ids'][$atr_val_id] == 'delete') {
                 //delete the description
                 $this->deleteAllAttributeValueDescriptions($atr_val_id);
                 //delete value if no other language
                 $this->deleteAttributeValues($atr_val_id);
             } else {
                 if ($data['attribute_value_ids'][$atr_val_id] == 'new') {
                     // New need to create
                     $attribute_value_id = $this->addAttributeValue($attribute_id, $data['sort_orders'][$atr_val_id]);
                     if ($attribute_value_id) {
                         $this->addAttributeValueDescription($attribute_id, $attribute_value_id, $language_id, $value);
                     }
                 } else {
                     //Existing need to update
                     $this->updateAttributeValue($atr_val_id, $data['sort_orders'][$atr_val_id]);
                     $this->updateAttributeValueDescription($attribute_id, $atr_val_id, $language_id, $value);
                 }
             }
         }
     }
     $this->clearCache();
 }
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:67,代码来源:attribute_manager.php

示例5: editOrderProduct

 /**
  * @param int $order_id
  * @param array $data
  */
 public function editOrderProduct($order_id, $data)
 {
     $order_id = (int) $order_id;
     $order_product_id = (int) $data['order_product_id'];
     $product_id = (int) $data['product_id'];
     if (!$product_id || !$order_id) {
         return false;
     }
     $this->load->model('catalog/product');
     $product_info = $this->model_catalog_product->getProduct($product_id);
     $order_info = $this->getOrder($order_id);
     $elements_with_options = HtmlElementFactory::getElementsWithOptions();
     if (isset($data['product'])) {
         foreach ($data['product'] as $product) {
             if ($product['quantity'] <= 0) {
                 // stupid situation
                 return false;
             }
             //check is product exists
             $exists = $this->db->query("SELECT op.product_id, op.quantity\n\t\t\t\t\t\t\t\t\t\t\t\t FROM " . $this->db->table("order_products") . " op\n\t\t\t\t\t\t\t\t\t\t\t\t WHERE op.order_id = '" . (int) $order_id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t    AND op.product_id='" . (int) $product_id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t    AND op.order_product_id = '" . (int) $order_product_id . "'");
             if ($exists->num_rows) {
                 //update order quantity
                 $this->db->query("UPDATE " . $this->db->table("order_products") . "\n\t\t\t\t\t\t\t\t\t\t  SET price = '" . $this->db->escape(preformatFloat($product['price'], $this->language->get('decimal_point')) / $order_info['value']) . "',\n\t\t\t\t\t\t\t\t\t\t  \t  total = '" . $this->db->escape(preformatFloat($product['total'], $this->language->get('decimal_point')) / $order_info['value']) . "',\n\t\t\t\t\t\t\t\t\t\t\t  quantity = '" . $this->db->escape($product['quantity']) . "'\n\t\t\t\t\t\t\t\t\t\t  WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $order_product_id . "'");
                 //update stock quantity
                 $old_qnt = $exists->row['quantity'];
                 $stock_qnt = $product_info['quantity'];
                 $qnt_diff = $old_qnt - $product['quantity'];
                 if ($qnt_diff != 0) {
                     if ($qnt_diff < 0) {
                         $new_qnt = $stock_qnt - abs($qnt_diff);
                     } else {
                         $new_qnt = $stock_qnt + $qnt_diff;
                     }
                     if ($product_info['subtract']) {
                         $this->db->query("UPDATE " . $this->db->table("products") . "\n\t\t\t\t\t\t\t\t\t\t\t  SET quantity = '" . $new_qnt . "'\n\t\t\t\t\t\t\t\t\t\t\t  WHERE product_id = '" . (int) $product_id . "' AND subtract = 1");
                     }
                 }
             } else {
                 // add new product into order
                 $product_query = $this->db->query("SELECT *, p.product_id\n\t\t\t\t\t\t\t FROM " . $this->db->table("products") . " p\n\t\t\t\t\t\t\t LEFT JOIN " . $this->db->table("product_descriptions") . " pd\n\t\t\t\t\t\t\t    ON (p.product_id = pd.product_id AND pd.language_id=" . $this->language->getContentLanguageID() . ")\n\t\t\t\t\t\t\t WHERE p.product_id='" . (int) $product_id . "'");
                 $this->db->query("INSERT INTO " . $this->db->table("order_products") . "\n\t\t\t\t\t\t\tSET order_id = '" . (int) $order_id . "',\n\t\t\t\t\t\t\t\tproduct_id = '" . (int) $product_id . "',\n\t\t\t\t\t\t\t\tname = '" . $this->db->escape($product_query->row['name']) . "',\n\t\t\t\t\t\t\t\tmodel = '" . $this->db->escape($product_query->row['model']) . "',\n\t\t\t\t\t\t\t\tprice = '" . $this->db->escape(preformatFloat($product['price'], $this->language->get('decimal_point')) / $order_info['value']) . "',\n\t\t\t\t\t\t\t\ttotal = '" . $this->db->escape(preformatFloat($product['total'], $this->language->get('decimal_point')) / $order_info['value']) . "',\n\t\t\t\t\t\t\t\tquantity = '" . (int) $product['quantity'] . "'");
                 $order_product_id = $this->db->getLastId();
                 //update stock quantity
                 $qnt_diff = -$product['quantity'];
                 $stock_qnt = $product_query->row['quantity'];
                 $new_qnt = $stock_qnt - (int) $product['quantity'];
                 if ($product_info['subtract']) {
                     $this->db->query("UPDATE " . $this->db->table("products") . "\n\t\t\t\t\t\t\t\t\t\t  SET quantity = '" . $new_qnt . "'\n\t\t\t\t\t\t\t\t\t\t  WHERE product_id = '" . (int) $product_id . "' AND subtract = 1");
                 }
             }
             if ($product['option']) {
                 //first of all find previous order options
                 // if empty result - order products just added
                 $order_product_options = $this->getOrderOptions($order_id, $order_product_id);
                 $prev_subtract_options = array();
                 //array with previous option values with enabled stock tracking
                 foreach ($order_product_options as $old_value) {
                     if (!$old_value['subtract']) {
                         continue;
                     }
                     $prev_subtract_options[(int) $old_value['product_option_id']][] = (int) $old_value['product_option_value_id'];
                 }
                 $po_ids = array();
                 foreach ($product['option'] as $k => $option) {
                     $po_ids[] = (int) $k;
                 }
                 //get all data of given product options from db
                 $sql = "SELECT *, pov.product_option_value_id, povd.name as option_value_name, pod.name as option_name\n\t\t\t\t\t\t\t\tFROM " . $this->db->table('product_options') . " po\n\t\t\t\t\t\t\t\tLEFT JOIN " . $this->db->table('product_option_descriptions') . " pod\n\t\t\t\t\t\t\t\t\tON (pod.product_option_id = po.product_option_id AND pod.language_id=" . $this->language->getContentLanguageID() . ")\n\t\t\t\t\t\t\t\tLEFT JOIN " . $this->db->table('product_option_values') . " pov\n\t\t\t\t\t\t\t\t\tON po.product_option_id = pov.product_option_id\n\t\t\t\t\t\t\t\tLEFT JOIN " . $this->db->table('product_option_value_descriptions') . " povd\n\t\t\t\t\t\t\t\t    ON (povd.product_option_value_id = pov.product_option_value_id AND povd.language_id=" . $this->language->getContentLanguageID() . ")\n\t\t\t\t\t\t\t\tWHERE po.product_option_id IN (" . implode(',', $po_ids) . ")\n\t\t\t\t\t\t\t\tORDER BY po.product_option_id";
                 $result = $this->db->query($sql);
                 $exclude_list = array();
                 //list of option value that we do not resave
                 $option_value_info = array();
                 foreach ($result->rows as $row) {
                     //skip files
                     if (in_array($row['element_type'], array('U'))) {
                         $exclude_list[] = (int) $row['product_option_value_id'];
                     }
                     $option_value_info[$row['product_option_id'] . '_' . $row['product_option_value_id']] = $row;
                     //compond key for cases when val_id is null
                     $option_types[$row['product_option_id']] = $row['element_type'];
                 }
                 //delete old options and then insert new
                 $sql = "DELETE FROM " . $this->db->table('order_options') . "\n\t\t\t\t\t\t\t\tWHERE order_id = " . $order_id . " AND order_product_id=" . (int) $order_product_id;
                 if ($exclude_list) {
                     $sql .= " AND product_option_value_id NOT IN (" . implode(', ', $exclude_list) . ")";
                 }
                 $this->db->query($sql);
                 foreach ($product['option'] as $opt_id => $values) {
                     if (!is_array($values)) {
                         // for non-multioptional elements
                         //do not save empty inputs and texareas
                         if (in_array($option_types[$opt_id], array('I', 'T')) && $values == '') {
                             continue;
                         } elseif ($option_types[$opt_id] == 'S') {
                             $values = array($values);
                         } else {
//.........这里部分代码省略.........
开发者ID:afshinnj,项目名称:abantecart-src,代码行数:101,代码来源:order.php

示例6: buildProductDetails

 /**
  * Collect product information for cart based on user selections
  * Function can be used to get totals and other product information
  * (based on user selection) as it is before getting into cart or after
  * @param int $product_id
  * @param int $quantity
  * @param array $options
  * @return array
  */
 public function buildProductDetails($product_id, $quantity = 0, $options = array())
 {
     if (!has_value($product_id) || !is_numeric($product_id) || $quantity == 0) {
         return array();
     }
     $stock = TRUE;
     $this->load->model('catalog/product');
     $elements_with_options = HtmlElementFactory::getElementsWithOptions();
     $product_query = $this->model_catalog_product->getProductDataForCart($product_id);
     if (count($product_query) <= 0 || $product_query['call_to_order']) {
         return array();
     }
     $option_price = 0;
     $option_data = array();
     $groups = array();
     //Process each option and value
     foreach ($options as $product_option_id => $product_option_value_id) {
         //skip empty values
         if ($product_option_value_id == '' || is_array($product_option_value_id) && !$product_option_value_id) {
             continue;
         }
         //Detect option element type. If single value (text, input) process diferently.
         $option_attribute = $this->attribute->getAttributeByProductOptionId($product_option_id);
         if ($option_attribute) {
             $element_type = $option_attribute['element_type'];
             $option_query['name'] = $option_attribute['name'];
         } else {
             //Not global attribute based option, select element type from options table
             $option_query = $this->model_catalog_product->getProductOption($product_id, $product_option_id);
             $element_type = $option_query['element_type'];
         }
         if (!in_array($element_type, $elements_with_options)) {
             //This is single value element, get all values and expect only one
             $option_value_query = $this->model_catalog_product->getProductOptionValues($product_id, $product_option_id);
             $option_value_query = $option_value_query[0];
             //Set value from input
             $option_value_query['name'] = $this->db->escape($options[$product_option_id]);
         } else {
             //is multivalue option type
             if (is_array($product_option_value_id)) {
                 $option_value_queries = array();
                 foreach ($product_option_value_id as $val_id) {
                     $option_value_queries[$val_id] = $this->model_catalog_product->getProductOptionValue($product_id, $val_id);
                 }
             } else {
                 $option_value_query = $this->model_catalog_product->getProductOptionValue($product_id, (int) $product_option_value_id);
             }
         }
         if ($option_value_query) {
             //if group option load price from parent value
             if ($option_value_query['group_id'] && !in_array($option_value_query['group_id'], $groups)) {
                 $group_value_query = $this->model_catalog_product->getProductOptionValue($product_id, $option_value_query['group_id']);
                 $option_value_query['prefix'] = $group_value_query['prefix'];
                 $option_value_query['price'] = $group_value_query['price'];
                 $groups[] = $option_value_query['group_id'];
             }
             $option_data[] = array('product_option_value_id' => $option_value_query['product_option_value_id'], 'name' => $option_query['name'], 'value' => $option_value_query['name'], 'prefix' => $option_value_query['prefix'], 'price' => $option_value_query['price'], 'sku' => $option_value_query['sku'], 'weight' => $option_value_query['weight'], 'weight_type' => $option_value_query['weight_type']);
             //check if need to track stock and we have it
             if ($option_value_query['subtract'] && $option_value_query['quantity'] < $quantity) {
                 $stock = FALSE;
             }
             $op_stock_trackable += $option_value_query['subtract'];
             unset($option_value_query);
         } else {
             if ($option_value_queries) {
                 foreach ($option_value_queries as $item) {
                     $option_data[] = array('product_option_value_id' => $item['product_option_value_id'], 'name' => $option_query['name'], 'value' => $item['name'], 'prefix' => $item['prefix'], 'price' => $item['price'], 'sku' => $item['sku'], 'weight' => $item['weight'], 'weight_type' => $item['weight_type']);
                     //check if need to track stock and we have it
                     if ($item['subtract'] && $item['quantity'] < $quantity) {
                         $stock = FALSE;
                     }
                     $op_stock_trackable += $option_value_query['subtract'];
                 }
                 unset($option_value_queries);
             }
         }
     }
     // end of options build
     //needed for promotion
     $discount_quantity = 0;
     // this is used to calculate total QTY of 1 product in the cart
     // check is product is in cart and calculate quantity to define item price with product discount
     foreach ($this->session->data['cart'] as $k => $v) {
         $array2 = explode(':', $k);
         if ($array2[0] == $product_id) {
             $discount_quantity += $v['qty'];
         }
     }
     if (!$discount_quantity) {
         $discount_quantity = $quantity;
     }
//.........这里部分代码省略.........
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:101,代码来源:cart.php

示例7: 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');
 }
开发者ID:siddht1,项目名称:abantecart-src,代码行数:68,代码来源:fields.php

示例8: main


//.........这里部分代码省略.........
             $this->data['special'] = FALSE;
         }
     }
     $this->data['price'] = $this->currency->format($this->data['price_num']);
     if (isset($this->data['special_num'])) {
         $this->data['special'] = $this->currency->format($this->data['special_num']);
     }
     $product_discounts = $promoton->getProductDiscounts($product_id);
     $discounts = array();
     foreach ($product_discounts as $discount) {
         $discounts[] = array('quantity' => $discount['quantity'], 'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], (bool) $this->config->get('config_tax'))));
     }
     $this->data['discounts'] = $discounts;
     $this->data['product_price'] = $product_price;
     $this->data['tax_class_id'] = $product_info['tax_class_id'];
     if (!$product_info['call_to_order']) {
         $this->data['form']['minimum'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'quantity', 'value' => $product_info['minimum'] ? (int) $product_info['minimum'] : 1, 'style' => 'short', 'attr' => ' size="3" '));
         $this->data['form']['add_to_cart'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'add_to_cart', 'text' => $this->language->get('button_add_to_cart'), 'style' => 'button1'));
     }
     $this->data['form']['product_id'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'product_id', 'value' => $product_id));
     $this->data['form']['redirect'] = $form->getFieldHtml(array('type' => 'hidden', 'name' => 'redirect', 'value' => $this->html->getURL('product/product', $url . '&product_id=' . $product_id, '&encode')));
     $this->data['model'] = $product_info['model'];
     $this->data['manufacturer'] = $product_info['manufacturer'];
     $this->data['manufacturers'] = $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $product_info['manufacturer_id'], '&encode');
     $this->data['description'] = html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8');
     $this->data['product_id'] = $product_id;
     $this->data['average'] = $average;
     $resource = new AResource('image');
     $thumbnail = $resource->getMainThumb('manufacturers', $product_info['manufacturer_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true);
     if (!preg_match('/no_image/', $thumbnail['thumb_url'])) {
         $this->data['manufacturer_icon'] = $thumbnail['thumb_url'];
     }
     // Preapare options and values for display
     $elements_with_options = HtmlElementFactory::getElementsWithOptions();
     $options = array();
     $product_options = $this->model_catalog_product->getProductOptions($product_id);
     //get info from cart if key presents
     $cart_product_info = array();
     if ($key) {
         $cart_product_info = $this->cart->getProduct($this->request->get['key']);
     }
     foreach ($product_options as $option) {
         $values = array();
         $name = $price = '';
         $default_value = $cart_product_info['options'][$option['product_option_id']];
         if ($option['element_type'] == 'R') {
             $default_value = is_array($default_value) ? current($default_value) : (string) $default_value;
         }
         $preset_value = $default_value;
         foreach ($option['option_value'] as $option_value) {
             $default_value = $option_value['default'] && !$default_value ? $option_value['product_option_value_id'] : $default_value;
             // for case when trying to add to cart withot required options. we get option-array back inside _GET
             if (has_value($this->request->get['option'][$option['product_option_id']])) {
                 $default_value = $this->request->get['option'][$option['product_option_id']];
             }
             $name = $option_value['name'];
             //check if we disable options based on out of stock setting
             if ($option_value['subtract'] && $this->config->get('config_nostock_autodisable') && $option_value['quantity'] <= 0) {
                 continue;
             }
             //Apply option price modifier
             if ($option_value['prefix'] == '%') {
                 $price = $this->tax->calculate($product_price * $option_value['price'] / 100, $product_info['tax_class_id'], (bool) $this->config->get('config_tax'));
                 if ($price != 0) {
                     $price = $this->currency->format($price);
                 } else {
开发者ID:vglide,项目名称:abantecart-src,代码行数:67,代码来源:product.php

示例9: getDownloadAttributesValues

 /**
  * @param int $download_id
  * @param string $mode - can be "full" - all download attributes (with empty values too),
  * "to_customer" - download atributes with values that allowed to display for customers,
  * "to_display"  - all download atributes with values
  * @return array
  */
 public function getDownloadAttributesValues($download_id, $mode = 'full')
 {
     if (!(int) $download_id) {
         return array();
     }
     $output = array();
     $attr = new AAttribute('download_attribute');
     $attributes = $attr->getAttributes();
     $ids = array();
     foreach ($attributes as &$attribute) {
         if ($mode == 'to_customer') {
             $attribute['settings'] = unserialize($attribute['settings']);
             if (!$attribute['settings']['show_to_customer']) {
                 continue;
             }
         }
         $ids[] = (int) $attribute['attribute_id'];
         $attribute['attribute_values'] = $attr->getAttributeValues($attribute['attribute_id']);
     }
     unset($attribute);
     if ($ids) {
         $result = $this->db->query("SELECT dav.attribute_id, dav.attribute_value_ids as value\n\t\t\t\t\t\t\t\t\t\t  FROM " . $this->db->table('download_attribute_values') . " dav\n\t\t\t\t\t\t\t\t\t\t  LEFT JOIN " . $this->db->table('global_attributes') . " ga\n\t\t\t\t\t\t\t\t\t\t        ON ga.attribute_id = dav.attribute_id\n\t\t\t\t\t\t\t\t\t\t  WHERE dav.attribute_id IN (" . implode(',', $ids) . ") AND dav.download_id = '" . $download_id . "'\n\t\t\t\t\t\t\t\t\t\t  ORDER BY ga.sort_order ASC");
         $attributes_with_options = HtmlElementFactory::getElementsWithOptions();
         foreach ($result->rows as $row) {
             if (!in_array($row['attribute_id'], $ids)) {
                 continue;
             }
             $row['value'] = unserialize($row['value']);
             if (in_array($attributes[$row['attribute_id']]['element_type'], $attributes_with_options)) {
                 foreach ($attributes[$row['attribute_id']]['attribute_values'] as $values) {
                     if (is_array($row['value']) && in_array($values['attribute_value_id'], $row['value'])) {
                         // do not include empty value for display for customer
                         if (!$row['value'] && in_array($mode, array('to_customer', 'to_display'))) {
                             continue 1;
                         }
                         $output[$attributes[$row['attribute_id']]['name']][] = $values['value'];
                     } elseif (!is_array($row['value']) && $values['attribute_value_id'] == $row['value']) {
                         // do not include empty value for display for customer
                         if (!$row['value'] && in_array($mode, array('to_customer', 'to_display'))) {
                             continue 1;
                         }
                         $output[$attributes[$row['attribute_id']]['name']] = $values['value'];
                     }
                 }
             } else {
                 // do not include empty value for display for customer or admin display
                 if (!has_value($row['value']) && in_array($mode, array('to_customer', 'to_display'))) {
                     continue;
                 }
                 $output[$attributes[$row['attribute_id']]['name']] = $row['value'];
                 // for checkbox value show text yes or no
                 if ($attributes[$row['attribute_id']]['element_type'] == 'C') {
                     $output[$attributes[$row['attribute_id']]['name']] = $row['value'] ? $this->language->get('text_yes') : $this->language->get('text_no');
                 }
             }
         }
     }
     return $output;
 }
开发者ID:InquisitiveQuail,项目名称:abantecart-src,代码行数:66,代码来源:download.php

示例10: _getForm

 private function _getForm()
 {
     $this->data = array();
     $this->data['error'] = $this->error;
     $this->data['cancel'] = $this->html->getSecureURL('catalog/attribute');
     $this->data['get_attribute_type'] = $this->html->getSecureURL('r/catalog/attribute/get_attribute_type');
     $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('catalog/attribute'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
     if (isset($this->request->get['attribute_id']) && $this->request->server['REQUEST_METHOD'] != 'POST') {
         $attribute_info = $this->attribute_manager->getAttribute($this->request->get['attribute_id'], $this->session->data['content_language_id']);
         $attribute_type_info = $this->attribute_manager->getAttributeTypeInfoById((int) $attribute_info['attribute_type_id']);
         //load values for attributes with options
         $this->data['elements_with_options'] = HtmlElementFactory::getElementsWithOptions();
         if (in_array($attribute_info['element_type'], $this->data['elements_with_options'])) {
             $values = $this->attribute_manager->getAttributeValues($this->request->get['attribute_id'], $this->session->data['content_language_id']);
             $attribute_info['values'] = array();
             foreach ($values as $v) {
                 $attribute_info['values'][] = addslashes(html_entity_decode($v['value'], ENT_COMPAT, 'UTF-8'));
             }
         }
         if (has_value($attribute_info['settings'])) {
             $attribute_info['settings'] = unserialize($attribute_info['settings']);
         }
     }
     if (has_value($this->request->get['attribute_type_id'])) {
         $attribute_type_info = $this->attribute_manager->getAttributeTypeInfoById((int) $this->request->get['attribute_type_id']);
     }
     $fields = array('name', 'attribute_group_id', 'attribute_type_id', 'element_type', 'sort_order', 'required', 'regexp_pattern', 'error_text', 'settings', 'status', 'values');
     if ($attribute_type_info['type_key'] != 'download_attribute') {
         $fields[] = 'attribute_parent_id';
     }
     foreach ($fields as $f) {
         if (isset($this->request->post[$f])) {
             $this->data[$f] = $this->request->post[$f];
         } elseif (isset($attribute_info[$f])) {
             $this->data[$f] = $attribute_info[$f];
         } else {
             $this->data[$f] = '';
             if ($f == 'status') {
                 $this->data[$f] = 1;
             }
         }
     }
     // build tabs on page
     $results = $this->attribute_manager->getAttributeTypes();
     foreach ($results as $type) {
         $this->data['attribute_types'][$type['attribute_type_id']] = $type;
     }
     if (isset($attribute_info['attribute_type_id'])) {
         $attribute_type_id = (int) $attribute_info['attribute_type_id'];
     } else {
         $attribute_type_id = (int) $this->request->get_or_post('attribute_type_id');
     }
     if (!$attribute_type_id) {
         $attribute_type_id = key($this->data['attribute_types']);
     }
     $this->_initTabs($attribute_type_id);
     //NOTE: Future inplementation
     /*$attribute_groups = array( '' => $this->language->get('text_select'));
     		$results = $this->attribute_manager->getAttributeGroups(array('language_id' => $this->session->data['content_language_id']));
     		foreach ($results as $type) {
     		    $attribute_groups[$type['attribute_group_id']] = $type['name'];
     	    }*/
     if (!isset($this->request->get['attribute_id'])) {
         $this->data['action'] = $this->html->getSecureURL('catalog/attribute/insert', '&attribute_type_id=' . $attribute_type_id);
         $this->data['heading_title'] = $this->language->get('text_insert') . $this->language->get('text_attribute');
         $this->data['update'] = '';
         $form = new AForm('ST');
     } else {
         $this->data['action'] = $this->html->getSecureURL('catalog/attribute/update', '&attribute_id=' . $this->request->get['attribute_id'] . '&attribute_type_id=' . $attribute_type_id);
         $this->data['heading_title'] = $this->language->get('text_edit') . $this->language->get('text_attribute');
         $this->data['update'] = $this->html->getSecureURL('listing_grid/attribute/update_field', '&id=' . $this->request->get['attribute_id']);
         $form = new AForm('HT');
         $this->data['attribute_id'] = $this->request->get['attribute_id'];
     }
     $this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['heading_title'], 'separator' => ' :: '));
     $form->setForm(array('form_name' => 'editFrm', 'update' => $this->data['update']));
     $this->data['form']['id'] = 'editFrm';
     $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'editFrm', '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'));
     $this->data['form']['fields']['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => $this->data['status'], 'style' => 'btn_switch'));
     $this->data['form']['fields']['name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'name', 'value' => $this->data['name'], 'required' => true, 'style' => 'large-field'));
     if ($attribute_type_info['type_key'] != 'download_attribute') {
         $parent_attributes = array('' => $this->language->get('text_select'));
         $results = $this->attribute_manager->getAttributes(array('attribute_type_id' => $attribute_type_id, 'limit' => null), 0, 0);
         foreach ($results as $type) {
             if (isset($this->request->get['attribute_id']) && $this->request->get['attribute_id'] == $type['attribute_id']) {
                 continue;
             }
             $parent_attributes[$type['attribute_id']] = $type['name'];
         }
         $this->data['form']['fields']['attribute_parent'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'attribute_parent_id', 'value' => $this->data['attribute_parent_id'], 'options' => $parent_attributes));
     }
     //NOTE: Future implementation
     /*$this->data['form']['fields']['attribute_group'] = $form->getFieldHtml(array(
     			'type' => 'selectbox',
     			'name' => 'attribute_group_id',
     			'value' => $this->data['attribute_group_id'],
     			'options' => $attribute_groups,
//.........这里部分代码省略.........
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:101,代码来源:attribute.php

示例11: 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') . '&nbsp;' . $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;
             }
//.........这里部分代码省略.........
开发者ID:harshzalavadiya,项目名称:fatak,代码行数:101,代码来源:product.php


注:本文中的HtmlElementFactory::getElementsWithOptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。