/**
  * Create thumbnail of image
  *
  * @param String $imageName
  *
  * @return String
  */
 protected function createThumbnailOfPicture($imageName)
 {
     if (empty($objImage)) {
         $objImage = new \ImageManager();
     }
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $objImage->_createThumbWhq($cx->getWebsiteImagesCrmProfilePath() . '/', $cx->getWebsiteImagesCrmProfileWebPath() . '/', $imageName, 40, 40, 70, '_40X40.thumb');
     return $objImage->_createThumbWhq($cx->getWebsiteImagesCrmProfilePath() . '/', $cx->getWebsiteImagesCrmProfileWebPath() . '/', $imageName, 121, 160, 70);
 }
Beispiel #2
0
 /**
  * Create thumbnails and update the corresponding Product records
  *
  * Scans the Products with the given IDs.  If a non-empty picture string
  * with a reasonable extension is encountered, determines whether
  * the corresponding thumbnail is available and up to date or not.
  * If not, tries to load the file and to create a thumbnail.
  * If it succeeds, it also updates the picture field with the base64
  * encoded entry containing the image width and height.
  * Note that only single file names are supported!
  * Also note that this method returns a string with information about
  * problems that were encountered.
  * It skips records which contain no or invalid image
  * names, thumbnails that cannot be created, and records which refuse
  * to be updated!
  * The reasoning behind this is that this method is currently only called
  * from within some {@link _import()} methods.  The focus lies on importing
  * Products; whether or not thumbnails can be created is secondary, as the
  * process can be repeated if there is a problem.
  * @param   integer     $arrId      The array of Product IDs
  * @return  boolean                 True on success, false on any error
  * @global  ADONewConnection  $objDatabase    Database connection object
  * @global  array
  * @static
  * @author  Reto Kohli <*****@*****.**>
  */
 static function makeThumbnailsById($arrId)
 {
     global $_ARRAYLANG;
     if (!is_array($arrId)) {
         return false;
     }
     $error = false;
     $objImageManager = new \ImageManager();
     foreach ($arrId as $product_id) {
         if ($product_id <= 0) {
             \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_INVALID_PRODUCT_ID'], $product_id));
             $error = true;
             continue;
         }
         $objProduct = Product::getById($product_id);
         if (!$objProduct) {
             \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_INVALID_PRODUCT_ID'], $product_id));
             $error = true;
             continue;
         }
         $imageName = $objProduct->pictures();
         $imagePath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopPath() . '/' . $imageName;
         // only try to create thumbs from entries that contain a
         // plain text file name (i.e. from an import)
         if ($imageName == '' || !preg_match('/\\.(?:jpg|jpeg|gif|png)$/i', $imageName)) {
             \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_UNSUPPORTED_IMAGE_FORMAT'], $product_id, $imageName));
             $error = true;
             continue;
         }
         // if the picture is missing, skip it.
         if (!file_exists($imagePath)) {
             \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_MISSING_PRODUCT_IMAGE'], $product_id, $imageName));
             $error = true;
             continue;
         }
         $thumbResult = true;
         $width = 0;
         $height = 0;
         // If the thumbnail exists and is newer than the picture,
         // don't create it again.
         $thumb_name = \ImageManager::getThumbnailFilename($imagePath);
         if (file_exists($thumb_name) && filemtime($thumb_name) > filemtime($imagePath)) {
             //$this->addMessage("Hinweis: Thumbnail fuer Produkt ID '$product_id' existiert bereits");
             // Need the original size to update the record, though
             list($width, $height) = $objImageManager->_getImageSize($imagePath);
         } else {
             // Create thumbnail, get the original size.
             // Deleting the old thumb beforehand is integrated into
             // _createThumbWhq().
             $thumbResult = $objImageManager->_createThumbWhq(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopPath() . '/', \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopWebPath() . '/', $imageName, \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_max_width', 'Shop'), \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_max_height', 'Shop'), \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_quality', 'Shop'));
             $width = $objImageManager->orgImageWidth;
             $height = $objImageManager->orgImageHeight;
         }
         // The database needs to be updated, however, as all Products
         // have been imported.
         if ($thumbResult) {
             $shopPicture = base64_encode($imageName) . '?' . base64_encode($width) . '?' . base64_encode($height) . ':??:??';
             $objProduct->pictures($shopPicture);
             $objProduct->store();
         } else {
             \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_ERROR_CREATING_PRODUCT_THUMBNAIL'], $product_id, $imageName));
             $error = true;
         }
     }
     return $error;
 }
 /**
  * Create thumbnail and update the corresponding ShopCategory records
  *
  * Scans the ShopCategories with the given IDs.  If a non-empty picture
  * string with a reasonable extension is encountered, determines whether
  * the corresponding thumbnail is available and up to date or not.
  * If not, tries to load the file and to create a thumbnail.
  * Note that only single file names are supported!
  * Also note that this method returns a string with information about
  * problems that were encountered.
  * It skips records which contain no or invalid image
  * names, thumbnails that cannot be created, and records which refuse
  * to be updated!
  * The reasoning behind this is that this method is currently only called
  * from within some {@link _import()} methods.  The focus lies on importing;
  * whether or not thumbnails can be created is secondary, as the
  * process can be repeated if there is a problem.
  * @param   integer     $id         The ShopCategory ID
  * @param   integer     $maxWidth   The maximum thubnail width
  * @param   integer     $maxHeight  The maximum thubnail height
  * @param   integer     $quality    The thumbnail quality
  * @return  string                  Empty string on success, a string
  *                                  with error messages otherwise.
  * @global  array
  * @static
  * @author  Reto Kohli <*****@*****.**>
  */
 static function makeThumbnailById($id, $maxWidth = 120, $maxHeight = 80, $quality = 90)
 {
     /*
         Note: The size and quality parameters should be taken from the
               settings as follows:
         \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_max_width','Shop'),
         \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_max_height','Shop'),
         \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_quality','Shop')
     */
     global $_ARRAYLANG;
     if ($id <= 0) {
         return sprintf($_ARRAYLANG['TXT_SHOP_INVALID_CATEGORY_ID'], $id);
     }
     $objCategory = ShopCategory::getById($id, LANGID);
     if (!$objCategory) {
         return sprintf($_ARRAYLANG['TXT_SHOP_INVALID_CATEGORY_ID'], $id);
     }
     $imageName = $objCategory->picture();
     $imagePath = SHOP_CATEGORY_IMAGE_PATH . '/' . $imageName;
     // Only try to create thumbs from entries that contain a
     // plain text file name (i.e. from an import)
     if ($imageName == '' || !preg_match('/\\.(?:jpe?g|gif|png)$/', $imageName)) {
         return sprintf($_ARRAYLANG['TXT_SHOP_UNSUPPORTED_IMAGE_FORMAT'], $id, $imageName);
     }
     // If the picture is missing, skip it.
     if (!file_exists($imagePath)) {
         return sprintf($_ARRAYLANG['TXT_SHOP_MISSING_CATEGORY_IMAGES'], $id, $imageName);
     }
     // If the thumbnail exists and is newer than the picture,
     // don't create it again.
     $thumb_name = ImageManager::getThumbnailFilename($imagePath);
     if (file_exists($thumb_name) && filemtime($thumb_name) > filemtime($imagePath)) {
         return '';
     }
     // Already included by the Shop.
     $objImageManager = new \ImageManager();
     // Create thumbnail.
     // Deleting the old thumb beforehand is integrated into
     // _createThumbWhq().
     if (!$objImageManager->_createThumbWhq(SHOP_CATEGORY_IMAGE_PATH . '/', SHOP_CATEGORY_IMAGE_WEB_PATH . '/', $imageName, $maxWidth, $maxHeight, $quality)) {
         return sprintf($_ARRAYLANG['TXT_SHOP_ERROR_CREATING_CATEGORY_THUMBNAIL'], $id);
     }
     return '';
 }
 /**
  * This function is used by the "insertEntry()" and "updateEntry()" function. It collects all values from
  * $_POST and creates the new entries in the database. This function was extracted from original source to be as
  * DRY/SPOT as possible.
  *
  * @global     ADONewConnection
  * @param    integer        $intMessageId: This is the id of the message which the new values will be linked to.
  */
 function insertEntryData($intMessageId)
 {
     global $objDatabase;
     $intMessageId = intval($intMessageId);
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     //Collect data for every language
     $arrValues = array();
     foreach ($_POST as $strKey => $strValue) {
         if (substr($strKey, 0, strlen('frmEditEntry_Subject_')) == 'frmEditEntry_Subject_') {
             $intLanguageId = intval(substr($strKey, strlen('frmEditEntry_Subject_')));
             $arrValues[$intLanguageId] = array('subject' => contrexx_addslashes(strip_tags($_POST['frmEditEntry_Subject_' . $intLanguageId])), 'content' => contrexx_addslashes($_POST['frmEditEntry_Content_' . $intLanguageId]), 'is_active' => intval(in_array($intLanguageId, $_POST['frmEditEntry_Languages'])), 'categories' => isset($_POST['assignedBlocks_' . $intLanguageId]) ? array($_POST['assignedBlocks_' . $intLanguageId]) : array(), 'image' => contrexx_addslashes(strip_tags($_POST['frmEditEntry_Image_' . $intLanguageId])), 'thumbnail' => isset($_POST['frmEditEntry_Thumbnail_Method_' . $intLanguageId]) && $_POST['frmEditEntry_Thumbnail_Method_' . $intLanguageId] == 'different' ? contrexx_addslashes(strip_tags($_POST['frmEditEntry_Thumbnail_' . $intLanguageId])) : '', 'thumbnail_type' => isset($_POST['frmEditEntry_Thumbnail_Type_' . $intLanguageId]) && $_POST['frmEditEntry_Thumbnail_Type_' . $intLanguageId] == '1' ? 'thumbnail' : 'original', 'thumbnail_width' => isset($_POST['frmEditEntry_Thumbnail_Method_' . $intLanguageId]) && $_POST['frmEditEntry_Thumbnail_Method_' . $intLanguageId] == 'original' ? intval($_POST['frmEditEntry_Thumbnail_Width_' . $intLanguageId]) : 0, 'thumbnail_height' => isset($_POST['frmEditEntry_Thumbnail_Method_' . $intLanguageId]) && $_POST['frmEditEntry_Thumbnail_Method_' . $intLanguageId] == 'original' ? intval($_POST['frmEditEntry_Thumbnail_Height_' . $intLanguageId]) : 0, 'attachment' => contrexx_addslashes($_POST['frmEditEntry_Attachment_' . $intLanguageId]), 'attachment_desc' => contrexx_addslashes($_POST['frmEditEntry_Attachment_Desc_' . $intLanguageId]), 'forward_url' => contrexx_addslashes($_POST['frmEditEntry_ForwardUrl_' . $intLanguageId]), 'forward_target' => contrexx_addslashes($_POST['frmEditEntry_ForwardTarget_' . $intLanguageId]));
         }
     }
     //save the placeholder
     if (isset($_POST['frmEditEntry_Placeholder'])) {
         $placeholder = $this->_formatPlaceholder($_POST['frmEditEntry_Placeholder']);
         $objDatabase->Execute("  INSERT INTO " . DBPREFIX . "module_data_placeholders\n                                     (`type`, `ref_id`, `placeholder`)\n                                     VALUES\n                                     ('entry', " . $intMessageId . ",\n                                      '" . $placeholder . "')");
         $err = $objDatabase->ErrorNo();
         if ($err == 1062) {
             //duplicate entry error
             $placeholder .= rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9);
             // not very beautiful...
             $objDatabase->Execute(" INSERT INTO " . DBPREFIX . "module_data_placeholders\n                                      (`type`, `ref_id`, `placeholder`)\n                                      VALUES\n                                      ('entry', " . $intMessageId . ",\n                                      '" . $placeholder . "')");
         }
     }
     //Insert collected data
     foreach ($arrValues as $intLanguageId => $arrEntryValues) {
         $objDatabase->Execute('    INSERT INTO ' . DBPREFIX . 'module_data_messages_lang
                                 SET    `message_id` = ' . $intMessageId . ',
                                     `lang_id` = ' . $intLanguageId . ',
                                     `is_active` = "' . $arrEntryValues['is_active'] . '",
                                     `subject` = "' . $arrEntryValues['subject'] . '",
                                     `content` = "' . $arrEntryValues['content'] . '",
                                     `image` = "' . $arrEntryValues['image'] . '",
                                     `thumbnail` = "' . $arrEntryValues['thumbnail'] . '",
                                     `thumbnail_type` = "' . $arrEntryValues['thumbnail_type'] . '",
                                     `thumbnail_width` = "' . $arrEntryValues['thumbnail_width'] . '",
                                     `thumbnail_height` = "' . $arrEntryValues['thumbnail_height'] . '",
                                     `attachment` = "' . $arrEntryValues['attachment'] . '",
                                     `attachment_description` = "' . $arrEntryValues['attachment_desc'] . '",
                                     `forward_url` = "' . $arrEntryValues['forward_url'] . '",
                                     `forward_target` = "' . $arrEntryValues['forward_target'] . '"
                             ');
         //Assign message to categories
         if (is_array($arrEntryValues['categories'])) {
             foreach ($arrEntryValues['categories'][0] as $intKey => $intCategoryId) {
                 $objDatabase->Execute('    INSERT INTO ' . DBPREFIX . 'module_data_message_to_category
                                         SET `message_id` = ' . $intMessageId . ',
                                             `category_id` = ' . $intCategoryId . ',
                                             `lang_id` = ' . $intLanguageId . '
                                     ');
                 if ($intLanguageId == $this->_intLanguageId) {
                     $_GET['catId'] = $intCategoryId;
                 }
             }
         }
         // create thumbnail if required
         if (empty($arrEntryValues['thumbnail'])) {
             if (!isset($objImage)) {
                 $objImage = new \ImageManager();
             }
             $strPath = dirname($cx->getWebsitePath() . $arrEntryValues['image']) . '/';
             $strWebPath = substr($strPath, strlen($cx->getWebsiteOffsetPath()));
             $file = basename($arrEntryValues['image']);
             $objImage->_createThumbWhq($strPath, $strWebPath, $file, $arrEntryValues['thumbnail_width'], $arrEntryValues['thumbnail_height'], 90, '.thumb', $cx->getWebsiteImagesDataPath() . '/', $cx->getWebsiteImagesDataWebPath() . '/', $intMessageId . '_' . $intLanguageId . '_' . $file);
         }
     }
 }
Beispiel #5
0
 private function createThumbnailOfImage($imageName, $profilePic = false)
 {
     static $objImage, $arrSettings;
     if (empty($objImage)) {
         $objImage = new \ImageManager();
     }
     if (empty($arrSettings)) {
         $arrSettings = \User_Setting::getSettings();
     }
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     if ($profilePic) {
         if (!$objImage->loadImage($cx->getWebsiteImagesAccessProfilePath() . '/' . $imageName)) {
             return false;
         }
         $rationWidth = $objImage->orgImageWidth / $arrSettings['profile_thumbnail_pic_width']['value'];
         $rationHeight = $objImage->orgImageHeight / $arrSettings['profile_thumbnail_pic_height']['value'];
         if ($arrSettings['profile_thumbnail_method']['value'] == 'crop') {
             if ($rationWidth < $rationHeight) {
                 $objImage->orgImageHeight = $objImage->orgImageHeight / $rationHeight * $rationWidth;
             } else {
                 $objImage->orgImageWidth = $objImage->orgImageWidth / $rationWidth * $rationHeight;
             }
             if (!$objImage->resizeImage($arrSettings['profile_thumbnail_pic_width']['value'], $arrSettings['profile_thumbnail_pic_height']['value'], 70)) {
                 return false;
             }
         } else {
             $ration = max($rationWidth, $rationHeight);
             $objImage->addBackgroundLayer(sscanf($arrSettings['profile_thumbnail_scale_color']['value'], '#%2X%2x%2x'), $arrSettings['profile_thumbnail_pic_width']['value'], $arrSettings['profile_thumbnail_pic_height']['value']);
         }
         $thumb_name = \ImageManager::getThumbnailFilename($cx->getWebsiteImagesAccessProfilePath() . '/' . $imageName);
         return $objImage->saveNewImage($thumb_name, true);
     } else {
         $thumb_name = \ImageManager::getThumbnailFilename($imageName);
         return $objImage->_createThumbWhq($cx->getWebsiteImagesAccessPhotoPath() . '/', $cx->getWebsiteImagesAccessPhotoWebPath() . '/', $imageName, $arrSettings['max_thumbnail_pic_width']['value'], $arrSettings['max_thumbnail_pic_height']['value'], 70, '', $cx->getWebsiteImagesAccessPhotoPath() . '/', $cx->getWebsiteImagesAccessPhotoWebPath() . '/', basename($cx->getWebsiteImagesAccessProfilePath() . '/' . $thumb_name));
     }
 }
 /**
  * the upload is finished
  * rewrite the names
  * write the uploaded files to the database
  *
  * @param string     $tempPath    the temporary file path
  * @param string     $tempWebPath the temporary file path which is accessable by web browser
  * @param array      $data        the data which are attached by uploader init method
  * @param integer    $uploadId    the upload id
  * @param array      $fileInfos   the file infos 
  * 
  * @return array the target paths
  */
 public static function notesUploadFinished($tempPath, $tempWebPath, $data, $uploadId, $fileInfos, $response)
 {
     global $objDatabase, $objFWUser;
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $depositionTarget = $cx->getWebsiteImagesCrmPath() . '/';
     //target folder
     $h = opendir($tempPath);
     if ($h) {
         while (false != ($file = readdir($h))) {
             $info = pathinfo($file);
             //skip . and ..
             if ($file == '.' || $file == '..') {
                 continue;
             }
             if ($file != '..' && $file != '.') {
                 //do not overwrite existing files.
                 $prefix = '';
                 while (file_exists($depositionTarget . $prefix . $file)) {
                     if (empty($prefix)) {
                         $prefix = 0;
                     }
                     $prefix++;
                 }
                 // move file
                 try {
                     $objFile = new \Cx\Lib\FileSystem\File($tempPath . '/' . $file);
                     $objFile->copy($depositionTarget . $prefix . $file, false);
                     // create thumbnail
                     if (empty($objImage)) {
                         $objImage = new \ImageManager();
                     }
                     $imageName = trim($prefix . $file);
                     $objImage->_createThumbWhq($cx->getWebsiteImagesCrmPath() . '/', $cx->getWebsiteImagesCrmWebPath() . '/', $imageName, 16, 16, 90, '_16X16.thumb');
                     $_SESSION['importFilename'] = $imageName;
                 } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
                     \DBG::msg($e->getMessage());
                 }
             }
             $arrFiles[] = $file;
         }
         closedir($h);
     }
     // return web- and filesystem path. files will be moved there.
     return array($tempPath, $tempWebPath);
 }
