예제 #1
0
 function save()
 {
     $jshopConfig = JSFactory::getConfig();
     require_once $jshopConfig->path . 'lib/uploadfile.class.php';
     JPluginHelper::importPlugin('jshoppingadmin');
     $dispatcher = JDispatcher::getInstance();
     $db = JFactory::getDBO();
     $value_id = JRequest::getInt("value_id");
     $attr_id = JRequest::getInt("attr_id");
     $post = JRequest::get("post");
     $attributValue = JTable::getInstance('attributValue', 'jshop');
     $dispatcher->trigger('onBeforeSaveAttributValue', array(&$post));
     $upload = new UploadFile($_FILES['image']);
     $upload->setAllowFile(array('jpeg', 'jpg', 'gif', 'png'));
     $upload->setDir($jshopConfig->image_attributes_path);
     $upload->setFileNameMd5(0);
     $upload->setFilterName(1);
     if ($upload->upload()) {
         if ($post['old_image']) {
             @unlink($jshopConfig->image_attributes_path . "/" . $post['old_image']);
         }
         $post['image'] = $upload->getName();
         @chmod($jshopConfig->image_attributes_path . "/" . $post['image'], 0777);
     } else {
         if ($upload->getError() != 4) {
             JError::raiseWarning("", _JSHOP_ERROR_UPLOADING_IMAGE);
             saveToLog("error.log", "SaveAttributeValue - Error upload image. code: " . $upload->getError());
         }
     }
     if (!$value_id) {
         $query = "SELECT MAX(value_ordering) AS value_ordering FROM `#__jshopping_attr_values` where attr_id='" . $db->escape($attr_id) . "'";
         $db->setQuery($query);
         $row = $db->loadObject();
         $post['value_ordering'] = $row->value_ordering + 1;
     }
     if (!$attributValue->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=attributesvalues&attr_id=" . $attr_id);
         return 0;
     }
     if (!$attributValue->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=attributesvalues&attr_id=" . $attr_id);
         return 0;
     }
     $dispatcher->trigger('onAfterSaveAttributValue', array(&$attributValue));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=attributesvalues&task=edit&attr_id=" . $attr_id . "&value_id=" . $attributValue->value_id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=attributesvalues&attr_id=" . $attr_id);
     }
 }
 function save()
 {
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     require_once $jshopConfig->path . 'lib/uploadfile.class.php';
     $id = JRequest::getInt("id");
     $productLabel = JTable::getInstance('productLabel', 'jshop');
     $post = JRequest::get("post");
     $lang = JSFactory::getLang();
     $post['name'] = $post[$lang->get("name")];
     JPluginHelper::importPlugin('jshoppingadmin');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeSaveProductLabel', array(&$post));
     $upload = new UploadFile($_FILES['image']);
     $upload->setAllowFile(array('jpeg', 'jpg', 'gif', 'png'));
     $upload->setDir($jshopConfig->image_labels_path);
     $upload->setFileNameMd5(0);
     $upload->setFilterName(1);
     if ($upload->upload()) {
         if ($post['old_image']) {
             @unlink($jshopConfig->image_labels_path . "/" . $post['old_image']);
         }
         $post['image'] = $upload->getName();
         @chmod($jshopConfig->image_labels_path . "/" . $post['image'], 0777);
     } else {
         if ($upload->getError() != 4) {
             JError::raiseWarning("", _JSHOP_ERROR_UPLOADING_IMAGE);
             saveToLog("error.log", "Label - Error upload image. code: " . $upload->getError());
         }
     }
     if (!$productLabel->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=productlabels");
         return 0;
     }
     if (!$productLabel->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=productlabels");
         return 0;
     }
     $dispatcher->trigger('onAfterSaveProductLabel', array(&$productLabel));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=productlabels&task=edit&id=" . $productLabel->id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=productlabels");
     }
 }
