Example #1
0
 public function lC_Image_Admin_resize()
 {
     global $lC_Language;
     parent::lC_Image_Admin();
     $lC_Language->loadIniFile('modules/image/resize.php');
     $this->_title = $lC_Language->get('images_resize_title');
 }
Example #2
0
<?php

/**
  @package    catalog::admin::templates
  @author     Loaded Commerce
  @copyright  Copyright 2003-2014 Loaded Commerce, LLC
  @copyright  Portions Copyright 2003 osCommerce
  @copyright  Template built on Developr theme by DisplayInline http://themeforest.net/user/displayinline under Extended license 
  @license    https://github.com/loadedcommerce/loaded7/blob/master/LICENSE.txt
  @version    $Id: general.js.php v1.0 2013-08-08 datazen $
*/
global $lC_Vqmod, $lC_Template, $lC_Language;
require_once $lC_Vqmod->modCheck('includes/applications/updates/classes/updates.php');
require_once $lC_Vqmod->modCheck('includes/applications/images/classes/images.php');
require_once $lC_Vqmod->modCheck('includes/classes/image.php');
$lC_Image_Admin = new lC_Image_Admin();
?>
<script>
$(document).ready(function() { 
  // set shortcuts current marker
  var loc = '<?php 
echo end(explode("/", $_SERVER['PHP_SELF']));
?>
';
  var noParams = '<?php 
echo empty($_GET) ? true : false;
?>
';
  var module = '<?php 
echo $lC_Template->getModule();
?>
Example #3
0
 public static function delete($id, $categories = null)
 {
     global $lC_Database;
     $lC_Image = new lC_Image_Admin();
     $delete_product = true;
     $error = false;
     $lC_Database->startTransaction();
     if (is_array($categories) && !empty($categories)) {
         $Qpc = $lC_Database->query('delete from :table_products_to_categories where products_id = :products_id and categories_id in :categories_id');
         $Qpc->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
         $Qpc->bindInt(':products_id', $id);
         $Qpc->bindRaw(':categories_id', '("' . implode('", "', $categories) . '")');
         $Qpc->setLogging($_SESSION['module'], $id);
         $Qpc->execute();
         if (!$lC_Database->isError()) {
             $Qcheck = $lC_Database->query('select products_id from :table_products_to_categories where products_id = :products_id limit 1');
             $Qcheck->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
             $Qcheck->bindInt(':products_id', $id);
             $Qcheck->execute();
             if ($Qcheck->numberOfRows() > 0) {
                 $delete_product = false;
             }
         } else {
             $error = true;
         }
     }
     if ($error === false && $delete_product === true) {
         $Qvariants = $lC_Database->query('select products_id from :table_products where parent_id = :parent_id');
         $Qvariants->bindTable(':table_products', TABLE_PRODUCTS);
         $Qvariants->bindInt(':parent_id', $id);
         $Qvariants->execute();
         while ($Qvariants->next()) {
             $Qsc = $lC_Database->query('delete from :table_shopping_carts where products_id = :products_id');
             $Qsc->bindTable(':table_shopping_carts', TABLE_SHOPPING_CARTS);
             $Qsc->bindInt(':products_id', $Qvariants->valueInt('products_id'));
             $Qsc->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
             if ($error === false) {
                 $Qsccvv = $lC_Database->query('delete from :table_shopping_carts_custom_variants_values where products_id = :products_id');
                 $Qsccvv->bindTable(':table_shopping_carts_custom_variants_values', TABLE_SHOPPING_CARTS_CUSTOM_VARIANTS_VALUES);
                 $Qsccvv->bindInt(':products_id', $Qvariants->valueInt('products_id'));
                 $Qsccvv->execute();
                 if ($lC_Database->isError()) {
                     $error = true;
                 }
             }
             if ($error === false) {
                 $Qpa = $lC_Database->query('delete from :table_products_variants where products_id = :products_id');
                 $Qpa->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
                 $Qpa->bindInt(':products_id', $Qvariants->valueInt('products_id'));
                 $Qpa->setLogging($_SESSION['module'], $id);
                 $Qpa->execute();
                 if ($lC_Database->isError()) {
                     $error = true;
                 }
             }
             if ($error === false) {
                 $Qp = $lC_Database->query('delete from :table_products where products_id = :products_id');
                 $Qp->bindTable(':table_products', TABLE_PRODUCTS);
                 $Qp->bindInt(':products_id', $Qvariants->valueInt('products_id'));
                 $Qp->setLogging($_SESSION['module'], $id);
                 $Qp->execute();
                 if ($lC_Database->isError()) {
                     $error = true;
                 }
             }
             // QPB
             if ($error === false) {
                 $Qpb = $lC_Database->query('delete from :table_products_pricing where products_id = :products_id');
                 $Qpb->bindTable(':table_products_pricing', TABLE_PRODUCTS_PRICING);
                 $Qpb->bindInt(':products_id', $Qvariants->valueInt('products_id'));
                 $Qpb->setLogging($_SESSION['module'], $id);
                 $Qpb->execute();
                 if ($lC_Database->isError()) {
                     $error = true;
                 }
             }
         }
         if ($error === false) {
             $Qr = $lC_Database->query('delete from :table_reviews where products_id = :products_id');
             $Qr->bindTable(':table_reviews', TABLE_REVIEWS);
             $Qr->bindInt(':products_id', $id);
             $Qr->setLogging($_SESSION['module'], $id);
             $Qr->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qsc = $lC_Database->query('delete from :table_shopping_carts where products_id = :products_id');
             $Qsc->bindTable(':table_shopping_carts', TABLE_SHOPPING_CARTS);
             $Qsc->bindInt(':products_id', $id);
             $Qsc->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qsccvv = $lC_Database->query('delete from :table_shopping_carts_custom_variants_values where products_id = :products_id');
             $Qsccvv->bindTable(':table_shopping_carts_custom_variants_values', TABLE_SHOPPING_CARTS_CUSTOM_VARIANTS_VALUES);
             $Qsccvv->bindInt(':products_id', $id);
             $Qsccvv->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qp2c = $lC_Database->query('delete from :table_products_to_categories where products_id = :products_id');
             $Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
             $Qp2c->bindInt(':products_id', $id);
             $Qp2c->setLogging($_SESSION['module'], $id);
             $Qp2c->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qs = $lC_Database->query('delete from :table_specials where products_id = :products_id');
             $Qs->bindTable(':table_specials', TABLE_SPECIALS);
             $Qs->bindInt(':products_id', $id);
             $Qs->setLogging($_SESSION['module'], $id);
             $Qs->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qpa = $lC_Database->query('delete from :table_products_variants where products_id = :products_id');
             $Qpa->bindTable(':table_products_variants', TABLE_PRODUCTS_VARIANTS);
             $Qpa->bindInt(':products_id', $id);
             $Qpa->setLogging($_SESSION['module'], $id);
             $Qpa->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qpd = $lC_Database->query('delete from :table_products_description where products_id = :products_id');
             $Qpd->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
             $Qpd->bindInt(':products_id', $id);
             $Qpd->setLogging($_SESSION['module'], $id);
             $Qpd->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qp = $lC_Database->query('delete from :table_products where products_id = :products_id');
             $Qp->bindTable(':table_products', TABLE_PRODUCTS);
             $Qp->bindInt(':products_id', $id);
             $Qp->setLogging($_SESSION['module'], $id);
             $Qp->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         if ($error === false) {
             $Qim = $lC_Database->query('select id, image from :table_products_images where products_id = :products_id');
             $Qim->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
             $Qim->bindInt(':products_id', $id);
             $Qim->execute();
             // added to check for other products using same image and do not delete
             $Qop = $lC_Database->query('select id from :table_products_images where image = :image');
             $Qop->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
             $Qop->bindInt(':image', $Qim->value('image'));
             $Qop->execute();
             if ($Qop->numberOfRows() < 2) {
                 while ($Qim->next()) {
                     $lC_Image->delete($Qim->valueInt('id'));
                 }
             }
         }
         // featured products
         if ($error === false) {
             $Qfp = $lC_Database->query('delete from :table_featured_products where products_id = :products_id');
             $Qfp->bindTable(':table_featured_products', TABLE_FEATURED_PRODUCTS);
             $Qfp->bindInt(':products_id', $id);
             $Qfp->setLogging($_SESSION['module'], $id);
             $Qfp->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         // QPB
         if ($error === false) {
             $Qpb = $lC_Database->query('delete from :table_products_pricing where products_id = :products_id');
             $Qpb->bindTable(':table_products_pricing', TABLE_PRODUCTS_PRICING);
             $Qpb->bindInt(':products_id', $id);
             $Qpb->setLogging($_SESSION['module'], $id);
             $Qpb->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
         // permalink
         if ($error === false) {
             $Qpb = $lC_Database->query('delete from :table_permalinks where item_id = :item_id');
             $Qpb->bindTable(':table_permalinks', TABLE_PERMALINKS);
             $Qpb->bindInt(':item_id', $id);
             $Qpb->execute();
             if ($lC_Database->isError()) {
                 $error = true;
             }
         }
     }
     // delete subproducts
     if ($error === false && $delete_product === true) {
         $Qcheck = $lC_Database->query('select products_id from :table_products where parent_id = :parent_id');
         $Qcheck->bindTable(':table_products', TABLE_PRODUCTS);
         $Qcheck->bindInt(':parent_id', $id);
         $Qcheck->execute();
         while ($Qcheck->next()) {
             // delete the description data
             $Qdel = $lC_Database->query('delete from :table_products_description where products_id = :products_id');
             $Qdel->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
             $Qdel->bindInt(':products_id', $Qcheck->valueInt('products_id'));
             $Qdel->setLogging($_SESSION['module'], $id);
             $Qdel->execute();
             // delete the image data
             $Qdel = $lC_Database->query('delete from :table_products_images where products_id = :products_id');
             $Qdel->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
             $Qdel->bindInt(':products_id', $Qcheck->valueInt('products_id'));
             $Qdel->setLogging($_SESSION['module'], $id);
             $Qdel->execute();
         }
         // delete the subproduct
         $Qdel = $lC_Database->query('delete from :table_products where products_id = :products_id');
         $Qdel->bindTable(':table_products', TABLE_PRODUCTS);
         $Qdel->bindInt(':products_id', $Qcheck->valueInt('products_id'));
         $Qdel->setLogging($_SESSION['module'], $id);
         $Qdel->execute();
         if ($lC_Database->isError()) {
             $error = true;
         }
     }
     // delete simple options
     if ($error === false && $delete_product === true) {
         $Qcheck = $lC_Database->query('select options_id from :table_products_simple_options where products_id = :products_id');
         $Qcheck->bindTable(':table_products_simple_options', TABLE_PRODUCTS_SIMPLE_OPTIONS);
         $Qcheck->bindInt(':products_id', $id);
         $Qcheck->execute();
         // delete the simple options values
         while ($Qcheck->next()) {
             $Qdel = $lC_Database->query('delete from :table_products_simple_options_values where options_id = :options_id AND products_id = :products_id');
             $Qdel->bindTable(':table_products_simple_options_values', TABLE_PRODUCTS_SIMPLE_OPTIONS_VALUES);
             $Qdel->bindInt(':options_id', $Qcheck->valueInt('options_id'));
             $Qdel->bindInt(':products_id', $id);
             $Qdel->setLogging($_SESSION['module'], $id);
             $Qdel->execute();
         }
         // delete the simple option
         $Qdel = $lC_Database->query('delete from :table_products_simple_options where products_id = :products_id');
         $Qdel->bindTable(':table_products_simple_options', TABLE_PRODUCTS_SIMPLE_OPTIONS);
         $Qdel->bindInt(':products_id', $id);
         $Qdel->setLogging($_SESSION['module'], $id);
         $Qdel->execute();
         $Qcheck->freeResult();
         if ($lC_Database->isError()) {
             $error = true;
         }
     }
     if ($error === false) {
         $lC_Database->commitTransaction();
         lC_Cache::clear('categories');
         lC_Cache::clear('category_tree');
         lC_Cache::clear('also_purchased');
         lC_Cache::clear('box-whats_new');
         return true;
     }
     $lC_Database->rollbackTransaction();
     return false;
 }
Example #4
0
 public function __construct()
 {
     global $lC_Language, $lC_MessageStack;
     parent::__construct();
     $this->_page_contents = 'edit.php';
     if ((lc_empty(CFG_APP_IMAGEMAGICK_CONVERT) || !@file_exists(CFG_APP_IMAGEMAGICK_CONVERT)) && !lC_Image_Admin::hasGDSupport()) {
         $_SESSION['error'] = true;
         $_SESSION['errmsg'] = $lC_Language->get('ms_warning_image_processor_not_available');
     }
     if (isset($_POST['subaction']) && $_POST['subaction'] == 'confirm') {
         $error = false;
         $has_variants = isset($_POST['variants']) ? true : false;
         $data = array('id' => isset($_POST['products_id']) ? $_POST['products_id'] : 0, 'quantity' => isset($_POST['products_quantity']) && $has_variants === false ? $_POST['products_quantity'] : 0, 'cost' => number_format(is_numeric($_POST['products_cost']) ? $_POST['products_cost'] : 0, DECIMAL_PLACES, '.', ''), 'price' => number_format(is_numeric($_POST['products_price']) ? $_POST['products_price'] : 0, DECIMAL_PLACES, '.', ''), 'msrp' => number_format(is_numeric($_POST['products_msrp']) ? $_POST['products_msrp'] : 0, DECIMAL_PLACES, '.', ''), 'weight' => $_POST['products_weight'], 'weight_class' => isset($_POST['products_weight_class']) ? $_POST['products_weight_class'] : '', 'status' => isset($_POST['products_status']) && $_POST['products_status'] == 'on' ? true : false, 'model' => isset($_POST['products_model']) ? $_POST['products_model'] : '', 'sku' => isset($_POST['products_sku']) ? $_POST['products_sku'] : '', 'tax_class_id' => isset($_POST['products_tax_class_id']) ? $_POST['products_tax_class_id'] : 0, 'shipping_rule_id' => isset($_POST['shipping_rule_id']) ? $_POST['shipping_rule_id'] : 0, 'products_name' => $_POST['products_name'], 'products_blurb' => $_POST['products_blurb'], 'products_description' => $_POST['products_description'], 'products_keyword' => $_POST['products_keyword'], 'products_tags' => $_POST['products_tags'], 'products_url' => $_POST['products_url'], 'has_children' => $has_variants, 'products_sort_order' => $_POST['products_sort_order']);
         if (isset($_POST['attributes'])) {
             $data['attributes'] = $_POST['attributes'];
         }
         if (isset($_POST['attributes2'])) {
             $data['attributes2'] = $_POST['attributes2'];
         }
         if (isset($_POST['categories'])) {
             $data['categories'] = $_POST['categories'];
         }
         if (isset($_POST['localimages'])) {
             $data['localimages'] = $_POST['localimages'];
         }
         // simple options
         if (isset($_POST['simple_options_group_name'])) {
             $data['simple_options_group_name'] = $_POST['simple_options_group_name'];
         }
         if (isset($_POST['simple_options_group_type'])) {
             $data['simple_options_group_type'] = $_POST['simple_options_group_type'];
         }
         if (isset($_POST['simple_options_group_sort_order'])) {
             $data['simple_options_group_sort_order'] = $_POST['simple_options_group_sort_order'];
         }
         if (isset($_POST['simple_options_group_status'])) {
             $data['simple_options_group_status'] = $_POST['simple_options_group_status'];
         }
         if (isset($_POST['simple_options_entry'])) {
             $data['simple_options_entry'] = $_POST['simple_options_entry'];
         }
         if (isset($_POST['simple_options_entry_price_modifier'])) {
             $data['simple_options_entry_price_modifier'] = $_POST['simple_options_entry_price_modifier'];
         }
         // specials
         if (isset($_POST['specials_pricing_switch']) && $_POST['specials_pricing_switch'] == 'on') {
             if (is_array($_POST['products_special_pricing'])) {
                 $data['products_special_pricing'] = $_POST['products_special_pricing'];
             }
             $data['specials_pricing_switch'] = 1;
             if (isset($_POST['products_special_pricing_enable1'])) {
                 $data['products_special_pricing_enable1'] = $_POST['products_special_pricing_enable1'] == 'on' ? 1 : 0;
             }
             if (isset($_POST['products_special_price'][1])) {
                 $data['products_special_price1'] = $_POST['products_special_price'][1];
             }
             if (isset($_POST['products_special_start_date'][1])) {
                 $data['products_special_start_date1'] = $_POST['products_special_start_date'][1];
             }
             if (isset($_POST['products_special_expires_date'][1])) {
                 $data['products_special_expires_date1'] = $_POST['products_special_expires_date'][1];
             }
         }
         // sub-products
         if (is_array($_POST['sub_products_name']) && count($_POST['sub_products_name']) > 1) {
             $data['has_subproducts'] = '1';
             $data['sub_products_name'] = $_POST['sub_products_name'];
             if (isset($_POST['sub_products_default']) && $_POST['sub_products_default'] != NULL) {
                 $data['sub_products_default'] = $_POST['sub_products_default'];
             }
             if (isset($_POST['sub_products_status']) && $_POST['sub_products_status'] != NULL) {
                 $data['sub_products_status'] = $_POST['sub_products_status'];
             }
             if (isset($_POST['sub_products_weight']) && $_POST['sub_products_weight'] != NULL) {
                 $data['sub_products_weight'] = $_POST['sub_products_weight'];
             }
             if (isset($_POST['sub_products_sku']) && $_POST['sub_products_sku'] != NULL) {
                 $data['sub_products_sku'] = $_POST['sub_products_sku'];
             }
             if (isset($_POST['sub_products_qoh']) && $_POST['sub_products_qoh'] != NULL) {
                 $data['sub_products_qoh'] = $_POST['sub_products_qoh'];
             }
             if (isset($_POST['sub_products_id']) && $_POST['sub_products_id'] != NULL) {
                 $data['sub_products_id'] = $_POST['sub_products_id'];
             }
             if (isset($_POST['sub_products_cost']) && $_POST['sub_products_cost'] != NULL) {
                 $data['sub_products_cost'] = $_POST['sub_products_cost'];
             }
             if (isset($_POST['sub_products_price']) && $_POST['sub_products_price'] != NULL) {
                 $data['sub_products_price'] = $_POST['sub_products_price'];
             }
         }
         // qpb
         $data['qpb_pricing_switch'] = isset($_POST['qpb_pricing_switch']) && $_POST['qpb_pricing_switch'] == 'on' ? true : false;
         if (is_array($_POST['products_qty_break_point']) && $_POST['products_qty_break_point'][1] != NULL) {
             $data['products_qty_break_point'] = $_POST['products_qty_break_point'];
         }
         if (is_array($_POST['products_qty_break_price']) && $_POST['products_qty_break_price'][1] != NULL) {
             $data['products_qty_break_price'] = $_POST['products_qty_break_price'];
         }
         // multi SKU options
         if (isset($_POST['variants'])) {
             $data['variants'] = $_POST['variants'];
         }
         // access levels
         if (isset($_POST['access_levels'])) {
             $data['access_levels'] = $_POST['access_levels'];
         }
         // options pricing
         if (isset($_POST['options_pricing'])) {
             $data['options_pricing'] = $_POST['options_pricing'];
         }
         // specials pricing
         if (isset($_POST['specials_pricing'])) {
             $data['specials_pricing'] = $_POST['specials_pricing'];
         }
         // group pricing
         $data['groups_pricing_switch'] = isset($_POST['groups_pricing_switch']) && $_POST['groups_pricing_switch'] == 'on' ? true : false;
         if (isset($_POST['group_pricing'])) {
             $data['group_pricing'] = $_POST['group_pricing'];
         }
         if ($error === false) {
             // the line below is used as a hook match point - do not not modify or remove
             $id = (int) lC_Products_Admin::save(isset($_GET[$this->_module]) && is_numeric($_GET[$this->_module]) ? $_GET[$this->_module] : null, $data);
             if (is_numeric($id)) {
                 if (empty($_POST['save_close'])) {
                     lc_redirect_admin(lc_href_link_admin(FILENAME_DEFAULT, $this->_module . '=' . $id . '&action=save&cID=' . $_GET['cID']));
                 } else {
                     lc_redirect_admin(lc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&cID=' . $_GET['cID']));
                 }
             } else {
                 $_SESSION['error'] = true;
                 $_SESSION['errmsg'] = $lC_Language->get('ms_error_action_not_performed');
             }
             lc_redirect_admin(lc_href_link_admin(FILENAME_DEFAULT, $this->_module . '&cID=' . $_GET['cID']));
         }
     }
 }
Example #5
0
 public static function fileUpload()
 {
     global $lC_Database, $lC_Vqmod, $_module;
     $lC_Image = new lC_Image_Admin();
     if (is_numeric($_GET[$_module])) {
         require_once $lC_Vqmod->modCheck('includes/classes/ajax_upload.php');
         // list of valid extensions, ex. array("jpeg", "xml", "bmp")
         $allowedExtensions = array('gif', 'jpg', 'jpeg', 'png');
         // max file size in bytes
         $sizeLimit = 10 * 1024 * 1024;
         $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
         $products_image = $uploader->handleUpload('../images/products/originals/');
         if ($products_image['exists'] == true) {
             if (isset($products_image['filename']) && $products_image['filename'] != null) {
                 $default_flag = 1;
                 $Qcheck = $lC_Database->query('select id from :table_products_images where products_id = :products_id and default_flag = :default_flag limit 1');
                 $Qcheck->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
                 $Qcheck->bindInt(':products_id', $_GET[$_module]);
                 $Qcheck->bindInt(':default_flag', 1);
                 $Qcheck->execute();
                 if ($Qcheck->numberOfRows() === 1) {
                     // is default image uploaded, remove the old default image first.
                     if (isset($_GET['default']) && $_GET['default'] == '1') {
                         $lC_Image->delete($Qcheck->value('id'));
                     } else {
                         $default_flag = 0;
                     }
                 }
                 $Qimage = $lC_Database->query('insert into :table_products_images (products_id, image, default_flag, sort_order, date_added) values (:products_id, :image, :default_flag, :sort_order, :date_added)');
                 $Qimage->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
                 $Qimage->bindInt(':products_id', $_GET[$_module]);
                 $Qimage->bindValue(':image', $products_image['filename']);
                 $Qimage->bindInt(':default_flag', $default_flag);
                 $Qimage->bindInt(':sort_order', 0);
                 $Qimage->bindRaw(':date_added', 'now()');
                 $Qimage->setLogging($_SESSION['module'], $_GET[$_module]);
                 $Qimage->execute();
                 foreach ($lC_Image->getGroups() as $group) {
                     if ($group['id'] != '1') {
                         $lC_Image->resize($products_image['filename'], $group['id']);
                     }
                 }
             }
         }
     }
     $result = array('result' => 1, 'success' => true, 'rpcStatus' => RPC_STATUS_SUCCESS);
     echo json_encode($result);
 }
Example #6
0
 public static function resizeBatch()
 {
     global $lC_Database, $lC_Language, $lC_Vqmod;
     require_once $lC_Vqmod->modCheck('includes/classes/image.php');
     $lC_Image_Admin = new lC_Image_Admin();
     $overwrite = isset($_GET['overwrite']) && $_GET['overwrite'] == '1' ? true : false;
     $result = array();
     if (!isset($_GET['groups']) || !is_array($_GET['groups'])) {
         return false;
     }
     $Qoriginals = $lC_Database->query('select image from :table_products_images');
     $Qoriginals->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
     $Qoriginals->execute();
     $counter = array();
     while ($Qoriginals->next()) {
         foreach ($_GET['groups'] as $groupID) {
             if ($groupID != '1' && in_array($groupID, $_GET['groups'])) {
                 if (!isset($counter[$groupID])) {
                     $counter[$groupID] = 0;
                 }
                 if ($overwrite === true || !file_exists(DIR_FS_CATALOG . DIR_WS_IMAGES . 'products/' . $group['code'] . '/' . $Qoriginals->value('image'))) {
                     $lC_Image_Admin->resize($Qoriginals->value('image'), $groupID);
                     $counter[$groupID]++;
                 }
             }
         }
     }
     $cnt = 0;
     $html = '';
     foreach ($counter as $key => $value) {
         // get group title
         $Qgroup = $lC_Database->query('select title from :table_products_images_groups where id = :id');
         $Qgroup->bindTable(':table_products_images_groups', TABLE_PRODUCTS_IMAGES_GROUPS);
         $Qgroup->bindInt(':id', $key);
         $Qgroup->execute();
         $class = $cnt % 2 ? 'even' : 'odd';
         $html .= '<tr class="' . $class . '">';
         $html .= '<td class="dataColResultsGroup"><span>' . $Qgroup->value('title') . '</span></td>';
         $html .= '<td class="dataColResultsTotal"><span>' . $value . '</span></td>';
         $html .= '</tr>';
         $cnt++;
     }
     $result['html'] = $html;
     $Qgroup->freeResult;
     //remove the resize flag if it exists
     if (file_exists(DIR_FS_WORK . 'resize.tmp')) {
         @unlink(DIR_FS_WORK . 'resize.tmp');
     }
     return $result;
 }