예제 #1
0
 private function initAttachmentForm()
 {
     if (!$this->context->controller->default_form_language) {
         $this->languages = $this->context->controller->getLanguages();
     }
     if ((bool) $this->product->product_id) {
         if ($this->product_exists_in_shop) {
             $attachment_name = array();
             $attachment_description = array();
             foreach ($this->languages as $language) {
                 $attachment_name[$language->lang_id] = '';
                 $attachment_description[$language->lang_id] = '';
             }
             $iso_tiny_mce = file_exists(COM_JEPROSHOP_JS_DIR . DIRECTORY_SEPARATOR . 'tiny_mce/langs/' . $this->context->language->iso_code . '.js') ? $this->context->language->iso_code : 'en';
             $attachment_link = JRoute::_('index.php?option=com_jeproshop&view=product&ajax=1&task=add_attachment&product_id=' . (int) $this->product->product_id);
             $attachment_uploader = new JeproshopFileUploader('attachment_file');
             $attachment_uploader->setMultiple(false)->setUseAjax(true)->setUrl($attachment_link)->setPostMaxSize(JeproshopSettingModelSetting::getValue('attachment_maximum_size') * 1024 * 1024);
             //->setTemplate('attachment_ajax.tpl');
             /*
                                     $data->assign(array(
                                             'obj' => $obj,
                                             'table' => $this->table,
                                             'ad' => __PS_BASE_URI__.basename(_PS_ADMIN_DIR_),
                                             'iso_tiny_mce' => $iso_tiny_mce,
                                             'languages' => $this->_languages,
                                             'id_lang' => $this->context->language->id,; */
             $attachments_1 = JeproshopAttachmentModelAttachment::getAttachments($this->context->language->lang_id, $this->product->product_id, true);
             $this->assignRef('attachments_1', $attachments_1);
             $attachments_2 = JeproshopAttachmentModelAttachment::getAttachments($this->context->language->lang_id, $this->product->product_id, false);
             $this->assignRef('attachments_2', $attachments_2);
             $this->assignRef('attachment_name', $attachment_name);
             $this->assignRef('attachment_description', $attachment_description);
             $attachment_maximum_size = JeproshopSettingModelSetting::getValue('attachment_maximum_size');
             $this->assignRef('attachment_maximum_size', $attachment_maximum_size);
             $attachment_uploader = $attachment_uploader->render();
             $this->assignRef('attachment_uploader', $attachment_uploader);
         } else {
             $this->displayWarning($this->l('You must save the product in this shop before adding attachements.'));
         }
     } else {
         $this->displayWarning($this->l('You must save this product before adding attachements.'));
     }
 }