예제 #1
0
 public function save()
 {
     if ($this->viewAccess() && JeproshopTools::checkAttachmentToken()) {
         $attachmentModel = new JeproshopAttachmentModelAttachment();
         $attachmentModel->saveAttachment();
     }
 }
예제 #2
0
 public function renderDetails($tpl = null)
 {
     $attachmentModel = new JeproshopAttachmentModelAttachment();
     $attachments = $attachmentModel->getAttachmentsList();
     $this->assignRef('attachments', $attachments);
     $pagination = $attachmentModel->getPagination();
     $this->assignRef('pagination', $pagination);
     $this->addToolBar();
     $this->sideBar = JHtmlSideBar::render();
     parent::display($tpl);
 }
예제 #3
0
 /**
  * Attach an existing attachment to the product
  *
  * @return void
  */
 public function attachment()
 {
     $app = JFactory::getApplication();
     if ($id = (int) $app->input->get('product_id')) {
         $attachments = trim($app->input->get('arrayAttachments'), ',');
         $attachments = explode(',', $attachments);
         if (!JeproshopAttachmentModelAttachment::attachToProduct($id, $attachments)) {
             JError::raiseError(500, JText::_('An error occurred while saving product attachments.'));
         }
     }
 }
예제 #4
0
 public function deleteSelection($attachments)
 {
     $return = 1;
     foreach ($attachments as $attachment_id) {
         $attachment = new JeproshopAttachmentModelAttachment((int) $attachment_id);
         $return &= $attachment->delete();
     }
     return $return;
 }
예제 #5
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.'));
     }
 }
예제 #6
0
 /**
  * Attach an existing attachment to the product
  *
  * @return void
  */
 public function processAttachments()
 {
     $app = JFactory::getApplication();
     $product_id = (int) $app->input->get('product_id');
     $data = JRequest::get('post');
     $input_data = $data['jform'];
     if ($product_id) {
         $attachments = trim($input_data['array_attachments'], ',');
         $attachments = explode(',', $attachments);
         if (!JeproshopAttachmentModelAttachment::attachToProduct($product_id, $attachments)) {
             $this->context->controller->has_errors = JText::_('An error occurred while saving product attachments.');
         }
     }
 }