integration new theme standard

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8169 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
lCherifi
2011-08-23 14:27:30 +00:00
parent 2a1e42606b
commit 2d228a4fb8
60 changed files with 1912 additions and 0 deletions
@@ -0,0 +1,214 @@
<?php
/*
* 2007-2010 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author Prestashop SA <contact@prestashop.com>
* @copyright 2007-2010 Prestashop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_CAN_LOAD_FILES_'))
exit;
class blockreinsurance extends Module
{
public function __construct()
{
$this->name = 'blockreinsurance';
if(version_compare(_PS_VERSION_, '1.4.0.0') >= 0)
$this->tab = 'front_office_features';
else
$this->tab = 'Blocks';
$this->version = '1.0';
parent::__construct();
$this->displayName = $this->l('Bloc reinsurance');
$this->description = $this->l('Add a block to display more infos to reassure your customers');
}
public function install()
{
return (parent::install() AND $this->installDB() AND Configuration::updateValue('blockreinsurance_nbblocks', 5) AND $this->registerHook('footer'));
}
public function installDB()
{
return Db::getInstance()->Execute('
CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'reinsurance` (
`id_contactinfos` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`filename` VARCHAR(100) NOT NULL,
`text` VARCHAR(300) NOT NULL,
PRIMARY KEY (`id_contactinfos`)
) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8 ;');
}
public function uninstall()
{
//Delete configuration
return (Configuration::deleteByName('blockreinsurance_nbblocks') AND $this->uninstallDB() AND parent::uninstall());
}
public function uninstallDB()
{
return Db::getInstance()->Execute('
DROP TABLE IF EXISTS `'._DB_PREFIX_.'reinsurance`');
}
public function addToDB()
{
$maxImageSize = 3007200;
if(isset($_POST['nbblocks']))
{
for($i = 1; $i <= (int)$_POST['nbblocks']; $i++)
{
$filename = explode('.', $_FILES['info'.$i.'_file']['name']);
if (isset($_FILES['info'.$i.'_file']) AND isset($_FILES['info'.$i.'_file']['tmp_name']) AND !empty($_FILES['info'.$i.'_file']['tmp_name']))
{
if ($error = checkImage($_FILES['info'.$i.'_file'], $maxImageSize))
return false;
elseif (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') OR !move_uploaded_file($_FILES['info'.$i.'_file']['tmp_name'], $tmpName))
return false;
elseif (!imageResize($tmpName, dirname(__FILE__).'/img/'.$filename[0].'.jpg'))
return false;
unlink($tmpName);
}
Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'reinsurance` (`filename`,`text`)
VALUES ("'.((isset($filename[0]) AND $filename[0] != '') ? pSQL($filename[0]) : '').
'", "'.((isset($_POST['info'.$i.'_text']) AND $_POST['info'.$i.'_text'] != '') ? pSQL($_POST['info'.$i.'_text']) : '').'")');
}
return true;
} else
return false;
}
public function removeFromDB()
{
$dir = opendir(dirname(__FILE__).'/img');
while (false !== ($file = readdir($dir)))
{
$path = dirname(__FILE__).'/img/'.$file;
if ($file != ".." AND $file != "." AND !is_dir($file))
{
unlink($path);
}
}
closedir($dir);
return Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'reinsurance`');
}
public function getAllFromDB()
{
return Db::getInstance()->ExecuteS('SELECT * FROM `'._DB_PREFIX_.'reinsurance`');
}
public function getContent()
{
// If we try to update the settings
if (isset($_POST['submitModule']))
{
Configuration::updateValue('blockreinsurance_nbblocks', ((isset($_POST['nbblocks']) AND $_POST['nbblocks'] != '') ? (int)$_POST['nbblocks'] : ''));
if($this->removeFromDB() && $this->addToDB())
echo '<div class="conf confirm"><img src="../img/admin/ok.gif"/>'.$this->l('Configuration updated').'</div>';
else
echo '<div class="conf error"><img src="../img/admin/disabled.gif"/>'.$this->l('An error occurred during the save').'</div>';
}
$nb_blocks = Configuration::get('blockreinsurance_nbblocks');
$infos = $this->getAllFromDB();
$content = '
<script type="text/javascript">
$(document).ready(function(){
var nb_blocks = 5;
nb_blocks = $("select[name=nbblocks]").val();
$("div.container_infos").each(function(){
id_div = $(this).attr("id").split("container_infos");
if(parseInt(id_div[1]) <= nb_blocks)
$(this).show();
else
$(this).hide();
});
$("select[name=nbblocks]").change(function(){
nb_blocks = $("select[name=nbblocks]").val();
$("div.container_infos").each(function(){
id_div = $(this).attr("id").split("container_infos");
if(parseInt(id_div[1]) <= nb_blocks)
$(this).show();
else
$(this).hide();
});
});
});
</script>
<h2>'.$this->displayName.'</h2>
<form method="post" action="'.Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']).'" enctype="multipart/form-data">
<fieldset class="width2">
<select name="nbblocks">';
// Show by default 5 blocks maximum
for($i = 1; $i <= 5; $i++)
{
$content .= '<option value="'.$i.'" '.(($i == $nb_blocks) ? 'selected="selected"' : '').'>'.$i.' '.$this->l('block(s)').'</option>';
}
$content .= '</select>
<div class="clear">&nbsp;</div>';
// Show by default 5 blocks maximum
for($i = 1; $i <= 5; $i++)
{
$content .= '<div id="container_infos'.$i.'" class="container_infos"><h3>'.$this->l('Block number').' '.$i.'</h3>'.
((!empty($infos[$i-1]) && $infos[$i-1]['filename'] != '') ? '<img src="'.Tools::getHttpHost(true)._MODULE_DIR_.$this->name.'/img/'.$infos[$i-1]['filename'].'.jpg" />' : '').
'<div class="clear">&nbsp;</div>
<p><label for="info'.$i.'_file">'.$this->l('Image for this block').' :</label>
<input type="file" name="info'.$i.'_file" /></p>
<p><label for="info'.$i.'_text">'.$this->l('Alternative text for this block').' :</label>
<input type="text" id="info'.$i.'_text" name="info'.$i.'_text" value="'.((!empty($infos[$i-1]) && $infos[$i-1]['text'] != '') ? $infos[$i-1]['text'] : '').'" /></p></div>';
}
$content .= '<div class="clear">&nbsp;</div>
<br /><center><input type="submit" name="submitModule" value="'.$this->l('Update settings').'" class="button" /></center>
</fieldset>
</form>
<div class="clear">&nbsp;</div>
<fieldset>
<legend>Addons</legend>
'.$this->l('This module has been developped by PrestaShop and can only be sold through').' <a href="http://addons.prestashop.com">addons.prestashop.com</a>.<br />
'.$this->l('Please report all bugs to').' <a href="mailto:addons@prestashop.com">addons@prestashop.com</a> '.$this->l('or using our').' <a href="http://addons.prestashop.com/contact-form.php">'.$this->l('contact form').'</a>.
</fieldset>';
return $content;
}
public function hookFooter($params)
{
global $smarty;
$infos = $this->getAllFromDB();
$smarty->assign(array(
'nbblocks' => Configuration::get('blockreinsurance_nbblocks'),
'infos' => $infos
));
return $this->display(__FILE__, 'blockreinsurance.tpl');
}
}
?>
@@ -0,0 +1,35 @@
{*
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 6594 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<!-- MODULE Block reinsurance -->
<div id="reinsurance_block" class="clearfix">
<ul class="width{$nbblocks}">
{foreach from=$infos item=info}
<li><img src="{$module_dir}img/{$info.filename}.jpg" alt="{$info.text}" /> <span>{$info.text}</span></li>
{/foreach}
</ul>
</div>
<!-- /MODULE Block reinsurance -->
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>blockreinsurance</name>
<displayName><![CDATA[Bloc reinsurance]]></displayName>
<version><![CDATA[1.0]]></version>
<description><![CDATA[Add a block to display more infos to reassure your customers]]></description>
<author><![CDATA[]]></author>
<tab><![CDATA[front_office_features]]></tab>
<is_configurable>1</is_configurable>
<need_instance>1</need_instance>
<limited_countries></limited_countries>
</module>
+17
View File
@@ -0,0 +1,17 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{blockreinsurance}prestashop>blockreinsurance_ac50afdeca5a62e1c47c3f216ec7638a'] = 'Bloc réassurance';
$_MODULE['<{blockreinsurance}prestashop>blockreinsurance_0cdd94b6a03ddcd4014822a822b675eb'] = 'Ajoute un bloc pour afficher des informations pour rassurer vos clients';
$_MODULE['<{blockreinsurance}prestashop>blockreinsurance_20015706a8cbd457cbb6ea3e7d5dc9b3'] = 'Configuration mise à jour';
$_MODULE['<{blockreinsurance}prestashop>blockreinsurance_31c78485b2a9d9151e0cde196934aad8'] = 'Une erreur est survenue lors de la sauvegarde';
$_MODULE['<{blockreinsurance}prestashop>blockreinsurance_1216aaefbc8bc11aa42f4ec5eec702dd'] = 'bloc(s)';
$_MODULE['<{blockreinsurance}prestashop>blockreinsurance_0845a5f7fbe242ef2472a78cc5ecae4d'] = 'Bloc numéro';
$_MODULE['<{blockreinsurance}prestashop>blockreinsurance_0dbf96dfb0a180d634c89bff8b258fba'] = 'Image pour ce bloc';
$_MODULE['<{blockreinsurance}prestashop>blockreinsurance_b7be073d3d2f885cc9ab4e5cb69a57d1'] = 'Texte alternatif pour ce bloc';
$_MODULE['<{blockreinsurance}prestashop>blockreinsurance_b17f3f4dcf653a5776792498a9b44d6a'] = 'Mettre à jour la configuration';
$_MODULE['<{blockreinsurance}prestashop>blockreinsurance_1b9441f293cd7307b59296f616bb858a'] = 'Ce module a été développé par PrestaShop et ne peut être vendu que sur';
$_MODULE['<{blockreinsurance}prestashop>blockreinsurance_6df4dad510fb08e2e6df44b53cb2ce29'] = 'Pour toute demande d\'information n\'hésitez pas à nous contacter sur';
$_MODULE['<{blockreinsurance}prestashop>blockreinsurance_d575acff7e1035a4212d2a53d5a8c115'] = 'ou en utilisant notre';
$_MODULE['<{blockreinsurance}prestashop>blockreinsurance_23372c0d3713719764670087006fc1b6'] = 'formulaire de contact';
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B