// Categories thumbnails
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{$displayBackOfficeCategory}
|
||||
{else}
|
||||
{$smarty.block.parent}
|
||||
{/if}
|
||||
|
||||
@@ -494,9 +494,10 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
'class' => 'btn-default'
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$this->tpl_form_vars['shared_category'] = Validate::isLoadedObject($obj) && $obj->hasMultishopEntries();
|
||||
$this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int)Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
|
||||
$this->tpl_form_vars['displayBackOfficeCategory'] = Hook::exec('displayBackOfficeCategory');
|
||||
|
||||
// Display this field only if multistore option is enabled
|
||||
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') && Tools::isSubmit('add'.$this->table.'root'))
|
||||
@@ -574,6 +575,8 @@ class AdminCategoriesControllerCore extends AdminController
|
||||
if (Tools::isSubmit('forcedeleteImage'))
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminCategories').'&conf=7');
|
||||
}
|
||||
|
||||
Hook::exec('actionBackOfficeCategory');
|
||||
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<name>actionOrderStatusUpdate</name><title>Order status update - Event</title><description>This hook launches modules when the status of an order changes.</description>
|
||||
</hook>
|
||||
<hook id="displayAdminOrder" live_edit="0">
|
||||
<name>displayAdminOrder</name><title>Display new elements in the Back Office, tab AdminOrder</title><description>This hook launches modules when the AdminOrder" tab is displayed in the Back Office"</description>
|
||||
<name>displayAdminOrder</name><title>Display new elements in the Back Office, tab AdminOrder</title><description>This hook launches modules when the AdminOrder tab is displayed in the Back Office</description>
|
||||
</hook>
|
||||
<hook id="displayFooter" live_edit="0">
|
||||
<name>displayFooter</name><title>Footer</title><description>This hook displays new blocks in the footer</description>
|
||||
@@ -77,7 +77,7 @@
|
||||
<name>displayPDFInvoice</name><title>PDF Invoice</title><description>This hook allows you to display additional information on PDF invoices</description>
|
||||
</hook>
|
||||
<hook id="displayAdminCustomers" live_edit="0">
|
||||
<name>displayAdminCustomers</name><title>Display new elements in the Back Office, tab AdminCustomers</title><description>This hook launches modules when the AdminCustomers" tab is displayed in the Back Office"</description>
|
||||
<name>displayAdminCustomers</name><title>Display new elements in the Back Office, tab AdminCustomers</title><description>This hook launches modules when the AdminCustomers tab is displayed in the Back Office</description>
|
||||
</hook>
|
||||
<hook id="displayOrderConfirmation" live_edit="0">
|
||||
<name>displayOrderConfirmation</name><title>Order confirmation page</title><description>This hook is called within an order's confirmation page</description>
|
||||
@@ -279,6 +279,12 @@
|
||||
</hook>
|
||||
<hook id="displayHomeTabContent" live_edit="1">
|
||||
<name>displayHomeTabContent</name><title>Home Page Tabs Content</title><description>This hook displays new elements on the homepage tabs content</description>
|
||||
</hook>
|
||||
</hook>
|
||||
<hook id="displayBackOfficeCategory" live_edit="0">
|
||||
<name>displayBackOfficeCategory</name><title>Display new elements in the Back Office, tab AdminCategories</title><description>This hook launches modules when the AdminCategories tab is displayed in the Back Office</description>
|
||||
</hook>
|
||||
<hook id="actionBackOfficeCategory" live_edit="0">
|
||||
<name>actionBackOfficeCategory</name><title>Process new elements in the Back Office, tab AdminCategories</title><description>This hook process modules when the AdminCategories tab is displayed in the Back Office</description>
|
||||
</hook>
|
||||
</entities>
|
||||
</entity_hook>
|
||||
|
||||
@@ -69,6 +69,8 @@ ALTER TABLE `PREFIX_employee` ADD `stats_compare_from` DATE NULL DEFAULT NULL
|
||||
|
||||
INSERT INTO `PREFIX_hook` (`id_hook` , `name` , `title` , `description` , `position` , `live_edit`)
|
||||
VALUES (NULL , 'displayHomeTab', 'Home Page Tabs', 'This hook displays new elements on the homepage tabs', '1', '1'),
|
||||
(NULL , 'displayHomeTabContent', 'Home Page Tabs Content', 'This hook displays new elements on the homepage tabs content', '1', '1');
|
||||
(NULL , 'displayHomeTabContent', 'Home Page Tabs Content', 'This hook displays new elements on the homepage tabs content', '1', '1'),
|
||||
(NULL , 'displayBackOfficeCategory', 'Display new elements in the Back Office, tab AdminCategories', 'This hook launches modules when the AdminCategories tab is displayed in the Back Office', '1', '1'),
|
||||
(NULL , 'actionBackOfficeCategory', 'Process new elements in the Back Office, tab AdminCategories', 'This hook process modules when the AdminCategories tab is displayed in the Back Office', '1', '1');
|
||||
|
||||
ALTER TABLE `PREFIX_employee` ADD `stats_compare_option` INT( 1 ) NOT NULL DEFAULT '1' AFTER `stats_compare_to`;
|
||||
@@ -33,7 +33,7 @@ class BlockCategories extends Module
|
||||
{
|
||||
$this->name = 'blockcategories';
|
||||
$this->tab = 'front_office_features';
|
||||
$this->version = '2.0';
|
||||
$this->version = '2.1';
|
||||
$this->author = 'PrestaShop';
|
||||
|
||||
parent::__construct();
|
||||
@@ -54,6 +54,8 @@ class BlockCategories extends Module
|
||||
!$this->registerHook('categoryDeletion') ||
|
||||
!$this->registerHook('actionAdminMetaControllerUpdate_optionsBefore') ||
|
||||
!$this->registerHook('actionAdminLanguagesControllerStatusBefore') ||
|
||||
!$this->registerHook('displayBackOfficeCategory') ||
|
||||
!$this->registerHook('actionBackOfficeCategory') ||
|
||||
!Configuration::updateValue('BLOCK_CATEG_MAX_DEPTH', 4) ||
|
||||
!Configuration::updateValue('BLOCK_CATEG_DHTML', 1))
|
||||
return false;
|
||||
@@ -113,6 +115,56 @@ class BlockCategories extends Module
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function hookDisplayBackOfficeCategory($params)
|
||||
{
|
||||
$this->smarty->assign(array(
|
||||
'name' => 'thumb',
|
||||
'images' => array()
|
||||
));
|
||||
|
||||
return $this->display(__FILE__, 'views/blockcategories_admin.tpl');
|
||||
}
|
||||
|
||||
public function hookActionBackOfficeCategory($params)
|
||||
{
|
||||
$total_errors = array();
|
||||
|
||||
for ($i=0; $i<3; $i++)
|
||||
if (isset($_FILES['thumb-'.$i]) && $_FILES['thumb-'.$i]['size'] > 0)
|
||||
{
|
||||
$errors = array();
|
||||
// Check image validity
|
||||
$max_size = (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE');
|
||||
|
||||
if ($error = ImageManager::validateUpload($_FILES['thumb-'.$i], Tools::getMaxUploadSize($max_size)))
|
||||
$errors[] = $error;
|
||||
|
||||
$tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS');
|
||||
|
||||
if (!$tmp_name)
|
||||
$errors[] = Tools::displayError('Invalid Temporary directory');
|
||||
|
||||
if (!move_uploaded_file($_FILES['thumb-'.$i]['tmp_name'], $tmp_name))
|
||||
$errors[] = Tools::displayError('Error uploading thumbnail image');
|
||||
|
||||
// Evaluate the memory required to resize the image: if it's too much, you can't resize it.
|
||||
if (!ImageManager::checkImageMemoryLimit($tmp_name))
|
||||
$errors[] = Tools::displayError('Due to memory limit restrictions, this image cannot be loaded. Please increase your memory_limit value via your server\'s configuration settings. ');
|
||||
|
||||
// Copy new image
|
||||
if (empty($errors) && !ImageManager::resize($tmp_name, _PS_CAT_IMG_DIR_.Tools::getValue('id_category').'-'.$i.'_thumb.jpg'))
|
||||
$errors[] = Tools::displayError('An error occurred while uploading the image.');
|
||||
|
||||
if (count($errors))
|
||||
$total_errors = array_merge($total_errors, $errors);
|
||||
|
||||
unlink($tmp_name);
|
||||
}
|
||||
|
||||
if (count($total_errors))
|
||||
;//TODO : Show errors
|
||||
}
|
||||
|
||||
public function hookLeftColumn($params)
|
||||
{
|
||||
if (!$this->isCached('blockcategories.tpl', $this->getCacheId()))
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>blockcategories</name>
|
||||
<displayName><![CDATA[Categories block]]></displayName>
|
||||
<version><![CDATA[2.0]]></version>
|
||||
<description><![CDATA[Adds a block featuring product categories.]]></description>
|
||||
<displayName><![CDATA[Bloc catégories]]></displayName>
|
||||
<version><![CDATA[2.1]]></version>
|
||||
<description><![CDATA[Ajoute un bloc proposant une navigation au sein de vos catégories de produits]]></description>
|
||||
<author><![CDATA[PrestaShop]]></author>
|
||||
<tab><![CDATA[front_office_features]]></tab>
|
||||
<is_configurable>1</is_configurable>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
function upgrade_module_2_1($object)
|
||||
{
|
||||
return ($object->registerHook('displayBackOfficeCategory') && $object->registerHook('actionBackOfficeCategory'));
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{for $foo=0 to 2}
|
||||
<div class="form-group">
|
||||
<input id="{$name}-{$foo}" type="file" name="{$name}-{$foo}" class="hide"/>
|
||||
<div class="dummyfile input-group">
|
||||
<span class="input-group-addon"><i class="icon-file"></i></span>
|
||||
<input id="{$name}-name-{$foo}" type="text" class="disabled" readonly/>
|
||||
<span class="input-group-btn">
|
||||
<button id="{$name}-selectbutton-{$foo}" type="button" class="btn btn-default">
|
||||
<i class="icon-folder-open"></i> {l s='Choose a file'}
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
{if isset($images.$foo) && $images.$foo}
|
||||
<div class="clearfix"> </div>
|
||||
<div id="image" class="thumbnail">
|
||||
{$images.$foo.image}
|
||||
<div class="text-center">
|
||||
<a class="btn btn-default" href="">
|
||||
<i class="icon-remove text-danger"></i> {l s='Delete'}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/for}
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('button[id|="{$name}-selectbutton"]').click(function(e) {
|
||||
var id = $(this).prop('id').replace('{$name}-selectbutton-', '');
|
||||
$('#{$name}-'+id).trigger('click');
|
||||
});
|
||||
$('input[id|="{$name}-name"]').click(function(e){
|
||||
var id = $(this).prop('id').replace('{$name}-name-', '');
|
||||
$('#{$name}-'+id).trigger('click');
|
||||
});
|
||||
$('input[id|="{$name}"]').change(function(e){
|
||||
var val = $(this).val();
|
||||
var id = $(this).prop('id').replace('{$name}-', '');
|
||||
var file = val.split(/[\\/]/);
|
||||
$('#{$name}-name-'+id).val(file[file.length-1]);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user