[*] MO : blockcms - Customizable footer

This commit is contained in:
fBrignoli
2011-09-21 09:41:54 +00:00
parent 3e0d63e011
commit 3da8ff887f
2 changed files with 258 additions and 197 deletions
+85 -26
View File
@@ -1,29 +1,29 @@
<?php <?php
/* /*
* 2007-2011 PrestaShop * 2007-2011 PrestaShop
* *
* NOTICE OF LICENSE * NOTICE OF LICENSE
* *
* This source file is subject to the Academic Free License (AFL 3.0) * This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt. * that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL: * It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php * http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to * 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 * obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately. * to license@prestashop.com so we can send you a copy immediately.
* *
* DISCLAIMER * DISCLAIMER
* *
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer * 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 * versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information. * needs please refer to http://www.prestashop.com for more information.
* *
* @author PrestaShop SA <contact@prestashop.com> * @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA * @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 7060 $ * @version Release: $Revision: 7060 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*/ */
if (!defined('_PS_VERSION_')) if (!defined('_PS_VERSION_'))
exit; exit;
@@ -309,7 +309,17 @@ class BlockCms extends Module
$cms_blocks_left = $this->getBlocksCMS(0); $cms_blocks_left = $this->getBlocksCMS(0);
$cms_blocks_right = $this->getBlocksCMS(1); $cms_blocks_right = $this->getBlocksCMS(1);
$isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$this->context->language->iso_code.'.js') ? $this->context->language->iso_code : 'en');
$ad = dirname($_SERVER["PHP_SELF"]);
$this->_html .= ' $this->_html .= '
<script type="text/javascript">
var iso = \''.$isoTinyMCE.'\' ;
var pathCSS = \''._THEME_CSS_DIR_.'\' ;
var ad = \''.$ad.'\' ;
</script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="'.__PS_BASE_URI__.'js/tinymce.inc.js"></script>
<script type="text/javascript" src="../js/jquery/jquery.tablednd_0_5.js"></script> <script type="text/javascript" src="../js/jquery/jquery.tablednd_0_5.js"></script>
<script type="text/javascript" src="../modules/blockcms/blockcms.js"></script> <script type="text/javascript" src="../modules/blockcms/blockcms.js"></script>
<script type="text/javascript">CMSBlocksDnD(\''.$this->secure_key.'\');</script> <script type="text/javascript">CMSBlocksDnD(\''.$this->secure_key.'\');</script>
@@ -402,6 +412,19 @@ class BlockCms extends Module
} }
else else
$this->_html .= '<p style="margin-left:40px;">'.$this->l('There is no CMS block set').'</p>'; $this->_html .= '<p style="margin-left:40px;">'.$this->l('There is no CMS block set').'</p>';
$languages = Language::getLanguages(false);
$default_language = (int)Configuration::get('PS_LANG_DEFAULT');
$div_id_language = 'block_language';
$footer_content_i18n = '<script type="text/javascript">id_language = Number('.$default_language.');</script>';
foreach ($languages as $lang)
$footer_content_i18n .= '<div id="block_language_'.$lang['id_lang'].'" style="display: '.($lang['id_lang'] == $default_language ? 'block' : 'none').'; float:left;">
<textarea class="rte" name="footer_text_'.(int)$lang['id_lang'].'">'.Tools::htmlentitiesUTF8(Configuration::get('FOOTER_CMS_TEXT_'.(int)$lang['id_lang'])).'</textarea>
</div>';
$footer_content_i18n .= $this->displayFlags($languages, $default_language, $div_id_language, $div_id_language, true);
$this->_html .= '</div> $this->_html .= '</div>
<div class="clear"></div> <div class="clear"></div>
</fieldset><br /> </fieldset><br />
@@ -410,7 +433,10 @@ class BlockCms extends Module
<legend><img src="'._PS_BASE_URL_.__PS_BASE_URI__.'modules/'.$this->name.'/logo.gif" alt="" /> '.$this->l('Footer\'s various links Configuration').'</legend> <legend><img src="'._PS_BASE_URL_.__PS_BASE_URI__.'modules/'.$this->name.'/logo.gif" alt="" /> '.$this->l('Footer\'s various links Configuration').'</legend>
<input type="checkbox" name="footer_poweredby_active" id="footer_poweredby_active" '.(((int)Configuration::get('FOOTER_POWEREDBY') === 1 || Configuration::get('FOOTER_POWEREDBY') === false) ? 'checked="checked"' : '').'> <label for="footer_active" style="float:none;">'.$this->l('Display "Powered by Prestashop"').'</label><br /><br /> <input type="checkbox" name="footer_poweredby_active" id="footer_poweredby_active" '.(((int)Configuration::get('FOOTER_POWEREDBY') === 1 || Configuration::get('FOOTER_POWEREDBY') === false) ? 'checked="checked"' : '').'> <label for="footer_active" style="float:none;">'.$this->l('Display "Powered by Prestashop"').'</label><br /><br />
<input type="checkbox" name="footer_active" id="footer_active" '.(Configuration::get('FOOTER_BLOCK_ACTIVATION') ? 'checked="checked"' : '').'> <label for="footer_active" style="float:none;">'.$this->l('Display the Footer\'s various links').'</label><br /><br /> <input type="checkbox" name="footer_active" id="footer_active" '.(Configuration::get('FOOTER_BLOCK_ACTIVATION') ? 'checked="checked"' : '').'> <label for="footer_active" style="float:none;">'.$this->l('Display the Footer\'s various links').'</label><br /><br />
<table cellspacing="0" cellpadding="0" class="table" width="100%"> <label style="display:block; padding:0; text-align: left">'.$this->l('Footer informations:').'</label><br /><br />
'.$footer_content_i18n.'
<table cellspacing="0" style="margin-top: 20px" cellpadding="0" class="table" width="100%">
<tr> <tr>
<th width="3%"><input type="checkbox" name="checkme" class="noborder" onclick="checkallCMSBoxes($(this).attr(\'checked\'))" /></th> <th width="3%"><input type="checkbox" name="checkme" class="noborder" onclick="checkallCMSBoxes($(this).attr(\'checked\'))" /></th>
<th width="3%">'.$this->l('ID').'</th> <th width="3%">'.$this->l('ID').'</th>
@@ -529,6 +555,36 @@ class BlockCms extends Module
foreach (Tools::getValue('footerBox') as $cmsBox) foreach (Tools::getValue('footerBox') as $cmsBox)
if (!preg_match("#^[01]_[0-9]+$#", $cmsBox)) if (!preg_match("#^[01]_[0-9]+$#", $cmsBox))
$errors[] = $this->l('Invalid CMS page or category'); $errors[] = $this->l('Invalid CMS page or category');
$empty_footer_text = true;
$footer_text = array();
$footer_text[(int)Configuration::get('PS_LANG_DEFAULT')] = Tools::getValue('footer_text_'.(int)Configuration::get('PS_LANG_DEFAULT'));
$languages = Language::getLanguages(false);
// set default values
foreach ($languages as $lang)
{
if ($lang['id_lang'] == (int)Configuration::get('PS_LANG_DEFAULT'))
continue;
$footer_text_value = Tools::getValue('footer_text_'.(int)$lang['id_lang']);
if (!empty($footer_text_value))
{
$empty_footer_text = false;
$footer_text[(int)$lang['id_lang']] = $footer_text_value;
}
else
$footer_text[(int)$lang['id_lang']] = $footer_text[(int)Configuration::get('PS_LANG_DEFAULT')];
}
if (!$empty_footer_text && empty($footer_text[(int)Configuration::get('PS_LANG_DEFAULT')]))
$errors[] = $this->l('Please provide a footer text for the default language');
else
{
foreach ($languages as $lang)
Configuration::updateValue('FOOTER_CMS_TEXT_'.(int)$lang['id_lang'], $footer_text[(int)$lang['id_lang']], true);
}
if (Tools::getValue('footer_active') != 0 AND Tools::getValue('footer_active') != 1) if (Tools::getValue('footer_active') != 0 AND Tools::getValue('footer_active') != 1)
$errors[] = $this->l('Invalid activation footer'); $errors[] = $this->l('Invalid activation footer');
} }
@@ -687,6 +743,8 @@ class BlockCms extends Module
Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', Tools::getValue('footer_active')); Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', Tools::getValue('footer_active'));
Configuration::updateValue('FOOTER_POWEREDBY', (Tools::getValue('footer_poweredby_active') == 'on' ? 1 : 0)); Configuration::updateValue('FOOTER_POWEREDBY', (Tools::getValue('footer_poweredby_active') == 'on' ? 1 : 0));
$this->_html = $this->displayConfirmation($this->l('Footer\'s CMS updated')); $this->_html = $this->displayConfirmation($this->l('Footer\'s CMS updated'));
} }
elseif (Tools::isSubmit('addBlockCMSConfirmation')) elseif (Tools::isSubmit('addBlockCMSConfirmation'))
@@ -747,7 +805,8 @@ class BlockCms extends Module
'cmslinks' => $cms_titles, 'cmslinks' => $cms_titles,
'theme_dir' => _PS_THEME_DIR_, 'theme_dir' => _PS_THEME_DIR_,
'display_stores_footer' => Configuration::get('PS_STORES_DISPLAY_FOOTER'), 'display_stores_footer' => Configuration::get('PS_STORES_DISPLAY_FOOTER'),
'display_poweredby' => ((int)Configuration::get('FOOTER_POWEREDBY') === 1 || Configuration::get('FOOTER_POWEREDBY') === false) 'display_poweredby' => ((int)Configuration::get('FOOTER_POWEREDBY') === 1 || Configuration::get('FOOTER_POWEREDBY') === false),
'footer_text' => Configuration::get('FOOTER_CMS_TEXT_'.(int)$this->context->language->id)
)); ));
return $this->display(__FILE__, 'blockcms.tpl'); return $this->display(__FILE__, 'blockcms.tpl');
} }
+2
View File
@@ -58,5 +58,7 @@
{/foreach} {/foreach}
{if $display_poweredby}<li class="last_item">{l s='Powered by' mod='blockcms'} <a href="http://www.prestashop.com">PrestaShop</a>&trade;</li>{/if} {if $display_poweredby}<li class="last_item">{l s='Powered by' mod='blockcms'} <a href="http://www.prestashop.com">PrestaShop</a>&trade;</li>{/if}
</ul> </ul>
{$footer_text}
<!-- /MODULE Block footer --> <!-- /MODULE Block footer -->
{/if} {/if}