207 lines
11 KiB
PHP
Executable File
207 lines
11 KiB
PHP
Executable File
<?php
|
|
if (!defined('_PS_VERSION_'))
|
|
exit;
|
|
|
|
class SkinStatic extends Module {
|
|
public function __construct() {
|
|
$this->name = 'skinstatic';
|
|
$this->tab = 'front_office_features';
|
|
$this->version = '1.0';
|
|
$this->author = 'Antadis';
|
|
|
|
parent::__construct();
|
|
|
|
$this->displayName = $this->l('Static skin items');
|
|
$this->description = $this->l('Allows to display static parts as a skin on the website.');
|
|
}
|
|
|
|
public function getContent() {
|
|
$this->_html = '<h2>'.$this->displayName.'</h2>';
|
|
|
|
$languages = Language::getLanguages(FALSE);
|
|
$divLangName = 'left_link_0¤right_link_0¤new_window_0¤fixed_0¤img_0¤left_link_1¤right_link_1¤new_window_1¤fixed_1¤img_1¤left_link_2¤right_link_2¤new_window_2¤fixed_2¤img_2';
|
|
$defaultFormLanguage = (int) Configuration::get('PS_LANG_DEFAULT');
|
|
|
|
if (Tools::isSubmit('btnSubmit')) {
|
|
Configuration::updateValue('SKINSTATIC_VERSION', (int) Configuration::get('SKINSTATIC_VERSION') + 1);
|
|
|
|
foreach($languages as $language) {
|
|
for($i=0; $i < 3; $i++) {
|
|
if(isset($_FILES['img_'.(int) $i.'_'.(int) $language['id_lang']]) && $_FILES['img_'.(int) $i.'_'.(int) $language['id_lang']]['name'] != '') {
|
|
if(!copy($_FILES['img_'.(int) $i.'_'.(int) $language['id_lang']]['tmp_name'], _PS_ROOT_DIR_.'/themes/site/skinstatic_cache/skin_'.(int) $i.'_'.(int) $language['id_lang'].'.jpg')) {
|
|
echo '<p class"error">'.$this->l('An error occured during the image upload.').'</p>';
|
|
continue;
|
|
}
|
|
|
|
file_put_contents(
|
|
_PS_ROOT_DIR_.'/themes/site/skinstatic_cache/columns_'.(int) $i.'_'.(int) $language['id_lang'].'.html',
|
|
str_replace(
|
|
array('{left_link}', '{right_link}', '{version}'),
|
|
array(
|
|
Tools::getValue('left_link_'.(int) $i.'_'.(int) $language['id_lang']),
|
|
Tools::getValue('right_link_'.(int) $i.'_'.(int) $language['id_lang']),
|
|
Configuration::get('SKINSTATIC_VERSION'),
|
|
),
|
|
'<style type="text/css">body#index #columns { background: url("http://dev.bebeboutik.com/themes/site/skinstatic_cache/skin_'.(int) $i.'_'.(int) $language['id_lang'].'.jpg?v={version}") no-repeat '.(Tools::getValue('fixed_'.(int) $i.'_'.(int) $language['id_lang'])? 'fixed center 0px': 'scroll center 0px').' #FFFFFF}</style><a'.((int) Tools::getValue('new_window_'.(int) $i.'_'.(int) $language['id_lang'])? ' onclick="window.open(this.href); return false;"': '').' id="skin-left" href="{left_link}"></a><a'.((int) Tools::getValue('new_window_'.(int) $i.'_'.(int) $language['id_lang'])? ' onclick="window.open(this.href); return false;"': '').' id="skin-right" href="{right_link}"></a>'.(Tools::getValue('fixed_'.(int) $i.'_'.(int) $language['id_lang'])? '
|
|
<script type="text/javascript">
|
|
<!--
|
|
$(document).ready(function() { var scrolling = $("#skin-left, #skin-right"); var pos = scrolling.position(); var size = scrolling.height() + 80; var max_size = $(document).height() - $("#footer").height() - 45; $(window).scroll(function(event) { offset = parseFloat(scrolling.css("marginTop").replace("px", "")); scrolling.css({ "marginTop": Math.min($(document).scrollTop(), max_size) + "px" }); }); '.($i == 0 && substr(Tools::getValue('left_link_'.(int) $i.'_'.(int) $language['id_lang']), 0, 28) == 'http://www.privatesportshop.'? '$("#skin-left, #skin-right").unbind("click").removeAttr("href").removeAttr("onclick").click(function(event) { event.stopPropagation(); event.preventDefault(); $("#privatesales_block li > a").first().trigger("click"); });': '').'
|
|
});
|
|
-->
|
|
</script>': '').'
|
|
'));
|
|
}
|
|
}
|
|
}
|
|
|
|
$this->_html .= '<p class="conf">'.$this->l('Links updated successfully.').'</p><br /><br />';
|
|
}
|
|
|
|
$this->_html .=
|
|
'
|
|
<script type="text/javascript">
|
|
var id_language = '.(int) $defaultFormLanguage.';
|
|
</script>
|
|
<form action="'.Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']).'" method="post" enctype="multipart/form-data">
|
|
<fieldset>
|
|
<legend><img src="../img/admin/prefs.gif" />'.$this->l('Links (logged out)').'</legend>
|
|
<div class="text clear">
|
|
<label>'.$this->l('Left link:').'</label>
|
|
<div class="margin-form">';
|
|
foreach($languages as $language) {
|
|
$this->_html .= '<div id="left_link_0_'.(int) $language['id_lang'].'" style="display: '.((int) $language['id_lang'] == $defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
<input type="text" style="width: 350px;" value="" name="left_link_0_'.(int) $language['id_lang'].'" />
|
|
</div>';
|
|
}
|
|
$this->_html .= $this->displayFlags($languages, $defaultFormLanguage, $divLangName, 'left_link_0', TRUE);
|
|
$this->_html .= '<div class="clear"></div>
|
|
</div>
|
|
</div>
|
|
<div class="text">
|
|
<label>'.$this->l('Right link:').'</label>
|
|
<div class="margin-form">';
|
|
foreach($languages as $language) {
|
|
$this->_html .= '<div id="right_link_0_'.(int) $language['id_lang'].'" style="display: '.((int) $language['id_lang'] == $defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
<input type="text" style="width: 350px;" value="" name="right_link_0_'.(int) $language['id_lang'].'" />
|
|
</div>';
|
|
}
|
|
$this->_html .= $this->displayFlags($languages, $defaultFormLanguage, $divLangName, 'right_link_0', TRUE);
|
|
$this->_html .= '<div class="clear"></div>
|
|
</div>
|
|
</div>
|
|
<div class="text">
|
|
<label>'.$this->l('Open link in new window').'</label>
|
|
<div class="margin-form">';
|
|
foreach($languages as $language) {
|
|
$this->_html .= '<div id="new_window_0_'.(int) $language['id_lang'].'" style="display: '.((int) $language['id_lang'] == $defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
<input type="checkbox" value="1" name="new_window_0_'.(int) $language['id_lang'].'" />
|
|
</div>';
|
|
}
|
|
$this->_html .= $this->displayFlags($languages, $defaultFormLanguage, $divLangName, 'new_window_0', TRUE);
|
|
$this->_html .= '<div class="clear"></div>
|
|
</div>
|
|
</div>
|
|
<div class="text">
|
|
<label>'.$this->l('Fixed background').'</label>
|
|
<div class="margin-form">';
|
|
foreach($languages as $language) {
|
|
$this->_html .= '<div id="fixed_0_'.(int) $language['id_lang'].'" style="display: '.((int) $language['id_lang'] == $defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
<input type="checkbox" value="1" name="fixed_0_'.(int) $language['id_lang'].'" />
|
|
</div>';
|
|
}
|
|
$this->_html .= $this->displayFlags($languages, $defaultFormLanguage, $divLangName, 'fixed_0', TRUE);
|
|
$this->_html .= '<div class="clear"></div>
|
|
</div>
|
|
</div>
|
|
<div class="text">
|
|
<label>'.$this->l('Image').'</label>
|
|
<div class="margin-form">';
|
|
foreach($languages as $language) {
|
|
$this->_html .= '<div id="img_0_'.(int) $language['id_lang'].'" style="display: '.((int) $language['id_lang'] == $defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
<input type="file" name="img_0_'.(int) $language['id_lang'].'" />
|
|
</div>';
|
|
}
|
|
$this->_html .= $this->displayFlags($languages, $defaultFormLanguage, $divLangName, 'img_0', TRUE);
|
|
$this->_html .= '<div class="clear"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<br />
|
|
|
|
<legend style="display: inline-block;"><img src="../img/admin/prefs.gif" />'.$this->l('Links (logged in)').'</legend>
|
|
<br />
|
|
<br />
|
|
<div class="text">
|
|
<label>'.$this->l('Left link:').'</label>
|
|
<div class="margin-form">';
|
|
foreach($languages as $language) {
|
|
$this->_html .= '<div id="left_link_1_'.(int) $language['id_lang'].'" style="display: '.((int) $language['id_lang'] == $defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
<input type="text" style="width: 350px;" value="" name="left_link_1_'.(int) $language['id_lang'].'" />
|
|
</div>';
|
|
}
|
|
$this->_html .= $this->displayFlags($languages, $defaultFormLanguage, $divLangName, 'left_link_1', TRUE);
|
|
$this->_html .= '<div class="clear"></div>
|
|
</div>
|
|
</div>
|
|
<div class="text">
|
|
<label>'.$this->l('Right link:').'</label>
|
|
<div class="margin-form">';
|
|
foreach($languages as $language) {
|
|
$this->_html .= '<div id="right_link_1_'.(int) $language['id_lang'].'" style="display: '.((int) $language['id_lang'] == $defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
<input type="text" style="width: 350px;" value="" name="right_link_1_'.(int) $language['id_lang'].'" />
|
|
</div>';
|
|
}
|
|
$this->_html .= $this->displayFlags($languages, $defaultFormLanguage, $divLangName, 'right_link_1', TRUE);
|
|
$this->_html .= '<div class="clear"></div>
|
|
</div>
|
|
</div>
|
|
<div class="text">
|
|
<label>'.$this->l('Open link in new window').'</label>
|
|
<div class="margin-form">';
|
|
foreach($languages as $language) {
|
|
$this->_html .= '<div id="new_window_1_'.(int) $language['id_lang'].'" style="display: '.((int) $language['id_lang'] == $defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
<input type="checkbox" value="1" name="new_window_1_'.(int) $language['id_lang'].'" />
|
|
</div>';
|
|
}
|
|
$this->_html .= $this->displayFlags($languages, $defaultFormLanguage, $divLangName, 'new_window_1', TRUE);
|
|
$this->_html .= '<div class="clear"></div>
|
|
</div>
|
|
</div>
|
|
<div class="text">
|
|
<label>'.$this->l('Fixed background').'</label>
|
|
<div class="margin-form">';
|
|
foreach($languages as $language) {
|
|
$this->_html .= '<div id="fixed_1_'.(int) $language['id_lang'].'" style="display: '.((int) $language['id_lang'] == $defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
<input type="checkbox" value="1" name="fixed_1_'.(int) $language['id_lang'].'" />
|
|
</div>';
|
|
}
|
|
$this->_html .= $this->displayFlags($languages, $defaultFormLanguage, $divLangName, 'fixed_1', TRUE);
|
|
$this->_html .= '<div class="clear"></div>
|
|
</div>
|
|
</div>
|
|
<div class="text">
|
|
<label>'.$this->l('Image').'</label>
|
|
<div class="margin-form">';
|
|
foreach($languages as $language) {
|
|
$this->_html .= '<div id="img_1_'.(int) $language['id_lang'].'" style="display: '.((int) $language['id_lang'] == $defaultFormLanguage ? 'block' : 'none').'; float: left;">
|
|
<input type="file" name="img_1_'.(int) $language['id_lang'].'" />
|
|
</div>';
|
|
}
|
|
$this->_html .= $this->displayFlags($languages, $defaultFormLanguage, $divLangName, 'img_1', TRUE);
|
|
$this->_html .= '<div class="clear"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<br />
|
|
|
|
<p class="margin-form submit">
|
|
<br />
|
|
<input class="button" name="btnSubmit" value="'.$this->l('Update settings').'" type="submit" />
|
|
</p>
|
|
</fieldset>
|
|
</form>';
|
|
|
|
return $this->_html;
|
|
}
|
|
}
|