bebeboutik/modules/skinstatic/AdminSkinStatic.php
Marion Muszynski 85b5bb049d fix console log
2017-03-09 11:53:55 +01:00

236 lines
15 KiB
PHP
Executable File

<?php
if(!defined('_PS_VERSION_')) {
exit;
}
class AdminSkinStatic extends AdminTab {
public $_html = '';
public function postProcess()
{
global $cookie;
$languages = Language::getLanguages(FALSE);
if (Tools::isSubmit('btnSubmit')) {
if (Tools::getValue('version')) {
Configuration::updateValue('SKINSTATIC_VERSION', (int) Configuration::get('SKINSTATIC_VERSION') + 1);
$id_lang = (int) Tools::getValue('version');
for($i=0; $i < 2; $i++) {
$reset = Tools::getValue('reset_'.(int) $i);
if ($reset) {
file_put_contents(
_PS_ROOT_DIR_.'/themes/site/skinstatic_cache/columns_'.(int) $i.'_'.(int) $id_lang.'.html',
str_replace(
array('{left_link}', '{right_link}', '{version}'),
array(
Tools::getValue('left_link_'.(int) $i),
Tools::getValue('right_link_'.(int) $i),
Configuration::get('SKINSTATIC_VERSION'),
),
'<a'.((int) Tools::getValue('new_window_'.(int) $i)? ' onclick="window.open(this.href); return false;"': '').' id="skin-left" href="{left_link}"></a><a'.((int) Tools::getValue('new_window_'.(int) $i)? ' onclick="window.open(this.href); return false;"': '').' id="skin-right" href="{right_link}"></a>'.(Tools::getValue('fixed_'.(int) $i)? '
<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), 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>': '').'
'));
}
if(isset($_FILES['img_'.(int) $i]) && $_FILES['img_'.(int) $i]['name'] != '')
{
if(!copy($_FILES['img_'.(int) $i]['tmp_name'], _PS_ROOT_DIR_.'/themes/site/skinstatic_cache/skin_'.(int) $i.'_'.(int) $id_lang.'.jpg')) {
echo '<p class"error">'.$this->l('An error occured during the image upload.').'</p>';
continue;
}
// version logged
if ($i == 1) {
file_put_contents(
_PS_ROOT_DIR_.'/themes/site/skinstatic_cache/columns_'.(int) $i.'_'.(int) $id_lang.'.html',
str_replace(
array('{left_link}', '{right_link}', '{version}'),
array(
Tools::getValue('left_link_'.(int) $i),
Tools::getValue('right_link_'.(int) $i),
Configuration::get('SKINSTATIC_VERSION'),
),
'<style type="text/css">body#index #columns { background: url("//www.bebeboutik.com/themes/site/skinstatic_cache/skin_'.(int) $i.'_'.(int) $id_lang.'.jpg?v={version}") no-repeat '.(Tools::getValue('fixed_'.(int) $i)? 'fixed center 0px': 'scroll center 0px').' #F1F1F1}</style><a'.((int) Tools::getValue('new_window_'.(int) $i)? ' onclick="window.open(this.href); return false;"': '').' id="skin-left" href="{left_link}"></a><a'.((int) Tools::getValue('new_window_'.(int) $i)? ' onclick="window.open(this.href); return false;"': '').' id="skin-right" href="{right_link}"></a>'.(Tools::getValue('fixed_'.(int) $i)? '
<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", "")); margin = 170; height = 750; if($(document).scrollTop()==0){margin = 30;} if($(document).scrollTop()>130){height = $(window).height();}; scrolling.css({ "marginTop": Math.min($(document).scrollTop(), max_size)-margin + "px", "height" : height+"px" }); }); '.($i == 0 && substr(Tools::getValue('left_link_'.(int) $i), 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>': '').'
'));
} else {
//echo "<pre>";var_dump(Tools::getValue('right_link_'.(int) $i),Tools::getValue('left_link_'.(int) $i));echo "</pre>";die();
file_put_contents(
_PS_ROOT_DIR_.'/themes/site/skinstatic_cache/columns_'.(int) $i.'_'.(int) $id_lang.'.html',
str_replace(
array('{left_link}', '{right_link}', '{version}'),
array(
Tools::getValue('left_link_'.(int) $i),
Tools::getValue('right_link_'.(int) $i),
Configuration::get('SKINSTATIC_VERSION'),
),
'<style type="text/css">body#index #columns { background: url("//www.bebeboutik.com/themes/site/skinstatic_cache/skin_'.(int) $i.'_'.(int) $id_lang.'.jpg?v={version}") no-repeat '.(Tools::getValue('fixed_'.(int) $i)? 'fixed center 0px': 'scroll center 0px').' #F1F1F1}</style><a'.((int) Tools::getValue('new_window_'.(int) $i)? ' onclick="window.open(this.href); return false;"': '').' id="skin-left" href="{left_link}"></a><a'.((int) Tools::getValue('new_window_'.(int) $i)? ' onclick="window.open(this.href); return false;"': '').' id="skin-right" href="{right_link}"></a>'.(Tools::getValue('fixed_'.(int) $i)? '
<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), 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('Skin updated successfully.').'</p><br /><br />';
} else {
$this->_html .= '<p class="error">'.$this->l('You have to choose a site version.').'</p><br /><br />';
}
}
}
public function display()
{
global $cookie;
$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';
$divLangName = 'left_link_1¤right_link_1¤new_window_1¤fixed_1¤img_1';
$divLangName .= '¤left_link_0¤right_link_0¤new_window_0¤fixed_0¤img_0';
$defaultFormLanguage = (int) Configuration::get('PS_LANG_DEFAULT');
$this->_html .=
'
<h2>Habillage graphique du site</h2>
<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 style="display: inline-block;"><img src="../img/admin/prefs.gif" />'.$this->l('Skin version').'</legend>
<br />
<div class="text">
<label>'.$this->l('Site version').'</label>
<div class="margin-form">';
foreach($languages as $language) {
$this->_html .= '<input type="radio" value="'.(int) $language['id_lang'].'" name="version" /> '.$language['iso_code'].' ';
}
$this->_html .= '
<div class="clear"></div>
<p>'.$this->l('Choose the site version to update').'</p></div>
</div>
<legend style="display: inline-block;"><img src="../img/admin/prefs.gif" />'.$this->l('Links (logged in)').'</legend>
<br />
<div class="text">
<label>'.$this->l('Remove actual skin').'</label>
<div class="margin-form">
<input type="checkbox" value="1" name="reset_1" />
<div class="clear"></div>
</div>
<div class="text">
<label>'.$this->l('Left link:').'</label>
<div class="margin-form">
<input type="text" style="width: 350px;" value="" name="left_link_1" />
</div>
<div class="clear"></div>
</div>
<div class="text">
<label>'.$this->l('Right link:').'</label>
<div class="margin-form">
<input type="text" style="width: 350px;" value="" name="right_link_1" />
</div>
<div class="clear"></div>
</div>
<div class="text">
<label>'.$this->l('Open link in new window').'</label>
<div class="margin-form">
<input type="checkbox" value="1" name="new_window_1" />
</div>
<div class="clear"></div>
</div>
<div class="text">
<label>'.$this->l('Fixed background').'</label>
<div class="margin-form">
<input type="checkbox" value="1" name="fixed_1" />
</div>
<div class="clear"></div>
</div>
<div class="text">
<label>'.$this->l('Image').'</label>
<div class="margin-form">
<input type="file" name="img_1" />
</div>
<div class="clear"></div>
</div>
<br />
<legend style="display: inline-block;"><img src="../img/admin/prefs.gif" />'.$this->l('Links (logged out)').'</legend>
<br />
<div class="text">
<label>'.$this->l('Remove actual skin').'</label>
<div class="margin-form">
<input type="checkbox" value="1" name="reset_0" />
<div class="clear"></div>
</div>
<div class="text">
<label>'.$this->l('Left link:').'</label>
<div class="margin-form">
<input type="text" style="width: 350px;" value="" name="left_link_0" />
</div>
<div class="clear"></div>
</div>
<div class="text">
<label>'.$this->l('Right link:').'</label>
<div class="margin-form">
<input type="text" style="width: 350px;" value="" name="right_link_0" />
</div>
<div class="clear"></div>
</div>
<div class="text">
<label>'.$this->l('Open link in new window').'</label>
<div class="margin-form">
<input type="checkbox" value="1" name="new_window_0" />
</div>
<div class="clear"></div>
</div>
<div class="text">
<label>'.$this->l('Fixed background').'</label>
<div class="margin-form">
<input type="checkbox" value="1" name="fixed_0" />
</div>
<div class="clear"></div>
</div>
<div class="text">
<label>'.$this->l('Image').'</label>
<div class="margin-form">
<input type="file" name="img_0" />
</div>
<div class="clear"></div>
</div>
<br />
<p class="margin-form submit">
<br />
<input class="button" name="btnSubmit" value="'.$this->l('Update settings').'" type="submit" />
</p>
</fieldset>
</form>';
echo $this->_html;
}
}