예제 #3
0
 function uploadImage($post)
 {
     $jshopConfig = JSFactory::getConfig();
     $dispatcher = JDispatcher::getInstance();
     $upload = new UploadFile($_FILES['category_image']);
     $upload->setAllowFile(array('jpeg', 'jpg', 'gif', 'png'));
     $upload->setDir($jshopConfig->image_category_path);
     $upload->setFileNameMd5(0);
     $upload->setFilterName(1);
     if ($upload->upload()) {
         $name = $upload->getName();
         if ($post['old_image'] && $name != $post['old_image']) {
             @unlink($jshopConfig->image_category_path . "/" . $post['old_image']);
         }
         @chmod($jshopConfig->image_category_path . "/" . $name, 0777);
         if ($post['size_im_category'] < 3) {
             if ($post['size_im_category'] == 1) {
                 $category_width_image = $jshopConfig->image_category_width;
                 $category_height_image = $jshopConfig->image_category_height;
             } else {
                 $category_width_image = JRequest::getInt('category_width_image');
                 $category_height_image = JRequest::getInt('category_height_image');
             }
             $path_full = $jshopConfig->image_category_path . "/" . $name;
             $path_thumb = $jshopConfig->image_category_path . "/" . $name;
             if ($category_width_image || $category_height_image) {
                 if (!ImageLib::resizeImageMagic($path_full, $category_width_image, $category_height_image, $jshopConfig->image_cut, $jshopConfig->image_fill, $path_thumb, $jshopConfig->image_quality, $jshopConfig->image_fill_color)) {
                     JError::raiseWarning("", _JSHOP_ERROR_CREATE_THUMBAIL);
                     saveToLog("error.log", "SaveCategory - Error create thumbail");
                 }
             }
             @chmod($jshopConfig->image_category_path . "/" . $name, 0777);
         }
         $category_image = $name;
         $dispatcher->trigger('onAfterSaveCategoryImage', array(&$post, &$category_image, &$path_full, &$path_thumb));
     } else {
         $category_image = '';
         if ($upload->getError() != 4) {
             JError::raiseWarning("", _JSHOP_ERROR_UPLOADING_IMAGE);
             saveToLog("error.log", "SaveCategory - Error upload image. code: " . $upload->getError());
         }
     }
     return $category_image;
 }
