public function renderForm($args, $data) { $helper = $this->getFormHelper(); $imagesTypes = ImageType::getImagesTypes('manufacturers'); $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Widget Form.')), 'input' => array(array('type' => 'html', 'html_content' => 'Please access <a href="http://apollotheme.com/" target="_blank" title="apollo site">Apollotheme.com</a> to buy professional version to use this '), array('type' => 'html', 'html_content' => '<a target="_blank" href="http://apollotheme.com/how-to-buy-pro-version/" target="_blank" title="How to buy">How to buy Professional Version</a>'), array('type' => 'html', 'html_content' => '<a target="_blank" href="http://apollotheme.com/different-between-free-pro-version/" target="_blank" title="Why should use">Why should use Professional Version</a>')), 'buttons' => array(array('title' => $this->l('Save And Stay'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveandstayleotempcp'), array('title' => $this->l('Save'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveleotempcp'))); $default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_language' => $default_lang); return $helper->generateForm($this->fields_form); }
public function makeFormConfigs() { if ($this->_fields_form) { return; } $imagesTypes = ImageType::getImagesTypes('manufacturers'); $fields_form = array('form' => array('legend' => array('title' => $this->l('Settings'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => 'text', 'label' => $this->l('Colums In Tab.'), 'name' => $this->renderName('col'), 'desc' => $this->l('The maximum column items in tab.'), 'default' => 3), array('type' => 'text', 'label' => $this->l('Manufacturers Per Page:'), 'name' => $this->renderName('page'), 'desc' => $this->l('The maximum number of manufacturers displayed in this block.'), 'required' => true, 'default' => 6), array('type' => 'switch', 'label' => $this->l('Show title:'), 'name' => $this->renderName('active_title'), 'is_bool' => true, 'desc' => 'Display or none display Module title.', 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('No'))), 'default' => 0), array('type' => 'switch', 'label' => $this->l('Auto play:'), 'name' => $this->renderName('active_play'), 'is_bool' => true, 'desc' => 'For carousel.', 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('No'))), 'default' => 0), array('type' => 'select', 'label' => $this->l('Shipping method:'), 'desc' => $this->l('Type image'), 'name' => $this->renderName('type_img'), 'required' => true, 'options' => array('query' => $imagesTypes, 'id' => 'name', 'name' => 'name'), 'default' => 'pf_manufacturer'), array('type' => 'text', 'label' => $this->l('Interval .'), 'name' => $this->renderName('intv'), 'desc' => $this->l('Enter Time(miniseconds) to play carousel. Value 1 to stop.'), 'default' => 8000)), 'submit' => array('title' => $this->l('Save'), 'class' => 'btn btn-default'))); $this->_fields_form[] = $fields_form; }
public function renderForm($args, $data) { $helper = $this->getFormHelper(); $imagesTypes = ImageType::getImagesTypes('manufacturers'); $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Widget Form.')), 'input' => array(array('type' => 'text', 'label' => $this->l('Limit'), 'name' => 'limit', 'default' => 10), array('type' => 'select', 'label' => $this->l('Image:'), 'desc' => $this->l('Select type image for manufacture.'), 'name' => 'image', 'default' => 'small' . '_default', 'options' => array('query' => $imagesTypes, 'id' => 'name', 'name' => 'name'))), 'buttons' => array(array('title' => $this->l('Save And Stay'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveandstayleotempcp'), array('title' => $this->l('Save'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveleotempcp'))); $default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_language' => $default_lang); return $helper->generateForm($this->fields_form); }
public function renderForm($args, $data) { $helper = $this->getFormHelper(); $imagesTypes = ImageType::getImagesTypes('manufacturers'); $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Widget Form.')), 'input' => array(array('type' => 'text', 'label' => $this->l('Items Per Page'), 'name' => 'itemspage', 'default' => 3, 'desc' => $this->l('The maximum number of products in each page Carousel (default: 3).')), array('type' => 'text', 'label' => $this->l('Colums In Tab'), 'name' => 'columns', 'default' => 3, 'desc' => 'The maximum column products in each page Carousel (default: 3).'), array('type' => 'text', 'label' => $this->l('Items In Tab'), 'name' => 'itemstab', 'default' => 6, 'desc' => $this->l('The maximum number of products in each Carousel (default: 6).')), array('type' => 'select', 'label' => $this->l('Image:'), 'desc' => $this->l('Select type image for manufacture.'), 'name' => 'image', 'default' => 'small_' . 'default', 'options' => array('query' => $imagesTypes, 'id' => 'name', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Interval'), 'name' => 'interval', 'default' => 8000, 'desc' => $this->l('Enter Time(miniseconds) to play carousel. Value 0 to stop.'))), 'buttons' => array(array('title' => $this->l('Save And Stay'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveandstayleotempcp'), array('title' => $this->l('Save'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveleotempcp'))); $default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_language' => $default_lang); return $helper->generateForm($this->fields_form); }
public function afterImageUpload() { /* Generate image with differents size */ if ($id_manufacturer = intval(Tools::getValue('id_manufacturer')) and isset($_FILES) and count($_FILES) and file_exists(_PS_MANU_IMG_DIR_ . $id_manufacturer . '.jpg')) { $imagesTypes = ImageType::getImagesTypes('manufacturers'); foreach ($imagesTypes as $k => $imageType) { imageResize(_PS_MANU_IMG_DIR_ . $id_manufacturer . '.jpg', _PS_MANU_IMG_DIR_ . $id_manufacturer . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height'])); } } }
protected function postImage($id) { $ret = parent::postImage($id); if ($id_store = (int) Tools::getValue('id_store') and isset($_FILES) and sizeof($_FILES) and file_exists(_PS_STORE_IMG_DIR_ . $id_store . '.jpg')) { $imagesTypes = ImageType::getImagesTypes('stores'); foreach ($imagesTypes as $k => $imageType) { imageResize(_PS_STORE_IMG_DIR_ . $id_store . '.jpg', _PS_STORE_IMG_DIR_ . $id_store . '-' . stripslashes($imageType['name']) . '.jpg', (int) $imageType['width'], (int) $imageType['height']); } } return $ret; }
protected function postImage($id) { $ret = parent::postImage($id); if ($id_category = intval(Tools::getValue('id_category')) and isset($_FILES) and sizeof($_FILES) and file_exists(_PS_CAT_IMG_DIR_ . $id_category . '.jpg')) { $imagesTypes = ImageType::getImagesTypes('categories'); foreach ($imagesTypes as $k => $imageType) { imageResize(_PS_CAT_IMG_DIR_ . $id_category . '.jpg', _PS_CAT_IMG_DIR_ . $id_category . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height'])); } } return $ret; }
public function __construct() { $this->table = 'powatag_configuration'; $this->lang = false; $this->_select = null; //If needed you can add informations to select issued from other databases $this->_join = null; //Join the databases here parent::__construct(); $this->bootstrap = true; $this->fields_options = array('api_settings' => array('title' => $this->l('API Settings'), 'image' => '../img/admin/prefs.gif', 'fields' => array('POWATAG_API_KEY' => array('title' => $this->l('API Key'), 'validation' => 'isString', 'type' => 'text', 'size' => '80', 'visibility' => Shop::CONTEXT_SHOP, 'required' => true), 'POWATAG_HMAC_KEY' => array('title' => $this->l('HMAC Key'), 'validation' => 'isString', 'type' => 'text', 'visibility' => Shop::CONTEXT_SHOP, 'size' => 80, 'required' => true), 'POWATAG_GENERATOR_URL' => array('title' => $this->l('Powatag Endpoint URL'), 'validation' => 'isString', 'type' => 'text', 'size' => 80), 'POWATAG_JS_URL' => array('title' => $this->l('Head JavaScript URL'), 'validation' => 'isString', 'type' => 'text', 'size' => 80), 'POWATAG_CSS_URL' => array('title' => $this->l('Head CSS URL'), 'validation' => 'isString', 'type' => 'text', 'size' => 80), 'POWATAG_LEGACY_ERRORS' => array('title' => $this->l('Legacy error codes enabled'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_SHOP)), 'submit' => array('title' => $this->l('Save'))), 'other_settings' => array('title' => $this->l('Other Settings'), 'image' => '../img/admin/tab-tools.gif', 'fields' => array('POWATAG_SHIPPING' => array('title' => $this->l('Shipping Method'), 'validation' => 'isInt', 'type' => 'select', 'identifier' => 'id_carrier', 'desc' => $this->l('This will be used to calculate shipping costs'), 'list' => Carrier::getCarriers($this->context->language->id, false, false, false, null, Carrier::ALL_CARRIERS), 'visibility' => Shop::CONTEXT_SHOP, 'required' => true), 'POWATAG_SUCCESS_MSG' => array('title' => $this->l('Sucess message'), 'validation' => 'isString', 'type' => 'textLang', 'size' => '80', 'visibility' => Shop::CONTEXT_SHOP), 'POWATAG_IMG_TYPE' => array('title' => $this->l('Image type to send'), 'validation' => 'isInt', 'type' => 'select', 'identifier' => 'id_image_type', 'list' => ImageType::getImagesTypes(), 'visibility' => Shop::CONTEXT_SHOP, 'required' => true)), 'submit' => array('title' => $this->l('Save'))), 'product_settings' => array('title' => $this->l('Product Settings'), 'image' => $this->module->getPathUri() . 'img/qr_code.png', 'fields' => array('POWATAG_QR' => array('title' => $this->l('QR Code enabled'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_SHOP), 'POWATAG_QR_POS' => array('title' => $this->l('QR code Position'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => 'displayRightColumnProduct', 'name' => $this->l('displayRightColumnProduct')), array('key' => 'displayLeftColumnProduct', 'name' => $this->l('displayLeftColumnProduct')), array('key' => 'displayFooterProduct', 'name' => $this->l('displayFooterProduct')), array('key' => 'displayProductButtons', 'name' => $this->l('displayProductButtons'))), 'visibility' => Shop::CONTEXT_SHOP), 'POWATAG_SKU' => array('title' => $this->l('Which SKU field to use '), 'validation' => 'isInt', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => Powatag::EAN, 'name' => $this->l('EAN13 or JAN')), array('key' => Powatag::UPC, 'name' => $this->l('UPC')), array('key' => Powatag::PRODUCT_ID, 'name' => $this->l('Product ID')), array('key' => Powatag::REFERENCE, 'name' => $this->l('REFERENCE')))), 'POWATAG_REDIRECT' => array('title' => $this->l('URL Redirect'), 'validation' => 'isString', 'type' => 'text', 'size' => 250), 'POWATAG_OFFER' => array('title' => $this->l('Promotional area'), 'validation' => 'isString', 'type' => 'text', 'size' => 250), 'POWATAG_LANG' => array('title' => $this->l('Language'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'site', 'name' => $this->l('Use site language')), array('key' => 'en_GB', 'name' => $this->l('en_GB')), array('key' => 'es_ES', 'name' => $this->l('es_ES')), array('key' => 'fr_FR', 'name' => $this->l('fr_FR')), array('key' => 'it_IT', 'name' => $this->l('it_IT')))), 'POWATAG_TYPE' => array('title' => $this->l('Type'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'bag', 'name' => $this->l('Bag')), array('key' => 'mobile-button', 'name' => $this->l('Mobile button')), array('key' => 'tablet-bag', 'name' => $this->l('Tablet bag')))), 'POWATAG_STYLE' => array('title' => $this->l('Style'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'act-left', 'name' => $this->l('act-left')), array('key' => 'act-right', 'name' => $this->l('act-right')), array('key' => 'buy-left', 'name' => $this->l('buy-left')), array('key' => 'buy-right', 'name' => $this->l('buy-right')), array('key' => 'give-left', 'name' => $this->l('give-left')), array('key' => 'give-right', 'name' => $this->l('give-right')), array('key' => 'bg-act-left', 'name' => $this->l('bg-act-left')), array('key' => 'bg-act-right', 'name' => $this->l('bg-act-right')), array('key' => 'bg-buy-left', 'name' => $this->l('bg-buy-left')), array('key' => 'bg-buy-right', 'name' => $this->l('bg-buy-right')), array('key' => 'bg-give-left', 'name' => $this->l('bg-give-left')), array('key' => 'bg-give-right', 'name' => $this->l('bg-give-right')))), 'POWATAG_COLORSCHEME' => array('title' => $this->l('Color scheme'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'light', 'name' => $this->l('Light')), array('key' => 'dark', 'name' => $this->l('Dark')))), 'POWATAG_DISPLAY' => array('title' => $this->l('Desktop / mobile'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'both', 'name' => $this->l('Both')), array('key' => 'desktop-only', 'name' => $this->l('Desktop only')), array('key' => 'mobile-only', 'name' => $this->l('Mobile only')))), 'POWATAG_VIDEO' => array('title' => $this->l('Video'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'POWATAG_DEBUG' => array('title' => $this->l('Developer mode'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool')), 'submit' => array('title' => $this->l('Save'))), 'logs' => array('title' => $this->l('Logs'), 'image' => '../img/t/AdminLogs.gif', 'fields' => array('POWATAG_API_LOG' => array('title' => $this->l('Enable applicative logging'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_SHOP), 'POWATAG_REQUEST_LOG' => array('title' => $this->l('Enable request logging'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_SHOP)), 'submit' => array('title' => $this->l('Save')))); }
function getContent() { // make url $url_vars = array('id_tab' => '13', 'section' => 'advanced_parameters'); if (version_compare(_PS_VERSION_, '1.5', '>')) { $url_vars['controller'] = Tools::getValue('controller'); } else { $url_vars['tab'] = Tools::getValue('tab'); } $url = $this->_getUrl($url_vars); $smarty_vars = array('url' => $url, 'sizes' => ImageType::getImagesTypes('products'), 'sizedefault' => $this->ebay_profile->getConfiguration('EBAY_PICTURE_SIZE_DEFAULT'), 'sizebig' => (int) $this->ebay_profile->getConfiguration('EBAY_PICTURE_SIZE_BIG'), 'sizesmall' => (int) $this->ebay_profile->getConfiguration('EBAY_PICTURE_SIZE_SMALL'), 'picture_per_listing' => (int) $this->ebay_profile->getConfiguration('EBAY_PICTURE_PER_LISTING'), 'api_logs' => Configuration::get('EBAY_API_LOGS'), 'activate_logs' => Configuration::get('EBAY_ACTIVATE_LOGS'), 'is_writable' => is_writable(_PS_MODULE_DIR_ . 'ebay/log/request.txt'), 'log_file_exists' => file_exists(_PS_MODULE_DIR_ . 'ebay/log/request.txt'), 'logs_conservation_duration' => Configuration::get('EBAY_LOGS_DAYS'), 'sync_products_by_cron' => Configuration::get('EBAY_SYNC_PRODUCTS_BY_CRON'), 'sync_products_by_cron_url' => $this->_getModuleUrl() . 'synchronizeProducts_CRON.php', 'sync_products_by_cron_path' => $this->_getModuleUrl() . 'synchronizeProducts_CRON.php', 'sync_orders_by_cron' => Configuration::get('EBAY_SYNC_ORDERS_BY_CRON'), 'sync_orders_by_cron_url' => $this->_getModuleUrl() . 'synchronizeOrders_CRON.php', 'sync_orders_by_cron_path' => $this->_getModuleUrl() . 'synchronizeOrders_CRON.php', 'orders_days_backward' => Configuration::get('EBAY_ORDERS_DAYS_BACKWARD'), 'stats' => Configuration::get('EBAY_SEND_STATS')); return $this->display('formAdvancedParameters.tpl', $smarty_vars); }
// ); return parent::renderForm(); } protected function afterImageUpload() { $res = true; /* Generate image with differents size */ if (($id_friend_data = (int) Tools::getValue('id_friend_data')) && isset($_FILES) && isset($_FILES) && count($_FILES) && $_FILES['image']['name'] != null && file_exists(_PS_MYFRIENDS_IMG_DIR_ . $id_friend_data . '.jpg')) { $images_types = ImageType::getImagesTypes('products'); foreach ($images_types as $k => $image_type) { $res &= ImageManager::resize(_PS_MYFRIENDS_IMG_DIR_ . $id_friend_data . '.jpg', _PS_MYFRIENDS_IMG_DIR_ . $id_friend_data . '-' . stripslashes($image_type['name']) . '.jpg', (int) $image_type['width'], (int) $image_type['height']); } } if (!$res) { $this->errors[] = Tools::displayError('Unable to resize one or more of your pictures.');
public function process() { parent::process(); if (!($id_category = (int) Tools::getValue('id_category')) or !Validate::isUnsignedId($id_category)) { $this->errors[] = Tools::displayError('Missing category ID'); } else { if (!Validate::isLoadedObject($this->category)) { $this->errors[] = Tools::displayError('Category does not exist'); } elseif (!$this->category->checkAccess((int) self::$cookie->id_customer)) { $this->errors[] = Tools::displayError('You do not have access to this category.'); } elseif (!$this->category->active) { self::$smarty->assign('category', $this->category); } else { $rewrited_url = self::$link->getCategoryLink((int) $this->category->id, $this->category->link_rewrite); /* Scenes (could be externalised to another controler if you need them */ self::$smarty->assign('scenes', Scene::getScenes((int) $this->category->id, (int) self::$cookie->id_lang, true, false)); /* Scenes images formats */ if ($sceneImageTypes = ImageType::getImagesTypes('scenes')) { foreach ($sceneImageTypes as $sceneImageType) { if ($sceneImageType['name'] == 'thumb_scene') { $thumbSceneImageType = $sceneImageType; } elseif ($sceneImageType['name'] == 'large_scene') { $largeSceneImageType = $sceneImageType; } } self::$smarty->assign('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : NULL); self::$smarty->assign('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : NULL); } $this->category->description = nl2br2($this->category->description); $subCategories = $this->category->getSubCategories((int) self::$cookie->id_lang); self::$smarty->assign('category', $this->category); if (isset($subCategories) and !empty($subCategories) and $subCategories) { self::$smarty->assign('subcategories', $subCategories); self::$smarty->assign(array('subcategories_nb_total' => sizeof($subCategories), 'subcategories_nb_half' => ceil(sizeof($subCategories) / 2))); } if ($this->category->id != 1) { $this->productListAssign(); } self::$smarty->assign(array('products' => (isset($this->cat_products) and $this->cat_products) ? $this->cat_products : NULL, 'id_category' => (int) $this->category->id, 'id_category_parent' => (int) $this->category->id_parent, 'return_category_name' => Tools::safeOutput($this->category->name), 'path' => Tools::getPath((int) $this->category->id), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'categorySize' => Image::getSize('category'), 'mediumSize' => Image::getSize('medium'), 'thumbSceneSize' => Image::getSize('thumb_scene'), 'homeSize' => Image::getSize('home'))); if (isset(self::$cookie->id_customer)) { self::$smarty->assign('compareProducts', CompareProduct::getCustomerCompareProducts((int) self::$cookie->id_customer)); } elseif (isset(self::$cookie->id_guest)) { self::$smarty->assign('compareProducts', CompareProduct::getGuestCompareProducts((int) self::$cookie->id_guest)); } } } self::$smarty->assign(array('allow_oosp' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'comparator_max_item' => (int) Configuration::get('PS_COMPARATOR_MAX_ITEM'), 'suppliers' => Supplier::getSuppliers())); }
public function renderForm($args, $data) { $helper = $this->getFormHelper(); $imagesTypes = ImageType::getImagesTypes('manufacturers'); $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Widget Form.')), 'input' => array(array('type' => 'select', 'label' => $this->l('Image'), 'desc' => $this->l('Select type image for manufacture.'), 'name' => 'image', 'default' => 'small' . '_default', 'options' => array('query' => $imagesTypes, 'id' => 'name', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Limit'), 'name' => 'itemstab', 'default' => 6, 'desc' => $this->l('The maximum number of products in each Carousel (default: 6).')), array('type' => 'select', 'label' => $this->l('Carousel type'), 'name' => 'carousel_type', 'default' => LeomanagewidgetsOwlCarousel::CAROUSEL_BOOTSTRAP, 'class' => 'form-action', 'options' => array('query' => LeomanagewidgetsOwlCarousel::getCaroulseOptions(), 'id' => 'value', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Items Per Page'), 'name' => 'itemspage', 'default' => 3, 'form_group_class' => 'carousel_type_sub carousel_type-' . LeomanagewidgetsOwlCarousel::CAROUSEL_BOOTSTRAP, 'desc' => $this->l('The maximum number of products in each page Carousel (default: 3).')), array('type' => 'text', 'label' => $this->l('Colums In Tab'), 'name' => 'columns', 'default' => 3, 'form_group_class' => 'carousel_type_sub carousel_type-' . LeomanagewidgetsOwlCarousel::CAROUSEL_BOOTSTRAP, 'desc' => 'The maximum column products in each page Carousel (default: 3).'), array('type' => 'text', 'label' => $this->l('Interval'), 'name' => 'interval', 'default' => 8000, 'form_group_class' => 'carousel_type_sub carousel_type-' . LeomanagewidgetsOwlCarousel::CAROUSEL_BOOTSTRAP, 'desc' => $this->l('Enter Time(miniseconds) to play carousel. Value 0 to stop.'))), 'buttons' => array(array('title' => $this->l('Save And Stay'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveandstayleotempcp'), array('title' => $this->l('Save'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveleotempcp'))); // Add library owl carousel $owl_carousel = new LeomanagewidgetsOwlCarousel(); $arrays = $owl_carousel->getOwlCarouselAdminFormOptions(); foreach ($arrays as $array) { # validate module $this->fields_form[1]['form']['input'][] = $array; } $default_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_language' => $default_lang); unset($args); return $helper->generateForm($this->fields_form); }
/** * 获取产品图片 */ public function getImages() { $result = Db::getInstance()->getAll(' SELECT * FROM `' . DB_PREFIX . 'product_to_image` WHERE `id_product` = ' . (int) $this->id . ' ORDER BY position ASC'); if ($result == false) { return false; } $imageType = ImageType::getImagesTypes(ImageType::IMAGE_PRDOCUT); foreach ($result as &$row) { foreach ($imageType as $type) { $row[$type['name']] = Image::getImageLink($row['id_image'], $type['name']); } } return $result; }
public function displayForm($isMainTab = true) { global $currentIndex, $cookie; parent::displayForm(); $imagesTypes = ImageType::getImagesTypes(); $imageObj = new Image(Tools::getValue('id_image')); echo ' <script type="text/javascript" src="../js/cropper/prototype.js"></script> <script type="text/javascript" src="../js/cropper/scriptaculous.js"></script> <script type="text/javascript" src="../js/cropper/builder.js"></script> <script type="text/javascript" src="../js/cropper/dragdrop.js"></script> <script type="text/javascript" src="../js/cropper/cropper.js"></script> <script type="text/javascript" src="../js/cropper/loader.js"></script> <form enctype="multipart/form-data" method="post" action="' . $currentIndex . '&imageresize&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '"> <input type="hidden" name="id_product" value="' . Tools::getValue('id_product') . '" /> <input type="hidden" name="id_category" value="' . Tools::getValue('id_category') . '" /> <input type="hidden" name="saveandstay" value="' . Tools::getValue('submitAddAndStay') . '" /> <input type="hidden" name="conf" value="' . Tools::getValue('toconf') . '" /> <input type="hidden" name="imageresize" value="imageresize" /> <input type="hidden" name="id_image" value="' . Tools::getValue('id_image') . '" /> <fieldset> <legend><img src="../img/admin/picture.gif" />' . $this->l('Image resize') . '</legend> ' . $this->l('Using your mouse, define which area of the image is to be used for generating each type of thumbnail.') . ' <br /><br /> <img src="' . _THEME_PROD_DIR_ . $imageObj->getExistingImgPath() . '.jpg" id="testImage"> <label for="imageChoice">' . $this->l('Thumbnails format') . '</label> <div class="margin-form""> <select name="imageChoice" id="imageChoice">'; foreach ($imagesTypes as $type) { echo '<option value="../img/p/' . $imageObj->getExistingImgPath() . '.jpg|' . $type['width'] . '|' . $type['height'] . '|' . $type['id_image_type'] . '">' . $type['name'] . '</option>'; } echo ' </select> <input type="submit" class="button" style="margin-left : 40px;" name="resize" value="' . $this->l(' Save all ') . '" /> </div>'; foreach ($imagesTypes as $type) { echo ' <input type="hidden" name="' . $type['id_image_type'] . '_x1" id="' . $type['id_image_type'] . '_x1" value="0" /> <input type="hidden" name="' . $type['id_image_type'] . '_y1" id="' . $type['id_image_type'] . '_y1" value="0" /> <input type="hidden" name="' . $type['id_image_type'] . '_x2" id="' . $type['id_image_type'] . '_x2" value="0" /> <input type="hidden" name="' . $type['id_image_type'] . '_y2" id="' . $type['id_image_type'] . '_y2" value="0" />'; } echo ' </fieldset> </form>'; }
private function deleteNoPictureImages($id_language) { $language = Language::getIsoById($id_language); $imagesTypes = ImageType::getImagesTypes('products'); $dirs = array(_PS_PROD_IMG_DIR_, _PS_CAT_IMG_DIR_, _PS_MANU_IMG_DIR_); foreach ($dirs as $dir) { foreach ($imagesTypes as $k => $imageType) { if (file_exists($dir . $language . '-default-' . stripslashes($imageType['name']) . '.jpg')) { if (!unlink($dir . $language . '-default-' . stripslashes($imageType['name']) . '.jpg')) { $this->_errors[] = Tools::displayError('an error occurred during the image deletion'); } } } if (file_exists($dir . $language . '.jpg')) { if (!unlink($dir . $language . '.jpg')) { $this->_errors[] = Tools::displayError('an error occurred during the image deletion'); } } } return !sizeof($this->_errors) ? true : false; }
public function loadImage($id_product, $images) { $images_array = $this->imagesToArray($images); $images_id = array(); $product = new Product($id_product); $image_types = ImageType::getImagesTypes('product'); if ($images_array) { foreach ($images_array as $img) { if (file_exists(_TM_ROOT_DIR_ . $img['url'])) { //ajout de l'image au produit $image = new Image(); $image->id_product = intval($product->id); $image->position = Image::getHighestPosition($product->id) + 1; if (!intval($product->id_image_default)) { $image->cover = 1; } else { $image->cover = 0; } $image->legend = 0; $image->add(); if ($image->cover) { $product->id_image_default = (int) $image->id; } $id_image = $image->id; $images_id[] = $id_image; $path = $image->getPathForCreation(); //echo $imgDir.$img['url']; @copy(_TM_ROOT_DIR_ . $img['url'], $path . '.jpg'); foreach ($image_types as $k => $image_type) { ImageManager::resize(_TM_ROOT_DIR_ . $img['url'], $path . '-' . stripslashes($image_type['name']) . '.jpg', $image_type['width'], $image_type['height']); } //@unlink($tmpName); } else { $this->_output .= '<div class="alert error">Image not exists!</div>'; } $product->update(); } } return $images_id; }
public function displayForm($order_states, $features, $attribute_groups, $neteven_feature_categories) { $customizable_fields = array(); if (Gateway::getConfig('CUSTOMIZABLE_FIELDS')) { foreach (explode('¤', Gateway::getConfig('CUSTOMIZABLE_FIELDS')) as $customizable_field) { $customizable_fields[] = explode('|', $customizable_field); } } $carriers = Carrier::getCarriers((int) $this->context->cookie->id_lang); $this->context->smarty->assign(array('SHIPPING_CARRIER_FRANCE' => Tools::safeOutput(Tools::getValue('SHIPPING_CARRIER_FRANCE', Gateway::getConfig('SHIPPING_CARRIER_FRANCE'))), 'SHIPPING_ZONE_FRANCE' => Tools::safeOutput(Tools::getValue('SHIPPING_ZONE_FRANCE', Gateway::getConfig('SHIPPING_ZONE_FRANCE'))), 'SHIPPING_CARRIER_INTERNATIONAL' => Tools::safeOutput(Tools::getValue('SHIPPING_CARRIER_INTERNATIONAL', Gateway::getConfig('SHIPPING_CARRIER_INTERNATIONAL'))), 'SHIPPING_ZONE_INTERNATIONAL' => Tools::safeOutput(Tools::getValue('SHIPPING_ZONE_INTERNATIONAL', Gateway::getConfig('SHIPPING_ZONE_INTERNATIONAL'))), 'carriers' => $carriers, 'order_states' => $order_states, 'features' => $features, 'module_path' => $this->_path, 'module_display_name' => $this->displayName, 'attribute_groups' => $attribute_groups, 'neteven_feature_categories' => $neteven_feature_categories, 'default_currency' => new Currency((int) Configuration::get('PS_CURRENCY_DEFAULT')), 'format_images' => ImageType::getImagesTypes('products'), 'cron_feature_url' => Tools::getProtocol(Tools::usingSecureMode()) . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/' . $this->name . $this->feature_url, 'cron_order_url' => Tools::getProtocol(Tools::usingSecureMode()) . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/' . $this->name . $this->order_url, 'cron_product_url' => Tools::getProtocol(Tools::usingSecureMode()) . $_SERVER['HTTP_HOST'] . __PS_BASE_URI__ . 'modules/' . $this->name . $this->product_url, 'customizable_fields' => $customizable_fields, 'neteven_token' => Tools::encrypt(Configuration::get('PS_SHOP_NAME')), 'NETEVEN_LOGIN' => Tools::safeOutput(Tools::getValue('NETEVEN_LOGIN', Gateway::getConfig('NETEVEN_LOGIN'))), 'NETEVEN_PASSWORD' => Tools::safeOutput(Tools::getValue('NETEVEN_PASSWORD', Gateway::getConfig('NETEVEN_PASSWORD'))), 'SYNCHRONISATION_ORDER' => (int) Gateway::getConfig('SYNCHRONISATION_ORDER'), 'SYNCHRONISATION_PRODUCT' => (int) Gateway::getConfig('SYNCHRONISATION_PRODUCT'), 'DEFAULT_BRAND' => Tools::safeOutput(Tools::getValue('DEFAULT_BRAND', Gateway::getConfig('DEFAULT_BRAND'))), 'SHIPPING_DELAY' => Tools::safeOutput(Tools::getValue('SHIPPING_DELAY', Gateway::getConfig('SHIPPING_DELAY'))), 'IMAGE_TYPE_NAME' => Gateway::getConfig('IMAGE_TYPE_NAME'), 'COMMENT' => Tools::safeOutput(Tools::getValue('COMMENT', Gateway::getConfig('COMMENT'))), 'SHIPPING_PRICE_LOCAL' => Tools::safeOutput(Tools::getValue('SHIPPING_PRICE_LOCAL', Gateway::getConfig('SHIPPING_PRICE_LOCAL'))), 'SHIPPING_PRICE_INTERNATIONAL' => Tools::safeOutput(Tools::getValue('SHIPPING_PRICE_INTERNATIONAL', Gateway::getConfig('SHIPPING_PRICE_INTERNATIONAL'))), 'SHIPPING_BY_PRODUCT' => (int) Gateway::getConfig('SHIPPING_BY_PRODUCT'), 'SHIPPING_BY_PRODUCT_FIELDNAME' => Tools::safeOutput(Tools::getValue('SHIPPING_BY_PRODUCT_FIELDNAME', Gateway::getConfig('SHIPPING_BY_PRODUCT_FIELDNAME'))), 'ID_ORDER_STATE_NETEVEN' => (int) Gateway::getConfig('ID_ORDER_STATE_NETEVEN'), 'NETEVEN_URL' => Tools::safeOutput(Tools::getValue('NETEVEN_URL', Gateway::getConfig('NETEVEN_URL'))), 'NETEVEN_NS' => Tools::safeOutput(Tools::getValue('NETEVEN_NS', Gateway::getConfig('NETEVEN_NS'))), 'MAIL_LIST_ALERT' => Tools::safeOutput(Tools::getValue('MAIL_LIST_ALERT', Gateway::getConfig('MAIL_LIST_ALERT'))), 'DEBUG' => (int) Gateway::getConfig('DEBUG'), 'SEND_REQUEST_BY_EMAIL' => (int) Gateway::getConfig('SEND_REQUEST_BY_EMAIL'), 'TYPE_SKU' => (int) (Gateway::getConfig('TYPE_SKU') !== false) ? Gateway::getConfig('TYPE_SKU') : 'reference')); return $this->display(__FILE__, 'views/templates/admin/nqgatewayneteven.tpl'); }
private function copyImg($item, $className) { require_once '../../images.inc.php'; $identifier = $this->supportedImports[strtolower($className)]['identifier']; $matchId = $this->getMatchId(strtolower($className)); $matchIdLang = $this->getMatchIdLang(); switch ($className) { default: case 'Product': $path = _PS_PROD_IMG_DIR_; $type = 'products'; break; case 'Category': $path = _PS_CAT_IMG_DIR_; $type = 'categories'; break; case 'Manufacturer': $path = _PS_MANU_IMG_DIR_; $type = 'manufacturers'; break; case 'Supplier': $path = _PS_SUPP_IMG_DIR_; $type = 'suppliers'; break; } $cover = 1; if (array_key_exists($item[$identifier], $matchId)) { if (array_key_exists('images', $item) && !is_null($item['images'])) { foreach ($item['images'] as $key => $image) { $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'import'); if (@copy(str_replace(' ', '%20', $image), $tmpfile)) { $imagesTypes = ImageType::getImagesTypes($type); ImageManager::resize($tmpfile, $path . (int) $matchId[$item[$identifier]] . '.jpg'); if ($className == 'Product') { $image = new Image(); $image->id_product = (int) $matchId[$item[$identifier]]; $image->cover = $cover; $image->position = Image::getHighestPosition((int) $matchId[$item[$identifier]]) + 1; $legend = array(); foreach ($item['name'] as $key => $val) { if (array_key_exists($key, $matchIdLang)) { $legend[$matchIdLang[$key]] = Tools::link_rewrite($val); } else { $legend[Configuration::get('PS_LANG_DEFAULT')] = Tools::link_rewrite($val); } } $image->legend = $legend; $image->add(); ImageManager::resize($tmpfile, $path . (int) $matchId[$item[$identifier]] . '-' . (int) $image->id . '.jpg'); foreach ($imagesTypes as $k => $imageType) { ImageManager::resize($tmpfile, $path . (int) $matchId[$item[$identifier]] . '-' . (int) $image->id . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height']); } } else { foreach ($imagesTypes as $imageType) { ImageManager::resize($tmpfile, $path . (int) $matchId[$item[$identifier]] . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height']); } } } else { @unlink($tmpfile); } @unlink($tmpfile); $cover = 0; } } } }
/** * Delete the product image from disk and remove the containing folder if empty * Handles both legacy and new image filesystems */ public function deleteImage($force_delete = false) { if (!$this->id) { return false; } // Delete base image if (file_exists($this->image_dir . $this->getExistingImgPath() . '.' . $this->image_format)) { unlink($this->image_dir . $this->getExistingImgPath() . '.' . $this->image_format); } else { return false; } $files_to_delete = array(); // Delete auto-generated images $image_types = ImageType::getImagesTypes(); foreach ($image_types as $image_type) { $files_to_delete[] = $this->image_dir . $this->getExistingImgPath() . '-' . $image_type['name'] . '.' . $this->image_format; } // Delete watermark image $files_to_delete[] = $this->image_dir . $this->getExistingImgPath() . '-watermark.' . $this->image_format; // delete index.php $files_to_delete[] = $this->image_dir . $this->getImgFolder() . 'index.php'; // Delete tmp images $files_to_delete[] = _PS_TMP_IMG_DIR_ . 'product_' . $this->id_product . '.' . $this->image_format; $files_to_delete[] = _PS_TMP_IMG_DIR_ . 'product_mini_' . $this->id_product . '.' . $this->image_format; foreach ($files_to_delete as $file) { if (file_exists($file) && !@unlink($file)) { return false; } } // Can we delete the image folder? if (is_dir($this->image_dir . $this->getImgFolder())) { $delete_folder = true; foreach (scandir($this->image_dir . $this->getImgFolder()) as $file) { if ($file != '.' && $file != '..') { $delete_folder = false; break; } } } if (isset($delete_folder) && $delete_folder) { @rmdir($this->image_dir . $this->getImgFolder()); } return true; }
/** * Copy a product image * * @param integer $id_product Product Id for product image filename * @param integer $id_image Image Id for product image filename */ public function copyImage($id_product, $id_image, $method = 'auto') { if (!isset($_FILES['image_product']['tmp_name']) or !file_exists($_FILES['image_product']['tmp_name'])) { return false; } if ($error = checkImage($_FILES['image_product'], $this->maxImageSize)) { $this->_errors[] = $error; } else { if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) or !move_uploaded_file($_FILES['image_product']['tmp_name'], $tmpName)) { $this->_errors[] = Tools::displayError('An error occured during the image upload'); } elseif (!imageResize($tmpName, _PS_IMG_DIR_ . 'p/' . $id_product . '-' . $id_image . '.jpg')) { $this->_errors[] = Tools::displayError('an error occurred while copying image'); } elseif ($method == 'auto') { $imagesTypes = ImageType::getImagesTypes('products'); foreach ($imagesTypes as $k => $imageType) { if (!imageResize($tmpName, _PS_IMG_DIR_ . 'p/' . $id_product . '-' . $id_image . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height'])) { $this->_errors[] = Tools::displayError('an error occurred while copying image') . ' ' . stripslashes($imageType['name']); } } } @unlink($tmpName); Module::hookExec('watermark', array('id_image' => $id_image, 'id_product' => $id_product)); } }
/** * Overload this method for custom checking * * @param integer $id Object id used for deleting images * TODO This function will soon be deprecated. Use ObjectModel->deleteImage instead. */ public function deleteImage($id) { $dir = null; /* Deleting object images and thumbnails (cache) */ if (key_exists('dir', $this->fieldImageSettings)) { $dir = $this->fieldImageSettings['dir'] . '/'; if (file_exists(_PS_IMG_DIR_ . $dir . $id . '.' . $this->imageType) and !unlink(_PS_IMG_DIR_ . $dir . $id . '.' . $this->imageType)) { return false; } } if (file_exists(_PS_TMP_IMG_DIR_ . $this->table . '_' . $id . '.' . $this->imageType) and !unlink(_PS_TMP_IMG_DIR_ . $this->table . '_' . $id . '.' . $this->imageType)) { return false; } if (file_exists(_PS_TMP_IMG_DIR_ . $this->table . '_mini_' . $id . '.' . $this->imageType) and !unlink(_PS_TMP_IMG_DIR_ . $this->table . '_mini_' . $id . '.' . $this->imageType)) { return false; } $types = ImageType::getImagesTypes(); foreach ($types as $imageType) { if (file_exists(_PS_IMG_DIR_ . $dir . $id . '-' . stripslashes($imageType['name']) . '.' . $this->imageType) and !unlink(_PS_IMG_DIR_ . $dir . $id . '-' . stripslashes($imageType['name']) . '.' . $this->imageType)) { return false; } } return true; }
/** * Delete resized image then regenerate new one with updated settings */ private function _regenerateThumbnails() { @ini_set('max_execution_time', 3600); $productsTypes = ImageType::getImagesTypes('products'); $categoriesTypes = ImageType::getImagesTypes('categories'); $languages = Language::getLanguages(); $productsImages = Image::getAllImages(); /* Delete categories images */ $toDel = scandir(_PS_CAT_IMG_DIR_); foreach ($toDel as $d) { if (preg_match('/^[0-9]+\\-(.*)\\.jpg$/', $d) or preg_match('/^([[:lower:]]{2})\\-default\\-(.*)\\.jpg$/', $d)) { unlink(_PS_CAT_IMG_DIR_ . $d); } } /* Regenerate categories images */ $errors = false; $categoriesImages = scandir(_PS_CAT_IMG_DIR_); foreach ($categoriesImages as $image) { if (preg_match('/^[0-9]*\\.jpg$/', $image)) { foreach ($categoriesTypes as $k => $imageType) { if (!imageResize(_PS_CAT_IMG_DIR_ . $image, _PS_CAT_IMG_DIR_ . substr($image, 0, -4) . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write category image. Please check the folder\'s writing permissions.'); } /* Regenerate No-picture images */ $errors = false; foreach ($categoriesTypes as $k => $imageType) { foreach ($languages as $language) { $file = _PS_CAT_IMG_DIR_ . $language['iso_code'] . '.jpg'; if (!file_exists($file)) { $file = _PS_PROD_IMG_DIR_ . Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT'))) . '.jpg'; } if (!imageResize($file, _PS_CAT_IMG_DIR_ . $language['iso_code'] . '-default-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write no-picture image to the category images folder. Please check the folder\'s writing permissions.'); } /* Delete manufacturers images */ $toDel = scandir(_PS_MANU_IMG_DIR_); foreach ($toDel as $d) { if (preg_match('/^[0-9]+\\-(.*)\\.jpg$/', $d) or preg_match('/^([[:lower:]]{2})\\-default\\-(.*)\\.jpg$/', $d)) { unlink(_PS_MANU_IMG_DIR_ . $d); } } /* Regenerate manufacturers images */ $manufacturersTypes = ImageType::getImagesTypes('manufacturers'); $manufacturersImages = scandir(_PS_MANU_IMG_DIR_); $errors = false; foreach ($manufacturersImages as $image) { if (preg_match('/^[0-9]*\\.jpg$/', $image)) { foreach ($manufacturersTypes as $k => $imageType) { if (!imageResize(_PS_MANU_IMG_DIR_ . $image, _PS_MANU_IMG_DIR_ . substr($image, 0, -4) . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write manufacturer images. Please check the folder\'s writing permissions.'); } /* Regenerate No-picture images */ $errors = false; foreach ($manufacturersTypes as $k => $imageType) { foreach ($languages as $language) { $file = _PS_MANU_IMG_DIR_ . $language['iso_code'] . '.jpg'; if (!file_exists($file)) { $file = _PS_PROD_IMG_DIR_ . Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT'))) . '.jpg'; } if (!imageResize($file, _PS_MANU_IMG_DIR_ . $language['iso_code'] . '-default-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write no-picture image to the manufacturer images folder. Please check the folder\'s writing permissions.'); } /* Delete suppliers images */ $toDel = scandir(_PS_SUPP_IMG_DIR_); foreach ($toDel as $d) { if (preg_match('/^[0-9]+\\-(.*)\\.jpg$/', $d) or preg_match('/^([[:lower:]]{2})\\-default\\-(.*)\\.jpg$/', $d)) { unlink(_PS_SUPP_IMG_DIR_ . $d); } } /* Regenerate suppliers images */ $suppliersTypes = ImageType::getImagesTypes('suppliers'); $suppliersImages = scandir(_PS_SUPP_IMG_DIR_); $errors = false; foreach ($suppliersImages as $image) { if (preg_match('/^[0-9]*\\.jpg$/', $image)) { foreach ($suppliersTypes as $k => $imageType) { if (!imageResize(_PS_SUPP_IMG_DIR_ . $image, _PS_SUPP_IMG_DIR_ . substr($image, 0, -4) . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write supplier images into the supplier images folder. Please check the folder\'s writing permissions.'); } /* Regenerate No-picture images */ $errors = false; foreach ($suppliersTypes as $k => $imageType) { foreach ($languages as $language) { $file = _PS_SUPP_IMG_DIR_ . $language['iso_code'] . '.jpg'; if (!file_exists($file)) { $file = _PS_PROD_IMG_DIR_ . Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT'))) . '.jpg'; } if (!imageResize($file, _PS_SUPP_IMG_DIR_ . $language['iso_code'] . '-default-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write no-picture image into the suppliers images folder.<br />Please check its writing permissions.'); } /* Delete scenes images */ $toDel = scandir(_PS_SCENE_IMG_DIR_); foreach ($toDel as $d) { if (preg_match('/^[0-9]+\\-(.*)\\.jpg$/', $d) or preg_match('/^([[:lower:]]{2})\\-default\\-(.*)\\.jpg$/', $d)) { unlink(_PS_SCENE_IMG_DIR_ . $d); } } /* Regenerate scenes images */ $scenesTypes = ImageType::getImagesTypes('scenes'); $scenesImages = scandir(_PS_SCENE_IMG_DIR_); $errors = false; foreach ($scenesImages as $image) { if (preg_match('/^[0-9]*\\.jpg$/', $image)) { foreach ($scenesTypes as $k => $imageType) { if (!imageResize(_PS_SCENE_IMG_DIR_ . $image, _PS_SCENE_IMG_DIR_ . substr($image, 0, -4) . '-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write scene images into the scene images folder. Please check the folder\'s writing permissions.'); } /* Regenerate No-picture images */ $errors = false; foreach ($scenesTypes as $k => $imageType) { foreach ($languages as $language) { $file = _PS_SCENE_IMG_DIR_ . $language['iso_code'] . '.jpg'; if (!file_exists($file)) { $file = _PS_PROD_IMG_DIR_ . Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT'))) . '.jpg'; } if (!imageResize($file, _PS_SCENE_IMG_DIR_ . $language['iso_code'] . '-default-' . stripslashes($imageType['name']) . '.jpg', intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write no-picture image into the scenes images folder.<br />Please check its writing permissions.'); } /* Delete products images */ $toDel = scandir(_PS_PROD_IMG_DIR_); foreach ($toDel as $d) { if (preg_match('/^[0-9]+\\-[0-9]+\\-(.*)\\.jpg$/', $d) or preg_match('/^([[:lower:]]{2})\\-default\\-(.*)\\.jpg$/', $d)) { unlink(_PS_PROD_IMG_DIR_ . $d); } } /* Regenerate No-picture images */ $errors = false; foreach ($productsTypes as $k => $imageType) { foreach ($languages as $language) { $file = _PS_PROD_IMG_DIR_ . $language['iso_code'] . '.jpg'; if (!file_exists($file)) { $file = _PS_PROD_IMG_DIR_ . Language::getIsoById(intval(Configuration::get('PS_LANG_DEFAULT'))) . '.jpg'; } $newFile = _PS_PROD_IMG_DIR_ . $language['iso_code'] . '-default-' . stripslashes($imageType['name']) . '.jpg'; if (!imageResize($file, $newFile, intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write no-picture image to the product images folder. Please check the folder\'s writing permissions.'); } /* Regenerate products images */ $errors = false; foreach ($productsImages as $k => $image) { if (file_exists(_PS_PROD_IMG_DIR_ . $image['id_product'] . '-' . $image['id_image'] . '.jpg')) { foreach ($productsTypes as $k => $imageType) { $newFile = _PS_PROD_IMG_DIR_ . $image['id_product'] . '-' . $image['id_image'] . '-' . stripslashes($imageType['name']) . '.jpg'; if (!imageResize(_PS_PROD_IMG_DIR_ . $image['id_product'] . '-' . $image['id_image'] . '.jpg', $newFile, intval($imageType['width']), intval($imageType['height']))) { $errors = true; } } } } // Hook watermark optimization $result = Db::getInstance()->ExecuteS(' SELECT m.`name` FROM `' . _DB_PREFIX_ . 'module` m LEFT JOIN `' . _DB_PREFIX_ . 'hook_module` hm ON hm.`id_module` = m.`id_module` LEFT JOIN `' . _DB_PREFIX_ . 'hook` h ON hm.`id_hook` = h.`id_hook` WHERE h.`name` = \'watermark\' AND m.`active` = 1'); if ($result and sizeof($result)) { foreach ($productsImages as $k => $image) { if (file_exists(_PS_PROD_IMG_DIR_ . $image['id_product'] . '-' . $image['id_image'] . '.jpg')) { foreach ($result as $k => $module) { if ($moduleInstance = Module::getInstanceByName($module['name']) and is_callable(array($moduleInstance, 'hookwatermark'))) { call_user_func(array($moduleInstance, 'hookwatermark'), array('id_image' => $image['id_image'], 'id_product' => $image['id_product'])); } } } } } if ($errors) { $this->_errors[] = Tools::displayError('Cannot write product image. Please check the folder\'s writing permissions.'); } return sizeof($this->_errors) > 0 ? false : true; }
protected function postImage($id) { $ret = parent::postImage($id); if (($id_category = (int) Tools::getValue('id_category')) && isset($_FILES) && count($_FILES) && $_FILES['image']['name'] != null && file_exists(_PS_CAT_IMG_DIR_ . $id_category . '.jpg')) { $images_types = ImageType::getImagesTypes('categories'); foreach ($images_types as $k => $image_type) { ImageManager::resize(_PS_CAT_IMG_DIR_ . $id_category . '.jpg', _PS_CAT_IMG_DIR_ . $id_category . '-' . stripslashes($image_type['name']) . '.jpg', (int) $image_type['width'], (int) $image_type['height']); } } return $ret; }
/** * Write the posted image on disk * * @param string $sreceptionPath * @param int $destWidth * @param int $destHeight * @param array $imageTypes * @param string $parentPath * @return boolean */ protected function writePostedImageOnDisk($receptionPath, $destWidth = null, $destHeight = null, $imageTypes = null, $parentPath = null) { if ($this->wsObject->method == 'PUT') { if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) { $file = $_FILES['image']; if ($file['size'] > $this->imgMaxUploadSize) { throw new WebserviceException(sprintf('The image size is too large (maximum allowed is %d KB)', $this->imgMaxUploadSize / 1000), array(72, 400)); } // Get mime content type $mime_type = false; if (Tools::isCallable('finfo_open')) { $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; $finfo = finfo_open($const); $mime_type = finfo_file($finfo, $file['tmp_name']); finfo_close($finfo); } elseif (Tools::isCallable('mime_content_type')) { $mime_type = mime_content_type($file['tmp_name']); } elseif (Tools::isCallable('exec')) { $mime_type = trim(exec('file -b --mime-type ' . escapeshellarg($file['tmp_name']))); } if (empty($mime_type) || $mime_type == 'regular file') { $mime_type = $file['type']; } if (($pos = strpos($mime_type, ';')) !== false) { $mime_type = substr($mime_type, 0, $pos); } // Check mime content type if (!$mime_type || !in_array($mime_type, $this->acceptedImgMimeTypes)) { throw new WebserviceException('This type of image format not recognized, allowed formats are: ' . implode('", "', $this->acceptedImgMimeTypes), array(73, 400)); } elseif ($file['error']) { throw new WebserviceException('Error while uploading image. Please change your server\'s settings', array(74, 400)); } // Try to copy image file to a temporary file if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($_FILES['image']['tmp_name'], $tmpName)) { throw new WebserviceException('Error while copying image to the temporary directory', array(75, 400)); } else { $result = $this->writeImageOnDisk($tmpName, $receptionPath, $destWidth, $destHeight, $imageTypes, $parentPath); } @unlink($tmpName); return $result; } else { throw new WebserviceException('Please set an "image" parameter with image data for value', array(76, 400)); } } elseif ($this->wsObject->method == 'POST') { if (isset($_FILES['image']['tmp_name']) && $_FILES['image']['tmp_name']) { $file = $_FILES['image']; if ($file['size'] > $this->imgMaxUploadSize) { throw new WebserviceException(sprintf('The image size is too large (maximum allowed is %d KB)', $this->imgMaxUploadSize / 1000), array(72, 400)); } require_once _PS_ROOT_DIR_ . '/images.inc.php'; if ($error = ImageManager::validateUpload($file)) { throw new WebserviceException('Image upload error : ' . $error, array(76, 400)); } if (isset($file['tmp_name']) && $file['tmp_name'] != null) { if ($this->imageType == 'products') { $product = new Product((int) $this->wsObject->urlSegment[2]); if (!Validate::isLoadedObject($product)) { throw new WebserviceException('Product ' . (int) $this->wsObject->urlSegment[2] . ' doesn\'t exists', array(76, 400)); } $image = new Image(); $image->id_product = (int) $product->id; $image->position = Image::getHighestPosition($product->id) + 1; if (!Image::getCover((int) $product->id)) { $image->cover = 1; } else { $image->cover = 0; } if (!$image->add()) { throw new WebserviceException('Error while creating image', array(76, 400)); } if (!Validate::isLoadedObject($product)) { throw new WebserviceException('Product ' . (int) $this->wsObject->urlSegment[2] . ' doesn\'t exists', array(76, 400)); } } // copy image if (!isset($file['tmp_name'])) { return false; } if ($error = ImageManager::validateUpload($file, $this->imgMaxUploadSize)) { throw new WebserviceException('Bad image : ' . $error, array(76, 400)); } if ($this->imageType == 'products') { $image = new Image($image->id); if (!(Configuration::get('PS_OLD_FILESYSTEM') && file_exists(_PS_PROD_IMG_DIR_ . $product->id . '-' . $image->id . '.jpg'))) { $image->createImgFolder(); } if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($file['tmp_name'], $tmpName)) { throw new WebserviceException('An error occurred during the image upload', array(76, 400)); } elseif (!ImageManager::resize($tmpName, _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '.' . $image->image_format)) { throw new WebserviceException('An error occurred while copying image', array(76, 400)); } else { $imagesTypes = ImageType::getImagesTypes('products'); foreach ($imagesTypes as $imageType) { if (!ImageManager::resize($tmpName, _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '-' . stripslashes($imageType['name']) . '.' . $image->image_format, $imageType['width'], $imageType['height'], $image->image_format)) { $this->_errors[] = Tools::displayError('An error occurred while copying image:') . ' ' . stripslashes($imageType['name']); } } } @unlink($tmpName); $this->imgToDisplay = _PS_PROD_IMG_DIR_ . $image->getExistingImgPath() . '.' . $image->image_format; $this->objOutput->setFieldsToDisplay('full'); $this->output = $this->objOutput->renderEntity($image, 1); $image_content = array('sqlId' => 'content', 'value' => base64_encode(file_get_contents($this->imgToDisplay)), 'encode' => 'base64'); $this->output .= $this->objOutput->objectRender->renderField($image_content); } elseif (in_array($this->imageType, array('categories', 'manufacturers', 'suppliers', 'stores'))) { if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !move_uploaded_file($file['tmp_name'], $tmpName)) { throw new WebserviceException('An error occurred during the image upload', array(76, 400)); } elseif (!ImageManager::resize($tmpName, $receptionPath)) { throw new WebserviceException('An error occurred while copying image', array(76, 400)); } $imagesTypes = ImageType::getImagesTypes($this->imageType); foreach ($imagesTypes as $imageType) { if (!ImageManager::resize($tmpName, $parentPath . $this->wsObject->urlSegment[2] . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height'])) { $this->_errors[] = Tools::displayError('An error occurred while copying image:') . ' ' . stripslashes($imageType['name']); } } @unlink(_PS_TMP_IMG_DIR_ . $tmpName); $this->imgToDisplay = $receptionPath; } return true; } } } else { throw new WebserviceException('Method ' . $this->wsObject->method . ' is not allowed for an image resource', array(77, 405)); } }
/** * ONLY FOR DEVELOPMENT PURPOSE */ public function backupImageImage() { $types = array(); foreach (ImageType::getImagesTypes('products') as $type) { $types[] = $type['name']; } $backup_path = $this->img_path . 'p/'; $from_path = _PS_PROD_IMG_DIR_; if (!is_dir($backup_path) && !mkdir($backup_path)) { $this->setError(sprintf('Cannot create directory <i>%s</i>', $backup_path)); } foreach (Image::getAllImages() as $image) { $image = new Image($image['id_image']); $image_path = $image->getExistingImgPath(); if (file_exists($from_path . $image_path . '.' . $image->image_format)) { copy($from_path . $image_path . '.' . $image->image_format, $backup_path . $this->generateId('image', $image->id) . '.' . $image->image_format); } foreach ($types as $type) { if (file_exists($from_path . $image_path . '-' . $type . '.' . $image->image_format)) { copy($from_path . $image_path . '-' . $type . '.' . $image->image_format, $backup_path . $this->generateId('image', $image->id) . '-' . $type . '.' . $image->image_format); } } } }
private function _getImageTypeSelect($configuration) { $html = '<select name="SHOPPING_FLUX_IMAGE">'; foreach (ImageType::getImagesTypes() as $imagetype) { $selected = $configuration['SHOPPING_FLUX_IMAGE'] == $imagetype['name'] ? 'selected = "selected"' : ''; $html .= '<option value="' . $imagetype['name'] . '" ' . $selected . '>' . Tools::safeOutput($imagetype['name']) . '</option>'; } $html .= '</select>'; return $html; }
/** * Delete product or category image * * @param integer $id_item Product or category id * @param integer $id_image Image id */ function deleteImage($id_item, $id_image = NULL) { $path = $id_image ? _PS_PROD_IMG_DIR_ : _PS_CAT_IMG_DIR_; $table = $id_image ? 'product' : 'category'; if (file_exists(_PS_TMP_IMG_DIR_ . $table . '_' . $id_item . '.jpg')) { unlink(_PS_TMP_IMG_DIR_ . $table . '_' . $id_item . '.jpg'); } if ($id_image and file_exists($path . $id_item . '-' . $id_image . '.jpg')) { unlink($path . $id_item . '-' . $id_image . '.jpg'); } elseif (!$id_image and file_exists($path . $id_item . '.jpg')) { unlink($path . $id_item . '.jpg'); } /* Auto-generated images */ $imagesTypes = ImageType::getImagesTypes(); foreach ($imagesTypes as $k => $imagesType) { if ($id_image and file_exists($path . $id_item . '-' . $id_image . '-' . $imagesType['name'] . '.jpg')) { unlink($path . $id_item . '-' . $id_image . '-' . $imagesType['name'] . '.jpg'); } elseif (!$id_image and file_exists($path . $id_item . '-' . $imagesType['name'] . '.jpg')) { unlink($path . $id_item . '-' . $imagesType['name'] . '.jpg'); } } /* BO "mini" image */ if (file_exists(_PS_TMP_IMG_DIR_ . $table . '_mini_' . $id_item . '.jpg')) { unlink(_PS_TMP_IMG_DIR_ . $table . '_mini_' . $id_item . '.jpg'); } return true; }
/** * Assigns scenes template variables */ protected function assignScenes() { // Scenes (could be externalised to another controller if you need them) $scenes = Scene::getScenes($this->category->id, $this->context->language->id, true, false); $this->context->smarty->assign('scenes', $scenes); // Scenes images formats if ($scenes && ($scene_image_types = ImageType::getImagesTypes('scenes'))) { foreach ($scene_image_types as $scene_image_type) { if ($scene_image_type['name'] == ImageType::getFormatedName('m_scene')) { $thumb_scene_image_type = $scene_image_type; } elseif ($scene_image_type['name'] == ImageType::getFormatedName('scene')) { $large_scene_image_type = $scene_image_type; } } $this->context->smarty->assign(array('thumbSceneImageType' => isset($thumb_scene_image_type) ? $thumb_scene_image_type : null, 'largeSceneImageType' => isset($large_scene_image_type) ? $large_scene_image_type : null)); } }
public static function copyImg($id_entity, $id_image = null, $url, $entity = 'products', $regenerate = true) { $kfsmirm = "url"; ${"GLOBALS"}["bzczzdqyd"] = "id_entity"; ${${"GLOBALS"}["tlsfxeardxw"]} = tempnam(_PS_TMP_IMG_DIR_, "ps_import"); ${${"GLOBALS"}["swugitwcekfq"]} = explode(",", Configuration::get("WATERMARK_TYPES")); switch (${${"GLOBALS"}["cvtsebg"]}) { default: case "products": ${${"GLOBALS"}["lpbvbgccdl"]} = new Image(${${"GLOBALS"}["uvlsrne"]}); ${${"GLOBALS"}["wtulgbqcgx"]} = $image_obj->getPathForCreation(); break; case "categories": ${${"GLOBALS"}["wtulgbqcgx"]} = _PS_CAT_IMG_DIR_ . (int) ${${"GLOBALS"}["bzczzdqyd"]}; break; } ${$kfsmirm} = str_replace(" ", "%20", trim(${${"GLOBALS"}["ttqxfd"]})); ${"GLOBALS"}["ghxdribmjq"] = "tmpfile"; $lobrjsdyfu = "url"; if (!ImageManager::checkImageMemoryLimit(${${"GLOBALS"}["ttqxfd"]})) { return false; } if (AgileHelper::copy(${$lobrjsdyfu}, ${${"GLOBALS"}["tlsfxeardxw"]})) { ${"GLOBALS"}["pimvwry"] = "tmpfile"; $eonlensp = "entity"; $izyosqyo = "regenerate"; ${"GLOBALS"}["djopvop"] = "path"; ImageManager::resize(${${"GLOBALS"}["pimvwry"]}, ${${"GLOBALS"}["djopvop"]} . ".jpg"); ${${"GLOBALS"}["jwrmfnly"]} = ImageType::getImagesTypes(${$eonlensp}); if (${$izyosqyo}) { $gagiwtklv = "images_types"; foreach (${$gagiwtklv} as ${${"GLOBALS"}["lvadwrx"]}) { ${"GLOBALS"}["ywiijdhhoyuf"] = "image_type"; ${"GLOBALS"}["iflsogwlox"] = "image_type"; ${"GLOBALS"}["yeyowiqlgu"] = "image_type"; $vhqrhojxebs = "tmpfile"; ${"GLOBALS"}["nbjagdwvwk"] = "path"; ${"GLOBALS"}["qdhosudwjdj"] = "watermark_types"; $iybxnfabykn = "image_type"; ImageManager::resize(${$vhqrhojxebs}, ${${"GLOBALS"}["nbjagdwvwk"]} . "-" . stripslashes(${$iybxnfabykn}["name"]) . ".jpg", ${${"GLOBALS"}["yeyowiqlgu"]}["width"], ${${"GLOBALS"}["iflsogwlox"]}["height"]); $fsqlvnus = "id_entity"; if (in_array(${${"GLOBALS"}["ywiijdhhoyuf"]}["id_image_type"], ${${"GLOBALS"}["qdhosudwjdj"]})) { Hook::exec("actionWatermark", array("id_image" => ${${"GLOBALS"}["uvlsrne"]}, "id_product" => ${$fsqlvnus})); } } } } else { $nnyuiure = "tmpfile"; unlink(${$nnyuiure}); return false; } unlink(${${"GLOBALS"}["ghxdribmjq"]}); return true; }
/** * copyImg copy an image located in $url and save it in a path * according to $entity->$id_entity . * $id_image is used if we need to add a watermark * * @param int $id_entity id of product or category (set in entity) * @param int $id_image (default null) id of the image if watermark enabled. * @param string $url path or url to use * @param string entity 'products' or 'categories' * @return void */ private static function copyImg($id_entity, $id_image = NULL, $url, $entity = 'products') { $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import'); $watermark_types = explode(',', Configuration::get('WATERMARK_TYPES')); switch ($entity) { default: case 'products': $imageObj = new Image($id_image); $path = $imageObj->getPathForCreation(); break; case 'categories': $path = _PS_CAT_IMG_DIR_ . (int) $id_entity; break; } $url_source_file = str_replace(' ', '%20', trim($url)); if (@copy($url_source_file, $tmpfile)) { imageResize($tmpfile, $path . '.jpg'); $imagesTypes = ImageType::getImagesTypes($entity); foreach ($imagesTypes as $k => $imageType) { imageResize($tmpfile, $path . '-' . stripslashes($imageType['name']) . '.jpg', $imageType['width'], $imageType['height']); } if (in_array($imageType['id_image_type'], $watermark_types)) { Module::hookExec('watermark', array('id_image' => $id_image, 'id_product' => $id_entity)); } } else { unlink($tmpfile); return false; } unlink($tmpfile); return true; }