Beispiel #7
0
 /**
  * Stores the posted Product, if any
  * @return  boolean           True on success, null on noop, false otherwise
  */
 static function store_product()
 {
     global $_ARRAYLANG;
     if (!isset($_POST['bstore'])) {
         return null;
     }
     $product_name = contrexx_input2raw($_POST['product_name']);
     $product_code = contrexx_input2raw($_POST['product_code']);
     // Multiple Categories
     $category_id = isset($_POST['shopCategoriesAssigned']) ? contrexx_input2raw(join(',', $_POST['shopCategoriesAssigned'])) : '';
     $customer_price = $_POST['customer_price'];
     $reseller_price = $_POST['reseller_price'];
     $discount_active = !empty($_POST['discount_active']);
     $discount_price = $_POST['discount_price'];
     //DBG::log("ShopManager::store_product(): customer_price $customer_price, reseller_price $reseller_price, discount_price $discount_price");
     $vat_id = $_POST['vat_id'];
     $short = contrexx_input2raw($_POST['short']);
     $long = contrexx_input2raw($_POST['long']);
     $stock = $_POST['stock'];
     $stock_visible = !empty($_POST['stock_visible']);
     $uri = contrexx_input2raw($_POST['uri']);
     $active = !empty($_POST['articleActive']);
     $b2b = !empty($_POST['B2B']);
     $b2c = !empty($_POST['B2C']);
     $date_start = contrexx_input2raw($_POST['date_start']);
     $date_end = contrexx_input2raw($_POST['date_end']);
     $manufacturer_id = isset($_POST['manufacturer_id']) ? contrexx_input2int($_POST['manufacturer_id']) : 0;
     $minimum_order_quantity = $_POST['minimum_order_quantity'];
     // Currently not used on the detail page
     //        $flags = (isset($_POST['Flags'])
     //                ? join(' ', $_POST['Flags']) : '');
     $distribution = $_POST['distribution'];
     // Different meaning of the "weight" field for downloads!
     // The getWeight() method will treat purely numeric values
     // like the validity period (in days) the same as a weight
     // without its unit and simply return its integer value.
     $weight = $distribution == 'delivery' ? Weight::getWeight($_POST['weight']) : $_POST['accountValidity'];
     // Assigned frontend groups for protected downloads
     $usergroup_ids = isset($_POST['groupsAssigned']) ? implode(',', $_POST['groupsAssigned']) : '';
     $discount_group_count_id = $_POST['discount_group_count_id'];
     $discount_group_article_id = $_POST['discount_group_article_id'];
     //DBG::log("ShopManager::store_product(): Set \$discount_group_article_id to $discount_group_article_id");
     $keywords = contrexx_input2raw($_POST['keywords']);
     for ($i = 1; $i <= 3; ++$i) {
         // Images outside the above directory are copied to the shop image folder.
         // Note that the image paths below do not include the document root, but
         // are relative to it.
         $picture = contrexx_input2raw($_POST['productImage' . $i]);
         // Ignore the picture if it's the default image!
         // Storing it would be pointless.
         // Images outside the above directory are copied to the shop image folder.
         // Note that the image paths below do not include the document root, but
         // are relative to it.
         if ($picture == self::$defaultImage || !self::moveImage($picture)) {
             $picture = '';
         }
         // Update the posted path (used below)
         $_POST['productImage' . $i] = $picture;
     }
     // add all to pictures DBstring
     $imageName = base64_encode($_POST['productImage1']) . '?' . base64_encode($_POST['productImage1_width']) . '?' . base64_encode($_POST['productImage1_height']) . ':' . base64_encode($_POST['productImage2']) . '?' . base64_encode($_POST['productImage2_width']) . '?' . base64_encode($_POST['productImage2_height']) . ':' . base64_encode($_POST['productImage3']) . '?' . base64_encode($_POST['productImage3_width']) . '?' . base64_encode($_POST['productImage3_height']);
     // Note that the flags of the Product *MUST NOT* be changed
     // when inserting or updating the Product data, as the original
     // flags are needed for their own update later.
     $objProduct = null;
     $product_id = intval($_POST['id']);
     if ($product_id) {
         $objProduct = Product::getById($product_id);
     }
     $new = false;
     if (!$objProduct) {
         $new = true;
         $objProduct = new Product($product_code, $category_id, $product_name, $distribution, $customer_price, $active, 0, $weight);
         if (!$objProduct->store()) {
             return \Message::error($_ARRAYLANG['TXT_SHOP_PRODUCT_ERROR_STORING']);
         }
         //            $product_id = $objProduct->id();
     }
     // Apply the changes to all Products with the same Product code.
     // Note: This is disabled for the time being, as virtual categories are, too.
     //        if ($product_code != '') {
     //            $arrProduct = Products::getByCustomId($product_code);
     //        } else {
     //            $arrProduct = array($objProduct);
     //        }
     //        if (!is_array($arrProduct)) return false;
     //        foreach ($arrProduct as $objProduct) {
     // Update each product
     $objProduct->code($product_code);
     // NOTE: Only change the parent ShopCategory for a Product
     // that is in a real ShopCategory.
     $objProduct->category_id($category_id);
     $objProduct->name($product_name);
     $objProduct->distribution($distribution);
     $objProduct->price($customer_price);
     $objProduct->active($active);
     // On the overview only: $objProduct->ord();
     $objProduct->weight($weight);
     $objProduct->resellerprice($reseller_price);
     $objProduct->discount_active($discount_active);
     $objProduct->discountprice($discount_price);
     $objProduct->vat_id($vat_id);
     $objProduct->short($short);
     $objProduct->long($long);
     $objProduct->stock($stock);
     $objProduct->minimum_order_quantity($minimum_order_quantity);
     $objProduct->stock_visible($stock_visible);
     $objProduct->uri($uri);
     $objProduct->b2b($b2b);
     $objProduct->b2c($b2c);
     $objProduct->date_start($date_start);
     $objProduct->date_end($date_end);
     $objProduct->manufacturer_id($manufacturer_id);
     $objProduct->pictures($imageName);
     // Currently not used on the detail page
     //                $objProduct->flags($flags);
     $objProduct->usergroup_ids($usergroup_ids);
     $objProduct->group_id($discount_group_count_id);
     $objProduct->article_id($discount_group_article_id);
     $objProduct->keywords($keywords);
     //DBG::log("ShopManager::store_product(): Product: reseller_price ".$objProduct->resellerprice());
     // Remove old Product Attributes.
     // They are re-added below.
     $objProduct->clearAttributes();
     // Add current product attributes
     if (isset($_POST['options']) && is_array($_POST['options'])) {
         foreach ($_POST['options'] as $valueId => $nameId) {
             $order = intval($_POST['productOptionsSortId'][$nameId]);
             $objProduct->addAttribute(intval($valueId), $order);
         }
     }
     // Mind that this will always be an *update*, see the call to
     // store() above.
     if (!$objProduct->store()) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_PRODUCT_ERROR_STORING']);
     }
     //        }
     // Add/remove Categories and Products to/from
     // virtual ShopCategories.
     // Note that this *MUST* be called *AFTER* the Product is updated
     // or inserted.
     // Virtual categories are disabled for the time being
     //        Products::changeFlagsByProductCode(
     //            $product_code, $flags
     //        );
     $objImage = new \ImageManager();
     $arrImages = Products::get_image_array_from_base64($imageName);
     // Create thumbnails if not available, or update them
     foreach ($arrImages as $arrImage) {
         if (!empty($arrImage['img']) && $arrImage['img'] != ShopLibrary::noPictureName) {
             if (!$objImage->_createThumbWhq(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopPath() . '/', \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopWebPath() . '/', $arrImage['img'], \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_max_width', 'Shop'), \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_max_height', 'Shop'), \Cx\Core\Setting\Controller\Setting::getValue('thumbnail_quality', 'Shop'))) {
                 \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_COULD_NOT_CREATE_THUMBNAIL'], $arrImage['img']));
             }
         }
     }
     \Message::ok($new ? $_ARRAYLANG['TXT_DATA_RECORD_ADDED_SUCCESSFUL'] : $_ARRAYLANG['TXT_DATA_RECORD_UPDATED_SUCCESSFUL']);
     switch ($_POST['afterStoreAction']) {
         case 'newEmpty':
             \Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop' . MODULE_INDEX . '&act=products&tpl=manage');
         case 'newTemplate':
             \Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop' . MODULE_INDEX . '&act=products&tpl=manage&id=' . $objProduct->id() . '&new=1');
     }
     \Cx\Core\Csrf\Controller\Csrf::redirect('index.php?cmd=Shop' . MODULE_INDEX . '&act=products');
     // Never reached
     return true;
 }
 private function createThumbnailOfImage($imageName, $profilePic = false)
 {
     static $objImage, $arrSettings;
     if (empty($objImage)) {
         $objImage = new \ImageManager();
     }
     if (empty($arrSettings)) {
         $arrSettings = \User_Setting::getSettings();
     }
     if ($profilePic) {
         if (!$objImage->loadImage(ASCMS_ACCESS_PROFILE_IMG_PATH . '/' . $imageName)) {
             return false;
         }
         $rationWidth = $objImage->orgImageWidth / $arrSettings['profile_thumbnail_pic_width']['value'];
         $rationHeight = $objImage->orgImageHeight / $arrSettings['profile_thumbnail_pic_height']['value'];
         if ($arrSettings['profile_thumbnail_method']['value'] == 'crop') {
             if ($rationWidth < $rationHeight) {
                 $objImage->orgImageHeight = $objImage->orgImageHeight / $rationHeight * $rationWidth;
             } else {
                 $objImage->orgImageWidth = $objImage->orgImageWidth / $rationWidth * $rationHeight;
             }
             if (!$objImage->resizeImage($arrSettings['profile_thumbnail_pic_width']['value'], $arrSettings['profile_thumbnail_pic_height']['value'], 70)) {
                 return false;
             }
         } else {
             $ration = max($rationWidth, $rationHeight);
             $objImage->addBackgroundLayer(sscanf($arrSettings['profile_thumbnail_scale_color']['value'], '#%2X%2x%2x'), $arrSettings['profile_thumbnail_pic_width']['value'], $arrSettings['profile_thumbnail_pic_height']['value']);
         }
         $thumb_name = \ImageManager::getThumbnailFilename($imageName);
         return $objImage->saveNewImage(ASCMS_ACCESS_PROFILE_IMG_PATH . '/' . $thumb_name);
     } else {
         return $objImage->_createThumbWhq(ASCMS_ACCESS_PHOTO_IMG_PATH . '/', ASCMS_ACCESS_PHOTO_IMG_WEB_PATH . '/', $imageName, $arrSettings['max_thumbnail_pic_width']['value'], $arrSettings['max_thumbnail_pic_height']['value'], 70);
     }
 }