예제 #4
0
파일: products.php 프로젝트: Tommar/vino2
 function uploadImages($product, $product_id, $post)
 {
     $jshopConfig = JSFactory::getConfig();
     $dispatcher = JDispatcher::getInstance();
     for ($i = 0; $i < $jshopConfig->product_image_upload_count; $i++) {
         $upload = new UploadFile($_FILES['product_image_' . $i]);
         $upload->setAllowFile(array('jpeg', 'jpg', 'gif', 'png'));
         $upload->setDir($jshopConfig->image_product_path);
         $upload->setFileNameMd5(0);
         $upload->setFilterName(1);
         if ($upload->upload()) {
             $name_image = $upload->getName();
             $name_thumb = 'thumb_' . $name_image;
             $name_full = 'full_' . $name_image;
             @chmod($jshopConfig->image_product_path . "/" . $name_image, 0777);
             $path_image = $jshopConfig->image_product_path . "/" . $name_image;
             $path_thumb = $jshopConfig->image_product_path . "/" . $name_thumb;
             $path_full = $jshopConfig->image_product_path . "/" . $name_full;
             rename($path_image, $path_full);
             if ($jshopConfig->image_product_original_width || $jshopConfig->image_product_original_height) {
                 if (!ImageLib::resizeImageMagic($path_full, $jshopConfig->image_product_original_width, $jshopConfig->image_product_original_height, $jshopConfig->image_cut, $jshopConfig->image_fill, $path_full, $jshopConfig->image_quality, $jshopConfig->image_fill_color)) {
                     JError::raiseWarning("", _JSHOP_ERROR_CREATE_THUMBAIL);
                     saveToLog("error.log", "SaveProduct - Error create thumbail");
                     $error = 1;
                 }
             }
             $error = 0;
             if ($post['size_im_product'] == 3) {
                 copy($path_full, $path_thumb);
                 @chmod($path_thumb, 0777);
             } else {
                 if ($post['size_im_product'] == 1) {
                     $product_width_image = $jshopConfig->image_product_width;
                     $product_height_image = $jshopConfig->image_product_height;
                 } else {
                     $product_width_image = JRequest::getInt('product_width_image');
                     $product_height_image = JRequest::getInt('product_height_image');
                 }
                 if (!ImageLib::resizeImageMagic($path_full, $product_width_image, $product_height_image, $jshopConfig->image_cut, $jshopConfig->image_fill, $path_thumb, $jshopConfig->image_quality, $jshopConfig->image_fill_color)) {
                     JError::raiseWarning("", _JSHOP_ERROR_CREATE_THUMBAIL);
                     saveToLog("error.log", "SaveProduct - Error create thumbail");
                     $error = 1;
                 }
                 @chmod($path_thumb, 0777);
                 unset($img);
             }
             if ($post['size_full_product'] == 3) {
                 copy($path_full, $path_image);
                 @chmod($path_image, 0777);
             } else {
                 if ($post['size_full_product'] == 1) {
                     $product_full_width_image = $jshopConfig->image_product_full_width;
                     $product_full_height_image = $jshopConfig->image_product_full_height;
                 } else {
                     $product_full_width_image = JRequest::getInt('product_full_width_image');
                     $product_full_height_image = JRequest::getInt('product_full_height_image');
                 }
                 if (!ImageLib::resizeImageMagic($path_full, $product_full_width_image, $product_full_height_image, $jshopConfig->image_cut, $jshopConfig->image_fill, $path_image, $jshopConfig->image_quality, $jshopConfig->image_fill_color)) {
                     JError::raiseWarning("", _JSHOP_ERROR_CREATE_THUMBAIL);
                     $error = 1;
                 }
                 @chmod($path_image, 0777);
                 unset($img);
             }
             if (!$error) {
                 $this->addToProductImage($product_id, $name_image, $post["product_image_descr_" . $i]);
                 $dispatcher->trigger('onAfterSaveProductImage', array($product_id, $name_image));
             }
         } else {
             if ($upload->getError() != 4) {
                 JError::raiseWarning("", _JSHOP_ERROR_UPLOADING_IMAGE);
                 saveToLog("error.log", "SaveProduct - Error upload image. code: " . $upload->getError());
             }
         }
         unset($upload);
     }
     for ($i = 0; $i < $jshopConfig->product_image_upload_count; $i++) {
         if ($post['product_folder_image_' . $i] != '') {
             if (file_exists($jshopConfig->image_product_path . '/' . $post['product_folder_image_' . $i])) {
                 $name_image = $post['product_folder_image_' . $i];
                 $name_thumb = 'thumb_' . $name_image;
                 $name_full = 'full_' . $name_image;
                 $this->addToProductImage($product_id, $name_image, $post["product_image_descr_" . $i]);
                 $dispatcher->trigger('onAfterSaveProductFolerImage', array($product_id, $name_full, $name_image, $name_thumb));
             }
         }
     }
     if (!$product->image) {
         $list_images = $product->getImages();
         if (count($list_images)) {
             $product = JTable::getInstance('product', 'jshop');
             $product->load($product_id);
             $product->image = $list_images[0]->image_name;
             $product->store();
         }
     }
     if (isset($post['old_image_descr'])) {
         $this->renameProductImageOld($post['old_image_descr'], $post['old_image_ordering']);
     }
 }
예제 #5
0
 function save()
 {
     $jshopConfig = JSFactory::getConfig();
     require_once $jshopConfig->path . 'lib/image.lib.php';
     require_once $jshopConfig->path . 'lib/uploadfile.class.php';
     $dispatcher = JDispatcher::getInstance();
     $apply = JRequest::getVar("apply");
     $_alias = JSFactory::getModel("alias");
     $db = JFactory::getDBO();
     $man = JSFactory::getTable('manufacturer', 'jshop');
     $man_id = JRequest::getInt("manufacturer_id");
     $post = JRequest::get("post");
     $_lang = JSFactory::getModel("languages");
     $languages = $_lang->getAllLanguages(1);
     foreach ($languages as $lang) {
         $post['name_' . $lang->language] = trim($post['name_' . $lang->language]);
         if ($jshopConfig->create_alias_product_category_auto && $post['alias_' . $lang->language] == "") {
             $post['alias_' . $lang->language] = $post['name_' . $lang->language];
         }
         $post['alias_' . $lang->language] = JApplication::stringURLSafe($post['alias_' . $lang->language]);
         if ($post['alias_' . $lang->language] != "" && !$_alias->checkExistAlias1Group($post['alias_' . $lang->language], $lang->language, 0, $man_id)) {
             $post['alias_' . $lang->language] = "";
             JError::raiseWarning("", _JSHOP_ERROR_ALIAS_ALREADY_EXIST);
         }
         $post['description_' . $lang->language] = JRequest::getVar('description' . $lang->id, '', 'post', "string", 2);
         $post['short_description_' . $lang->language] = JRequest::getVar('short_description_' . $lang->language, '', 'post', "string", 2);
     }
     if (!$post['manufacturer_publish']) {
         $post['manufacturer_publish'] = 0;
     }
     $dispatcher->trigger('onBeforeSaveManufacturer', array(&$post));
     if (!$man->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=manufacturers");
         return 0;
     }
     if (!$man_id) {
         $man->ordering = null;
         $man->ordering = $man->getNextOrder();
     }
     $upload = new UploadFile($_FILES['manufacturer_logo']);
     $upload->setAllowFile(array('jpeg', 'jpg', 'gif', 'png'));
     $upload->setDir($jshopConfig->image_manufs_path);
     $upload->setFileNameMd5(0);
     $upload->setFilterName(1);
     if ($upload->upload()) {
         if ($post['old_image']) {
             @unlink($jshopConfig->image_manufs_path . "/" . $post['old_image']);
         }
         $name = $upload->getName();
         @chmod($jshopConfig->image_manufs_path . "/" . $name, 0777);
         if ($post['size_im_category'] < 3) {
             if ($post['size_im_category'] == 1) {
                 $category_width_image = $jshopConfig->image_category_width;
                 $category_height_image = $jshopConfig->image_category_height;
             } else {
                 $category_width_image = JRequest::getInt('category_width_image');
                 $category_height_image = JRequest::getInt('category_height_image');
             }
             $path_full = $jshopConfig->image_manufs_path . "/" . $name;
             $path_thumb = $jshopConfig->image_manufs_path . "/" . $name;
             if (!ImageLib::resizeImageMagic($path_full, $category_width_image, $category_height_image, $jshopConfig->image_cut, $jshopConfig->image_fill, $path_thumb, $jshopConfig->image_quality, $jshopConfig->image_fill_color, $jshopConfig->image_interlace)) {
                 JError::raiseWarning("", _JSHOP_ERROR_CREATE_THUMBAIL);
                 saveToLog("error.log", "SaveManufacturer - Error create thumbail");
             }
             @chmod($jshopConfig->image_manufs_path . "/" . $name, 0777);
             unset($img);
         }
         $man->manufacturer_logo = $name;
     } else {
         if ($upload->getError() != 4) {
             JError::raiseWarning("", _JSHOP_ERROR_UPLOADING_IMAGE);
             saveToLog("error.log", "SaveManufacturer - Error upload image. code: " . $upload->getError());
         }
     }
     if (!$man->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=manufacturers");
         return 0;
     }
     $dispatcher->trigger('onAfterSaveManufacturer', array(&$man));
     if ($this->getTask() == 'apply') {
         $this->setRedirect("index.php?option=com_jshopping&controller=manufacturers&task=edit&man_id=" . $man->manufacturer_id);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=manufacturers");
     }
 }
 function save()
 {
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     require_once JPATH_COMPONENT_SITE . '/lib/uploadfile.class.php';
     require_once JPATH_COMPONENT_SITE . "/lib/csv.io.class.php";
     $ie_id = JRequest::getInt("ie_id");
     if (!$ie_id) {
         $ie_id = $this->get('ie_id');
     }
     $lang = JSFactory::getLang();
     $db = JFactory::getDBO();
     $_importexport = JSFactory::getTable('ImportExport', 'jshop');
     $_importexport->load($ie_id);
     $alias = $_importexport->get('alias');
     $_importexport->set('endstart', time());
     $_importexport->store();
     //get list tax
     $query = "SELECT tax_id, tax_value FROM `#__jshopping_taxes`";
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $listTax = array();
     foreach ($rows as $row) {
         $listTax[intval($row->tax_value)] = $row->tax_id;
     }
     //get list category
     $query = "SELECT category_id as id, `" . $lang->get("name") . "` as name FROM `#__jshopping_categories`";
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $listCat = array();
     foreach ($rows as $row) {
         $listCat[$row->name] = $row->id;
     }
     $_products = JSFactory::getModel('products', 'JshoppingModel');
     $dir = $jshopConfig->importexport_path . $alias . "/";
     $upload = new UploadFile($_FILES['file']);
     $upload->setAllowFile(array('csv'));
     $upload->setDir($dir);
     if ($upload->upload()) {
         $filename = $dir . "/" . $upload->getName();
         @chmod($filename, 0777);
         $csv = new csv();
         $data = $csv->read($filename);
         if (is_array($data)) {
             foreach ($data as $k => $row) {
                 if (count($row) < 2 || $k == 0) {
                     continue;
                 }
                 $tax_value = intval($row[5]);
                 if (!isset($listTax[$tax_value])) {
                     $tax = JSFactory::getTable('tax', 'jshop');
                     $tax->set('tax_name', $tax_value);
                     $tax->set('tax_value', $tax_value);
                     $tax->store();
                     $listTax[$tax_value] = $tax->get("tax_id");
                 }
                 $category_name = $row['6'];
                 if (!isset($listCat[$category_name]) && $category_name != "") {
                     $cat = JSFactory::getTable("category", "jshop");
                     $query = "SELECT max(ordering) FROM `#__jshopping_categories`";
                     $db->setQuery($query);
                     $ordering = $db->loadResult() + 1;
                     $cat->set($lang->get("name"), $category_name);
                     $cat->set("category_ordertype", 1);
                     $cat->set("products_page", $jshopConfig->count_products_to_page);
                     $cat->set("products_row", $jshopConfig->count_products_to_row);
                     $cat->set("category_publish", 0);
                     $cat->set("ordering", $ordering);
                     $cat->store();
                     $listCat[$category_name] = $cat->get("category_id");
                 }
                 $product = JSFactory::getTable('product', 'jshop');
                 $product->set("product_ean", $row[1]);
                 $product->set("product_quantity", $row[2]);
                 $product->set("product_date_added", $row[3]);
                 $product->set("product_price", $row[4]);
                 $product->set("min_price", $row[4]);
                 $product->set("product_tax_id", $listTax[$tax_value]);
                 $product->set("currency_id", $jshopConfig->mainCurrency);
                 $product->set($lang->get("name"), utf8_encode($row[7]));
                 $product->set($lang->get("short_description"), utf8_encode($row[8]));
                 $product->set($lang->get("description"), utf8_encode($row[9]));
                 $product->store();
                 $product_id = $product->get("product_id");
                 $category_id = $listCat[$category_name];
                 if ($category_name != "" && $category_id) {
                     $_products->setCategoryToProduct($product_id, array($category_id));
                 }
                 unset($product);
             }
         }
         @unlink($filename);
     } else {
         JError::raiseWarning("", _JSHOP_ERROR_UPLOADING);
     }
     if (!JRequest::getInt("noredirect")) {
         $mainframe->redirect("index.php?option=com_jshopping&controller=importexport&task=view&ie_id=" . $ie_id, _JSHOP_COMPLETED);
     }
 }
예제 #7
0
 function save()
 {
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     require_once $jshopConfig->path . 'lib/image.lib.php';
     require_once $jshopConfig->path . 'lib/uploadfile.class.php';
     JPluginHelper::importPlugin('jshoppingadmin');
     $dispatcher = JDispatcher::getInstance();
     $_alias = $this->getModel("alias");
     $db = JFactory::getDBO();
     $category = JTable::getInstance("category", "jshop");
     if (!$_POST["category_id"]) {
         $_POST['category_add_date'] = getJsDate();
     }
     if (!isset($_POST['category_publish'])) {
         $_POST['category_publish'] = 0;
     }
     $post = JRequest::get('post');
     $_lang = $this->getModel("languages");
     $languages = $_lang->getAllLanguages(1);
     if ($post['category_parent_id'] == $post['category_id']) {
         $post['category_parent_id'] = 0;
     }
     $dispatcher->trigger('onBeforeSaveCategory', array(&$post));
     foreach ($languages as $lang) {
         $post['name_' . $lang->language] = trim($post['name_' . $lang->language]);
         if ($jshopConfig->create_alias_product_category_auto && $post['alias_' . $lang->language] == "") {
             $post['alias_' . $lang->language] = $post['name_' . $lang->language];
         }
         $post['alias_' . $lang->language] = JApplication::stringURLSafe($post['alias_' . $lang->language]);
         if ($post['alias_' . $lang->language] != "" && !$_alias->checkExistAlias1Group($post['alias_' . $lang->language], $lang->language, $post['category_id'], 0)) {
             $post['alias_' . $lang->language] = "";
             JError::raiseWarning("", _JSHOP_ERROR_ALIAS_ALREADY_EXIST);
         }
         $post['description_' . $lang->language] = JRequest::getVar('description' . $lang->id, '', 'post', "string", 2);
         $post['short_description_' . $lang->language] = JRequest::getVar('short_description_' . $lang->language, '', 'post', "string", 2);
     }
     if (!$category->bind($post)) {
         JError::raiseWarning("", _JSHOP_ERROR_BIND);
         $this->setRedirect("index.php?option=com_jshopping&controller=categories");
         return 0;
     }
     $edit = $category->category_id;
     $upload = new UploadFile($_FILES['category_image']);
     $upload->setAllowFile(array('jpeg', 'jpg', 'gif', 'png'));
     $upload->setDir($jshopConfig->image_category_path);
     $upload->setFileNameMd5(0);
     $upload->setFilterName(1);
     if ($upload->upload()) {
         $name = $upload->getName();
         if ($post['old_image'] && $name != $post['old_image']) {
             @unlink($jshopConfig->image_category_path . "/" . $post['old_image']);
         }
         @chmod($jshopConfig->image_category_path . "/" . $name, 0777);
         if ($post['size_im_category'] < 3) {
             if ($post['size_im_category'] == 1) {
                 $category_width_image = $jshopConfig->image_category_width;
                 $category_height_image = $jshopConfig->image_category_height;
             } else {
                 $category_width_image = JRequest::getInt('category_width_image');
                 $category_height_image = JRequest::getInt('category_height_image');
             }
             $path_full = $jshopConfig->image_category_path . "/" . $name;
             $path_thumb = $jshopConfig->image_category_path . "/" . $name;
             if (!ImageLib::resizeImageMagic($path_full, $category_width_image, $category_height_image, $jshopConfig->image_cut, $jshopConfig->image_fill, $path_thumb, $jshopConfig->image_quality, $jshopConfig->image_fill_color)) {
                 JError::raiseWarning("", _JSHOP_ERROR_CREATE_THUMBAIL);
                 saveToLog("error.log", "SaveCategory - Error create thumbail");
             }
             @chmod($jshopConfig->image_category_path . "/" . $name, 0777);
             unset($img);
         }
         $category->category_image = $name;
     } else {
         if ($upload->getError() != 4) {
             JError::raiseWarning("", _JSHOP_ERROR_UPLOADING_IMAGE);
             saveToLog("error.log", "SaveCategory - Error upload image. code: " . $upload->getError());
         }
     }
     $this->_reorderCategory($category);
     if (!$category->store()) {
         JError::raiseWarning("", _JSHOP_ERROR_SAVE_DATABASE);
         $this->setRedirect("index.php?option=com_jshopping&controller=categories");
         return 0;
     }
     $dispatcher->trigger('onAfterSaveCategory', array(&$category));
     $success = $edit ? _JSHOP_CATEGORY_SUCC_UPDATE : _JSHOP_CATEGORY_SUCC_ADDED;
     if ($this->getTask() == 'apply') {
         $this->setRedirect('index.php?option=com_jshopping&controller=categories&task=edit&category_id=' . $category->category_id, $success);
     } else {
         $this->setRedirect('index.php?option=com_jshopping&controller=categories', $success);
     }
 }